[previous]
[index]
[next]
Example 9: Displaying Messages on an LED Wand Clock
This example demonstrates the application of tasking, FIFOs and
interrupt service routines to the display of messages on a
Fantazein® LED wand clock.
- The stock clock has a built-in microcontroller that lets you set
messages via a keypad.
- A wand with 8 LEDs waves back and forth. As it waves, the LEDs
change to display dots for the current vertical segment of the message
character. Persistence of vision makes the message appear suspended in
space.
 |
 |
Information on the stock clock is at www.fantazein.com
You'll need to
hack into it and do a bunch of rewiring to connect it to the parallel
port.
Read these instructions to hack the
clock and void your warrantee.
|
Principle of Operation
- Hardware hacks to the clock redirect the 8 LEDs from the built-in
microcontroller to the output data bits of the parallel port.
- A Hall effect sensor generates an interrupt when the wand passes
into and out of one of the ends. This is also redirected to the
parallel port.
- The main task that writes the LEDs suspends itself immediately
upon execution. It never runs periodically.
- An interrupt service routine resumes the main task, with a flag
that signifies which direction the wand is waving.
- Depending on the wand direction, the main task outputs a bit
pattern appropriate to the current vertical segment of the character
to be displayed, and reschedules itself to run sometime later.
- These segments are computed from a font definition file, stored in
an array in the Linux task, and sent using a FIFO to the RT task.
- No new RT Linux concepts are introduced here. We're putting
together what we've learned in the previous examples. For the curious,
the Linux application code shows how to get immediate keyboard input
by setting the non-blocking option.
Running the Demo
To run the demo, change to the 'ex09_ledclock' subdirectory of the
top-level tutorial directory, and run the 'run' script by typing
./run
Alternatively, change to the top-level tutorial directory and run the
'runall' script there by typing
./runall
and selecting the "LED Clock" button.
Type in messages, which are then displayed banner-like on the wand
clock. RETURN clears the messages, CTRL-C stops the demo.
See the Real-Time Task Code
See the Linux Application Code
Next: Example 10, Determining Stack Size
Back: Example 8, RC Airplane Servomotor Control