Shop OBEX P1 Docs P2 Docs Learn Events
BStamp problem Code or electric — Parallax Forums

BStamp problem Code or electric

yceman_cristiyceman_cristi Posts: 5
edited 2009-11-05 22:44 in BASIC Stamp
Hy, I have a little problem and i don't see the solution. shakehead.gif I have a normal Boe Bot with a BStamp 2px. The problem is the following: i run a normal code to move the engines front, back, clockwise and counter clockwise. For each movement i have a simple message. while operating the code on the BStamp it runs with no problem, once i start the engines it goes into an infinite loop and executes only the first part, the second i close the engines the programs continues normal. Sorry for the code the attachment manager had an error. Please help me solve the problem. Thanks

Program
' {$STAMP BS2px}
' {$PBASIC 2.5}

i VAR Word

FOR i=1 TO 120
PULSOUT 15,850
PULSOUT 14,850
PAUSE 20
DEBUG "a"
NEXT

FOR i=1 TO 124
PULSOUT 15,650
PULSOUT 14,650
PAUSE 20
DEBUG "b"
NEXT

FOR i=1 TO 122
PULSOUT 14,650
PULSOUT 15,850
PAUSE 20
DEBUG "c"
NEXT

FOR i=1 TO 122
PULSOUT 15,650
PULSOUT 14,850
PAUSE 20
DEBUG "d"
NEXT
end

response from debug: the program should drive the robot with approximation 3 sec in each movement, when i shut down the engines it continues with b

aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccc
ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccdddddddddddddddddddddddddddddddddddddddddddddddddddddddddd
dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2009-11-05 17:59
    Before the first "FOR" statement, put
    DEBUG "Starting..."

    Sometimes when using servo-motors with a BS2, you 'brown-out' reset the BS2. If you have the above 'debug' statement, you'll see the brown-out reset occurring.
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-11-05 18:01
    Oh, and the numbers you're using for PULSOUT look like they're for a BS2 'plain', not a BS2px. The 'tick size' is different, I believe.
  • yceman_cristiyceman_cristi Posts: 5
    edited 2009-11-05 18:08
    Thanks for the idee, but i have done that the reset occurs after the first for , how can I correct this problem by code?
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-05 18:12
    You can't correct the problem by coding. You have to fix the power supply problem.

    That's not completely true. You have two problems

    1) The PULSOUT constants (850 and 650) need to be changed when you use a BS2px. On a BS2, they cause the PULSOUT to produce a pulse of 1700us and 1300us respectively. They would need to be changed to 2125 and 1625 respectively for a BS2px to produce the same pulses.

    2) You are probably powering the servos from Vdd (the regulated +5V supply). Servos when they're first starting to move or when they're under mechanical load can draw a lot of current, as much as 1 Ampere. You're starting two servos at the same time. That could easily require more current than the regulator can supply and maybe more current than the battery can supply. The Stamp's supply voltage drops below about 4.3V and it automatically resets. You need to power the servos from the unregulated input supply and that supply voltage has to be in the range 6-7.5V, higher and the servo motors can be damaged.

    Post Edited (Mike Green) : 11/5/2009 6:24:01 PM GMT
  • yceman_cristiyceman_cristi Posts: 5
    edited 2009-11-05 18:14
    Sorry idea, yes it is for a normal BStamp 2 but were can i find the difference, i thought the code was the same, the performance difference being the only one.
  • Mike GreenMike Green Posts: 23,101
    edited 2009-11-05 18:24
    The "Basic Stamp Syntax and Reference Manual" and the help files of the Stamp Editor both contain the information on the timing differences for the various statements. Look at the section on the PULSOUT statement for the specific units used for the BS2 (2us) and the BS2px (0.8us). The serial input and output statement also have timing differences (SERIN and SEROUT).
  • yceman_cristiyceman_cristi Posts: 5
    edited 2009-11-05 19:10
    Thanks Mike, you are right, the duration is 0.8 not 2(for BStamp 2), i was just calculating the power requirement and the servos seem to be operating in the 140mA +- 50mA with no load, i am operating on piles so i think on the second point your also right. I'm just working with Basic stamp just about 3 days and I love the support that I'm getting. Thank you very much.
  • allanlane5allanlane5 Posts: 3,815
    edited 2009-11-05 20:12
    "on piles" meaning "on battery" for us US-ians. I hope you're using AA or larger batteries for this, a nine-volt can't give more than 50 mA or so.
  • yceman_cristiyceman_cristi Posts: 5
    edited 2009-11-05 22:44
    yes on battery, actually i am using 4xAA, the problem with a nine volt is that the engine has the working voltage between 4-6 V, of course it can go up in load , but 9 V is to much(500>= mA curent in a normal one ). Thanks for the posts and help allanlane5.
Sign In or Register to comment.