Interesting discovery regarding servos and current

Hi - on my 6 legged robot I put high side current amplifiers on each servo power line. My hope was to use current information from the
buggers as a basic force feedback. I put a low pass filter on the output of the current amplifiers and ran that into an ADC. Problem was - I never got very good data from it. Pretty much no data at all. I've been really busy with other things (mostly gait generation), so I couldn't spend much time figuring out what was wrong, so I essentially just forgot about it.
Anyways - I inherited an old analog scope, and have been messing around with it today trying to figure out how to use it (I'm much more used to the high end DSOs that we have in my university's labs)
I decided to take a look at the output from those high side current amplifiers, expecting utter rubbish to be on the output. Instead - it was a nice clean square wave. I then added in a second channel which was the PWM pulse I'm feeding it, and no big surprise here, the current square wave starts right after the PWM signal's falling edge. What I find interesting, however, is that the magnitude of the current square wave is pretty much constant. Instead, the duration of the square wave is what varies with load on the servo! The harder I press against the servo, the longer the current pulse gets. All with a very nice and constant amount of current. I had previously read in the amount of current flowing with my multimeter and found a sort of exponential relationship with load vs. current - but that must be because my multimeter was averaging! Suddenly now, everything makes sense. This also explains why I found that max current tapers out as you increase the PWM frequency - I suspect that at a certain point the duty cycle of the current pulse hits 100% - hence it tapering out.
It's annoying though - the ADC isn't even really necessary. I just need to time how long the current pulse is. I think in the next iteration of my leg controllers I'll just put an op-amp integrator on the lines so that I don't have to waste extra CPU cycles on it. For now - I'm just going to constantly sample the ADCs and watch for the falling edge of the current pulse.
Well, hope this is helpful to somebody out there. Wish I had figured this out sooner!
-Michael
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Hi Michael. I did this same experiment a couple of years ago, and this was discussed in a thread named "r/c servo internal pulses" on this forum on 24-25 April 2005. Maybe this link will work ...
http://groups.google.com/group/comp.robotics.misc/browse_frm/thread/ebcd26f277bb4d0f/93f84a013bc0c7a2?lnk=st&q=servo+pulse+current&rnum=3&hl=en#93f84a013bc0c7a2
Since the current pulses have a nominal 20-msec period and extend from about 2-msec under no load up to about 8-msec or so under heavy torque, you should be able to low-pass filter this and read it with an A/D channel. You would need a long RC time constant, order of 50-100 msec to get a decent reading.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Hi Dan - I found that during no load conditions the current pulse went away completely. Didn't measure the peak length - I'm always afraid that I'll kill the bugger if I torque on it too hard :)
So you're suggesting a really low low pass filter and then measuring it before the next pulse is generated? Seems like it'd work OK for an approximation, but it'll be far from perfect, obviously. I'll give it a shot next chance I get - see what sorts of results I can get from it. I think I'll still be going with integrators on my next board though - I'd really prefer that higher level of precision.
-Michael
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

I imagine different serv os use slightly different schemes. I used a GWS servo, opened it up, and looked at the voltage directly across the motor terminals. It was minimum 2-msec pulses, with each occurring right after the signal pulse. Also, I did wreck the servo by over- torquing it with my fingers, while experimenting with faster update rates. For high torques, the motor pulsewidth increased to about 7-8 msec, and when I increased the update rate to 100-pps [10-msec], the feedback loop internal to the servo crashed. I did this all to find the limits of what was usable.
Also, I mentioned using a low-pass filter with very long time constant so it would in effect measure the "average" current, so it wouldn't matter when you take the measurement w.r.t. the actual current pulses. OTOH, if you have the processing power to measure the pulse-widths directly, that would be more accurate.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Oh - I see what you're talking about now. Using a low pass filter in that way would give a very, very rough estimate of the average current over the past series of pulses. I want a measurement of the last pulse, so such a system would not work for me.
I have devised a scheme to measure the lengths of the pulses with my software. It is requiring me to rewrite much of my PWM generation code, but it should give me very accurate results. Instead of having each of the pulses for the three motors generated sequentially, I'm having them generated at the same time. Specifically, I'm having their falling edges be generated at the same time. That way, I can watch all three ADC channels at the same time and measure the current pulse length of all three fairly easily. It all works pretty well in my head, I'll have to see how the implementation goes later today.
-Michael
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

As an update: I successfully changed my PWM generation code to the new scheme above mentioned. After the PWM pulses are generated, I integrate all three servo currents over a fixed period of time, right now 10ms. I've been importing this data into the computer, and graphing it with Excel. Right now I'm just looking at a tripod gait with a 5 second period, and I'm looking at one of the corner legs. Interestingly enough, it seems the knee servo is the only servo that has a very nice looking spike when ground contact is made. It increases about 4x when it hits the ground. The others sometimes do, but sometimes don't. What I'm exploring now is how different gaits, different gait speeds, and different legs affect these currents. My goal is to be able to sense ground contact with any gait, any leg, and any gait speed.
-Michael
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Cool. Your scheme of integrating for 10-msec synchronized to the servo signal pulses sounds superior to either measuring current pulse widths directly or doing the sort of low-pass filtering I mentioned. I'll remember this :)
I spent a lot of time trying to add touch sensors to feet and legs on my walkers, but all mechanical schemes are a big PITN. But then, I'm a programmer and electrical engineer, not a mechanical engineer.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
Michael wrote:

Yes, you've discovered switch mode power control. That's how almost all motor controllers, and lamp dimmers, have worked for about twenty years now.
R/C servos started going to switchers around ten years to fifteen years ago. Some of the smaller, older ones still have linear amps.
                    John Nagle
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.