April
1998, Issue 93
Software
Development for RTOSs
A REAL-TIME
EXAMPLE
So,
enough of the theories. Lets look at a real example.
Remember the RC-servobased robot controller I
told you about last month for the six-legged Stiquito
II robots? If you recall, I presented some sample code
to illustrate the idea of interrupt latency.
To
illustrate two kinds software development environmentstarget
and host basedI ported the interrupt-based servo
driver and gait generator to two popular RTOSs, Phar
Lap ETS and QNX. While the original example also included
a network-based command interpreter, I wont worry
about it for here. (Ill save it for another column.)
I
replaced the main module with a new module,
test1.c (shown
in Listings 1ab), which does the necessary initialization
and starts GaitThread(), which is implemented in
module
gait.c (see
Listing 2).
GaitThread()
is a high-level
process, which computes the necessary patterns for the
legs actuators. The RC-servobased driver is implemented
using an interrupt service routine in gait.c. Just
like test1.c, ISRs
are RTOS specific, so I have two versions, which are
given in Listings 3a and 3b.