Arduino™ (see www.arduino.cc) is an open-source electronics prototyping platform, designed to make digital electronics more accessible to non-specialists in multidisciplinary projects. Arduino™ has gained popularity, because it provides both hardware and compatible software focused on developing working prototypes. By making it easier to build the first prototype, Arduino lowers the barrier of entry to the field of modern microelectronics and enables a host of new applications.

However, programming the Arduino microcontroller (Atmel AVRmega) remains a challenge. Traditionally, Arduino programs are written in a sequential manner, which means that whenever an Arduino program needs to synchronize with some external event, such as a button press, arrival of a character through the serial port, or a time delay, it explicitly waits in-line for the occurrence of the event. Waiting "in-line" means that the Arduino processor spends all of its cycles constantly checking for some condition in a tight loop (called the polling loop).

Although this approach is functional in many situations, it doesn't work very well when there are multiple possible sources of events whose arrival times and order you cannot predict and where it is important to handle the events in a timely manner. The fundamental problem is that while a sequential program is waiting for one kind of event (e.g., a button press), it is not doing any other work and is not responsive to other events (e.g., characters from the serial port).

Another big problem with the sequential program structure is wastefulness in terms of power dissipation. Regardless of how much or how little actual work is being done, the Arduino processor is always running at top speed, which drains the battery quickly and prevents you from making truly long-lasting battery-powered devices.

Event-Driven Programming for Arduino™

For these and other reasons experienced programmers turn to the long-know design strategy called event-driven programming, which requires a distinctly different way of thinking than conventional sequential programs. All event-driven programs are naturally divided into the application, which actually handles the events, and the supervisory event-driven infrastructure (framework), which waits for events and dispatches them to the application. The control resides in the event-driven framework, so from the application standpoint, the control is inverted compared to a traditional sequential program.

It turns out that the QP™/C++ state machine framework beautifully complements the Arduino™ platform and provides everything you need to build responsive, robust, and power-efficient Arduino programs based on modern hierarchical state machines. In many ways the open source QP/C++ state machine framework is like a modern real-time operating system (RTOS) specifically designed for executing event-driven state machines. The free QM™ graphical modeling tool takes Arduino programming to the next level, by eabling automiatic code generation of complete Arduino sketches.

The QP/C++ Development Kit (QDK) for Arduino is different from most other QDKs in that it is self-contained and includes the simplified and compacted source-code version of the QP/C++ framework. The QDK-Arduino is designed to plug directly into the Arduino IDE to become immediately useful without building a binary library. The extensive Application Note "Event Driven Arduino Programming with QP" describes the main concepts and how to get started.


NOTE: QP/C++ Development Kit (QDK) for Arduino is licensed under the modified GPLv3 license with the QP-Arduino Exception. Specifically, the Exception removes the requirement to expose your proprietary source code as long as you deploy it on an Arduino-Certified board.


QP™ Development Kits (QDKs) for Arduino™

NOTE: The QP-Arduino integration is compatible only with the Arduino IDE 1.5.x (still in BETA as of this writing). The older Arduino IDE 1.0.x is not compatible with the provided code.

Currenlty QP project examples are only available for the AVR-based Arduinos (e.g., Arduino-UNO). Support for the ARM Cortex-M based Arduinos (e.g., Arduino-DUE) is planned in the future.

QDK™ Board QP™ Version Arduino IDE Documentation Download
QDK/C++™
QDK/C++ for Arduino-1.5.x Arduino UNO QP/C++ 5.3.0/
QM 3.2.0
Arduino-1.5.7 or newer Application Note (1.1MB)
QP on Arduino Playground
Download QP/Arduino from SourceForge.net
QM™
Free QM Tool Download QM from SourceForge.net

The following screen shot shows the PELICAN crossing example downloaded and executed directly from the free QM modeling tool.


Related Development Kits

QP Development Kits for AVR

Last updated: November 19, 2014