|
All About Servos
What's
Inside a servo
A servo consists of a small motor, a gearset, a feedback
potentiometer (variable resistor), and some control
electronics. The motor spins at variable speeds (much
faster than the output shaft) and is coupled to a (reduction)
gearset that converts the motor's high speed into something
that is more usable for our purpose. When you reduce
the motor's speed through a reduction gearset, you gain
torque. Torque is the 'twisting' power of the servo
-the more torque, the heavier the object the servo can
move.
How They Work
A servo is a classic example of a closed-loop feedback
system. The potentiometer is coupled to the output gear.
It's resistance is proportional to the position of the
servo's output shaft (0° to 180 °). This resistance
is used by the control electronics to generate an error
signal when the desired position isn't the same as the
current position. If you send a servo a command to place
itself at 90° and the head is actually at 45°,
an error signal will cause the motor to move the head
(via the gears) until the error signal is 0 (when the
head has reached 90°). If the head had been at 180°,
an error signal of opposite polarity would have been
generated and the motor would have turned in the oposite
direction to bring the head 'back' to 90°. As you
can see, the current position is 'fed-back' to the control
system in a loop to maintain a zero error signal. The
farther the actual position from the desired position,
the faster the motor turns to bring the error back to
zero.
How are They Controlled
Servos have 3 wires coming out of them: Power, Ground
and Control. The Control lead is used to send the positioning
signal we're going to talk about. Servos are controlled
using a system called Pulse Code Modulation (PCM). In
order to understand this, you need to understand the
terms "miliseconds"(ms) and "microseconds"(µs).
1 ms is 1/1000th of a second; or put another way, there
are 1000 ms in every second. 1 µs is 1/1,000,000th
(one -one millionth) of a second, or, there are 1 million
µs in each second. Servo manufacturers usually
specify pulse-widths in µs, so it's hands to be
able to convert between µs and ms. The servo's
electronics work in 20 ms blocks (50 of them every second).
For each 20 ms block, the servo needs to see a positive-going
pulse who's period (width in ms) tells it where to position
the head (output shaft).
The period of the pulse that is sent determines where
(0° to 180°) to place the head. Different servo
manufacturers require different pulse-widths, so you
have to experiment a little to find the pulse-widths
that correspond to each position. For example, the Futaba
servo sold by HVW Technologies has a 90° position
(middle) pulse-width of about 1.5 ms. This means that
if you send a 1.5 ms pulse to the servo at least once
every 20 ms, the servo will move to, and hold at, it's
90° position. If you try to turn the head with your
hand you will feel the servo forcing against you, trying
to keep the 90° position.
This is easily done with a BASIC Stamp 2, with a single
line of code:
PULSOUT pin, 750
where pin is the Stamp pin connected to the
servo's control line. The PULSOUT command works in multiples
of 2 µs, so we need 750 x 2µs = 1500 µS
which is 1.5 ms
In practice, you can send pulses more often that once
every 20 ms; you can send them less often as well, but
if you don't send any pulses for about 50 ms or so,
the control electronics in the servo will "go to
sleep"(enter a power-saving mode). Don't forget,
servos were designed for R/C airplanes and cars, where
battery life is important. When a servo powers-down,
it no longer works against an applied force to maintain
it's position. You will find that even then the head
is fairly difficult to turn.
Continuous Rotation
For many applications, modified servos make excellent
drive wheels for mobile robots -but how do you get them
to keep going around instead of stopping at 180°
? There are a couple of problems:
- The feedback loop: The servos' head gear
is connected to the feedback potentiometer (so it
can track the head's position and "feed-back"this
information to the control electronics). The potentiometer
has a finite resistance -it can't keep increasing
with successive rotations of the head gear.
- Mechanical Stop: The head gear has a little
plastic tab on it that hits other plastic tabs on
the servo's case at the 0° and 180° positions.
This tab stops the head from going all the way around
Solution ? -Make the servo think that it's head is
always at the 90° (middle) point (there are 2 ways
to do this, see below) and cut-off the plastic tab.
When you give it a command to go to 0°, the control
circuitry will see that the head is at 90° and will
turn the motor on to try and bring the head to 0°.
What happens though is that since the resistance isn't
changing as the head moves, the control system will
keep the motor on forever. Telling the servo to go to
180° will cause the motor to spin (forever) in the
opposite direction. The tab no longer mechanically stops
the head. Presto ! a very nifty little gearmotor.
There are 2 ways to make the servo think it's head
is always at 90°:
- Method 1: Remove the potentiometer and replace
it with 2 resistors who's values match the "center"
resistance of the potentiometer.
- Method 2: Leave the potentiometer in, but
stop it from turning with the head gear.
Which method should you use ? -That depends
on your application, but generally, the second method
is much faster and simpler. Some things to consider:
|
Method 1
|
Method 2
|
|
PRO
|
CON
|
PRO
|
CON
|
- Immune to vibrations
- You have a nice little pot left over
|
- Can't be easily un-done
- Requires you find suitable resistors to replace
pot.
- Requires soldering
|
- Fast
- Easily reversed
- No soldering
|
|
Drawbacks
- Servos can have their drawbacks; they're not incredibly
powerful although they are ceratinly strong enough
for most people's needs.
- Unless you spend considerably more for servos with
ball bearings, the servo's lifespan may be less than
what you might hope for. Back to our earlier comment
about what servos are designed for, they are NOT designed
to support several pounds of side force while continuously
rotating. Realize that a few minutes of continuous
rotation on a robot weighing 2 pounds is the equivalent
in wear to many, many, many hours of use in it's intended
area of use (R/C Planes, cars etc.). That said, you
can still expect most servos -even those without ball
bearings, to last several years of intermittent experimental
or competition (not Sumo competitions !) use. If you
have an application that will see extended, continuous,
or heavy-duty use buy ball-bearing servos -they cost
more but will last much longer and provide smoother
performance.
- Servos require constant attention from the control
system. A pulse must be sent every 20 ms or more so
the control electronics must continuously allocate
resources to do this. Not a huge problem in most cases.
|