Servo control
I am working on a Human Powered Submarine for my capstone class, I have a 2 axis joystick controlling 4 servos. I need one of the axis' on the joystick to move one of its two servos counter clockwise and the other one clockwise. This way the control surfaces, that the servos control, rotate the same direction. Thanks for any help.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- Stephen
Are the servos continuous or not and do you need control of speed / angle.
Do you want motion from 8 of the joystick positions or 4.
Jeff T.
DEBUG "Program Running!"
time·········· VAR· Word
DO
· HIGH 7
· PAUSE 10
· RCTIME 7, 1, time
· time = time */ 500
· time = time + 400
· PULSOUT 14, time
·HIGH 7
· PAUSE 10
· RCTIME 7, 1, time
· time = time */ 500
· time = time + 400
· PULSOUT 13, time
· HIGH 8
· PAUSE 10
· RCTIME 8, 1, time
· time = time */ 500
· time = time + 400
· PULSOUT 12, time
· HIGH 8
· PAUSE 10
· RCTIME 8, 1, time
· time = time */ 500
· time = time + 400
· PULSOUT 15, time
LOOP
·
The servos should be getting pulses about every 20ms and you've got at least 40ms just of PAUSEs.
Another observation is that you're reading the joysticks twice. Is that necessary?
How about reading the one on pin 7 once, then doing the two PULSOUTs in succession (pin 14, then pin 13)?
That would also eliminate a pair of PAUSEs and get the loop time down to a bit over 20ms which is ok.
Generally, pulse widths less than 1.5ms result in movement of the servo in one direction while
pulse widths greater than 1.5ms result in movement of the servo in the other direction. You
could do the first PULSOUT using time, then the second using 750-time (for a BS2's timing granularity).
Obviously, you'd handle the other joystick axis and the other two servos the same way.