Shop OBEX P1 Docs P2 Docs Learn Events
BOE Bot servo question — Parallax Forums

BOE Bot servo question

rpl3000rpl3000 Posts: 2
edited 2013-01-02 17:15 in BASIC Stamp
I'm going through the "Robotics with the BOE-Bot" book and I reached a glitch or there is something that I don't understand.

I'm at the point of making the two continuous servos run for three seconds and then reverse. When I first loaded and ran the code the servos would run for three seconds, then reverse direction for a instant and then rotate the initial direction for three seconds.... repeat. Also the debug window continuously displays "program running" so it seems that the program is being reset w/o finishing.

Can anyone offer any insight? I'm using a USB and the USB to 232 adapter.

When I comment out one PULSOUT in the seconf FOR loop sometimes it works as expected. Sometimes it resets the program w/o finishing.

' {$STAMP BS2}
' {$PBASIC 2.5}

' make the servo's run for a fixed time
' ControlServoRunTimes.bs2

DEBUG "program running", CR

counter VAR Byte

FOR counter = 1 TO 122
PULSOUT 13, 850
PULSOUT 12, 650
PAUSE 20
NEXT

FOR counter = 1 TO 122
PULSOUT 13, 650
PULSOUT 12, 850
PAUSE 20
NEXT

END


edit:
I can repeat the glitch.
When I load it from the editor, it resets. If I turn off the board, then turn it to position 1 and run it, the LEDs go out after 6 seconds, as expected. Then I switch the position 2 and run, it reverses as expected. When I then run it from the editor, the reverse glitch happens.

Comments

  • ercoerco Posts: 20,257
    edited 2013-01-01 17:41
    Low batteries, probably resetting the Stamp when you suddenly reverse. Try new batteries. Also try a PAUSE 1000 between your loops to avoid super high current draw when slamming from full forward to reverse.
  • rpl3000rpl3000 Posts: 2
    edited 2013-01-02 17:06
    Excelllent thanks!

    The batteries were at 5.2V. I checked but thought that this was OK voltage. The "pause 1000" also worked great even at 5.2V

    Now can someone please explain what happened? The servos reverse drawing more current than usual for an instant, so what happens that makes the chip reset? Which pin drops in voltage or is it something else?
  • ercoerco Posts: 20,257
    edited 2013-01-02 17:15
    rpl3000 wrote: »
    The "pause 1000" also worked great even at 5.2V

    Now can someone please explain what happened? The servos reverse drawing more current than usual for an instant, so what happens that makes the chip reset? Which pin drops in voltage or is it something else?

    Yes, the motors and Stamp are all powered by the same batteries. Instant reverse (without the pause) briefly draws so much current through the servos that the battery voltage drops below the minimum that the electronics (regulator & Stamp) need, so the Stamp resets like you just turned it on. The pause 1000 reduces the current spike and voltage drop.

    5.2 volts is pretty marginal! 4 new AA batteries are closer to 6.4V initially.
  • erco wrote: »
    rpl3000 wrote: »
    The "pause 1000" also worked great even at 5.2V

    Now can someone please explain what happened? The servos reverse drawing more current than usual for an instant, so what happens that makes the chip reset? Which pin drops in voltage or is it something else?

    Yes, the motors and Stamp are all powered by the same batteries. Instant reverse (without the pause) briefly draws so much current through the servos that the battery voltage drops below the minimum that the electronics (regulator & Stamp) need, so the Stamp resets like you just turned it on. The pause 1000 reduces the current spike and voltage drop.

    5.2 volts is pretty marginal! 4 new AA batteries are closer to 6.4V initially.

    Hey man, so this is like a post 3 years in the future, but thanks, this helped. It was like a, I quote "Magic School Bus experience." Thanks again, even if you didn't realize it.

  • ercoerco Posts: 20,257
    Thank me in 2019 and we'll call it even. :)
Sign In or Register to comment.