# Measuring current using a shunt and ADC

#### zero10

Joined Sep 20, 2012
12
I am working on building a small electronics / project cabinet with an integrated power supply and one of the things I would like it to do is display the voltage and current on each of the different voltages supplied (+3.3V, +5.0V, +12.0V).

The project will include a few 4-digit 7-segment LED displays for showing this information that are driven by a PIC16F88 microcontroller. The voltage measuring I have got figured out (although maybe not in the best way), I figure I can just use a resistor voltage divider to bring the voltage down far enough that I can measure it with an ADC (I currently have a MCP3208 but could swap to a different one if it helps me with my current measuring goal).

Also, I have some 0.010 ohm resistors that I scavenged from another power supply which seemed like they would be good for the current measuring part of this project, but this is where I start to get out of the realm of what I know (or think I know) and I need some help.

The idea I had was to use the shunt resistors on the positive supply for each voltage (as the ground is common) then measure the voltage difference across them, but there are a couple things that I see as problems with this:
1) The voltage difference across the shunt is small. At 20A, which is about the limit of what I can supply, it would only be 0.2V. I am worried using a very low reference voltage on my ADC is going to produce large errors in its readings.
2) The voltage relative to ground on each side of the shunt is different on each supply line, and in one case greatly exceeds the voltages I can apply to my ADC or any other part of the control circuitry so I can't directly connect either measurement point to my ADC or microcontroller.

What is the best technique for this?

I hope I am missing some obvious solution. I am sorry to say I really am not that experienced with this sort of thing, most of my experience is in digital electronics and common-voltage components. I thought perhaps I could use a dual supply rail-to-rail op-amp with feedback to amplify the voltage difference and bring it to something near the common ground (0-5V perhaps) then sample it with my ADC, but I don't know how well they deal with measuring the difference between say +12.4V and +12.39V when supplied with +/-5V. Is that even safe? It seems like there is something terribly wrong with that idea

Sorry to ramble, and I would appreciate any advice you can give

#### crutschow

Joined Mar 14, 2008
31,110
Yes, the common-mode voltage can cause offset problems when trying to use standard amplifiers to measure the small voltage across a high-side shunt. Instead you can use a high-side sense amplifier designed for that such as this. Here's a search for other similar devices.

#### zero10

Joined Sep 20, 2012
12
Okay that is really cool. I guess I should have thought that perhaps there is a device designed specifically for this situation, thanks!

I checked the price list on the LTC6101 and it seems they are about $5 each in small quantities. That isn't too bad but when digging about for similar parts I found the TSC1021A which does 20V/V gain (so I shouldn't get over 4V on my ADC) and is priced at ~$1.35/each. I have compared the spec sheets and see they are slightly different, but given my intended goal would the TSC1021A work just as well for me?

Chip packaging doesn't matter much, I'll be making my own PCB for this and am rather good with soldering so whether it's DIP or TSOP or whatever is of almost no consequence.

#### ramancini8

Joined Jul 18, 2012
473
Measuring voltage with a divider should work; filter the divider well, use temperature stable resistors, and calibrate the divider with a good meter. You can measure current with a series pass resistor as you have suggested, but when the current is small the signal is small and very suceptable to noise. A further problem with this method is that the sense resistor is at the supply rail making it difficult to sense without some sort of device to translate the sense voltage to the ADC's input range. A more elegant and fun method might be to use a Hall sensor. If you insist on using a resistive current sensor look at Burr Brown's line of supply translators which mirror a voltage near the supply rail to a ground reference.

#### Ron H

Joined Apr 14, 2005
7,014
Measuring voltage with a divider should work; filter the divider well, use temperature stable resistors, and calibrate the divider with a good meter. You can measure current with a series pass resistor as you have suggested, but when the current is small the signal is small and very suceptable to noise. A further problem with this method is that the sense resistor is at the supply rail making it difficult to sense without some sort of device to translate the sense voltage to the ADC's input range. A more elegant and fun method might be to use a Hall sensor. If you insist on using a resistive current sensor look at Burr Brown's line of supply translators which mirror a voltage near the supply rail to a ground reference.
There is a buttload of companies that make high side current sense amplifiers.

#### crutschow

Joined Mar 14, 2008
31,110
......................................
If you insist on using a resistive current sensor look at Burr Brown's line of supply translators which mirror a voltage near the supply rail to a ground reference.
Did you miss my post?

#### zero10

Joined Sep 20, 2012
12
Thanks for all the input guys, this has been a huge help. It looks like high side sense amplifiers are exactly the right tool for what I am trying to do.

I think I might have asked too vague of a question on my last post. After giving this some more thought and reading the spec sheet a couple of times I think I know my answer. The sheet seems to indicate that Vsense is safe up to 1.0V, though with a gain of 20 it isn't terribly useful to go past about 250mV in my situation, which with my resistors gives me a maximum current of 25A. My power supply will put out 30-35A on all rails, but I am perfectly fine with limiting the viewable current a little bit as I think 25A gives me plenty of range still and it doesn't hurt anything to exceed 25A, I just wouldn't get a useful reading. All of the voltages I want to measure (except the -5V) are within the normal operating ranges for this device and it is available with a gain of 20 which is good for the resistors I have now, or a gain of 50 if I wanted to buy some lower resistance shunts, which I just might to keep the voltage drop down.

The input offset voltage is a little bit high on this chip compared to others, but I don't think that will be a problem. Since I am taking the reading through an ADC and using a microcontroller to do some math on it already I think I can make any relevant corrections to the output value as a result of this so long as they are predictable, which I think they will be unless I mis-understand?

I guess the only thing that worries me is that the stated output voltage accuracy seems to decrease significantly (from 1.5% to 12%) as Vsense falls from 50mV to 10mV. Does this mean it is going to bounce around a lot, or that it may be stable but incorrect? I could probably adapt for either case so long as it is predictable, and I suppose I could just buy some and see but assembly of this project is still over a month away and I would prefer not to buy parts that end up being unusable

#### crutschow

Joined Mar 14, 2008
31,110
..................................

I guess the only thing that worries me is that the stated output voltage accuracy seems to decrease significantly (from 1.5% to 12%) as Vsense falls from 50mV to 10mV. Does this mean it is going to bounce around a lot, or that it may be stable but incorrect? I could probably adapt for either case so long as it is predictable, and I suppose I could just buy some and see but assembly of this project is still over a month away and I would prefer not to buy parts that end up being unusable
The output will be stable, but with lower accuracy. That is usually not a big concern when measuring power supply output current unless you need accurate current measurements for testing purposes. In that case you just use an external more accurate ammeter in series with the power supply output.