Let's Make Robots!

Sensing servo feedback


I'm new to this forum, robotics, electronics and microcontrollers, however I have been programming a long time and I'm currently studying computer science.

I recently bought an Arduino board with the purpose of making robots for experimenting with my special interest: AI.

I wish to build a walking robot and experiment with varios ways of giving it a nervous system. So I will need to find a way to get feedback directly from the servos, thereby being able to read the amount of stress (load) they experience at a given time.

So far I thought of 3 ways to do this:

1) The simplest way is connecting the servo output (=the servos ground wire) to an analog in port on the Arduino. My classmate who's into electronics said this was possible if I attached a small resisitor to the Arduino ground. The thing is he said that the Arduino would have a large resistor build in (so to speak) on the analog in. So if I just connected the servo output to the analog in without the resistor I would get no reading cause the electricity would flow into the Arduino ground where there is no resistance. Makes sense. He also calculated that I need a 6 ohm resistor based on the peak current draw of the servos I intend to use (HXT900 = 750mA). I'll try this out soon.

2) I could also use a current sensor (thermistor I believe they're called) to do the same thing, connecting it either to the servos 5V input or the output (not sure how?), and again reading the value from an analog in port. I'll also try this solution.

3) This is the really cool but difficult solution. A servo has build in a potentiometer. There are ways to modify servos so that you can read the position from this potentiomenter. Then one can actually move the servos position MANUALLY and later read it's position. And it can also provide a way of reading the stress of the servo.

Here is a manual on this conversion:


So basically I need all the advice/input I can get. Does this sound plausible? Is there a 4th or 5th solution I haven't considered? Anyone has tried something similar? Any ideas would be appreciated...

Aniss1001 :)

Comment viewing options

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

Your explanation is a bit technical for me so I'll need a bit of time to digest it. Or rather I added a few items to my research todo list. Eg. error signal, high and low comparitor, transisents..

Just one thing..You said: "..you could also measure the current. This will require careful processing as it full of transisents such as the current / error when the motor first starts to move the leg". I suppose this means that I have to take into account the "normal healthy" current draw peaks occurring when the servo starts up, and not confuse this with the stress/load a servo may experience due to external influences? If so then that had occurred to me and it's probably not gonna be easy. But then again nothing worth doing is, is it? :)




Hi Aniss1001,

Robotics is one place where the real world makes its presence felt.

The comment about careful processing, if you consider your leg when walking, the muscles exert a great force to start the leg moving forward, then the force drops off as the leg swings forward and then the forces reverse after the foot is planted, imagine the electrical signals.

The same for your servo, at the beginning of the step, the voltage will be high (large error = large V and I) the V and I drops as the targe position is neared, at the begining of movement the servo is basically stalled (current high).

Now then you put the communtator noise and other noise on top, the Voltage/Current signal needs be cleaned and then evaluated.

It would seem were ARE on the same page. And like I said I did consider that quite a bit. When I tell a servo to move I will allow it to have an abnormal current draw for the first few milliseconds (how many will depend on a test). It's only if the the current draw doesn't decline at the expected rate that I will assume something is wrong (=the servo is experiencing stress).

But since clcheunghk just informed me that I can ONLY measure the current while the servo ISN'T moving I'm not quite sure what to think anymore ?!

Like I said I've spent A LOT of hours googling these things, but it's not easy. The unknowns just seem to endlessly multiply. Eg. I research one unknown: servo, and soon end up with a long list of unknowns: speed, torque, gearing, PPM, PWM, noise, (peak) current draw, servo controller, PID loop..etc.etc.. (note: these are not new questions since I have most of these subjects covered by now!)

Therefore I very much appreciate these forums :)

So I have a few more questions:

1) You said (about a gutted servo): "Control is not position of the servo anymore, it is the speed of the servo". I very much love that idea. Are you sure that gutting the servo is necesary for controling the speed or COULD there be another way? (perhaps a software solution..I'm prepared to code my own servo library rather that using the existing Arduino one if necesary)

2) I read this in the comments of the trossen manual: "it will work with only 1 ground. The second one is to help prevent ground loops and it makes the servo a bit more flexible on how it can be connected". However you guys ALSO ended up with an extra ground (I presume since you also have 5 wires from each servo). I don't quite see how a redundant ground wire is more flexible (?), but the ground loop thing (another item for my research list) seems like something you'd wanna avoid. But the message is quite vage: it will work with only 1 ground BUT it will cause ground loops (ok, then it won't work I guess?). Anyway why did you choose to put the extra ground? Have you tested it without it? It would be MUCH simpler if I could avoid that one thus having only 4 wires from each servo...


Aniss :)

I suppose you could control the speed rather than position with the Trossen mod too.  Since you are seeing the pot position, you can just send the servo signal telling it to go way past the desired position, which I will call X+5.  The servo will go as fast as possible, then as you get closer to your desired X, bring the servo signal down to X+4, X+3, X+2, X+1 and when your pot tells you it's there, the servo signal will simply be X to keep it in place.
To reach a position more slowly, you will be sending servo commands of X-5, X-4, X-3, etc.  Basically telling it to go to the position just ahead of where it is and change it just as it reaches that position.

