Monday, 9 March 2015

Scheduling on the Arduino

I'm currently working on a project that requires an Arduino to
  • monitor the positionof two rotary encoders
  • monitor the state of set five push buttons and
  • send the state of everything over a Serial link whenever something changes
This is not as simple as it seems.

All of the components are mechanical and are subject to contact bounce, and many of the Arduino libraries are blocking. I need the code to be performant and responsive.

A promising Task framework

Fortunately I found a promising blog post from Alan Burlison; the task framework that he describes looks as if it will help me to solve the problem.

One minor problem: the sourceforge project appears to contain no code, and the archive file referred to in the blog was written prior to the release of Arduino version 1.0. As a result the code in the archive needs minor tweaks to work.

I like the look of the Task framework. It's lightweight and tries to do much less than FreeRTOS, but it seems powerful enough to do what I want and makes very economical use of RAM and program memory.

I'll do some more experimenting tomorrow and report. If it works as well as I think it will I may also use it on the Teensy 3.1 which forms part of C3Pi.