How to set up a servo limit switch?

Thread Starter

danforth

Joined May 8, 2011
22
Hello, I am trying to set up a servo limit switch. The servo is a standard hobby servo (used in R/C cars) modified for continuous rotation. It is being controlled by a basic wired servo driver (PWM).

Hobby servos are controlled by a pulse width range of 1.0ms - 2.0ms with 1.5ms being the "center". So for example when the servo driver knob is turned to the left (between 1.0ms and 1.5ms) the servo will turn to the left. When the driver knob is turned to the right (between 1.5ms and 2.0ms) the servo will turn to the right.

Basically what I want to happen is when the limit switch is tripped I want the servo to stop moving in that direction and only be able to work when the knob is turned in the opposite direction. So for example if the servo is moving left and the limit switch is tripped the servo will stop and the knob on the driver will only work when turned to the right.

I hope I made this simple to understand.:cool: Oh, and I will be forever grateful to anyone who has any ideas on how to make this work.
 

#12

Joined Nov 30, 2010
18,224
The limit switches that I know about are simple mechanical devices. You place a normally closed micro-switch where the motion of the servo will click it at the stop point, and the switch stops the current to the servo.
 

Thread Starter

danforth

Joined May 8, 2011
22
Oh sorry, I forgot to add that the servo must be powered on at all times. Cutting power to the servo is not an option because then the servo will not work when the knob is turned the opposite direction. Also if the power is cut the servo will not maintain its "holding power" and the drive train will drift.

What I had in mind is that when the limit switch is tripped it switches to a different circuit which stops the servo in one direction only. Then when the servo moves away from the switch it is returned to normal. So it will be a "momentary" switch.
 

Kermit2

Joined Feb 5, 2010
4,162
Then you must use the 1.5ms 'center' you describe, and change any motor drive PWM signal to this whenever the switch is contacted. According to your description(?) the motor would then be powered but would not turn left or right. Additional logic would be required after that, which can tell which way the motor WAS turning and change the PWM signal to move the motor in the OPPOSITE direction.
OR
The switch would/should override the control temporarily and cause other circuits to provide the 'neutral' PWM signal to stop the motor, it will also have to relinquish control after a short time, back to the main control. If the main control is still trying to drive the motor the wrong way, this circuit would again assume control and this loop would continue until the main control knob is turned in the proper direction to move the motor away from the switch.

Something like that?
 

Thread Starter

danforth

Joined May 8, 2011
22
Kermit, yes you are right, that is actually what I was thinking. When the switch is tripped I must provide the servo with a 1.5ms pulse signal to stop it. The part I am having trouble with is how to regain normal control of the servo and move it away from the switch. Somehow only provide a 1.5ms pulse when the knob is turned one way (toward the limit switch) yet the knob will still have the ability to control the servo in the opposite direction and guide the servo away from the limit switch.

I will draw up a quick schematic to make my vision more clear. Thank you for your idea by the way.
 

Thread Starter

danforth

Joined May 8, 2011
22


By the way the driver knob is not spring loaded. It is just a basic potentiometer which translates the resistance of the potentiometer into a PWM signal which is then sent to the servo.

Ok so for example, when the carriage hits the limit switch on the left, the knob will be somewhere between the 1.0ms and 1.5ms range. If I can somehow switch that entire left range to 1.5ms while still maintaining the integrity of the 1.5ms - 2.0ms range then I am golden. Because then I will be able to move the carriage in the opposite direction (towards the right).
 

shortbus

Joined Sep 30, 2009
10,045
Could you use the limit switch to trigger a secondary oscillator that is set to the 1.5ms signal(say a 555 astable with no pot, just trimmers to set frequency) Once you turn the main control on the driver it will over ride the limit ciruit.
 

John P

Joined Oct 14, 2008
2,025
Reading the messages I was just forming a reply "A processor could do this" when I reached djsfantasi's response.

But it's pretty tricky. If hitting the switch caused the pulse width to go to 1.5msec, the carriage won't simply stop where it is, instead it'll immediately move to the middle of the track. What you'd need to do would be to pre-calibrate the system and figure out what the PW is for each limit switch location, and prevent the input from ever exceeding that, meaning it mustn't be too high for one end or too low for the other. I'm not even sure that limit switches really belong in this device. If you correctly limit the servo input, you'd never be able to drive it past the usable range.
 
Top