Let's Make Robots!

Sensing servo feedback

Hi,

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:

forums.trossenrobotics.com/tutorials/how-to-diy-128/get-position-feedback-from-a-standard-hobby-servo-3279/



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.

I've made a video:

http://www.youtube.com/watch?v=9RRb78VJUp0

The situation will be like this: 

- when the robot is at rest, it takes about 0.25-0.35 Amp current.

- when the robot is moving, it takes about 0.35-1 Amp, on average. Note that you need to compute the average reading or otherwise there will be a lot of noise.

- when I bend the leg of the robot, some servo is under stress, the current usage is going up to 1.4 Amp.

Hope this can you help visualize your idea.

Very cool video and great explanation. Are these the HXT-12 servos?
Those are MG995 with my version of openservo. More information at http://letsmakerobots.com/node/2423
1st of all you're english seems fine. Sorry if I gave you any other impression.

The reason I wrote "what?" was because you said...

"if you want to measure the stress of a servo at any time by taking measure of the current it uses, you have to make sure the servo is not moving at the time of measurement. The reading of a moving servo is not useful in this case."

...And I was unaware that a servo even draws current while NOT moving. So I got confused. I still have very limited knowledge of servos.

My idea was to measure the current draw ONLY while the servo is moving. Like this: I tell the servo to move to a specific position. If something is blocking it's movement then it stalls and I should be able to detect an abnormally high current draw, thus I would know that something is blocking it's movement.

So I wanna ask you one more thing: in the video..is the current draw reaching 1.4A simply because you're bending the leg OR because it's trying to move at the same time (thus it is stalling)?

Sorry if my questions seem silly. I will off course be spending hours experimenting myself once I get my setup up and running...


Thanks again for all your input :)

Aniss


PS: WOW! Your walking robot is even more impressive. I hope one day to be as skilled as you. Respect!!

>> And I was unaware that a servo even draws current while NOT moving. 

You are basically correct. The servo only draw a very little current when it is not moving when it is not under "stress". i.e. the servo already move to the decided position.

>> So I wanna ask you one more thing: in the video..is the current draw reaching 1.4A simply because you're bending the leg OR because it's trying to move at the same time (thus it is stalling)?

When I bend it, the servo positions are shifted away from the original position, so it tries very hard to restall back..and thus a high current is measured. 


>> PS: WOW! Your walking robot is even more impressive. I hope one day to be as skilled as you. Respect!! 

Thank you ! I am also a beginner in robot building.

Just one last question..for now anyway :)

Is the servo trying to restall back because your microcontroller is constantly telling it to do so, or simply because of the last command received?

 

Thanks

The OpenServo modification he made might rely on last position sent, but regular servos will only seek a position that is being updated every 20 ms or so. Stopping update pulses will cause the servo to go slack, not seek a position.

That's what I thought...

And as promised I'm out of questions....for the time being :)

 

Aniss1001.. over and out

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! ;)