# Current measurement with shunt

I need to measure pretty high currents (maximum 100A) flowing from one battery to another. I came up with a solution involving the measurement of the voltage drop across a shunt resistor. The supply I'm using for powering the circuit is isolated from such batteries. Since I'd rather use a single rail supply for the board, containing both analog conditioning system and microcontroller, I came up with the following schematic.

I chose a Rail-to-Rail output OpAmp (LT6232) in order to have its output ranging from 3.3V to 0V. The simulation has been carried out using LTSpice and its device models.

The output voltage (from how I designed the resistors) should follow the formula Vout = (Rf/R1)*(V2 - V1) + V_ref.

1) if Vbat1 = Vbat2 (current on the shunt 0A), I would measure 1.65V (correct!)

2) if Vbat1 < Vbat2 (i.e. Vbat2 = 12.15V and Vbat1 = 12V, current on the shunt 100A), I would measure ~3.3V (correct!)

3) if Vbat1 > Vbat2 (i.e. Vbat2 = 12V and Vbat1 = 12.15V, current on the shunt -100A), I should be measuring something around 0V, instead the simulation shows something slightly below 500mV.

What am I doing wrong? Thanks for helping.

• note the opamp nput voltages are very different, therefore it's not operating as an amplifier. Commented Jun 9, 2019 at 13:50
• @Neil_UK I can't figure out why they are, ofc in this condition it's amplifying a common mode Commented Jun 9, 2019 at 13:53
• What is "ofc"? Please try to be clear in your writing. Commented Jun 9, 2019 at 14:31
• I will agre that 150mV difference into that diffamp ought to give 1.65v out. However, that's a rail voltage, and I (and you) don't know how good the LT6232 model is. There are two experiments you can do. a) raise the Vcc and Vref so the output is well away from the rails and b) replace the 6232 with an ideal opamp. BTW, I never feel it's a good idea to have two parts of a circuit isolated, except for the sense resistors R1 R2. At least you'll know where you are if you define their relative potential by connecting Vref to V1 for instance. Commented Jun 9, 2019 at 15:04
• Use an instrumentation amplifier (IC or circuit) Commented Jun 9, 2019 at 15:05

To address the question regarding the simulation behavior, According to the datasheet it is a rail-to-rail op. amp. only in the output:

You may change your gain and V_ref (which is like an offset) to meet the input specification. (2.65+1.15)/2 = 1.9 V at the op. amp. inputs for the equilibrium could be a starting point.

I'm concerned with your floating reference with the batteries. You must control your common voltage. Your circuit should follow the measured circuit reference (maybe by powering your 0-3.3V circuit from the 12V with a DC-DC converter or linear regulator) or you may provide an isolation layer.

Op.amp. with finite open loop gain (otherwise ideal for DC) and matched resistors:

Same op. amp. and matched resistors, common mode voltage:

Now with slightly unmatched resistors:

It will be worse when you consider that the real op. amp. will also have a common mode gain and the input range has limits.

Common mode voltage does matter hence you must control it for proper measurement. Every simulation that considers an infinite resistance from the common battery terminal and your circuit misleads your design, since even a 1k resistor is enough to guarantee the input voltage potential.

• Since the batteries are floating, there is no common mode signal present at all. You applied a ground to the negative junction of the batteries that does not exist in the problem. So the common mode capabilities of the opamp are irrelevant in this problem. Commented Jun 10, 2019 at 15:23
• I know the connection does not exist. I'm trying to show the problem with common mode voltage. How it is possible to say for sure that there is no common voltage in the case if resistance between the common connection is infinite. It is clear in simulation but not in real circuits. The 1K resistors move the battery potential to wherever they want, which may not be the case in the real circuit. Commented Jun 10, 2019 at 15:28
• The OP specifically said the measurement system was isolated, so there is no common mode signal. The batteries are shown as floating. Only if the measurement system was grounded to the battery common connection could there ever be a common mode signal. So you don't need to design for it. Commented Jun 10, 2019 at 15:41

Current measurement with shunt and with no defined ground reference

