FIGURE 3. Hardware setup on Brain Alpha PCB.
“volume down” arranged in a convenient diamond-pattern with an “enter” key in the center, then you
don’t need the labels at all. In any case, jot down the
actual key names for the five keys you want to use and
the corresponding values from the chart of “infra”
values for each key-press presented in Figure 5. I’ll be
using the appropriate values for the remote shown
earlier in Figure 4.
Finally, a word of caution may be in order. Most
Universal remotes have a row of buttons near the top
that allow you to switch between controlling a TV, a
VCR (how quaint!), a DVD player, or whatever. The
SIRC protocols involved are different for each device
and PICAXE processors are only capable of responding
to the TV protocol. So, if you are in the middle of
experimenting and you lose control (of the TankBot,
that is), you may have accidentally pressed the button
for one of the other remote functions; pressing “TV”
again should correct the problem.
10 digit keys for channel selection, which are almost always
laid out in the configuration shown in the “before” side on
the left. To clearly identify the relevant keys, I used a small
label printer to print four arrows and a “no smoking”
symbol (which was the closest my label printer could get to
“stop”), used a paper-punch to make them round, and
pasted them in the layout shown in the “after” photo on
the right of Figure 4.
If you are fortunate enough to find a remote with keys
for “channel up,” “channel down,” “volume up,” and
FIGURE 4. Universal IR remote (with and without labels).
56 SERVO 12.2008
Taking Control — Software
The software we will be using ( TankBotRemote.bas) is
too large to include here, so it’s available for download
from the SERVO website. Now is a good time to download
it and print out a copy for use with the following discussion. To begin with, (as you can see in your printout), I have
included the arithmetic involved in arriving at the values for
the four directional constants that I used in the program.
Be sure to calculate your own directional constants based
on the two “stopp” values you obtained when you tested
your servos. Also, as we did in the Servo Test.bas program
previously, we are again using a simple “do…loop” as a
means of implementing an infinite loop.
With this in mind, let’s take a look at what’s happening
inside our infinite loop. When the TankBot is initially
powered up, it’s just sitting there waiting for an “infrain2”
command to be received. At that point, all program
execution is paused until a key is pressed on the SIRC TV
remote. As soon as that happens, the value of the key press
is placed in the built-in variable “infra.” Because the “infra”
variable is built in, you don’t need to declare it in your
program – it’s always available. Actually, “infra” is just
another name for variable b13, so whenever you use it
in a program make sure you don’t also assign b13 to some
other variable. If you do, it won’t be flagged as an error but
your program will most likely malfunction.
As soon as a key is pressed on the remote, its value
(refer to Figure 5) is assigned to “infra” and the program
continues execution. The function of the next two “low”
commands is to be sure that both servos are completely
stopped. You might be tempted to use your two “stopp”
values for this purpose, but there is a good reason for not
doing so: Over time, your servo’s “stopp” value can change
slightly due to mechanical wear so your TankBot could
move very slowly when you want it to be stopped entirely.