Using 2 Continuous Rotation Servos at Once
in BASIC Stamp
Hi all,
I am trying to move something on an x-y table, controlled by two continuous rotation servos. I am wondering how to get from point A to B "as the crow flies", by making both servos run simultaneously, as opposed to moving in direction 1 for a period of time and then direction 2 for a period of time. The main obstacle I am facing is getting both servos to operate at exactly the same time. If anyone could help me code this, that would help a lot. I'm using the Basic STAMP Board of Education revC.
I am trying to move something on an x-y table, controlled by two continuous rotation servos. I am wondering how to get from point A to B "as the crow flies", by making both servos run simultaneously, as opposed to moving in direction 1 for a period of time and then direction 2 for a period of time. The main obstacle I am facing is getting both servos to operate at exactly the same time. If anyone could help me code this, that would help a lot. I'm using the Basic STAMP Board of Education revC.
Comments
' count1 is time to run for servo 1 (20ms units) ' time1 is servo 1 control pulse width (2us units) ' count2 & time2 are similar for servo 2 ' This loop outputs servo control pulses as needed for ' servos 1 and 2 approximately every 20ms compensating ' for the times needed for the control pulses. When both ' servos are no longer running, the loop stops. do while count1 > 0 and count2 > 0 delay = 10000 ' 20 milliseconds if count1 > 0 then ' servo 1 still running pulsout servo1,time1 ' PULSOUT takes time1 to execute delay = delay - time1 ' adjust for that (2us per unit) count1 = count1 - 1 ' one less 20ms period to go endif if count2 > 0 then ' same thing for servo 2 pulsout servo2,time2 delay = delay - time2 count2 = count2 - 1 endif pause delay / 500 ' delay 20ms less time for servo pulses loop
The above code will run both servos at the same time with independent speed settings and durations, but servos are pretty sloppy. How are you going to ensure that you've moved to the coordinates you think you've moved to, particularly after several moves?