A Tutorial on Using Linux for Real-Time Tasks

Real Time Linux Tasks

[Andreas] has created this tutorial on real-time (RT) tasks in Linux. At first blush that sounds like a rather dry topic, but [Andreas] makes things interesting by giving us some real-world demos using a Raspberry Pi and a stepper motor. Driving a stepper motor requires relatively accurate timing. Attempting to use a desktop operating system for a task like this is generally ill-advised. Accurate timing is best left to a separate microcontroller. This is why we often see the Raspi paired with an Arduino here on Hackaday. The rationale behind this is not often explained.

[Andreas] connects a common low-cost 28BYJ-48 geared stepper motor with a ULN2003 driver board to a Raspberry Pi’s GPIO pins. These motors originally saw use moving the louvers of air conditioners. In general, they get the job done, but aren’t exactly high quality. [Andreas] uses a simple program to pulse the pins in the correct order to spin the motor. Using an oscilloscope, a split screen display, and a camera on the stepper motor, [Andreas] walks us through several common timing hazards, and how to avoid them.

The most telling hazard is shown last. While running his stepper program, [Andreas] runs a second program which allocates lots of memory. Eventually, Linux swaps out the stepper program’s memory, causing the stepper motor to stop spinning for a couple of seconds. All is not lost though, as the swapping can be prevented with an mlockall() call.

The take away from this is that Linux is not a hard real-time operating system. With a few tricks and extensions, it can do some soft real-time tasks. The best solution is to either use an operating system designed for real-time operation, or offload real-time operations to a separate controller.

[Read more...]

Real-time Arduino interpreter ditches the PC

computerless_arduino

When prototyping a project using an Arduino, there are a few things that are pretty much required equipment. A computer for generating sketches is typically one of those things, but [Adam] over at Teague Labs is looking to change all that with his current project, the Computerless Arduino.

Instead of using a computer to alter the code running on the Arduino, they have implemented a real-time code interpreter using a Teensy 2.0. The microcontroller is connected to a 5-button LCD display where the user can view the status of any port, view the current running code, as well as alter that code on the fly.

The real-time instruction set is somewhat limited, making it a breeze for newcomers to begin using the Arduino. While that may turn some people off, it still has enough functionality baked in to handle moderately sized projects as well.

Be sure to check out the video we have posted below to see the interpreter in action.

[Read more...]

Upgrading the Freetronics twentyten with a real-time clock

[John Boxall] finds himself doing a fair amount of projects that require a realtime clock. He does fast and frequent prototyping, usually using the Freetronics twentyten which is an Arduino alternative that boasts a few features like a nice prototyping area, edge visible LEDs, and Mini USB. What is lacking, however, is a real-time clock. Instead of making another shield type system, he just wanted to permanently add this feature to his board. He shares the whole process is photographed and explained quite well for anyone who would want to follow along.