This is an interesting problem to solve, and you have over complicated the reasoning (you don't need a voltage reference in the front end) and are probably confused further by the simulator.

Lets start with a very simple measuring device based on a single opamp.

1. The device is battery powered.
2. The device is fully floating with no defined ground reference point.
3. The output measuring range is 0-3.3V into an A/D.
4. The device can measure +/-100A relative to two points (ie across the shunt).
5. V1 and V2 do not matter, only the voltage developed across the sense resistor matters.

The circuit below shows a single opamp that amplifies the input signal (+/- 150mV) to +/-3.3V. I've used a typical opamp (not rail to rail) and the simulator assumes +/-15V supply rails. I know this is not what the target is but it serves as a starting point.

NOTE: The ground I show here is ONLY to satisfy the simulator. I could have applied the ground symbol to anywhere in the circuit. I chose to ground Probe_A to make it easier to understand the next change to be made.

simulate this circuit – Schematic created using CircuitLab

If Probe_A is positive relative to Probe_B then the output will be negative.
If Probe_A is negative relative to Probe_B then the output will be positive.
The ground reference shown is only needed for the simulator to run, but it does then define the relative voltages for the opamp output and the probe inputs.
To get +/-3.3V fullscale output for 150mV (100A in the shunt) input we need a gain of 22.

Now on to your problem. I am assuming your battery powered instrument uses two probes to connect to the shunt resistor which is permanently in place. The instrument can therefore be touched to the shunt with Probe_A being positive or negative relative to Probe_B.
So there are two connection variables:

1. We don't know which battery voltage is highest.
2. We don't know which way around the Probes will connect.

Therefore it would be helpful to be able to measure +/-100A and perhaps light an LED next to the probe touching the highest voltage battery.

As I assume the voltage being measured across the shunt is being digitized by an A/D we can do the following:

simulate this circuit

Now I have biased the input for the opamp to 3.3V/2, this is buffered by an opamp and fed to the negative input. This does not need to be a reference voltage, you simply need the MCU VDD/2 so you can measure either polarity signal.
I've also changed the gain of the opamp so that it outputs +/-1.65 relative to the supply center point of the 3.3V supply.

If Probe_A is positive relative to Probe_B then the output will be positive but below VCC/2. Ov output to the A/D = 100A.
If Probe_A is negative relative to Probe_B then the output will be positive but above VCC/s. 3.3V. 3.3V output to the A/D = 100A.
Mid point on your A/D = 0A.

Most MCU A/D's use the supply voltage as the reference voltage and this causes some loss of accuracy. You could get higher accuracy by using an external reference for the A/D rather than using 3.3V as the FSD reference then use a D/A to set the mid point voltage.

You can then decide in code whether to light an LED next to Probe A or B to designate the higher voltage point.

• So what is wrong with the OP's circuit? That's the actual question here. Commented Jun 9, 2019 at 23:54
• The OP tried to use a reference against which to measure. Which does not work in the circuit shown. It's an easy mistake to make. You are simply trying to measure the voltage developed across the sense resistor, and you know that it's 150mV full scale. You simply need to amplify that voltage to use the reference IN the A/D to measure the voltage from the opamp that describes the current. You don't need any reference in the amplifier at all whether it be a differential or single ended measurement. Commented Jun 10, 2019 at 0:22

OK, third try. I was comparing my results with the wrong test case. Floating shunt is not the problem, it is a common mode input problem.

For the case where V1 > V2, the current must flow up to balance the input and the opamp will sink the current. The output voltage will be:

Vout = Vref - (r0 + Rf) * 75 uA = 0 (confirmed with simulation ~0)

The opamp inputs are Vref/2 = 0.825 V

This is outside the common mode input range of the opamp (>1.5V or > 1.05V more than V-, which is ground, exact value depends on Vcc), the opamp is not guaranteed to behave properly.

simulate this circuit – Schematic created using CircuitLab

• There is absolutely nothing wrong with a floating measurement system We do it all the time when we use a multimeter. The voltage reference is not required. Commented Jun 10, 2019 at 14:46
• If you are going to down-vote, please explain what is wrong with this analysis. This is the only answer that explains why the OPs circuit doesn't work. Commented Jun 10, 2019 at 14:46
• I though I just explained it in the comment. Commented Jun 10, 2019 at 14:47
• No, you didn't explain what is wrong with my analysis, you just stated that the circuit should work with a floating shunt. Why does my simulation agree with my analysis? Yes, floating measurements are used successfully all the time, but apparently not with this type of circuit. Commented Jun 10, 2019 at 14:57
• OK, sorry, I was using the wrong test case for my analysis. Everything will work find, floating or not, if you stay within the common mode input range of the opamp. Commented Jun 10, 2019 at 16:37