- moving 2 servo at one time -
sushiandmorihiko
Posts: 40
hello,its me again,
i wonder if i can move 2 servo together at one time eg i have this code:
FOR boom = 1200 TO 470 STEP 40
PULSOUT 2, boom
PAUSE 20
NEXT
PAUSE 200
FOR boom = 470 TO 1200 STEP 40
PULSOUT 2, boom
PAUSE 20
NEXT
PAUSE 200
FOR boom = 1200 TO 300 STEP 40
PULSOUT 3, boom
PAUSE 40
NEXT
PAUSE 200
FOR boom = 300 TO 1200 STEP 40
PULSOUT 3, boom
PAUSE 40
NEXT
PAUSE 200
conventionally,they should move step by step, after the upper part is done than it will get to the lower part. can i execute these part together so that the servo will move together too?
thanks ,people
i wonder if i can move 2 servo together at one time eg i have this code:
FOR boom = 1200 TO 470 STEP 40
PULSOUT 2, boom
PAUSE 20
NEXT
PAUSE 200
FOR boom = 470 TO 1200 STEP 40
PULSOUT 2, boom
PAUSE 20
NEXT
PAUSE 200
FOR boom = 1200 TO 300 STEP 40
PULSOUT 3, boom
PAUSE 40
NEXT
PAUSE 200
FOR boom = 300 TO 1200 STEP 40
PULSOUT 3, boom
PAUSE 40
NEXT
PAUSE 200
conventionally,they should move step by step, after the upper part is done than it will get to the lower part. can i execute these part together so that the servo will move together too?
thanks ,people
Comments
The second loop works the same way. You can even have the two servos move differently if you
compute the two pulse widths somehow. For example, you could have the loop count represent
the percentage of movement from the beginning, then compute the two different pulse widths
from that. The loop would read FOR percent = 1 TO 100 and you'd do the computation accordingly.
how do i do the calculation--i think it is going to be complex isnt it
thanks mike green
PULSOUT 2,boom
PULSOUT 3,1500-boom
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
It's been awhile for my program,
but would something like this work?
FOR
boom1 = 1200 TO 470 STEP 40
boom2 = 1200 TO 300 STEP 40
PULSOUT 2, boom1
PULSOUT 3, boom2
PAUSE 20
NEXT
PAUSE 200
FOR
boom1 = 470 TO 1200 STEP 40
boom2 = 300 TO 1200 STEP 40
PULSOUT 2, boom1
PULSOUT 3, boom2
PAUSE 20
NEXT
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
David
There are 10 types of people in this world,...
Those that understand binary numbers, and those that don't!!!
That's not legal PBasic. Read the section of the manual on the FOR statement.
Like I said, it's been a little bit for me.
Just throwing out an idea.
Have a good one!!!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
David
There are 10 types of people in this world,...
Those that understand binary numbers, and those that don't!!!
FOR boom1 = 1200 TO 470 STEP 40
boom2 = boom2 + 40
PULSOUT 2, boom1
Pulsout 3, boom2
PAUSE 20
NEXT
PAUSE 200
boom2 = 1200
FOR boom1 = 470 TO 1200 STEP 40
boom2 = boom2 - 40
PULSOUT 2, boom1
pulsout 3, boom2
PAUSE 20
NEXT
PAUSE 200
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
' {$STAMP BS2}
' {$PBASIC 2.5}
BoomPos1 VAR Word
BoomPos2 VAR Word
I······· VAR Word
FOR I = 0 TO 22
· BoomPos1 = 1200 - (40 * I)
· BoomPos2 = 400 + (40 * I)
· PULSOUT 2, BoomPos1
· PULSOUT 3, BoomPos2
· PAUSE 20
NEXT
FOR I = 0 TO 22
· BoomPos1 = 400 + (40 * I)
· BoomPos2 = 1200 - (40 * I)
· PULSOUT 2, BoomPos1
· PULSOUT 3, BoomPos2
· PAUSE 20
NEXT
Point being, you've got a 'starting position', an 'ending position', and some 'increment' to get you there, and a certain number of steps.· Within that framework, you have a lot of freedom.