nested for...next loops
Glimpy
Posts: 5
This code doesn't work for me.
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM2}
k VAR Word
l VAR Word
FOR k=400 TO 1200 STEP 20
DEBUG DEC k ,CR
FOR l=1 TO 10
PULSOUT 14,k
· PAUSE 20
NEXT
NEXT
If it works for you then let me know what I'm doing wrong.
' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM2}
k VAR Word
l VAR Word
FOR k=400 TO 1200 STEP 20
DEBUG DEC k ,CR
FOR l=1 TO 10
PULSOUT 14,k
· PAUSE 20
NEXT
NEXT
If it works for you then let me know what I'm doing wrong.
Comments
What is causing you to believe it's not working?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
If you see the reset message more than once then you know the BASIC Stamp is being reset by some problem with your circuit or programming connection.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Post Edited (Jon Williams) : 12/2/2004 1:51:52 PM GMT
I have white connected to P14 through a resistor, black is connected to ground and red is connected to +. These colors are the wire colors on the servo. Disconnecting the servo alleviates the problem. What suggestions have you? Could the servo be shorted white to black?
This only happens when you don't have a large enough power supply driving the Servo.
How are you powering this board? With a 9-volt battery? With a 6-volt wall-wart?
Is the Servo connected to 'Vin' (which is the un-regulated output from the wall-wart) or the 'Vdd' (which is the 5-volt regulated output from the 7805)? With a 6-volt wall-wart, it should be connected to Vin.
The 'holding' torque of servo's from different manufacturer's does vary. The Parallax supplied Futaba servo's can be turned by hand. I've held other vendor's servo's that couldn't. The servo output shaft is tied to the servo motor through reduction gears, which could make it difficult or impossible for you to turn the servo by hand.
Possible solutions (one of the following may fix the problem)
1. Use a 7.5 or higher voltage wall-wart, and drive the servo from Vdd (there's a jumper on the BOE to select this)
2. Drive the Servo from Vin if you aren't already.
3. Replace the 7804 with a low-drop-out regulator. (LM3804-5? Not sure of the exact part number) A low drop-out regulator will regulate down to about 0.5 volts difference between input and output voltages.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office