QP and Arduino

share on: 
Share on reddit
Share on linkedin
Share on twitter
Share on email
Originally published on:  
2021-01-05
Last updated on: 
QP for Arduino logo
Table of Contents
Tags:   

The Quantum Leaps’ QP™ real-time embedded frameworks (RTEFs) and the QM™ modeling tool complement the Arduino platform and provide everything you need to program Arduino graphically with event-driven active objects and modern hierarchical state machines.

Getting Started with Modern Arduino Programming

The following video explains how to download and install all the software you need to get started with Modern Arduino Programming:

Recommended video “Modern Arduino Programming with QP”:

Downloading QP™ for Arduino

The following free downloads contain everything you need to get started with QP on Arduino: the QP/C++ and QP-nano Arduino libraries and the QM™ modeling tool bundled together:

Current version 6.9.3
(June 16, 2021)

The latest QP-Arduino code, with the recent enhancements and bug fixes, is available on:

QP-Arduino Project on Arduino PROJECT HUB

Modern Event-Driven Programming for Arduino

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 or a timout (delay()), a button press, or arrival of a character through the serial port, 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).

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…

Application Note: A Crash Course in UML State Machines
Application Note: "Event-Driven Arduino Programming with QP and QM"

Using QM with the Arduino IDE

The “External Tools” menu in QM is no longer configured for direct building Arduino projects. This is because Arduino kept changing their build process and it was impossible to keep adjusting the External Tools. Also, after introducing support for ARM-based Arduino (QP/C++ library for Arduino), the support for Arduino builds has become even more problematic.

So, instead of using QM directly, the intended way of working with the Arduino examples is to use the Arduino IDE for building and downloading the code, but to configure it to “Use external editor”. (To configure Arduino IDE to “Use external editor”, click on the menu File | Preferences and check the checkbox in the “Preferences” dialog box, as shown below:)

Arduino IDE external editor setting
Configuring the Arduino IDE to "Use external editor"

This “external editor” is now the QM modeling tool, where you can work with the models (.qm files) and then to generate code from these models. In this scenario, the Arduino IDE is used only to build and upload the code to the Arduino board(s).

The following screen shot shows this workflow. The “external editor” mode of the Arduino IDE is really nice, because it automatically picks up any changes made to the project files.

QP/QM for Arduino workflow
Using QM as the "external editor" for the Arduino IDE

Discontinued Support for AVR-based Arduinos

NOTE:
Due to the decision to discontinue the QP-nano framework, the support for AVR-based Arduinos will be also discontinued in the future. Moving forward, we will only support the QP/C++ framework for ARM-based Arduinos (e.g., SAM-based Arduino DUE, etc.)

Arduino Playground Now Obsolete

NOTE:
Due to phasing out of the “Arduino Playground”, the QP-Arduino posts on “Arduino Playground” could not be updated and are now obsolete.

Discussion

One Response

Leave a Reply