The QP state machine framework has been just released (see http://arduino.cc/playground/Code/QP).

The QP framework very nicely complements the Arduino platform and provides everything you need to build well-structured, responsive, robust, and power-efficient Arduino programs based on modern hierarchical state machines. In many ways the open source QP state machine framework is like a modern real-time operating system (RTOS) specifically designed for executing event-driven state machines.

The QP development kit for Arduino provides also an example model for the free QM graphical modeling tool. QM takes Arduino programming to the next level, by eabling automiatic code generation of complete Arduino sketches.

The extensive Application Note "Event Driven Arduino Programming with QP" describes the main concepts and how to get started.

An Arduino port of the QP framework has been requested in this forum (see http://arduino.cc/forum/index.php/topic,38787.0.html), but it is no longer possible to post responses to the older forum.

In my opinion, Mr. Samek's book is well worth the money. "Hierarchical state machines" are an excellent solution to a class of problems often encountered in Arduino projects. While Mr. Samek didn't introduce hierarchical state machines to the world his implementation is elegant, powerful, safe, and easy to maintain.

In my case, I couldn't wait for an "Arduino port" and created a simplified variant (QHsm with a shallow event queue). But, even that, has allowed me to quickly build bug free easy to maintain applications.

The big draw-back is the additional Flash requirements. My simple applications would very likely fit into 4k (or maybe even 2K). QHsm pushes them from 6K to just under 8K.

The book "Practical UML Statecharts in C/C++, Second Ed." (PSiCC2) has not been written with the beginner in mind. As the author of this book I just don't want anybody to get disappointed, especially because Arduino itself is targeted for non-specialists in embedded software development.

So, before you rush to buy the book based on some buzzwords, like "UML", "statecharts", or "ARM Cortex-M3", please play with the provided examples on your Arduino (see http://arduino.cc/playground/Code/QP) and take a closer look at the code. You can also read the introduction and the first chapter of the PSiCC2 book online at http://www.state-machine.com/psicc2/PSiCC2_excerpts.pdf. This first chapter is designed as a quick tutorial.

Event-driven programming can feel very unnatural for many people. That's alright. You have other alternatives, like the traditional RTOS, the venerable superloop with polling, protothreads (which are specifically designed to avoid state machines), and so on.

On the other hand, some studies indicate that event-driven programming introduced early in the teaching of software development can be beneficial (see "Event-driven Programming can be Simple Enough for CS 1" at http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.33.9431). So, if you like the event-driven approach, you would need an event-driven framework. QP is one of such frameworks and the PSiCC2 book is the ultimate resource for it.

The QP state machine framework for Arduino has been updated to the latest QP version 4.5.02 and is compatible with the latest graphical QM modeling tool version 2.2.02. The main improvement in these version is compliance of the source code with the strict MISRA-C++:2008 guidelines.

The QP framework is described in the updated Arduino Playground article http://arduino.cc/playground/Code/QP, which describes how to download the code and tools.

I am very interested in using this framework for my project. I am an experienced but rusty programmer but new to Arduino. I'm used to thinking in higher level object oriented methods, know UML and understand state machines.

Becasue the QP framework uses the timers and interupts of the Arduino does this interfere with other functions that also use times such as Pulse Width Modulation for the built in analogwrite functions or the functions in the standard Servo library?

I am using an ATMega2560 board with the AdaFruit Motor Shield on it and the AFMotor library (which used PWM) and the Servo to control several motors and servos. I've only done simple test code at this point to verify all my hardware works together in a very simple run time environment.

I'd like to make sure there won't be a conflict before investing the time in learning and implementing anything in the QP Framework.

So far I have not been able to find any examples of project using this framework on Arduino, could you point me to any?