# continuous servo position control

With a continuous rotation servo I can control the direction and the speed of the servo, but I need to control the position as well. I know it's not possible directly due to lack of feedback control in a continuous servo, but I found some hints about adding an encoder to let you control the position.

Is it possible to add an encoder to a continuous servo to control its position, and if so, how?

Also, can I add a thing to block the motion of the servo like the picture below or would having such a stop effect and damage the servo?

• I've already made a mistake and bought a continuous servos so i'm trying to find a solution – jimmy cluter Feb 3 '13 at 18:52
• It sounds like you want a conventional servo, not a continuous servo, for this application. – Dave Tweed Feb 3 '13 at 18:59
• You could also look at reconnecting the internal potentiometer of the servo, since most so-called "continuous operation" servos I know of, simply have the pot disconnected, everyhing else remains as is. – Anindo Ghosh Feb 3 '13 at 19:07
• @AnindoGhosh : i don't think that the internal potentiometer is existed in the one i bought , but i will try to open it to check that. – jimmy cluter Feb 3 '13 at 19:10
• Since you're looking for a quick and cheap hack to correct an error, rather than general guidelines on good design practice, this question needs to be closed as being "too localized" to your particular situation. – Dave Tweed Feb 4 '13 at 15:12

Yes, a rotary encoder can be added to any motor, including a servo that has been modified for continuous rotation, and used for position control.

However, this is a bit counter-intuitive, since the servo's internal circuitry already provides position control, using the integrated potentiometer as a rotary sensor. Disconnecting this positioning mechanism, then adding an external position determination sensor or encoder to achieve the same result seems unnecessary.

Be that as it may, the usual method to obtain such position control with a rotary encoder involves bonding the rotary encoder to the shaft of the motor, then taking the encoded values into a microcontroller, using a PID algorithm in the microcontroller, driven as a function of this position information, to control voltage and polarity of the motor for bringing the motor to a halt at the desired position.

In very simplified terms, if the servo's detected position, courtesy the rotary encoder, is clockwise to the desired position, the PID algorithm would rotate the motor anti-clockwise until the two positions are identical. Vice versa for detected position being anti-clockwise to the desired position. If any external torque moves the shaft away from the rest position subsequently, the rotary encoder feeds fresh angular data to the PID code, which then applies the logic outlined above.

Regarding addition of a mechanical stop to a servo motor, this is a feasible approach in general - the motor will draw its stall current, which is higher than normal operating current. You do need to check the datasheet of the motor in question to verify how long it can withstand stall current, though. Not all motors can cope with constant stall.

The solution in such case can be one of the following:

• Use code in the microcontroller, along with appropriate current sensing circuitry, to detect when the motor current goes over a calibrated threshold, i.e. the motor stops at the mechanical stop. At such time, stop powering the motor. This is complex, and non-trivial at the circuitry end due to power losses in the sense resistor you use. For large current motors, Hall current sensors or non-invasive sensors can be used, reducing the power loss.
• Use a limit switch instead of a mechanical hard stop, and use the switch close signal as a digital input to your microcontroller, and use code to stop powering the motor when the limit is triggered. This is the simplest and least expensive solution, and safe for the motor as well.

The only servos that "lack" movement or position sensing are cheap hobby servos. Those are the worst kind to use for any kind of rugged system. Not only do they only read feedback over a partial arc (not 360 degrees,) but they also don't even return any feedback to the commander at all.

You can buy higher-quality servos with real position encoders, real current sensors, PID controllers for motion control, RS-485 serial communciation both ways, and much more. Those servos can "go to a point" or "rotate at a speed" or do any other kind of motion you want.

For example, I'm putting this guy in my current project:

http://support.robotis.com/en/product/dynamixel/mx_series/mx-64.htm

It's still a "hobby" style servo, but quite capable and so far, real

• these PID controllers are greats and exactly what i need , but if u take a look at their price in amazon they costs about 219$and others 499$ , so they are not cheap . but @Anindo-Ghosh suggests to add a rotary servo and bonding it with the shaft encoder and using a PID algorithm on the microcontroller to control the position , i know this will adds overhead but its a cheap solution – jimmy cluter Feb 4 '13 at 8:48
• In general, you will get what you pay for. – Jon Watte Feb 6 '13 at 0:48