Shop OBEX P1 Docs P2 Docs Learn Events
Getting Stuck — Parallax Forums

Getting Stuck

nwojessenwojesse Posts: 10
edited 2006-10-19 16:29 in Learn with BlocklyProp
Both of the basic stamps that I am using get stuck on a FOR...NEXT loop.

Here is the code:

' Robotics with the Boe-Bot - BothServosThreeSeconds.bs2
' Run both servos in opposite directions for three seconds, then reverse
' the direction of both servos and run another three seconds.
' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Program Running!"
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
The only problem is that the servos just keep running the first FOR..NEXT loop and never moves on to the second.sad.gif
P.S. I am using·two properly wired Boe-Bots.

Comments

  • edited 2006-10-18 16:51
    Try a new set of AA alkaline batteries.·
    ·
    With tired batteries, the voltage drops too low when the servos demand more current for the direction change.· The BASIC Stamp has a brownout detection circuit that shuts it down until the supply voltage returns to acceptable levels.· When the BASIC Stamp starts up again, it starts at the beginning of the program.·
    ·
    You might notice a hesitation between each time·it executes the first FOR...NEXT loop.· During that time, the second FOR...NEXT loop starts and the sudden reverse of the motors draws too much current, causing the supply voltage to drop.· The BASIC Stamp shuts itself back down, so the servos stop drawing power.· The supply voltage returns, and the program starts over again at the beginning, with the first FOR...NEXT loop.
    ·
    In Robotics with the Boe-Bot, we put a piezospeaker on the Boe-Bot and add a FREQOUT command to the beginning of the program.· If the Boe-Bot beeps in the middle of a maneuver, it's a sign that the batteries are tiring out.
    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
  • nwojessenwojesse Posts: 10
    edited 2006-10-18 21:32
    Well that's sad. "Change the batteries!" I can see why, though. That's going to be a lot of batteries. Thanks a bunch.

    Post Edited (nwojesse) : 10/19/2006 2:36:07 PM GMT
  • Mike GreenMike Green Posts: 23,101
    edited 2006-10-18 23:14
    A 6V NiMH rechargable battery pack (with 5 cells) should work fine in the BOE-BOT other than trying to figure out where the 5th cell goes. 4 cells only gives you 4.8 to 5V which is a little low for the regulator on the BOE. The servos would be happy with it.
  • AImanAIman Posts: 531
    edited 2006-10-19 13:21
    I realize the BOE-BOT is mobile, however with the descrition you are giving it sounds like a sationary application. If its possible you may want to consider a power source you can plug into the wall. No batteries to change.
  • nwojessenwojesse Posts: 10
    edited 2006-10-19 14:35
    Thanks guys. Yes, my instructor and I have been looking a power supplies for when the Boe-Bot doesn't have to be running around. Unfortunately, for most of my application, I have to see what it does. Therefore, I do need some kind of mobile power source. When my instructor got the Boe-Bots, it came with battery holders. The only problem is, you can only fit four. So thanks, Mr. Green, for that idea. We will check it out.
  • edited 2006-10-19 16:29
    Regarding power supplies that plug into the wall, it's important to have the servo power jumper in the correct position. Please see pages 60-61 in Robotics with the Boe-Bot v2.2.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
Sign In or Register to comment.