Measuring voltage over current-sensing resistor on analog input

Hi guys,

I really hope somebody is able to help me with this one. I am in the process of building a monitoring system for a rather large solar installation as part of a charity project and have one or two questions to help me get over the finish line.

I am using current sensing low resistance shunts to measure the current at various points in a 12v (around 100A!) circuit. I can successfully put a multimeter over the shunts to see the voltage drop and calculate the current in the circuit.

I am struggling however to work out how to get this value into the Arduino (Pro Mini) safely and would prefer not to fry anything! I have spent a while searching the Forums and whilst there is some info, I would love confirmation from somebody that these things will work in my specific use-case.

From what I understand, I have two options…

As the voltage drop is pretty tiny across the shunts, I could put this value into an op-amp and boost it up to a usable 0-5v - Like what is done here? - http://electronics.stackexchange.com/questions/99656/how-to-sense-current-being-used-by-motors

Alternatively, I could measure the voltage (using a potential divider circuit to get it down to 5v or less) between one side of the resistor and ground and the other side and ground, then do the maths on the arduino to work out the voltage drop.

I wondered if both of these options are valid and/or which would be the better option?

I attach a summary of what I am trying to do in image form, any help at all would be greatly appreciated! This is my first post, so apologies if I am missing any required detail.

Thanks,
Sam

You will need amplification either way, I think. May as well use a differential amp to both amplify the voltage and isolate the shunts from the Arduino. What is the value of the voltage drop across the shunt at 100A?

Thanks GroundFungus,

It is a 0.0001 Ohm resistor. So I would believe that to be a 0.01v at 100A (V = 0.0001 x 100)

Cheers,
Sam

Many of the Atmel micro processors (but NOT the Atmega 328 in the Uno and Nano) have the ability for measuring the differential voltage between two analog pins and they also contain amplifiers. This means that the device can measure voltages that are not referenced to its own GND. Have a look, for example, at the Atmega 2560 datasheet.

This Youtube video (not mine, by the way) illustrates the process.

...R

The Tiny25/45/85 also has diff inputs, if you need only a few pins.

From the data sheet.

– 10-bit ADC
• 4 Single Ended Channels
• 2 Differential ADC Channel Pairs with Programmable Gain (1x, 20x)
• Temperature Measurement

Probably not enough gain, still (0.01 * 20 = 0.2) even with the 1.1V reference.

Thanks guys, really appreciate it.

Sadly I am fairly constrained to a ‘pro mini’ clone due to size and cost factors as well as its ease of integrating into a semi-permanent installation. I can use a Mega if required but would much sooner stick with the current board. That being said, I didn’t know that the Atmega chips supported that sort of voltage difference calculation, that’s great to know. Thanks!

So if I understand the above correctly, I would need an op-amp with about 500x gain?

Please forgive my basic electronics knowledge here, but would something like the attached picture work? In which case, what resistance values would I need for R1-4?

Thanks again,
Sam

I would need an op-amp with about 500x gain?

Not necessarily. If you use the internal 1.1V analogReference (Vref) the gain would need to be 100.

The analog reference is what any analog input is referenced to (LSB = Vref / 1024). On a 5v Arduino, the default Vref is the 5V supply, but you can change that to the internal 1.1V Vref. The internal 1.1V Vref is also more accurate than the default reference because it is not dependent on the supply voltage.

As to the circuit I won't comment. Hopefully a member will help you find a suitable differential amplifier.

The Atmega 2560 (as in the Mega) also has x200 gain.

And the 32U4 MCU in the Micro has x40 and x200 gain if you need a small form factor.

...R

Robin2, does the 2560 have a 2.56V Vref like some of the other AVR chips? It is hard to find in the data sheet.

Edit: Found it, Yes it does.

The LTC2946 does everything you need - and you can buy it as an arduino shield…

edit - sorry - actually as a demo board. Libraries are available.

regards

Allan

0.0001 Ohms - are you sure?

The wires leading to your shunt will have a higher resistance than the shunt.

You will need an OP-Amp with a negative supply voltage as rail-to-rail is not going down to 0.01V.

Forget about measuring current directly with the Arduino.
You need a preamp for the tiny voltage across a shunt.

Is the shunt in the +12volt line or in the ground line.
To prevent problems with ground loops (and negative rails), it would be better/easier to have the shunt high-side.

There are several chips that can measure the voltage across a shunt high-side.
The INA219 is a common chip for this task. Adafruit has it on a breakout board.

Just connect the current inputs to your high-side shunt (onboard and external shunt in parallel).
The INA219 has a build-in 12-bit A/D for current and voltage, and connects to the MCU with a 2-wire I2C bus.
Leo…

Hi,
I agree with Wawa about your shunt, use differential readings on both of the shunts.

Is your charge controller the type that disconnects the panels from the batteries on the NEG or POS lead?

You would be better measuring panel current on the output of the charge controller rather than the input to the charge controller.

How big is the PV installation, Watts?

Tom... :slight_smile:

TomGeorge:
How big is the PV installation, Watts?

OP mentioned 12volt/100A (1200watt).
12volt is rather lossy, and only used for relatively small systems.
Leo..

Wawa:
OP mentioned 12volt/100A (1200watt).
12volt is rather lossy, and only used for relatively small systems.
Leo..

Yes, I hope he has big enough wiring to take that sort of current.
What is the charge controller?
Tom.... :slight_smile:

Hi Guys,

Thanks so much for your help, I really appreciate it. Unfortunately due to unforeseen circumstances, I haven’t been able to progress much with this over the last couple of weeks, back on track now and ready to roll (in a much reduced timeframe!). Sorry for the delay in replying.

The INA219 looks perfect! That saves me some pins and allows me to continue my use of the little, cheap pro mini by using the i2c bus.

So, taking all of your advice on-board, I believe this circuit diagram should work?

I have made the following changes:

  • Added the INA219 with it’s current sensing resistor wired in parallel to the shunt
  • Moved the ‘IN’ current measurement to after the controller
  • Moved both of these measurements to the +ve side

My (fairly n00b) questions are:

  • Can the INA219 measure voltages that low at a reasonable resolution? I see that it’s maximum voltage difference between the pins is 320mV but I see no minimum measurement.
  • The current at this point in the circuit is going to be fairly low, right? So I’m not likely to fry anything?

The wiring is all capable of that kind of power, thanks but I don’t think anything is going to melt :slight_smile: I’m not certain which charge controller we have at the moment but is there anything in particular I need to watch out for?

Thanks again for the help!

Cheers,
Sam