Page 266 - Amphibionics : Build Your Own Biologically Inspired Robot
P. 266
Amphibionics 06 3/24/03 9:02 AM Page 245
Chapter 6 / Crocobot: Build Your Own Robotic Crocodile
switch, since that was possibly the position that is was stopped
at during the last cycle. The program goes into a tight while loop
to monitor the leg switch. When the leg makes a complete cycle,
the leg switch is activated, program execution breaks out of the
while loop, and the leg motor is turned off. The microcontroller
then goes through the same logic with the right leg moving in a
forward direction. With both the left leg and the right leg moving
for one cycle in the forward direction, the robot’s body is moved
forward. This logic works for most cases, but depending on the
position of the leg during the last leg cycle, the leg may actually
trigger the switch right away, and a full leg cycle does not occur.
This is taken care of by having each routine run twice, so that if
a cycle was missed on the first time through, it will occur the
second time through.
Each of the walking routines uses the logic stated above. In order
for the robot to walk in reverse, both legs move in the reverse
direction. To turn the robot to the right, the left leg moves forward
and the right leg moves in reverse. To turn the robot to the left, the
left leg moves in reverse, while the right leg moves forward. Any of
the four walking routines can be combined to diversify the move-
ment. An example of this would be if you wanted the robot to move
forward and to the right. This would be accomplished by calling
the forward subroutine and then the right subroutine, alternating
between the two.
Program 6.5 is called walk-routines.bas. This program demonstrates
each of the four walking routines that will be used later with the
remote control. Program the PIC 16F84 with the walk-routines.hex
file listed in Program 6.6. When the program executes, the robot will
run through the forward routine five times, for a total of 10 leg cycles.
It will then turn to the left, walk in reverse, and then turn to the right.
Now that the walking routines have been developed, the radio
remote control can be added.
245