Let's Make Robots!

How to read servo angles

I am thinking to build a robot arm or similar construction which can perform pre-recorded moves.

So, my question is if there is any way to read the servo angle/position and store it in a value (lets say in the EEPROM) and later just run the program to read these values to perform the same moves than before.

Comment viewing options

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

I have tested my theory and have written a tip/walkthrough explaining how to do it.


Well, just let me say thank you ;-)

The pot inside the servo usually connects between ground and an internally regulated voltage of about 2.5V. You can just solder a wire onto the middle pin of the pot and read it directly.

As the servos reference voltage is less than the 5V used to power your processor you will not get the best resolution. There are two ways to improve the resolution.

1. feed the servo pots output to an amplifier

2. (assuming the use of an Arduino) If your application uses the analog inputs for reading servos only then you can change the ADC reference voltage to a lower value using the analogReference() command. Take care here, incorrect use could damage your analog inputs.


Thanks OddBot, will che check this too. So, are you saying I can use the servo AND read the pot at the same time by soldering the wire on the middle pin?

Yes. Your analog pin will be reading the same voltage from the pot that the servo circuitry uses to control it's movement.

For the sake of 1 extra wire this is the easiest and most accurate way to know the servos position.

Thanks Patrick and Chris, will see if I can do it. The thing wih the pots on the second arm seems the best solution, so you can assamble the arm and program it with the other one...and see right away the result.

Hi Lumi,

My idea was to use the modified servos on the second arm (use the cheapest servos you can find and remove everything except the pot, solder the 3 wires on the pot). The pot's of servos are linear and you can re-build exactly the same arm and you don't need to worry how to make joints on common pot's.

I got mini servos for 15 RMB per piece, they would be cheap enough to try this ;-)

Thanks Markus

My links are not linking right (in the comment above)

and I can't seem to find the exact post I wanted to show you...

Working on it.

By the way --I have seen the hacked servos with extra wires on the pots --they work well and it is a simple fix but I could never get past the fact that you are driving the gear-train the wrong way (when moving the servos by hand).

To cut to the chase, and in case I can't find the post, the solution is to build a second arm (possibly smaller and to scale) and put pots on the joints instead of servos. The robot brain's loop is to simply check the position of all the pots, and write those values to the eeprom. All the data is written sequentially, so all you need is to know the end number of each routine. --The start number for each routine is the end number (from the last routine) +1. Now, to play back your routine, you just run the procedure in reverse.

The eeprom is read back, step by step and the values are sent to your servos. You will have to play a bit with some pauses between each of the steps. This is to replicate the time it took for the micro processor to get through each loop when it was recording. A few tests with a stopwatch and you can easily play back at the same speed you recorded at. --or-- you can "puppet" the arm (when teaching) in slow motion. When played back, you lessen the pauses. This will give you the "regular" speed you want, but at much higher resoulution.