Page 158 ·
Robotics with the Boe-Bot
The BASIC Stamp’s EEPROM stores the program it runs, but you can take advantage of
any unused portion of the program to store values. This is a great way to store custom
navigation routines. The
DATA
directive can store values in EEPROM. Bytes are stored
by default, but adding the
Word
modifier to each data item allows you to store values up
to 65535 in two bytes’ worth of EEPROM memory space. You can read values back out
of EEPROM using the
READ
command. If you are retrieving a word-sized variable, make
sure to place a
Word
modifier before the variable that will receive the value that
READ
fetches.
SELECT…CASE
was introduced as a way of evaluating a variable on a case by
case basis, and executing a different code block depending on the case. Optional
DO…LOOP
conditions are helpful in certain circumstances;
DO UNTIL
(Condition)
...
LOOP
and
DO
...
LOOP UNTIL (Condition)
were demonstrated as ways to
keep executing a
DO…LOOP
until a particular condition is detected.
Questions
1.
What direction does the left wheel have to turn to make the Boe-Bot go forward?
What direction does the right wheel have to turn?
2.
When the Boe-Bot pivots to the left, what are the right and left wheels doing?
What PBASIC commands do you need to make the Boe-Bot pivot left?
3.
If your Boe-Bot veers slightly to the left when you are running a program to
make it go straight ahead, how do you correct this? What command needs to be
adjusted and what kind of adjustment should you make?
4.
If your Boe-Bot travels 11 in/s, how many pulses will it take to make it travel 36
inches?
5.
What’s the relationship between a
FOR…NEXT
loop’s
Counter
argument and the
PULSOUT
command’s
Duration
argument that makes ramping possible?
6.
What directive can you use to pre-store values in the BASIC Stamp’s EEPROM
before running a program?
7.
What command can you use to retrieve a value stored in EEPROM and copy it to
a variable?
8.
What code block can you use to select a particular variable and evaluate it on a
case by case basis and execute a different code block for each case?
9.
What are the different conditions that can be used with
DO…LOOP
?
Exercises
1.
Write a routine that makes the Boe-Bot back up for 350 pulses.