Shop OBEX P1 Docs P2 Docs Learn Events
robotics with the Boe-Bot, Whisker and led question-Chapter 5 — Parallax Forums

robotics with the Boe-Bot, Whisker and led question-Chapter 5

Dave45Dave45 Posts: 36
edited 2006-01-12 01:12 in BASIC Stamp
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

Comments

  • Earl FosterEarl Foster Posts: 185
    edited 2006-01-11 04:18
    It should work the same with the exception of the order of operations.· Can you give any other details?

    Post Edited (ebf306) : 1/11/2006 4:24:58 AM GMT
  • Dave45Dave45 Posts: 36
    edited 2006-01-11 10:49
    In the book the high commands to turn on the Led's is above the gosubs. When I write the program that way when the Boe-Bot runs into a wall the speaker will beep indicating the program is starting over. Instead of backing up and turning it will try to go forward again. Just keeps doing this. When I put the HIGH command after the gosubs the Boe-Bot will back up and turn the way it's suppose to. The led's don't light until after the turn. I think the led's should light when the whiskers first make contact, writing it the way it shows in the book. Not a big deal, I just wanted to understand why this happens.
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2006-01-11 11:22
    Dave -

    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 smile.gif

    Regards,

    Bruce Bates
  • Dave45Dave45 Posts: 36
    edited 2006-01-11 12:14
    Sorry, I forgot to mention that it does the· same thing·even if you hold the robot in your hand and push the whisker with your hand. It happens on contact with either whiskers independently or when both touch at once. I didn't mean the Boe-Bot hits the wall, I meant when the whiskers·hit the wall. The whiskers stick out about 3 inches in front of the Boe-Bot. I can't figure out how the order of the commands would cause this to happen. At first i thought it was a short of some kind, but I've checked everything. When everything looked good I figured I had typed something wrong. That wasn't it either. So then i changed the order of the commands and it worked. It's just that the Led's don't light until after the gosubs.· Like I said, it's not a big deal, I just want to understand why this happens. Thanks for your reply's.
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2006-01-11 15:33
    Dave, it sounds as if your whiskers may be wired incorrectly, shorting Vss to Vdd when activated.· Can you confirm how these are wired?· Shorting the supply like that will also cause a reset via the brown-out circuit.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Dave45Dave45 Posts: 36
    edited 2006-01-12 01:12
    The thing is, the whiskers work perfectly without the commands to light the led's when a whisker is pressed. They will even·work when the high commands are after the gosub commands. The only time it does it is when the HIGH commands for the Led's is put before the gosub commands. I've checked all wiring and it's right. Thanks for the responses.
Sign In or Register to comment.