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 :)

Torque and Posistion…
You have asked/ mentioned 2 things here. First off, you don’t need to monitor the servo’s posistion as you are coding it to go to a certain position so after a short pause for the servo to move it is at the position you told it to go. You wouldn’t need any feed-back loop there. However, if your robot arm (or whatever) is lifting weight and you want to monitor the torque coming out of the servos, I would say a measure of current is the way to go. A thermistor is a no-go, this is a sensor for heat. I like the idea of a amp-meter of some kind on the supply or ground of the servo but the specifics, I dunno. There are a lot of electronics geeks around here, someone will have the answer.

What about gutting?

My team is building a MechWarfare biped with regular cheap servos. We are gutting the servos and leaving just the motor and pot in place so we can read the pot and move the motor ourselves. Basically doing exactly what the servo already does, but we can coordinate many servos together better (if one is slowing due to torque, slow the others to not lose synch), and get much better results (smoother movement since our PIC has more analog and PWM bits) than the servos come with standard.

Downside is that you will have 5 wires coming back from each servo which could get messy if you’re not careful.

Thanks a bunch…

Thanks a bunch for the replies :slight_smile:

First off I forgot to mention the 4th method I’ve been considering. Simply putting touch (or presure) sensors on the feet of the robot so it senses if it’s touching the ground. I’ll probably do that no matter what in combination with one (or maybe several) of the other methods.



To Chris:

I am aware how a normal servo works… I tell it to move to a specific angle - wait a few ms - and it should assume that angle. However if something is in the way and it’s unable to comply, or a moving object changes the servos position, there is no way of telling. With the modification I mentioned (see link) I could detect that and make the robot act accordingly (eg. compensate, retract it’s legs or run away scared in the latter case…hehe).

Sorry for mentioning the thermistor. My mistake. It’s because I was recently researching on current LIMITERS (for something else) and these thermistors kept popping up in that context?! Dunno why?!

Likewise when I was researching on current SENSORS the term hall effect sensor (seemingly for measuring magnetism of some sort) keeps popping up?! Dunno how these are related?!

See here for example: news.thomasnet.com/fullstory/459232

This off course is on my research todo list, but I haven’t gotten around to it yet, since that list is pretty long.

Anyway there are current sensors available as tiny chips. There are also breakout boards for these but they’re a bit expensive and takes up a lot of space, considering that I wish to place one on ALL my servos (12 for starters). Besides… the ones I have found seem to be overkill since they’re generally capable of measuring atleast 5 Amps (often up to 50). I just need 0 to 1 Amp (tops).

See for example these:
www.technobots.co.uk/acatalog/Online_Catalogue_Current_Sensors_614.html
www.dpcav.com/xcart/product.php?productid=16190

So if anyone knows of a cheap chip (or other component) for measuring lower currents it would be awesome??!!



To FingerTech:

Sounds pretty much like the conversion I was mentioning as the 3rd option. It also ends up with 5 wires from each servo. However in my case the servo seemingly maintains its ability to turn to a specified position, which I actually don’t really need if I instead could detect the ACTUAL position at any given time.

So your “gutting” solution would be just as good to me, and perhaps it’s easier to do THAT conversion? If so I’ll go for your solution since my hands are not particularly good at handling tiny objects. :S

But the link you provided has no information about this. Do you have a link or something that provides information about this conversion? I’d very much appreciate ANY clue as to how this is done??!!

 

Thanks

Aniss

Cheers :slight_smile:

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):

www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1232572239

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.

To ALL:

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:

news.thomasnet.com/fullstory/459232
www.technobots.co.uk/acatalog/Online_Catalogue_Current_Sensors_614.html
www.dpcav.com/xcart/product.php?productid=16190

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 :slight_smile:

Aniss

Good catch!

Good catch on the PWM/PPM. I edited my comment so it doesn’t throw anyone off. Even in the second option (sending speed instead of position) it will still be servo signals (PPM) signals coming out of the PIC because that is all the servo circuitry understands. As it says in that artical, you don’t want to send PWM signals to a servo.

For a “noob”, you seem to be catching on quickly! Keep it up!

Thanks!

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 :slight_smile:

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 :slight_smile:

Servos are controlled by

Servos are controlled by PWM, not PPM.

Pulse Position Modulation, as Wikipedia states, has information encoded in a time shifted pulse from a known timebase.

Pulse Width modulation encodes information in the width of the pulse. Servos read a pulse width from 1 to 2 milliseconds to determine where the output should be positioned. The pulse may be generated from an RC receiver that picks up a PPM radio signal from the transmitter, but it still generates a PWM signal to drive the servo.

A Shunt resistor method is

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:

http://hk.myblog.yahoo.com/jw!afd6dGGRHBRkp2laqwk198fg/article?mid=202

You can see it in action behind the robot arm:

http://www.youtube.com/watch?v=MJpIJGed_ng

 

Servo Position feed back

Hello,

