Page 278 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 278
Amphibionics 06 3/24/03 9:02 AM Page 257
Chapter 6 / Crocobot: Build Your Own Robotic Crocodile
16C71. These A/D converters will be used to convert the voltages
from the control stick potentiometers to 8-bit digital values. Each
potentiometer is configured as a voltage divider so that a unique
voltage represents each position along the X and Y axis. The
PicBasic Compiler also makes using the A/D converters very easy.
Using the ADCIN command, it is easy to set the number of bits in
the result, set the clock source, set the sampling rate, and set the
port pins to analog. Once that has all been set up, simply read the
channel value and store the result in a variable. I have listed all of
the A/D converter registers in the comments of the transmitter
code if you are interested in exactly what is happening.
The program for the robot is called rx-remote.bas and is listed in
Program 6.11. Compile the code and then program the PIC 16F84
with the rx-remote.hex file listed in Program 6.12. Insert the pro-
grammed 16F84 into the 18-pin socket on the robot’s main board.
The program for the remote control is called tx-remote.bas and is
listed in Program 6.13. Make sure that the PIC 16C71 has been U.V.
erased. Compile the code and then program the PIC 16C71 with the
tx-remote.hex file listed in Program 6.14. Insert the programmed
16C71 into the 18-pin socket on the remote control circuit board.
Place the robot on the floor and turn on the power. Turn on the
power to the remote control. Push the button on the front of the
remote. The robot should make a sound. Try controlling the robot’s
direction using the control stick. When everything is working cor-
rectly, place the top on the transmitter project enclosure and secure
it in place with the screws that came with the box.
With the control stick sitting in the middle position, the robot will
be stopped. With the stick pushed all the way forward, the robot
will walk forward. When the control stick is pulled backwards, the
robot will walk in reverse. When the control stick is positioned to
the right, the robot will turn to the right, and when the stick is
positioned to the left, the robot will turn to the left. The poten-
tiometer values were determined by taking the A/D readings and
257