# position control of a servo with a potentiometer

Hi,

I am working on a rescue robot project. Here I need to change a servomotor's position according to an analog signal taken from a potentiometer connected to the motors shaft. I modified my servo to work on continuous rotation since a rotation of 90 degrees is not enough for me. I need to connect the servo to a potentiometer to get a signal for the servo's position, so that I can use it on my program written to control the robot. I am using Arduino Duemilanove to control the robot.

Basically I need help for getting the analog signal taken from the potentiometer into Arduino. Since I modified my servo to work on continous rotation you can consider it as a DC motor. I will be glad if you can help me on connections and arduino codes to get the signal and control the motor. An example code will be very nice so I can modify it to my project.

I need to connect the servo to a potentiometer to get a signal for the servo's position, so that I can use it on my program written to control the robot.

And there is a requirement that is sure to cause problems or damage. Because your servo is capable of continuous rotation and most pots have fixed travel (270 degrees is common) what happens when the pot reaches one of it's stops?

I have seen continuous rotation pots, but they are kind of rare, expensive and difficult to find. Have you obtained the pot yet?

What you probably need to do is evaluate the input from the analog pot and determine which direction the servo needs to rotate to bring the pot to its desired position. You probably could use the "map" function to decide what the desired input voltage from the pot should be, then send a "0" or "180" to the servo to turn in the direction needed to reposition the pot as desired. When the pot voltage matches the desired voltage, send the neutral/stop position to the servo (usually ~90).

I have seen continuous rotation pots, but they are kind of rare, expensive and difficult to find. Have you obtained the pot yet?

You mean a rotary encoder? ;D If you can get a high resolution rotary encoder then maybe that is what you need. I would have thought that a 270deg pot would be enough though as it has not been stated that 360deg is needed.

A stepper motor would be more appropriate than a continuous rotation servo as then it has set steps and is not just fast or slow, forward or reverse as a continuous rotation servo is...

Mowcius

You mean a rotary encoder?

There really are continous rotation pots that when you reach max resistance it 'jumps' to zero ohms and starts increasing again. I saw one application where a wind vane was coupled to such a pot to measure wind direction.

If you can get a high resolution rotary encoder then maybe that is what you need.

But unless it's a absolute mult-channel encoder it will lack a reference of it's inital position.

I would have thought that a 270deg pot would be enough though as it has not been stated that 360deg is needed.

The problem is that there is nothing to keep the servo from moving past a single turn and thus the problem of coupling to a pot that does have hard stops.

A stepper motor would be more appropriate than a continuous rotation servo as then it has set steps and is not just fast or slow, forward or reverse as a continuous rotation servo is...

Again a external reference sensor would be required to set the initial position on start-up.

Again a external reference sensor would be required to set the initial position on start-up.

Yes but it should be easier on a stepper as you have more control over the position movement.

There really are continous rotation pots that when you reach max resistance it 'jumps' to zero ohms and starts increasing again. I saw one application where a wind vane was coupled to such a pot to measure wind direction.

Yeah I know, I was just pulling your leg about the rotary encoder ;D

Mowcius