In this case, the difference between our way is that our reference stays at the servo center position (because of our matched resistors replacing the pot).  In this new way the reference would be dynamic depending on position and desired position.  Not something I would want to code, but it could be a fun learning experience!

It's important to decide whether all that extra work is worth the ability to better control servo speed, or if you should justbuy a servo controller board that does it for you. http://www.lynxmotion.com/Product.aspx?productID=395

And you could still do the pot feedback wires for manual positioning.

Oh, and 5 wires was for our first plan of controlling the motor directly and reading the pot without the servo circuitry.  Using the built-in circuitry and reading the pot directly will require us to use 6 wires.  Using 4 wires (just one on the pot) shouldn't cause any ground loops, but by bringing back the pot's ground you can use it as a reference for your wiper and get less error in the reading.  Of course, multiply that by as many servos as you need.  That's why I've delegated the servo control to another team member! ;)

I kinda liked your ad hoc idea about intentionally over/under-shooting the servos to control speed. But I just read AI's comment and it would seem it's a no go. Too bad..

About the lynxmotion board: Well, funding is a major issue. And since I live in Argentina getting things shipped is slow, expensive and risky. Besides like you said about the build in motor controller: The potmeter is allready there, why not use it? :) And I can't help thinking: If this board you mention is capable of controlling the speed of a normal unmodified servo then I SHOULD be able to do the same somehow using an Arduino, no?!

And you lost me a bit in the latter part. 1st about the 6 wires, but that's ok. Then later when you said: "by bringing back the pot's ground you can use it as a reference for your wiper and get less error in the reading". Don't know what a "wiper" is for starters, but I understand your comment like this: You recommend adding the extra ground wire. Not like the trossen manual says to avoid ground loops or get more flexibility (whatever that means), but because it will give me less errors in the reading (of the servo potmeter's position I suppose)?

Wiper = center wire of the pot - the one you will read analog voltages from.

My guess is that the Lynxmotion SSC controls the speed the same way I suggested.  You could email Jim (the owner) and find out.  I believe he designed it himself.

Bringing back the pot's ground wire was suggested by my teammate.  He thinks resistance in the wires will introduce error into the analog reading, and that the analog ground will help. Honestly, he's better than me at this stuff.  :)

About the Wiper: Ah, I allready knew that actually. Seems I'm learning too much too fast and some of it just spills over :(

And..quote: "he's better than me at this stuff". Then he must be pretty damned good ;) Seriously, you've been an ENORMOUS help. For some reason your explanations just seem to pan out to me, which isn't the case with everybody.

Thanks again...

To Al1970:

Thanks for clearing the thermistor thing up for me. It all makes sense. I'm not entirely sharp on what (servo) noise means but I have read that it could damage the servo and the rest of the circuit (inluding my Arduino I suppose), so I'll definately reconsider that.

To FingerTech:

Thanks for a VERY informative comment. It sounds like the "gutting" is the better but also way more complicated option. Since I'm gonna get a batch soon of REALLY cheap servos (3.65 us$ each) I'm probably gonna try it out on one just to check it out. Having the extra precision may not be a necesity right now but in the long run it seems like the way to go.

And you're right about the overshooting. That's a common problem with cheap servos. They also have a much higher peak current draw compared to their more expensive equivalents. The HXT900 peaks at ~750A while the Hitec equivalent peaks at only ~400A.

And just to clear something up: Servos are NOT controlled by PWM (pulse width modulation). They are controlled by PPM (pulse POSITION modulation). However basic DC moters DO use PWM (I think?!) and since a "gutted" servo is basically just a DC moter with a potmeter attached you're probably right in your case.

Here is a link to a very informative comment by the guy who wrote the newest servo library for Arduino (capable of controlling up to 12 servos on a standard board and 48 servos on the Arduino Mega):


Here is a quote: "You should not use the arduino analogWrite PWM function to drive a hobby servo. They do not use PWM and could damage a servo or speed controller. Its confusing because many references do incorrectly use the term PWM in articles about servos."

I think it may be useful reading even if you're using a Pic. There are also several other good links within that thread.

Again thanks for taking the time to write a thorough comment. You've been of great help.


I did a bit more research on the current sensing. It seems there are 2 ways of doing it.

1) The IC's I mentioned earlier which are seemingly (all?) based on hall effect tecnology.

2) Using something called a SHUNT RESISTOR. So if anyone has experience using those things or knows of a web page with practical info on that I'd be very grateful?!

Sorry about the broken links. It seems that this forum doesn't accept links without the "http://"-prefix. I corrected the link in the topic description, but since I cannot edit my later comments (?!) I'll post the links again:


And sorry for writing so many questions. But I AM a noob. It's not because I'm too lazy to research myself. I spend every available moment on just that. Less that 2 months ago I barely knew what a circuit, microcontroller or servo was, but I'm learning new stuff every day, not least thanks to nice folks on the Arduino forum and now here.

Cheers :)


A Shunt resistor method is quite simple and common. It is basically a very small resistor, say 0.1 ohm, connect in serial with you servo, and you can then measure the voltage across the shunt, amplify it by an op amp, and feed to your ADC.

I've made a current control module, which cut-off the power supply for the robot when the load exceed certain amount, it is also using a shunt:


You can see it in action behind the robot arm: