Stuck on EepromNavigation program from Robotics with the BoeBot
Alright, I'm stumped! When running this program (code to follow), the BoeBot makes a reasonably accurate 1st left turn and right turn. The 2nd left turn, though, measures closer to 60deg rather than the expected 90. This is particularly troubling since both left turns reference the same subroutine. What am I missing? Does it matter (can't see why it would) if the BoeBot goes into the turn from reverse instead of forward?
Code:
' ROBTOICS with the BO-BOT - EepromNavigation.bs2
' Navigate using characteristics stored in EEPROM
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running"
'
!Variables!
pulsecount VAR Word
address VAR Byte
instruction VAR Byte
'
!EEPROM Data!
' Address: 0123456789
' ||||||||||
DATA "FLFFRBLBBQ"
'
!Initialization!
FREQOUT 4,1000,3000
'
!Main Routine!
DO UNTIL (instruction = "Q")
READ address, instruction
address=address+1
SELECT instruction
CASE "F": GOSUB Forward
CASE "B": GOSUB Backward
CASE "L": GOSUB Left_Turn
CASE "R": GOSUB Right_Turn
ENDSELECT
LOOP
FREQOUT 4,1000,2500
END
'
!Subroutine Forward!
Forward:
FOR pulsecount=1TO 64
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
'
!Subroutine Backward!
Backward:
FOR pulsecount=1TO 64
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
'
!Subroutine Left__Turn!
Left_Turn:
FOR pulsecount=1TO 17
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
'
!Subroutine Right_Turn!
Right_Turn:
FOR pulsecount=1TO 18
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
Code:
' ROBTOICS with the BO-BOT - EepromNavigation.bs2
' Navigate using characteristics stored in EEPROM
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running"
'
!Variables!
pulsecount VAR Word
address VAR Byte
instruction VAR Byte
'
!EEPROM Data!
' Address: 0123456789
' ||||||||||
DATA "FLFFRBLBBQ"
'
!Initialization!
FREQOUT 4,1000,3000
'
!Main Routine!
DO UNTIL (instruction = "Q")
READ address, instruction
address=address+1
SELECT instruction
CASE "F": GOSUB Forward
CASE "B": GOSUB Backward
CASE "L": GOSUB Left_Turn
CASE "R": GOSUB Right_Turn
ENDSELECT
LOOP
FREQOUT 4,1000,2500
END
'
!Subroutine Forward!
Forward:
FOR pulsecount=1TO 64
PULSOUT 13,850
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
'
!Subroutine Backward!
Backward:
FOR pulsecount=1TO 64
PULSOUT 13,650
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
'
!Subroutine Left__Turn!
Left_Turn:
FOR pulsecount=1TO 17
PULSOUT 13,650
PULSOUT 12,650
PAUSE 20
NEXT
RETURN
'
!Subroutine Right_Turn!
Right_Turn:
FOR pulsecount=1TO 18
PULSOUT 13,850
PULSOUT 12,850
PAUSE 20
NEXT
RETURN
Comments
I had that same thought, so I did, by placing
PULSOUT 13,750
PULSOUT 12, 750
PAUSE 20
at the beginning of the DO/LOOP. Couldn't tell that it had any positive effect (though I was able to see the pauses, esp between f/f commands), so I took it out.
BTW, it's noteworthy that there are at least two different ways to stop a servo. Sending a long stream of 750-uS pulses actually puts the brakes on to stop quickly. Alternatively, if you simply stop sending pulses to it and wait, it will coast to a stop more gently.