that the voltage levels are correct, turn off both power
switches and (using jumper wires) connect the two pins of
H2 to the corresponding power rails of the breadboard and
connect the upper rails to the lower rails — ground to
ground and +5V to +5V, of course! Turn on the “Board
Power” switch again and use your multimeter to check that
the breadboard is powered correctly. Finally, turn off the
board power once more and insert the 14M in its socket,
making certain that pin 1 is to the upper-left.
Before we actually program the TankBot, let’s make
sure that Brain Alpha’s circuitry is functioning properly. To
do so, you need two items: a “straight-through” serial cable
to connect between your PC’s serial port; and the DB9
female connector on the Brain Alpha Board, along with the
free PICAXE Programming Editor software available from
Revolution Education ( www.reved.co.uk/picaxe). There
isn’t space here to go into detail on how to use the
Programming Editor, but it’s very intuitive and includes
ample documentation.
In a future article, we’ll explore an
advanced feature of the PICAXE-14M; some
of its pins can be converted from inputs to
outputs and vice versa. (As you probably
have guessed, it’s the pins with the bidirectional carets.) For the time being,
however, we’re going to disregard the
carets on the legends of H1 and H3 and
simply use the H1 pins as the 14M’s inputs
and the H3 pins as its outputs. Our test
circuit is ultra-simple: Just attach an LED
and 330 ohm current limiting resistor
between output 2 of H3 and ground as
shown in Figure 5. Actually, if you look
closely at the photograph in Figure 5 you
won’t see the current-limiting resistor
because it’s built into the LED I am using
(see www.JRHackett.net/LEDs.htm),
which makes bread-boarding a little simpler.
To make sure that the Brain Alpha board is
functioning properly, we are going to
download a “Hello World” Basic program
shown in Figure 6. It’s very simple and can be
quickly typed into the Programming Editor
directly. Once you have done so, make sure
Brain Alpha is powered and then choose
“Run” under the “PICAXE” menu in the
Programming Editor. After a brief delay,
you should see the LED blink slowly. If not,
double-check your wiring and try again. If
you can’t resolve the issue, email me at
Ron@JRHackett.net and I’ll try to help.
Once we know that the Brain Alpha board
is working properly, we can move on to
testing the TankBot. Before we do so, we
need to briefly discuss servo motors and the
PICAXE “servo” command. We’ll just cover
the basics here; a detailed discussion can be found in Part II
of the PICAXE manual (available on the RevEd website or
under the “help” menu of the Programming Editor software).
The TankBot’s servo motors require a continuous pulse-train
to operate. The pulses must each be between 0.75 ms and
2. 25 ms, and must occur in 20 ms intervals. Theoretically,
a 1. 50 ms pulse-train (halfway between the two extremes)
will cause the servo to stop rotating. In reality, a servo’s
“stop” value may differ slightly from the theoretical value
of 1. 5 ms. (You will need to experiment with your servos to
find their exact stop values.) As the pulse length increases
upward from 1. 5 ms the servo rotates proportionally faster
in one direction. As the pulse length decreases downward
from 1. 5 ms, the servo rotates proportionally faster in the
opposite direction. As a result, we have fully proportional
speed control of the servo with 75 steps in both directions.
The format for the PICAXE servo command is “servo pin,
pulse” where “pin” is the output pin to which the servo is
■ FIGURE 4
SERVO 09.2008 59