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.
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.

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 for the replies :)

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

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.

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

Aniss

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!

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.

Darn terminology.

I'm just going to call it "servo signal" from now on. :P

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

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.

PPM

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.

PWM

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.

Servo PWM

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