QM - Programming Arduino the Modern Way

QM - Programming Arduino the Modern Way © GPL3+

Use an powerfull tool to model your Arduino project behavior, say goodbye to "delay" and let QP control events.

  • 1,820 views
  • 0 comments
  • 7 respects

Components and supplies

Apps and online services

About this project

QM?

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.

Installing

First of all, download QP-nano for arduino and QM Modelling tool:

https://sourceforge.net/projects/qpc/files/QP-nano_Arduino/

https://sourceforge.net/projects/qpc/files/QM/

Since you download QP nano, install it on your Arduino sketchbook location, that usually is: C:\Users\<user>\Documents\Arduino.

Running first example

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.

http://www.state-machine.com/psicc2/

Thank you!

Code

Comments

Similar projects you might like

Programming 8x8 LED Matrix

by SAnwandter1

  • 114,106 views
  • 26 comments
  • 105 respects

Programming Arduino Using Python!!!

by Smart Technology

  • 6,808 views
  • 1 comment
  • 13 respects

Programming ATtiny85 with Arduino Uno

Project tutorial by Arjun Ganesan

  • 213,035 views
  • 74 comments
  • 184 respects

Programming 4 Digit 7 Segment LED Display

by SAnwandter1

  • 79,840 views
  • 21 comments
  • 66 respects

Programming ATtiny13 with Arduino Uno

by Tauno Erik

  • 10,923 views
  • 7 comments
  • 20 respects
Add projectSign up / Login