Centering Servo
Motors
In the September 2008 issue of SERVO
Magazine, we assembled and tested
the new SERVO TankBot kit with its
PICAXE-14M based Brain Alpha PC board.
This month, we’ll take a look at the process
of “centering” the TankBot’s servo motors,
which can greatly improve the TankBot’s
performance. Once we have tuned-up our
motors, we’ll implement a quick-and-easy
project that will enable us to control the
TankBot with any Universal TV remote
control capable of transmitting the Sony
Infrared Control (SIRC) protocol.
As we discussed in the
first Tankbot article back in
September, the PICAXE
servo command generates a
continuous pulse-train in
the background, suitable for
driving the TankBot’s servo
motors. The complete syntax
of the command is “servo,
pin, pulse” where “pin”
refers to the PICAXE I/O pin
to which the servo is
connected and “pulse” is a
value between 75 and 225
(in 10 μs units). Theoretically, 150 (1,500 μs or 1.5 ms) is
the center value that will cause the servo to stop rotating
altogether; values above 150 should cause the servo to
rotate in one direction (higher values produce faster
rotation) and values below 150 should produce servo
rotation in the opposite direction. This is in theory only –
actually, every servo’s center point varies somewhat from
the theoretical value of 150.
In the TankBot manual, there is a section that details
the procedure, for disassembling your servos and adjusting
them so that their center values are each exactly 150. If you
feel comfortable carrying out that procedure, it’s certainly
worth doing. However, for the benefit of readers who
would rather not explore the inner physical mechanism of
their servos, we’re going to approach the problem entirely
in software. When you have completed the following
procedure, you will know the actual center value for each
of your servos and be able to compensate for their
differences from the theoretical values in your TankBot
54 SERVO 12.2008
programs — without needing
to disassemble the motors.
Basically, we’re going
to take a trial-and-error
approach to finding the
actual center value for each
of our servos. Begin by
setting up your TankBot
with a block of wood (or
whatever) underneath it so
that both tank treads will
be free to rotate without
actually moving the
TankBot. We’ll be using the
Servo Test.bas program
shown in Figure 1 to
determine the actual center
value for each of our servos,
but before we do that there are a couple of things about
the program that require a brief explanation. First, since the
constant “motor” is set equal to 5, the program will only
test the TankBot’s left servo (which is connected to the
14M’s output5); later we will change the value of “motor”
to 4 and test the right servo. Secondly, I’m actually not a
bad speller, but because the word “stop” is reserved in the
PICAXE system and can’t be used as a name in a program,
we’ll be using “stopp.”
The main structure in the program is a “do...loop,”
which is a powerful structure for repeating the commands
it contains (again, see Part II of the PICAXE manual for
details). We are using the “do…loop” in its simplest form,
i.e., without a “while” or “until” clause that can specify
when to terminate the loop. Since we have not provided a
way of terminating, this form of the “do…loop” is called an
infinite loop — like the Eveready Bunny, it just keeps on
going (until the TankBot’s batteries give out)!
Finally, notice that the first time we issue a command