Help! - Programming 6 servos with 2 tact switches

Dear all,
Is there any way i can use only 2 switches to control my servos (i have six servos) individually?
When i added PULSOUT 15, DURATION below the PULSOUT 14, DURATION
Both servos rotate identically at the same time, which is not what i want.
I want to be able to control each of the six servos individually with the 2 switches … (or do i need 12 switches to control these 6 servos instead?)
Would anyone lend me a helping hand, please?
Thanksss.
Kah Yee Wong
Melbourne, Australia


’ {$STAMP BS2}
’ {$PBASIC 2.5}

DURATION VAR Word

DURATION =750

DO
IF IN0=1 THEN
IF DURATION > 500 THEN
DURATION = DURATION - 25
ENDIF
ENDIF

IF IN1=1 THEN
IF DURATION < 1000 THEN
DURATION = DURATION + 25
ENDIF
ENDIF

PULSOUT 14, DURATION
’ PULSOUT 15, DURATION
PAUSE 10

DEBUG HOME, DEC4 DURATION, " = DURATION"

LOOP


What ever servo(s) you want to go in the opposite direction, you might have to reverse them by sending them the opposite of 750 pulse command (what ever that is). Check your stamp manual… So pulse one bank 750 and the other bank 1250 (I think that’s the opposite).

Richard

thanks for the response but i guess u haven’t got my message.
i would like to control 6 servos individually with 2 tact switches. The code above only allows me to utilise the 2 tact switches for ONLY ONE SERVO.
With the code above, one tact switch controls clock-wise motion while one tact switch controls counter clock-wise motion.
I know the pulse that would cause counter close-wise and clock-wise motion.
Anyway, thanks for your response… appreciate that.
Kah Yee Wong
Melbourne, Australia

I’m not sure about the tact switches, but most switches only have two states, open (0) and closed (1). If you have two switches, the normal logic would only support four outputs. You could have 00, 10, 01, and 11. Using a demultiplexing setup, you could send a 1 to control a single servo at a time, while the other three would get a 0 sent to them.

It sounds like your problem is finding a way to select 1 of the 6 servos to receive the adjustment. You can use the fact that both switches pressed is an invalid condition to set a selection mode. For example press both switches for half a second so the controller knows you are going to select a servo, press and release one of the switches a number of times to pick a servo, now press the other switch to indicate you have finished selecting, and finally use the switches as before with one being CW and the other CCW adjustments to the servo position. This is crude but would allow for the setup you present. A better design would allow for some sort of user feedback as to which servo was currently selected for modification, such as an LED. If you are using digital servos you may be able to exploit the fact that they don’t move without any signal applied and then source an LED from the signal line itself, since only the selected servo would be receiving updates. Another crude but possibly effective way would be to “twitch” the servo as it was selected by moving it a small fraction and then back to its setting position.

Other than the constraints of your problem you don’t provide any useful information to determine what may or may not be practical for you to implement, thus you get what you get and if folks don’t get your message it is not becasue they are not trying. :wink:

Im With Eddie, I don’t quite understand if 6 servos are to be moved indipendently from just two outputs? Or like what Eddie said where you want to “program” which of the six servos to modify for movement.

:question: :question:

I think I get the jist of it. Like EddieB said, use both buttons, but just to select the servo you want to move. then one switch can adjust CW and the other is CCW on the selected servo. Then to move to the next servo press both buttons again. Having a speaker or LED would make it much easier to know you are now ready to adjust the next servo in the series.