Measuring current using a shunt resistor

Arduino guru's,

I think I know the answer to this but I was thinking of measuring current (like around 20-100A) using a shunt resistor, and an arduino measuring the voltage drop.

I found a shunt with resistance of 0.0001 ohms, but at 50 amps, voltage drop is 0.005 volts--I'm pretty sure the arduino is not very accurate at that voltage.

The only other option I see is to use a hall effect sensor, but i have no way to test its accuracy.

Thanks in advance.

At those sorts of currents I would use a Hall effect current sensor. These are calibrated when you by them.

AC, DC.

Voltage.

If DC, uni- or bi-directional.

I found a shunt with resistance of 0.0001 ohms, but at 50 amps, voltage drop is 0.005 volts--I'm pretty sure the arduino is not very accurate at that voltage.

With the 1.1V reference the Arduino's ADC reads in steps of about 1mV. So it could read the 5mV drop, but without much resolution.

How much voltage drop can you accept? It's probably best to start with that, and then calculate the required resistance. Practically speaking, 0.0001 Ohms is going to be "difficult" because the connections to the resistor will likely be greater than that. In most situations, 0.0001 Ohms would be considered a "dead short". According to "The Internet" one foot of 18AWG wire is 0.006 Ohms.

Make sure the Arduino is floating (no common power or ground connection to the circuit you're measuring) or put the shunt in the ground circuit so the Arduino's ground doesn't "short out" circuit, which could be a disaster all-around.

The only other option I see is to use a hall effect sensor, but i have no way to test its accuracy.

Calibrate it with a multimeter.

Galvanic measurements (low voltage DC) might be better done "high-side".
Adafruit has two boards that can be made to measure any current with an external shunt.
One with the INA169 (60volt) and one with the INA219 (26volt).
The INA219 has an onboard 12-bit A/D for current and voltage.
Leo..

The Arduinos that do NOT use the Atmega328 chip can measure differential voltage (between 2 analog pins) and include an amplifier for low voltages. This YouTube video may be helpful.

...R

Robin2:
The Arduinos that do NOT use the Atmega328 chip can measure differential voltage (between 2 analog pins) and include an amplifier for low voltages.

But note that these voltages must be within the 5V or 3V3 powering the board.

sonnyyu:
The method of sensor AC:

Voltage Sensing Unit:

  • Resistor divider
  • AC Voltage stepdown transformer

Current Sensing Unit:

  • Current transformer
  • Hall effect-based current sensor
  • Rogowski coil sensor
  • Shunt resistor

...

The method of sensor DC:

Voltage Sensing Unit:

  • Resistor divider

Current Sensing Unit:

  • Hall effect-based current sensor
  • Shunt resistor

Grumpy_Mike:
But note that these voltages must be within the 5V or 3V3 powering the board.

I understand that the difference must be within that range but does the absolute voltage matter if the power being measured does not have a common GND with the Arduino ?

In this case the voltage difference across the shunt is very small.

...R

You can not measure the differential voltage if you do not have a common ground so yes they can't be outside the power supply limits.

Grumpy_Mike:
You can not measure the differential voltage if you do not have a common ground

My understanding that the differential voltage option just measures the difference in voltage between the two analog pins. I don't think it measures either voltage by reference to Arduino GND. This is an excerpt from the Mega 2560 datasheet

If differential channels are selected, the voltage difference between the selected input channel
pair then becomes the analog input to the ADC

I am thinking of using this myself and I don't want to blow up my Mega.

...R

I don't want to blow up my Mega.

You will not blow up your Mega, it just won't work.

You would not think of trying to measure a single ended analogue signal without a common ground, so measuring two is not going to make any difference. The two signals go into an operational amplifier on the chip. These voltages need to be referenced to the common ground of that operational amplifier before any amplification can take place.

I shall do more reading tomorrow. So far it has been inconclusive.

If I use my DMM to measure the voltage across a shunt it has no way of knowing that the shunt is part of a 12v circuit.

...R

Robin2:
If I use my DMM to measure the voltage across a shunt it has no way of knowing that the shunt is part of a 12v circuit.

Unless it was also being powered by that circuit.

Robin2:
If I use my DMM to measure the voltage across a shunt it has no way of knowing that the shunt is part of a 12v circuit.

...R

Yes and that is exactly the same as measuring a single voltage with a floating Arduino. The negative lead of your meter is the ground. But making two voltage measurements requires that common ground and a wire for the second voltage.

Grumpy_Mike:
But making two voltage measurements requires that common ground and a wire for the second voltage.

Please understand that I am not arguing for its own sake and I am taking very careful note of what people are saying.

It seems to me that in differential mode the Atmega 2560 only makes one voltage measurement - the difference (just like a DMM ?)

And it will not be powered by the circuit it is measuring.

...R

It seems to me that in differential mode the Atmega 2560 only makes one voltage measurement

Yes it makes only one measurement which is the result of the difference between two voltages on the +ve and -ve inputs of an op amp inside the processor.

Where is the common ground that is needed in order for that op amp to work?

Anyway if you don't believe me then try it yourself. Get your Mega and wire up a 1.5V battery across the two analogue pins, then see if what you read makes sense.

Grumpy_Mike:
Get your Mega and wire up a 1.5V battery across the two analogue pins, then see if what you read makes sense.

That's part of the plan - but it may have to wait until tomorrow. Today the Mega is engaged in some Yun experiments.

...R

Initial tests are positive.

Connecting a 1.5v battery (or two in series) between pins A0 and A1 gets a consistent reading that is about 5% off. The values also seem to be consistent when the polarity is reversed.

This is the short test program.

void setup(){
	Serial.begin(9600);
	Serial.println("Starting DiffADC");
	
		// set up ADC
	//~ ADMUX =  0b01000000;	// use ADC0 single ended
	ADMUX =  0b01010000;	// use ADC0 and ADC1 as + and -
	//~ ADCSRA = 0b10000000;
	ADCSRA = 0b10000111;
	ADCSRB = 0b00000000;
}

void loop() {
		// start the ADC
	ADCSRA |= 0b01000000;

	// ADSC is cleared when the conversion finishes
	while (bit_is_set(ADCSRA, ADSC));

		// we have to read ADCL first; doing so locks both ADCL
		// and ADCH until ADCH is read.  reading ADCL second would
		// cause the results of each conversion to be discarded,
		// as ADCL and ADCH would be locked when it completed.
	byte low  = ADCL;
	byte high = ADCH;
		// combine the two bytes
	int val = (high << 8) | low;
	
	Serial.print("ADC val ");
	Serial.print(val);
	Serial.print("  ");
	Serial.println(val, HEX);
	delay(300);

}

I will try to figure why the readings are a bit off. Regular analogRead() gives a better result.
However if the error is consistent and predictable it can be fudged out.

...R

Try a 100n cap from ONE analogue input to ground.
Leo..