Controlling 2 servos at almost the same time with BS2
jacko87
Posts: 6
Hi all,
I have a problem with my project. I need to run at least 2 servo motors at almost the same time using BS2. Here is my simple BS2 code:
the specification of the 1st servo is pulse 2100 at -90deg and pulse 1250 at 90deg, and the 2nd servo is pulse 2350 at -90deg and pulse 1670 at 90deg.
The code above will make 1st servo run slowly from -90deg to 90deg, however the 2nd servo will run from 90deg to more then -90deg.
I need the 2nd servo to run to -90deg (from pulse 1670 to 2350). The servo I use is GWS S-125 Standard 360Deg. Can anyone help me with this?
Thx before..
I have a problem with my project. I need to run at least 2 servo motors at almost the same time using BS2. Here is my simple BS2 code:
' {$STAMP BS2p} ' {$PBASIC 2.5} PULSE VAR Word PULSE2 VAR Word Init: PULSE2 = 1670 MAIN: FOR PULSE = 2100 TO 1250 STEP 5 PULSOUT 0, PULSE PULSOUT 1, PULSE2 PULSE2 = PULSE2 + 5 PAUSE 20 NEXT
the specification of the 1st servo is pulse 2100 at -90deg and pulse 1250 at 90deg, and the 2nd servo is pulse 2350 at -90deg and pulse 1670 at 90deg.
The code above will make 1st servo run slowly from -90deg to 90deg, however the 2nd servo will run from 90deg to more then -90deg.
I need the 2nd servo to run to -90deg (from pulse 1670 to 2350). The servo I use is GWS S-125 Standard 360Deg. Can anyone help me with this?
Thx before..
Comments
If you need PULSE2 to go from 1670 to 2350, then that's a Delta of 680, or 136 after you divide the step increment.
For your code, instead of using the line...
PULSE2 = PULSE2 + 5
... change it to...
PULSE2 = PULSE2 + 4
... 4 times 170 (<- the number of iterations from your FOR/NEXT loop) equals 680 which is the Delta you want on PULSE2
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
is there other method to run 2 servos at almost the same time? I thought of using FOR too for the 2nd Servo, but the loop for the 2nd servo will be carried out repetitively.. Can I combine AND or OR Function with FOR?