Let's Make Robots!

Sensing your servo's position

determines servo position

Sometimes you need to know what position a servo is currently in. Two examples are:

1. The robot has lots of legs and the power has just been turned on. Without knowing the servos current position the legs may become tangled when the servos are initialized.

2. A servo is being used to opperate a gripper. When an object is grabbed it prevents the servo from closing the gripper. By knowing what the actual position of the servo is we can:
   (a) determine the aproximate size of the object
   (b) adjust how tightly the servo grips the object

Most hobby servos use a simple pot to measure the position of the servo. Because the supply voltage of the servo can vary this pot usually connects between an internally regulated reference voltage and ground.

The internal reference voltage is usually between 2V - 4V (depends on the servo being used), well below the minimum opperating voltage of the servo. This means the voltage on the output of the pot (The middle pin) should be between 0V and the reference voltage which is easily measured by your processors analog inputs.

You can see in this terrible photo that the white wire goes to the center pin of the pot. I soldered a yellow wire to the PCB on the opposite side so that it fitted neatly inside the tiny servo case.

Using a cheap blue miniature servo my analog input gives me a reading between 97 and 801 as the servo rotates through almost 180 degrees. that gives me a resolution of aproximately 0.25 degrees which is plenty for most applications.

I have also tried this with a Futaba servo which seems to have a reference voltage of 2V. as such I only got values from 65 to 425 over almost 180 degrees which gave an aproximate resolution of 0.6 degrees.

I was getting some noise from the motor on my analog input. By inserting a 100nF capacitor between the power pins of the servo socket (no soldering required) the electrical noise was reduced noticeably. I recommend using sheilded cable with the sheild grounded if noise is still an issue.

Hope this helps, good luck and enjoy!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

You know I have been pondering for years if or if not this would work. Somehow the back of my mind said no, not possible ...so it stayed in the back of my mind (bad mistake).

Of course it works..... only now I see you have already "cracked the case" on this one...

...I have already done the mod to a MG90s servo and I work really well.

Why did I not see this three years ago. Duh.


There was another article I read about servo noise.

They suggested to twist the wires. This works for telephone as it reduces cross talk between ajacent wires.

Perhaps this is needed in this case to help drop the noise level. Also adding the cap helps too.


Just a thought.

Twisting the wires can help but in this case you just have a single signal wire and the 3 core ribbon cable of the servo. As electrical noise is generally high frequency and your analog is very low frequency, a second, 100nF cap from your signal wire to ground will be a more effective option.

A typical servo has a small potentiometer inside connected to the output shaft. The pot is wired with one side of the pot connected to ground and the other side to a reference voltage. The output (middle pin) gives a voltage that is proportional to the servo's position.

An analog servo will convert the incoming pulses from your microcontroller or RC receiver into a voltage and then compare the voltage of the signal with the voltage from the pot.

A digital servo has a small processor that reads the analog value of the pot and compares it to the pulse width of the signal.

The servo then adjust the speed and direction of it's motor in an attempt to match the value from the pot to the value of the signal. The greater the difference between the two values the faster the motor is driven.

A continuous rotation servo has the pot replaced by two resistors that give a voltage equal to the center position or a pot locked at the center position. The speed and direction of the motor are equal to the difference between the value of the incoming signal and the value of the central position created by the two resistors or locked pot.


Thanks.  Does that means that if a, for example, a 10ms pulse will position 'half left' on a servo that a 20ms pulse equals 'full left'?

I'm going to order one today.  Experimentation will help me as well. Thanks again.

In theory your signal range is 1mS - 2mS which is 1000uS - 2000uS.

1500uS is the center position.

In practice some servo brands have an increased range.
I have some servos that go from 700uS - 2300uS. 1500uS is still the center position.

Got it.  Thanks.


I am new to servos meaning I have never programmed one with a toy remote control in my hand...

Can you page slap me with a basic dummy guide to servo control that you would recommend?  I have seen several sites on the web that basicaly tell me how to pulse the control line for full left or full right or center, but I have not found a good tutorial on how the servo knows how to get to any angle in between.  Not that it is important because I'm just wanting the basics, but I am using the MSP430.

I did a similar thing when my servo motor's control board burned out! What I did was to connect the potentiometer to one of the micro-controller's analog to digital input and implement a PID servo controller into the micro. However, I think we can improve the method you described here by converting the potentiometer analog signal to digital in the servo and then send the result through I2C bus (for example) to the controller board. This reduces the noise effect majorly. However, it is more expensive to impelement but it is practical specially for cases in which the position of the potentiometer should be determined with minimum noise effect.