Chapter 4: Boe-Bot Navigation · Page 157
SUMMARY
This chapter introduced the basic Boe-Bot maneuvers: forward, backward, rotating in
place to turn to the right or left, and pivoting. The type of maneuver is determined by the
PULSOUT commands’ Duration arguments. How far the maneuver goes is determined
by the
FOR…NEXT loop’s StartValue and EndValue arguments.
Chapter 2 included a hardware adjustment, physically centering the Boe-Bot’s servos
with a screwdriver. This chapter focused on fine tuning adjustments made by
manipulating the software. Specifically, a difference in rotation speed between the two
servos was compensated for by changing the
PULSOUT command’s Duration argument
for the faster of the two servos. This changes the Boe-Bot’s path from a curve to a
straight line if the servos are not perfectly matched. To refine turning so that the Boe-Bot
turns to the desired angle, the
StartValue and EndValue arguments of a FOR…NEXT loop
can be adjusted.
Programming the Boe-Bot to travel a pre-defined distance can be accomplished by
measuring the distance it travels in one second, with the help of a ruler. Using this
distance, and the number of pulses in one second of run time, you can calculate the
number of pulses required to cover a desired distance.
Ramping was introduced as a way to gradually accelerate and decelerate. It’s kinder to
the servos, and we recommended that you use your own ramping routines in place of the
abrupt start and stop routines shown in the example programs. Ramping is accomplished
by taking the same variable that’s used as the
Counter argument in a FOR…NEXT loop and
adding it to or subtracting it from 750 in the
PULSOUT command’s Duration argument.
Subroutines were introduced as a way to make pre-programmed maneuvers reusable by a
PBASIC program. Instead of writing an entire
FOR…NEXT loop for each new maneuver, a
single subroutine that contains a
FOR…NEXT loop can be executed as needed with the
GOSUB command. A subroutine begins with a label, and ends with the RETURN command.
A subroutine is called from the main program with a
GOSUB command. When the
subroutine is finished and it encounters the
RETURN command, the next command to be
executed is the one immediately following the
GOSUB command.