Software apps and online services
QM is a graphical state machine modeling tool, that use the event-driven framework, QP!
So, QP can be easily adapted to work on Windows, Mac, Linux and ARM microcontrolers. In this tutorial we you running this powerfull tool on Arduino.
First of all, download QP-nano for arduino and QM Modelling tool:
Since you download QP nano, install it on your Arduino sketchbook location, that usually is: C:\Users\<user>\Documents\Arduino.
Open blinky example on Arduino IDE:
Also since you installed QM tool, open.qm file located at C:\Users\<user>\Documents\Arduino\libraries\qpn_avr\examples\blinky
Here you can see the project state machine represented in UML notation, containing states, transitions and actions components.
Each component has its own action field where you can insert code to perform functions.
To generate the code of your state machine project, you need to create a.ino file in QM following the example.
After you insert all your actions in states and transitions, generate code and open.ino file on Arduino IDE.
Explanation about some code:
- QActive_armX((QActive *)me, 0U, BSP_TICKS_PER_SEC/2U, BSP_TICKS_PER_SEC/2U) - arm timer to send timeout event after 2 seconds.
- Q_TRAN(&Blinky_off) - Transition to OFF state.
- Q_TRAN(&Blinky_on) - Transition to ON state.
- Q_ENTRY_SIG - Event that is generate when entering a state to perform an action
- Q_TIMEOUT_SIG - Event generated by TIMER.
Now, upload your code to an arduino board and see a program running without spagetti code.
To improve your knowledge about QP framework and event-driven programming read the most popular book about UML statecharts and event-driven programming for embedded systems.