I think for walking machines servo feed back is useful, for example in the MIT 6 Legged robots (Genghis, Atila et al) they sampled the error signal as a way of detirmining if the Leg had bumped into something and to detect when it was on the ground. This information is used in conjunction with the command target position to control roll and pitch.

A point to note is that a typical servo (old) uses the Mitsubish M51660L (a replacement for the earlier Signetics NE544 chip).

So getting back to measuring the current position and torque, there are a couple of ways of doing this.

Typically Model servo drive the output shaft to the target position using a torque proportional to the distance between the current postion and the commanded position (linear proportional to error).

MIT basically tapped the motor (voltage) and used a high and a low comparitor, the idea being the Servo drive chip would drive the motor with a Voltage proportional to the error, if you bump something you should see result in the drive voltage not declining with time and if the motor goes to stall you should see this, 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.

Another way is the the M51660L has a pin (9) which provides an Error Signal (pulse output), I havent played with this signal, it is normally tied to pin (11) via a resistor which controls the deadband.

all the best

Cliff

Positional Feedback

Your link to Trossen was broken. Here it is http://forums.trossenrobotics.com/tutorials/how-to-diy-128/get-position-feedback-from-a-standard-hobby-servo-3279/

That’s a good tutorial and easier than my suggestion. The problem we had when considering this approach was that the servo we are using is very strong but not very accurate. It goes full speed then overshoots the position, as if there was no PID loop at all. (Guess that’s why they’re so cheap!) This is fine for the usual robot, but we need our Mech to have very smooth walking gaits.

That tutorial did remind me though; at our last meeting we decided to try using the motor control portion from the servo instead of making our own (it’s already there, so why not use it). Below are the main differences between the two methods.

1)Trossen tutorial:
Hardware - No modification to the servo, just the addition of GND and WIPER feedback wires.
Software - Control the servo as usual; send a single servo position command and let it find its way to there. If there is overshoot, you will have to live with it.
Benefit - Easy to do, and gets you positional feedback.

2)Our way:
Hardware - Pot is disconnected from servo circuitry and fed back to our PIC. Replaced in servo circuitry by two matched resistors (so the servo thinks it is always centered).
Software - Control is not position of the servo anymore, it is the speed of the servo. The further from center our commanded position is, the faster the servo will turn. The pot is monitored and we can slow the servo down before it gets there, solving the overshoot problem.
Benefit - Gets positional feedback, have more control over the speed/power of the servo (especially helpful since we need to coordinate 17 servos to move smoothly together).

Honestly, the first way is easier and I would go that route unless you absolutely need the precision that we do.

PS - the cheap yet strong servos I mentioned are these: HXT 12kg Metal Gear Servo - 183oz-in for $12.37USD.

Darn terminology. I’m just

Darn terminology.

I’m just going to call it “servo signal” from now on. :stuck_out_tongue:

Controlling servo speed

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! :wink:

The plot thickens…

Thanks for a lot of wonderful input. Unfortunately I have classes now (mathematical analisis…sigh!) so I’ll get back on the case as soon as I have time…

:slight_smile:

Ok?
Ok? Now I’m just confused! So the page I linked to was wrong? Like I said it’s written by the guy who wrote the latest servo library, which the entire Arduino community is now using to control their servos, so I kinda accepted him as an authority on the matter. But then again you also sound like you know what you’re talking about and what you’re saying corresponds with my original idea of how it worked…So…I truly don’t know what to believe anymore?!

Have you read the page I linked to? Where am I/he going wrong?

Correct me if/when I’m wrong: A servo basically is a DC motor, some gears, a potmeter and a motor controller (usually a small PCB with a chip). Could it be that the following is the case: the motor controller receives a PPM signal (from Arduino or other) and then generates a PWM signal to turn the DC moter to the desired position? That would explain why there seems to be such a mixup about the whole ordeal…

Anyway thanks for your input. I definately need to be completely sharp on this. When I get the time I’ll try studying the code of the Arduino servo library (it’s open source so…)

Perhaps…
Perhaps we should just call it servos signals like FingerTech suggests:)

PPM, PWM, and Servo PWM

PPM: Pulse position modulation has a fixed length high pulse that arrives at different times, referenced to a fixed frequency. How far ahead or behind the fixed time is what is important.

But ignore that because that’s not how servos work!

PWM:Pulse Width Modulation has a fixed frequency and variable period. The length of the pulse is what’s important.

Servo PWM: Just PWM, with a fixed frequency of ~20ms. A period of 1.5ms tells the servo circuitry “center”. Period of 0.5ms or 2.5ms sends the servo fully CW or CCW.

There, hope that made up for any confusion I might have caused!

Thanks

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? :slight_smile:

 

Thanks

Aniss

Nice idea but …

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? :slight_smile: 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)?

Hey

The source of confusion is hardly you, but rather that I’m getting different info from different folks who all seem to know what they talk about. And besides this explanation corresponds with my ORIGINAL understand of how servos works, before I read the PPM thing…

PS: Nice diagrams