# Current sensing power supply for hobby servos

I'm trying to design a power supply for 8 hobby servos which senses the current consumed by each of them. Size and cost are the main drivers, much more so than absolute accuracy.

I'm designing for 1A per channel, although it might be nice to have a couple of 2A channels.

I have an MCU with enough single-ended analog inputs. If the best way to do this is differentially, which I suppose might happen if the sense resistor is on the high side of the load (is there a reason to put it there), then I might need more pins and would probably add something like a MAX11609 or MAX11611 I2C ADC. Apart from knowing whether it needs to be single-ended or differential, I've got the ADC part under control.

My questions are:

1. Where do I put the sense resistor?
2. How do I do sufficient low-pass filtering that I can sample these current measurements slowly (say 10Hz) and smooth out whatever is going on at frequencies higher than that?
3. Does it make sense to look at something like a current-mirror FET? I can't seem to find any with current ratings remotely as low as 1-2A, they all seem to be rated for 40A+ and sized accordingly. It would be nice because then there would be over-current protection, but I can certainly live without it if its going to be a 300% price difference and a 100% size difference.
4. How do I amplify the signal? Does it make sense to amplify before or after filtering, and before or after multiplexing?
5. Is there something I'm not thinking of which is going to cause a major problem. ;)

An alternative approach might be an IC like MIC2545A, Programmable Current Limit High-Side Switch. To address your question points:

1. The device replaces the current sense resistor, goes on the high side, and also provides a current sense flag output, current limiting, and a logic level MOSFET switch with a 50 milliohm RdsOn, in an 8-pin package (6 actual pins).
2. An optional series RC, parallel to the current limit set resistor, provides the smoothing out / low pass you need - see datasheet.
3. The steady-state current limit is set by a single current limit set resistor, to a range of 500mA to 3 amperes, although with only a +/-20% accuracy in your desired range. Also, as the IC is a current limit switch, your requirement for limiting is met.
4. Not required, the device does this internally.
5. Yes: This may not be the optimal part for your specific need, there may be similar, cheaper devices that meet your specification. Experts in this community would suggest better alternatives, I trust - an n-way array version might exist, so you can address your 8 motor requirement with 8/n of the ICs.

As both through-hole DIP and 8-pin SOIC packages exist, you have both prototyping and final product options.

Putting the sense resistor in the high-side is generally recommended. If it's in the low-side, the micro will operate at a different ground than the load (lower by the voltage drop across the sense resistor).

There are pre-fab devices like TI's INA213 that contain a high-precision, low-offset differential amplifier with fixed gain and are intended for high-side sensing. You can easily add a low-pass filter to the output of this device (plus scaling, if necessary) and bring that signal to your ADC.

You could also build discrete differential op-amp circuits (use a rail-to-rail part with low input offset for accuracy). It's a matter of accuracy and linearity vs. cost - the INA213 is a bit pricey but is extremely accurate and very small.

If your power supply has a remote inhibit, you can use the micro to cut the power if one of the rails goes over-current. You may also wish to consider self-resetting PTC polyfuses in series with each servo (again on the high-side) which will give per-motor protection.

• That INA213 and its brethren are very interesting, thanks for the pointer. Will adding a capacitor in parallel with each servo, after that servo's sense resistor, act as a low pass filter for the power current itself and therefore also for the signal, or is there some reason that wouldn't work out well? – Doug McClean Jul 6 '11 at 14:52
• As far as the PTC fuses go, it looks like I can get an N-channel logic-gate MOSFET with a lower/comparable resistance for about half the money (at least in the quantities I am looking at), at this point I am considering that plus the INA213 or similar device. – Doug McClean Jul 6 '11 at 14:56
• Maybe the INA216 instead? Seems to be similar, except cheaper and it only works on the high side of the load. – Doug McClean Jul 6 '11 at 15:14
• @Doug - INA216 measures 0.8mm x 0.8mm. Good luck! :-) – stevenvh Jul 6 '11 at 15:35
• @Doug - The INA199A2 may be a better alternative. At least it comes in a more reasonable SC-70 package. – stevenvh Jul 6 '11 at 15:45
1. Your options are high-side or low-side. High-side is the best, because it doesn't modify your ground level, but is also the more difficult to measure. I would go for low-side, i.e. resistor between ground and servo V-. Choose a value which doesn't decrease the power supply too much, yet gives you a decent reading. A few hundred millivolts voltage drop may be a good value.

2. An RC filter helps, and you can take advantage of the microcontroller to average over the latest N samples (This is effectively a FIR filter)

3. Current mirror would be nice to create at the mirror side a larger voltage (larger sense resistor), but I don't think you'll need it.

4. Depending on the accuracy you may or may not need amplification. If you do need it a non-inverting opamp amplifier is a solution. You need an RRIO (Rail-to-Rail I/O) type.

$\frac{V_{OUT}}{V_{IN}} = \frac{R_1 + R_2}{R_1}$

1. No, unless I forgot about it myself as well :-)
• Steven, with the low-side solution do I need to be worried about the servo misinterpreting the PWM control signal (which is referenced to the system ground) by comparing it with the elevated ground it sees because of the voltage drop across the sense resistor? I'm thinking no, because it should only be ~50 mV ish, but I've never tried something like that before. – Doug McClean Jul 6 '11 at 14:36
• @Doug - 50mV should not be a problem. It all depends on how accurate you want to measure the current. A lower voltage will have relatively more noise on it. And that's where your LPF comes in. – stevenvh Jul 6 '11 at 14:53
• @Doug - I don't know what the input impedance to the servo looks like, but if it's not capacitive you can always lift the lower level of the signal by adding a series resistor and a pullup to V+. Also check the servo's datasheet to see what the input voltage range is. – stevenvh Jul 6 '11 at 15:07
1. Depends on what you do with question 3 and amount of wires per motor.

2. I'd suggest to sample it 20x of your position loop bandwith. Normally its >=2Khz.

3. The current sense, amplifier and torque PID normally are insulated from rest of curcuit. Having high power side insulated, gives you more freedom to choose where to put current sense. For 3-4 wires motors, you will need only 2 sensors per motor and some triginometry calc to derive the 3rd, 4th value.

4. Dont filter ouput current or use very rudimentary 800Hz filters. For 1-2A current it is not important. Have amplifier individual per motor. If you multiplex amplifier, then you will have much worse frequency bandwidth. The major rule is that current PID bandwithd should be 10 times higher than position PID bandwidth. Also you dont need to have more than 800 Hz for current loop. so 80Hz is normal limit for PID. Choosing bandwidth is sort of frequency planning to decouple 2 cascades of servo, to avoid chaotic oscillations.

5. You possibly did not think that motor servo is actually a PID position servo cascaded to Current/Torque servo. So the current should not only be measured, but be tightly looped throught local current amplifier controlled by its own PID fed from current sensor.

• It is locally measured by the control circuit in the hobby servo, but I'm trying to do something that doesn't require the user to crack open the case, poke around for that signal, and solder to it there. This measurement isn't for control, it's only for low-bandwidth load monitoring, and that is why I was thinking way down in the 10Hz range. I can certainly sample it way more often and digitally filter from there. – Doug McClean Jul 6 '11 at 16:02