|
by Jeff Loeliger
Start ý The
Answer Isý ý Designing Functions ý Demonstration
ý Youýre in Control ý Sources
and PDF
When dabbling in robotics, one of the
hardest things encountered is obtaining the motors and geartrains.
One solution is to use RC servosýthey are cheap, lightweight, hard
wearing, come in many sizes, and have a standard interface. The drawback
is that they are relatively hard to control.
There are a few options open for controlling
servos. You can use the main micro (obviously takes up valuable CPU
time), a separate control board (more expensive and cumbersome), or
you can use a custom chip (again, more expensive).
This article covers implementing a fourth
option that involves no extra cost and no loading to the CPU, and
provides control of up to 16 servos.
PROBLEM DEFINITION
Servos have a three-wire interface: ground,
power, and control. The input to the control line is a pulse-code
modulated signal from which all servo timings and positions are derived.
All servos have their own limits but convention states that applying
a 1.5-ms signal holds the servo in neutral, a 1-ms signal turns it
full counter-clockwise, and a 2-ms signal results in a full clockwise
turn (see Figure 1). The signal must be repeated no less than every
30ý50 ms or the servo may start jittering and finally stop driving
the output. The result would be the loss of active hold on the desired
position. The use of timer hardware and software algorithms is therefore
essential to allow the accurate control of timed events.
|
|
| Figure 1ýThe control signal
for a servo should be repeated every 30ý50 ms. By convention,
1.5 ms signal is centered. |
As I mentioned earlier, there are three
options currently available for servo timing control. The first method
is the main microcontroller. When controlling the servo with software
alone, itýs often hard to obtain an accurate output of the control
signal. If the CPU is overloaded, the signal may be less accurate
which causes the servo to jitter. This form of control also places
extra loading on the CPU. Timer hardware can be used on the main microcontroller
to eliminate jitter. However, the number of channels available is
usually limited.
The second method, using an external
board for servo control, adds to the cost of the system and takes
up valuable space (a commodity not usually in abundance in robotic
systems). Servo control with an external board requires a serial signal
via a UART interface. The main micro-controller must therefore have
a spare UART interface to talk to the servo controller. Coordination
problems can also arise because the speed of the UART interface determines
how fast the CPU can update the servo positions.
The third and final option is the custom
chip. This form of control has the same UART issues as described in
the external board solution. Although less of an issue on size, it
can significantly add to the overall system cost.
NEXT
Circuit Cellar provides up-to-date information for engineers. Visit
www.circuitcellar.com for
more information and additional articles.
For subscription information, call (860) 875-2199, subscribe@circuitcellar.com
or subscribe online.
ýCircuit Cellar, the Magazine for Computer Applications. Posted with
permission. |