Precision current measurement
Graham Stabler
Posts: 2,510
I'm working on a system that uses a small magnetic actuator to measure force, it has position feedback and a PID loop maintains it's position, when force is applied it resists and the current through the coils is proportional to the applied force.
The PWM duty is also proportional to the force however the constant of proportionality is most likely a function of temperature and the supply voltage. I'm thinking it will be much safer to measure the current on the low side of the h-bridge.
I'm wondering if in this digital age there are any off the shelf devices with serial outputs to do this, I've found some with PWM output. Alternatively I suppose I would use a current sense resistor and an ADC, probably filtering before converting to smooth out the PWM?
I think I am talking a range of about 0-200mA single direction (I can derive current direction from the PID code) and I'd like as much resolution as "possible".
Any ideas appreciated.
Graham
The PWM duty is also proportional to the force however the constant of proportionality is most likely a function of temperature and the supply voltage. I'm thinking it will be much safer to measure the current on the low side of the h-bridge.
I'm wondering if in this digital age there are any off the shelf devices with serial outputs to do this, I've found some with PWM output. Alternatively I suppose I would use a current sense resistor and an ADC, probably filtering before converting to smooth out the PWM?
I think I am talking a range of about 0-200mA single direction (I can derive current direction from the PID code) and I'd like as much resolution as "possible".
Any ideas appreciated.
Graham
Comments
I like the 16 bit sigma-delta ADCs with PGA gains of up to 16 that come in SOT23 package that can be mounted right next to the shunt. Examples are the TI ADS1100, ADS1115, or Microchip MCP3421 and Analog Devices has one too I think. With the PGA gain of 16 the full scale range becomes 0.256 volt differential, about 7 microvolts per bit. I2C interface.
That sounds really neat and as you say the potential for getting it really close to the shunt is appealing. When you say shunt, are you refering to a low ohm resistor in series or is there some other configuration? Would you recommend a little SMT low ohm resistor to match the small sot23 device keeping all compact?
Graham
For best accuracy consider the ppm temperature rating of the shunt. You could spend anywhere from 5 pence for 200ppm generic resistors to 10 GBP for Vishay Precision 2ppm shunts. (10 US cents to US$15 each)
A lower resistor value, say 0.1 Ω could save on the power, but woul take amplification to fill a 16 bit, 0.256 V full scale range. If this is driven by PWM, it is going to need a filtering buffer anyway to give back the average current.
The ADC would not have to be right next to the shunt, but it would then need a shielded cable. Those particular ADCs do not reject 50 or 60 Hz mains pickup well, unlike some of the high end high resolution converters.
In terms of the filter/amp, I have seen special amps for shunts, should I go along those lines?
Sorry if I seem lazy, I just wanted to get the benefit of some experience before shooting off down some tangential line. I'm reading the art of electronics to try an actually learn some electronics (my degree in electronics is good for anything but that) but I have to finish reading Kraus, "Electromagnetics" first because I am building the actuator as well. Oh the joy of over promising
Graham
Vishay do some sense resistors, a 0.1ohm with 0.1% tolerance and +-15ppm/C The tolerance is not an issue as I will calibrate to know forces, the actual current is not needed, the 15ppm seems OK. They do a 1W and 2W version, @200mA I am only talking 4mW dissipation so I suspect ambient temperature fluctuations will be the main issue, I could go crazy and use the 2W device for belt and braces but it is a little big at ~9mm square.
Now for amps.
Graham
A part that impresses me, and is somewhat 'hidden' in the Current Shunt Monitor filing at TI, is this one
http://www.ti.com/product/ina226
This is i2c, and does both 36V reading and 80mV current (Hi or lo side) and to a 16 bit precision, via the i2c bus... (oh, and besides I and V, it also tells you the power too.. )
TI says $1.30/1K
I purchased a few of the 0.01% resistors from Digikey for purposes of calibration around the shop, and I was surprised, that evoked a phone call from the Vishay Precision Rep. I guess they are hungry for customers who are willing to pay $15 for one resistor. That led to a visit from a FAE who put on an impressive demo of their products in terms of overall performance and ability to survive abuse unscathed. I'm attaching their demo prospectus. It gave me a new perspective on those run of the mill things we call resistors!
I also implemented an analog voltage in using an ADS1251 and the datasheet circuit for a +-10v input. My observed noise floor is about 30uVp-p. I think the circuit could do better, but one of the power supplies on the board is very noisy at a frequency I wasn't expecting.
Sigma Delta ADCs are nice for high precision because they make lots of crude measurements fast and average them to get a slower high precision measurement. Due to this they naturally measure the average voltage between sample instants. Furthermore, they only alias a narrow band of frequencies near the ADCs internal clock rate. This rate is often 64x the sample rate, so designing an anti-aliasing filter becomes much easier. Most Sigma Deltas also use a Sinc/CIC/moving-average filter internally, so have extremely high rejection of frequencies that are a multiple of the sample rate. In my case I sampled at 4KHz, the same speed as the Q-switch on a nearby laser. I also made sure my PWM frequencies were a multiple of 4KHz. In my application I further divide by 128 with a 3rd order CIC filter. This nets me another 3.5 bits, a much more comfortable 31.25Hz data-rate, and pretty good 60Hz rejection. (the datasheet thankfully has a good description of all this too)
Lawson
Thanks for that, I started exploring current sense amps last night and there seems to be a myriad of products, that one looks very interesting, the programmable integration is particularly interesting. I need to read a little more of the datasheet, I have a little chart where I am adding the various devices I find, there are a lot of trade off's with each.
Tracy,
Thanks, I had limited my search to one UK supplier (RS for speed purposes) but I can get those equally easily in the UK, pretty amazing parts. I love the demos, videos of which are here: http://www.vishaypg.com/landingpage/videos/ knowing these parts are available makes me feel much more confident about making something work really well and without the dreaded drift we see all the time on our supposedly temperature compensated strain gauge based force balances.
Lawson,
Wow the ADS1251 is a beast! One of the problems with a lot of the amps was a low sampling rate, I need greater than 83Hz, I don't need 20kHz @19bit and probably don't need 19 or 24bit but it is really nice to have the options. I don't need the programmable gain of the other amps as I will need to add an amp anyway so it might be ideal. Thanks also for the other tips.
Cheers,
Graham
Lawson, did you implement your voltage reference as they show in the datasheet with the REF3040 and OPA350? I'm not sure if I will have to have one reference per ADC or if they can share, I suppose one each is the optimal.
Graham
I implemented the data-sheet suggested reference. (I'm sure someone makes a better reference if you looked) For the temperature sensors this was more to cut noise than for precision requirements. I setup the temperature sensors so the measured voltage would be radiometric to the ADC's reference. (I also made the AA filter roughly radiometric) To first order, I don't really care what the reference voltage is on my temperature sensors. So in this case I used a separate reference for each ADC to simplify the design/layout. (i.e. 3 identical circuits vs one big mess of a circuit)
If I had more than one voltage input I'd probably use one reference with a filter and buffer for each ADC. This should minimize drift between the reference of each ADC. The op-amp adds some drift and offset so this matching wouldn't be perfect.
The OPA350 is a really nice op-amp. I'd also suggest looking at the new OPA365 op-amp. It's a bit faster and has better noise/input specifications.
In your case Graham, I'd be really tempted to hook an ADC like the ADS1251 directly to your current shunt with only a passive anti-aliasing filter. Basically, the fewer parts between the ADC and the signal, the fewer places noise and temperature drifts can sneak in.
Lawson
For a 0.1ohm shunt I would only be talking 0.02v full scale so I would have thought I would need an amp? I also need to filter out the PWM, might that need a better filter?
I totally get your point, I can spend as much as I like on the shunt but it will not help much if I then add a lot of noise/drift elsewhere.
Graham
For PWM filtering make sure the anti-aliasing filter is really strong at the first alias. (1.56MHz and about -80dB filtering in my case) Also make sure the PWM operates at a multiple of the sample rate. The synchronous PWM lets you take advantage of the Nulls in the ADC's response from it's internal filtering. In my case, I have a 48KHz PWM signal that couples into all my signals due to 4 feet of ribbon cable with randomly assigned wires. (the ribbon cable is a hold over from the initial controller) I've seen no sign of this PWM signal in my data.
Lawson
A 24 bit converter could be really nice because then you skip the gain and offset error of the PGA. To add to the mix to pore over on the weekend, also look at the data sheets on the LTC24xx series from Linear Technology. Their products are always thought through with attention to detail and they offer unconventional switched capacitor architectures (a legacy of Jim Williams). Analog devices also has chips and converters specifically designed for PID weigh scales, and although IMHO their designs might be considered, "old school", their app notes for the design of weigh scales are superb and worth a perusal.
I'm getting more of a picture of what you are after. What level of precision? I hear also 83 Hz sampling rate and am wondering where that is coming from.
Re: 24 bit converters. At 20mV full scale input with a 0.1Ω shunt, and 16 bits resolution, the lsb will be 0.3 microvolt. That is challenging, even for a 24 bit converter, I think. The lsb of a 24 bit converter with a 4.096V reference is 0.24 microvolts. Lawson has more experience with this, but I would guess that would be lost down in the noise. A 1Ω shunt would put it up at 3µV per bit.
There is going to be a lot to consider about the DC error budget. With a shunt, you do have to have an absolute reference, no ratiometric conversion here. A reference drift of 15ppm and an offset drift of 1 µV/°C in an op amp would swamp the 2ppm drift of the shunt. At a target of 16 bit resolution, one bit is 15ppm, absolute.
For an op-amp, I'd be inclined to suggest a CAZ (autozeroing) op amp like the LTC1051 or LTC2055, offset voltage microvolts, drift < 0.025 µV/°C. On the other hand their noise density is relatively high, and the bandwidth is not great at 500kHz. It would be sufficient if the sample rate is low. The reason op amps like the OPA365 or LT1351 are used before the inputs of ADCs, for rapid sampling rates, is that the input sampling requires charging a small capacitor inside the ADC, and that kicks out a sudden load into the op amp driving the input, and the op amp amp can't be thrown off by that. At low sample rates, the input can be isolated with an RC network, but the RC time of that creates an error in relation to the sampling interval and average ADC input current. Some of the Linear Tech sigma-delta ADCs have a feature they call "easy-drive" that balances out those currents so that they can directly digitize from high impedance sources, however, I think those ADCs are limited to rates of around 10 SPS.
The big issue looming in my view is the PWM drive and the averaging required to get a smooth analog signal. What form of PWM will you be using, and in particular what frequency? That will determine the time constant of the allowable filter, and it will presumably be a frequency much greater than the 83 Hz. At 200 mA, the power issue is not out of the range of an analog solution and some heat. Use Prop duty mode PWM (or a constant frequency PWM at high frequency), and prefilter it to DC to drive the magnetics? That would simplify the current sensing quite a bit.
Jim
Lawson,
1ohm would seem sensible and be fine in terms of the power dissipation, seems a no brainer for a 10X increase in signal level. When you say "super sample like I did", what are you referring to? Simply having the 24bits or some over sampling? Thanks for the tips on the multiple of PWM for my sampling rate.
RS_Jim,
My understanding is that when the noise is shot noise limited (thermal noise is lower than shott noise) then essentially the more electrons you have to play with the better your SNR. Because you are taking an average and the more of them there are the less the random shows up. Then for how long do you sample if you capture within a single PWM cycle? If you neglect inductance then you could imagine the peak current would be the same for 1% and 100% duty.
Kwinn,
This was my first thought, the duty is proportional to current and hence torque. HOWEVER the constant of proportionality is R when it comes to the current produced by a given duty. That is the R of the coil and unless I try to add coolers/heaters that is likely to change with the ambient temperature and the heating of the coil.
Tracy,
Lots to think about and I need to investigate your leads but a few answers to your questions:
The 83hz, is a minimum based on the fact that my robot arm will be responding to the measured forces, I can give it updates at a rate higher than 83Hz. I suspect I will need to sample at a higher rate still to try and do some path planning. To a first approximation the robot moves to try and reduce the measured force to zero. It is a bit weird but I am making a force balance and then trying to stop it from measuring a force! I think the 83hz is a bit low but I am stuck with it.
The PWM will be generated using the counters, fixed frequency, not sure of the exact frequency but fairly high I suspect because I want my PID loop to be fairly snappy. I like the idea of filtering before application to the coils, I'm not trying to make this super efficient.
Cheers,
Graham
Lawson
Now to throw the cat among the pigeons, while checking out LT's offerings I found this app note: http://cds.linear.com/docs/Application%20Note/an07f.pdf
Essentially they are talking about using --- to frequency converters in order to digitize analogue signals directly at the source with no need for amplification to get high resolution It seems there are ICs to do this too and I imagine it would be fairly easy for one cog to monitor 6 of these signals. But I'm not sure which is better, swings or roundabouts.
Graham
are you aware, that something like this was in an Elektor project this year for a precision scale?
http://www.elektor.de/jahrgang/2011/marz/elektronische-feinwaage.1708565.lynkx
They used the pwm- Signal to generate a filtered analog voltage. This voltage was used to give a sceduled current. The current was controlled via shunt for feedback and power transistor and opamp LM358. So no need for the additional adc. (I would fear, that if you use pwm and adc, the two are likely to create errors due to timing misalignings.)
I have experimented with the setup myself but only used the pwm- signal and got a lot of drift.
Good luck Christof
But to explore that idea of direct current to frequency conversion... You can imagine a replacing your 1 Ω sampling resistor with a precision 1 millifarad capacitor (as if!). At 200mA input current, it would take 5 milliseconds to charge that up to 1 volt. That time is directly proportional to the current. Then discharge and measure again, and with 200 mA, you have a frequency of 200 Hz. But as such it is not an easy idea to implement. It might be possible to mirror the large current into a much smaller, manageable current and do the same thing, a current to frequency or current to time converter. The PWM drive would have to be much higher in frequency and consideration given to the issues and techniques that Lawson brought up, to avoid aliasing. It is hard to make such a converter with a resolution much greater than 10 bits. The crystal ball shows a circuit with lots of parts. How much precision does the robot arm need, other proprioceptive feedback?
I hadn't seen that project but I was aware that this method is used in precision balances.
It took me a while to understand your description but I think I get it now. They create a voltage controlled current source and drive the coil with this so that the PWM duty is proportional to current despite any temperature changes in the load etc. Clever. Something to think about for sure!
Graham
I will be running a real time linux box to provide commands to the robot, these are just in the form of position corrections. The controller will take the 6 components of force from my balance, convert them using a matrix so they make some sense and that will form the input to a PID loop of some sort making corrections to the robot try and reduce the force to zero. Basically this is a flight simulator for tiny flying machines.
What resolution? This is a hard one, we expect with gentle flight to see a max of 0.6N required at the output of each actuator. My actuator should be able to do about 1N @ 20mA (according to FEM model) though now with the Mummetal ordered to reduce hysterisis effects it might be more. Do I need 16bit? Not sure, that would be 1.52mg per bit. The bearings in my system would likely add more error. So I'm starting to think a nice simple ADC off a 1ohm would be more than fine. What has always worried me is that I make something that works well and then drifts off madly, I probably don't need the 2ppm but the closer I get the less I need to worry.
I think I am starting to like the method Christof linked to more and more.
Graham
I'm firstly a little confused as to the idea behind these current type DACs, many of the datasheets just show them controlling an op-amp to create a voltage, is the idea just to boost the output drive and get a lower output impedance?
I'm assuming I can take the current out part of the DAC and plug that into an op-amp based current source circuit?
Graham
The first stage develops a voltage across the resistor R2, proportional to the input voltage. The second stage forces a proportional current output through the load. Io = (Vin * R2) / (R1 * R3), referred to ground.
The feedback condition in the second op-amp forces equal voltages across R2 and R3, which means a regulated current in the whole path through R2, the mosfet and the load. If the coil does not have to be ground referenced, then one stage will suffice.
Tracy,
Yes, that makes sense, the only advantage of the AD device was the fact it was a single chip requiring only a transistor, however it was a big device. If I go with your suggestion with either PWM or voltage type DAC then there are plenty of small devices to choose from. If I take the PWM route I can rely on good PWM switching accuracy from the prop but assume I would need to be careful to ensure a good quality power supply if I wanted to make the most of the resolution so that the amplitude of the PWM signal was consistent?
Graham
http://www.youtube.com/watch?v=kAgX1rMICqU
http://www.youtube.com/watch?v=QdbqeFrMhfI
The tube in the second video is homemade from carbon fibre and holds the permanent magnet for the actuator.
Cheers,
Graham
*edit* I'd also suggest looking at silicon carbide ball bearings. While I doubt you need the hardness, I'd expect the lower density to be welcome.
Another thing to worry about is vibrations from your robot arm. I'd expect a constant hum at the PWM frequency of the robot arm, plus a position/speed dependent noise from motor cogging, gear boxes, and encoder quantization. Depending on the control system, there is also likely to be vibrations due to gain scheduling or other controller mode shifts. (likely a good idea to move an accelerometer around with the arm to measure all this)
I assume the robot arm can be controlled in a coordinate system fixed to the end effector? Building the controller to link your force balance and the robot arm in an *orthogonal* set of axes that moves with the force balance will make your life vastly simpler. (i.e. you want to de-couple each controller) If the arm is moving quickly, it might be worth constructing the controllers in a coordinate system defined by the principal axes of inertia to avoid high frequency cross-coupling.
Lawson