robotics with the Boe-Bot, Whisker and led question-Chapter 5
Dave45
Posts: 36
When I run the program in the book to have the Led's light up when a whisker touches it starts the program at the beginning as soon as a whisker touches something. Running the whiskers without the Led code works right. The only way I could get it to work was to enter the Led code after the gosub commands. When I entered it as the book show's it, it restarts the program. Wiring has been triple checked, it's right. Any ideas why when the code to light the Led's is first it restarts? Program that works is below.
'Robotics with the Boe-Bot - RoamingWithWhiskersAndLeds.bs2
'Boe-Bot uses whiskers to detect objects, and navigates around them.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
pulsecount······ VAR··· Byte·········· 'For...Next loop counter.
FREQOUT 4, 2000, 3000
DO
· IF (IN5 = 0) AND (IN7 = 0) THEN····· 'Both whiskers detect obstacles
··· GOSUB back_up····················· 'Back up and U-turn (Left twice)
··· GOSUB turn_left
··· GOSUB turn_left
··· HIGH 10
··· HIGH 1
· ELSEIF (IN5 = 0) THEN··············· 'Left whisker contacts
··· GOSUB back_up····················· 'Back up and turn right
··· GOSUB turn_right
··· HIGH 10
· ELSEIF (IN7 = 0) THEN··············· 'Right whisker contacts
··· GOSUB back_up····················· 'Back up and turn left
··· GOSUB turn_left
··· HIGH 1
· ELSE································ 'Both whiskers 1, no contacts
··· LOW 10
··· LOW 1
··· GOSUB forward_pulse··············· 'Apply a forward pulse
· ENDIF······························· 'and check again
LOOP
forward_pulse:························ 'Send a single pulse forward.
·· PULSOUT 13, 850
·· PULSOUT 12, 680
·· PAUSE 20
· RETURN
turn_left:···························· 'Left turn, about 90-degrees
· FOR pulsecount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
turn_right:··························· 'Right turn, about 90-degrees
· FOR pulsecount = 0 TO 20
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
back_up:······························ 'Back up
· FOR pulsecount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 820
··· PAUSE 20
· NEXT
· RETURN
'Robotics with the Boe-Bot - RoamingWithWhiskersAndLeds.bs2
'Boe-Bot uses whiskers to detect objects, and navigates around them.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
pulsecount······ VAR··· Byte·········· 'For...Next loop counter.
FREQOUT 4, 2000, 3000
DO
· IF (IN5 = 0) AND (IN7 = 0) THEN····· 'Both whiskers detect obstacles
··· GOSUB back_up····················· 'Back up and U-turn (Left twice)
··· GOSUB turn_left
··· GOSUB turn_left
··· HIGH 10
··· HIGH 1
· ELSEIF (IN5 = 0) THEN··············· 'Left whisker contacts
··· GOSUB back_up····················· 'Back up and turn right
··· GOSUB turn_right
··· HIGH 10
· ELSEIF (IN7 = 0) THEN··············· 'Right whisker contacts
··· GOSUB back_up····················· 'Back up and turn left
··· GOSUB turn_left
··· HIGH 1
· ELSE································ 'Both whiskers 1, no contacts
··· LOW 10
··· LOW 1
··· GOSUB forward_pulse··············· 'Apply a forward pulse
· ENDIF······························· 'and check again
LOOP
forward_pulse:························ 'Send a single pulse forward.
·· PULSOUT 13, 850
·· PULSOUT 12, 680
·· PAUSE 20
· RETURN
turn_left:···························· 'Left turn, about 90-degrees
· FOR pulsecount = 0 TO 20
··· PULSOUT 13, 650
··· PULSOUT 12, 650
··· PAUSE 20
· NEXT
· RETURN
turn_right:··························· 'Right turn, about 90-degrees
· FOR pulsecount = 0 TO 20
··· PULSOUT 13, 850
··· PULSOUT 12, 850
··· PAUSE 20
· NEXT
· RETURN
back_up:······························ 'Back up
· FOR pulsecount = 0 TO 40
··· PULSOUT 13, 650
··· PULSOUT 12, 820
··· PAUSE 20
· NEXT
· RETURN
Comments
Post Edited (ebf306) : 1/11/2006 4:24:58 AM GMT
This now makes a GOOD DEAL of sense!
The problem starts and end when you HIT THE WALL. This should NEVER happen! Once you hit the wall, the motors will stall. A stalled motor with no overcurrent protection will draw HUGE amounts of current. This HUGE current drawdown is causing the Stamp to reset, because the brownout protection is seeing an inordinately LOW VOLTAGE. The HIGH current drawdown will cause a LOW voltage condition to appear.
Once you move it away from the wall, all goes well UNITL you HIT another wall. The solution is, your whiskers must extent out far enough, or the bot must be rolling slow enough that hitting the wall is not a possibility. These are robots, not bumper cars
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com