Introduction to real-time systems 17
Both situations may involve responding to sensors providing feedback infor-
mation. There are several different types of motor available, each with its
own special area of application: stepper, DC servo, universal AC, induction
AC, and synchronous AC. DC servo and stepper motors are most commonly
controlled with microprocessors; the latter we will meet again in Chapter 2.
Both DC servo and steppers can provide rotation and dynamic positioning.
Stepper motors in particular require accurately timed sequences of pulses to
control their speed and direction.
Microprocessor-based controllers can handle such a problem by holding
pulse pattern tables in memory and accessing the entries in sequence at the
correct rate. Another interesting type of positioning servo motor is supplied
by Futaba for model makers. It also uses a digital pulse input to specify
the required angular position of the motor shaft. Commonly, a 2 ms pulse
will indicate a central, neutral position, a 1.5 ms pulse sets the shaft to
45
and a 2.5 ms pulse sends the shaft to +45
. Unfortunately, unlike the
stepper motor, the positioning pulses need to be repeated every 20 ms, to
refresh the controller. This is quite a problem for a processor when several
positioning units have to be serviced simultaneously, as is the case with a
robot arm. Arranging for five timing pulses to be dispatched every 20 ms,
with an accuracy of 50
µs, really does benefit from some special hardware
support.
1.12 Debugging real-time systems
When debugging real-time code extra difficulties emerge, such as the impos-
sibility of usefully single stepping through doubtful code, or reproducing
elusive, time critical input situations. Inserting a neanderthal
printf( )
statement in an attempt to isolate the bug will completely change the execu-
tion timing (my aged PC/200 takes nearly 1 ms to complete a call to printf).
Confusion often arises when dealing with prototype hardware. Errors can be
blamed on the software, when in fact the problem is due to the new electron-
ics. Such uncertainty makes debugging more difficult and challenging. Extra
equipment may need to be acquired, by purchase, hire or loan, to generate
complex test signals, and capture the results using sophisticated logic ana-
lysers, In Circuit Emulators (ICE) or digital storage oscilloscopes. Initially, a
very useful trick is to insert a couple of output instructions within your code,
which will emit a short indicator pulse from a spare output port. This can
be picked up by the oscilloscope and viewed. It is an enormous advantage to
be able to see the relative timings of ongoing processing activity, set against
traces obtained from external events. When dealing with systems which are
processing fast streams of data interleaved with intermittent, much slower
events, capturing the correct sequences for analysis can be tricky. In this
situation, you may be able to get your software to trigger the viewing trace,
and so synchronize the oscilloscope display to the events under investigation.

Get Real-Time Systems Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.