# some grumbles about (hobby) high side current sense/measurements

#### ag-123

Joined Apr 28, 2017
273
high side current sensing/measurements is *difficult* to do with typical 'flea' market op amps say those floating on AliX etc.
1st high side measurements requires pretty much rail-to-rail op amps and more importantly those that can take a high common mode voltage as measurements across the sense resistor is very often higher than the limits for cmrr.
Hence, what is left is dedicated high side current sense amplifiers, they proved price competitive vs trying to make a discrete solution (e.g. using 'ordinary flea market' op amps).

As I'm using an stm32 which has rather decent ADCs, I started looking for *analog* high side amps.
I started looking at datasheets, an interesting one is INA139 (40v)/INA169(60v) INA139 is adequate for my purpose
The nice thing about this is the gain setting resistor is external, hence, I'm thinking about multiplexing resistors for different gains. Probably, not a best solution. But it turns out they are rather pricy.

Next I looked at fixed gain current sense amps. e.g. INA180 (uni-direction)/INA181 (bi-direction)
Gain options: – 20 V/V (A1 devices) – 50 V/V (A2 devices) – 100 V/V (A3 devices) – 200 V/V (A4 devices)
looks good. And these are 'cheap' and 'abundant', apparently, I'd guess these are the most used in 'real' devices.
How then to achieve, 'programmable' gain? I think through it a while, toyed with the notion to use the same shunt but say connect an A1 sensor and an A2 sensor in 'parallel'. It seemed quite feasible to do this, but I'd guess I'd need to calibrate the measurements to compensate for the different wire lengths to the shunt resistor and possibly errors.

Then I took a look at INA219
This is a 'fully digital' current sense amplifier and provides the reading over i2c and has the PGA built-in.
Then it turns out, the completely assembled INA219 modules on the 'flea' markets
https://www.aliexpress.com/w/wholesale-ina219.html
cost less or equal to a single INA169 for the chip alone.
The true INA219 chip prices aren't really that much less.
I'd think a reason for this could be due to bulk purchases and mass production, which resulted in the lower cost per unit.
And I'd guess things like INA138/INA168 (unidirection), INA139/INA169 (bidirectional), but are simply analog looks rather costly as they are 'less frequently' used parts, say vs the INA180/181 and/or even the INA219.
There was reports of shortages of INA219 prior, but I'd guess it is somewhat relieved by now.

the grumble is that 'measuring currents' (especially on the high side) is anything but 'simple', what seemed 'simple' about measuring the small voltages across the shunt is naively 'simple', but that there is no 'easy way' to measure that on the high side.

Last edited:

#### dl324

Joined Mar 30, 2015
15,511
high side current sensing/measurements is *difficult* to do with typical 'flea' market op amps say those floating on AliX etc.
I wouldn't buy any opamps from Ali Express.

TLDR. Post a schematic of what you're trying to do.

#### ag-123

Joined Apr 28, 2017
273
I wouldn't buy any opamps from Ali Express.

TLDR. Post a schematic of what you're trying to do.
well, 'unfortunately', the INA219 'modules' met my needs for the time being, I end up ordering 2 instead of doing it the more 'analog' way say using INA139/INA169, it just feels the mcu is 'underutilised', INA219 'does the job' :/

#### dl324

Joined Mar 30, 2015
15,511
well, 'unfortunately', the INA219 'modules' met my needs for the time being
I implemented high side current sensing in a power supply circuit I designed using an LM393. It's a 40-50 year old design that doesn't have rail to rail inputs and I was able to make it work.

The P channel MOSFET I used to interrupt current had a max gate voltage of 6V, and I made that work too.

#### ag-123

Joined Apr 28, 2017
273
I've been thinking that it may be possible to use PNP transistors or P channel mosfets, but that i've not (yet) worked a useable circuit. in my (google) searches, I stumbled across circuits like this
https://data.epo.org/publication-server/document?iDocId=1426498&iFormat=0

The voltages across the darlington pair (or for that matter simply a transistor) is somewhat difficult to analyse.
I'd imagine that the darlington pair is driven to saturation so lets call that voltage Vce-sat (say 1.2 v, actually it'd vary).

Then that the current flowing through R1 and R2 is $\frac{ V_{sense} - V_{ce sat} }{R1 + R2}$
And that $V_{out} = \frac{ ( V_{sense} - V_{ce sat} ) * R2}{ R1 + R2 }$

This is probably incorrect as Vsense across Rsense is nowhere in the equation.
But that this seemed to be a 'common' way 'single chip' current sense amps are designed.

Another way seem to be to assume
$V_{sense} = V_{R1} \\ I_{R1} = \frac{V_{R1}}{R1} \\ \text{and that} \ \ I_{R1} = I_{R2} \\ \text{so that} \ \ V_{out} = (V_{R1} / R1) * R2 \\ V_{out} = V_{sense} * R2 / R1$

this seemed to match the literature of some of the current sense ICs. This circuit may be worth experimenting.
But that this may still depend on the op amp having CMRR that extends to the Vsense voltages and that it probably require it to be a rail to rail amp.

Last edited:

#### dl324

Joined Mar 30, 2015
15,511
This is what I did. I used 3 rectifier diodes up stream from the current sense resistor for V+ for the comparator to satisfy common mode input voltage requirements. The negative supply for the comparator had to consider the maximum Vgs for the MOSFET. I used another zener for that. The output from Q1 went to the regulator.

#### ag-123

Joined Apr 28, 2017
273
@dl324, it is a nice circuit there
edit:
other notes, I'd think the 'easiest' way to get that circuit posted 2 comments earlier is to simply get one of the high side current sense ICs.
It seemed there are various based on that design, but that many of them apparently is based on a fixed gain e.g. 20/50/100 etc.
The fixed gain ones apparently have a lower price in the markets, probably as those are the most used ones of the lot.

Last edited:

#### Ian0

Joined Aug 7, 2020
7,016
I've been thinking that it may be possible to use PNP transistors or P channel mosfets, but that i've not (yet) worked a useable circuit. in my (google) searches, I stumbled across circuits like this
https://data.epo.org/publication-server/document?iDocId=1426498&iFormat=0
View attachment 285987
The voltages across the darlington pair (or for that matter simply a transistor) is somewhat difficult to analyse.
I'd imagine that the darlington pair is driven to saturation so lets call that voltage Vce-sat (say 1.2 v, actually it'd vary).

Then that the current flowing through R1 and R2 is (Vsense - Vce-sat) / (R1 + R2).
And that Vout = (Vsense - Vce-sat) * R2 / (R1 + R2)

This is probably incorrect as Vsense across Rsense is nowhere in the equation.
But that this seemed to be a 'common' way 'single chip' current sense amps are designed.

Another way seem to be to assume Vsense = V_R1,
I_R1 = V_R1 / R1
and that I_R1 = I_R2, so that
V_out = (V_R1 / R1) * R2 = Vsense * R2 / R1
this seemed to match the literature of some of the current sense ICs. This circuit may be worth experimenting.
But that this may still depend on the op amp having CMRR that extends to the Vsense voltages and that it probably require it to be a rail to rail amp.