ENGR-50                                            Laboratory 2A                        

 

EEPROM and INCREMENTAL SPEED NAVIGATION

 

Objective: 

 

-- To control robot movement using a list of directions, "FRLFFLQ"

-- Add your own movement patterns, such as circles, 45 degree turns, etc.

-- Experiment with continuous/incremental speed changes in a for loop.

 

EEPROM

 

1)  Start with the for-loop for moving forward:

pulses var byte

 

main:

forward:

 for pulses = 1 to 60

 pulsout 12, 500

 pulsout 13, 1000

 pause 20

next

 

2)  Duplicate it three times, and modify each copy to go backwards, right, and left.

 

3)  Add line labels to identify each section         backward:        right:      left:

 

4)  after each section, insert a   goto main statement

 

5)  right under pulses var byte, make a new variable called instruction, set equal to "F"

instruction var byte ' Stores instruction retrieved from EEPROM.

instruction = "F"    ' set the value of instruction equal to the letter F

 

6)  Insert an if-then statement right after main:

if instruction = "F" then forward ' check if forward command, jump to line forward.

 

7)  add three more if-then statements for backward, right, and left

 

8) add a stop command right after all of your if-then statements

stop

 

9)  run the robot, change the value of instruction to B, R, L and Q, and see what happens

 

10)  add another variable beneath your other variables, to keep track of EE_prom address

EE_address var byte ' Stores & increments EEPROM address.

 

11) and a line of data for holding instructions right under that one

data "FFFBBLFFRFFQ" ' List of Boe-Bot navigation instructions.

 

 

12)  now, right after main, read the next instruction in the list

main:

read EE_address, instruction ' Read at EE_address & store in instruction

EE_address= EE_address+1

 

13) congratulations!  You can now control the robot simply by changing the data string.  This is one way programmers save memory space when doing complicated things.

 

 

INCREMENTAL SPEED NAVIGATION

 

Start with a new program,

pulses var byte

 

main:

for pulses = 0 to 500       ' start forward (500/1000, end backward (1000/500)

 pulsout 12, 500  + pulses

 pulsout 13, 1000 – pulses

 pause 20

next

 

The above program starts moving the robot forward, slowing gradually and reversing, until it is finally going backwards. What does the next program do?

 

main:          

for pulses = 0 to 250   ' start forward, end:_____________

 pulsout 12, 500 + pulses

 pulsout 13, 1000

 pause 20

next

 

for pulses = 0 to 500   ' starts turning left, ends:___________

 pulsout 12, 1000

 pulsout 13, 1000 – pulses

 pause 20

next

 

CHALLENGES: 

 

In your EEPROM program, add two more sections to allow a 45 degree turn (in other words, half of a right angle)  the symbol for a 45 degree left turn could be "l" and the symbol for a 45 degree right turn could be "r". Use these sections in a new data string.  This will come in handy if you decide in the challenge to draw a letter like the letter "M" or "N"

 

1) draw a block letter from the alphabet by changing your data list in the EEPROM program. The letter you choose should not contain any internal circles, for example, H, E, M, G, L, X,

 

2) merge your continuous loop program with your EEPROM program, using special symbols to allow adding circles, spirals, squares, to your drawing palette.