Jump to content

Shunt Electronics Help Wanted


system 4-50

Featured Posts

I'd like to couple a standard shunt up to an Arduino so that I can play with the charge/drain values on my boat.

The shunt will typically give me -50 to +50 mv.

The Arduino voltage sensor has a range of 0 to 3.3V.

How can I convert the former into the latter?

I am happy with resistor bridges to reduce voltages but going the other way about, I haven't a clue.

My electronics knowledge is small and patchy.

Any thoughts?

Link to comment
Share on other sites

I'd like to couple a standard shunt up to an Arduino so that I can play with the charge/drain values on my boat.

The shunt will typically give me -50 to +50 mv.

 

You need to know another of the three bits of data associated with V=IR to start with. Either the resistance of your shunt, or the current through the shunt which returns the 50mV you mention.

 

 

 

The Arduino voltage sensor has a range of 0 to 3.3V.

How can I convert the former into the latter?

I am happy with resistor bridges to reduce voltages but going the other way about, I haven't a clue.

My electronics knowledge is small and patchy.

Any thoughts?

 

 

Not sure what you mean by this. I thnink youy actually want to know how to translate the (up to) 50mV reading on the volt meter into current. Yes?

P.S. on reflection, it's probably really simple provided we assume a constant battery voltage. If your shunt returns a drop of 50mV when passing a current of say 100A, then all lower volt drops mean the current is proportionally lower. Or have I got hold of the wring end of the stick? Or the wrong stick even? :)

Link to comment
Share on other sites

 

You need to know another of the three bits of data associated with V=IR to start with. Either the resistance of your shunt, or the current through the shunt which returns the 50mV you mention.

 

 

 

 

 

Not sure what you mean by this. I thnink youy actually want to know how to translate the (up to) 50mV reading on the volt meter into current. Yes?

P.S. on reflection, it's probably really simple provided we assume a constant battery voltage. If your shunt returns a drop of 50mV when passing a current of say 100A, then all lower volt drops mean the current is proportionally lower. Or have I got hold of the wring end of the stick? Or the wrong stick even? smile.png

Assuming its a 300A 50mv shunt then 300A out (!) will give me +50V across the shunt.

If I connect this to the Arduino analog in pin and ground it will successfully detect the voltage.

But the Ard has a range of 0 to 3.3V and converts this to a 0 to 4096 digital value.

50mv will only give me 4096*(50/3300) digital value which = 62.

A range of 0 to 62 is a bit coarse.

Then there is the problem of the shunt voltage being + or - and the Ard is only positive.

Link to comment
Share on other sites

I'd like to couple a standard shunt up to an Arduino so that I can play with the charge/drain values on my boat.

The shunt will typically give me -50 to +50 mv.

The Arduino voltage sensor has a range of 0 to 3.3V.

How can I convert the former into the latter?

I am happy with resistor bridges to reduce voltages but going the other way about, I haven't a clue.

My electronics knowledge is small and patchy.

Any thoughts?

 

This explains what a shunt is and how it works:

 

A current shunt provides a means of measuring the electrical current flowing through the cable it is inserted within. Electrically its a very low specific resistance that causes a tiny voltage drop in the order of millivolts, proportional to the current flowing through it in either direction. The voltage drop is so incredibly small as to have insignificant impact on connected devices.

The display device is calibrated to the resistance in order to indicate current in amps flowing through it, according to Ohms Law, Current = Voltage divided by Resistance. When the current flow is reversed so is the polarity of the voltage drop and the display indicates accordingly.
As resistance isn't the only relevant parameter for a shunt, its value is usually defined as the maximum current it can handle without overheating and consequent distortion of its resistance, and the millivolts it drops at that maximum current. Remember its only resistance that defines its calibration though.
Some current measuring battery monitors offer in their calibration the option of using different resistance shunts. The Magnetronic DCC4000 for example can be calibrated for three different shunt resistances allowing readings from 0.01 to 4000 amps.
Smart shunts are now arriving on the scene. Working by the same principles, the voltage drop is measured by circuitry on the device itself which digitizes the result so it can be sent any practical distance to the display without cable loss or interference.

 

The +/- 50mV you mention is fortunately a typical value at the shunts max current capability. Victron typically supply 500 amp ones that give this volt drop at max current. Given one of these if you measured say 1mV across the shunt it would indicate 10 amps passing through it. Hopefully this is enough info to answer your query.

Link to comment
Share on other sites

Off the top of my head I'm thinking that you could probably do this with an OP amp and a handful of resistors as long as the shunt is in the -ve lead. I don't have time to draw a diagram but I'm thinking the shunt output (battery side of shunt) goes to the inverting input and the two resistors go in series from the +ve rail to ground. The non-inverting input connects to the junction of the two resistors. The voltage at the battery end of the shunt will vary + - 50mV, resulting in an varying positive output.

 

You'd need a good stable voltage regulator for the OP amp as the output voltage will be highly affected by it. You'd need to experiment with the resistor bridge values - try something like 22k and 6k for starters maybe. You may also need to reduce the output voltage with another bridge.

 

Anyway, something to think about.

 

Tony

HI, there is loads of info on the net, this is a good start

 

http://arduinotronics.blogspot.co.uk/2015/05/reading-current-shunt-with-arduino.html

That's somewhat more elegant than my analogue approach but doesn't address the -ve current flow when the battery is being charged.

 

Tony

Link to comment
Share on other sites

If I understand correctly what it is you are trying to do, you should be able to do all the necessary conversion within the Arduino software. I have a remote monitor on my boat using a Uno, which I can interrogate to give me (among other things) the leisure battery voltage. I just feed the sensor pin via a 3:1 resistor volt drop. The max voltage an Arduino can read is 5v, so this gives me a scale of 0-15v which is fine for a 12v battery. You should be able to do something similar to read +/50mV.

If it helps, my voltage reading function looks like this:

 

float getVL()
{
reading = analogRead(vlPin); //take reading
vbuffer[index1] = reading + vcor; //adjust & store current reading
index1++;
if (index1 >= bufferSize) index1 = 0;
reading = vaverage(); //reading is average of last "n" readings
float voltage = 15.0 * reading / 1023; //3:1 divider
return (voltage);
}
I suspect that for a current shunt, you will need to make use of the AREF pin.
Hope this helps,
steve
Link to comment
Share on other sites

 

If I understand correctly what it is you are trying to do, you should be able to do all the necessary conversion within the Arduino software. I have a remote monitor on my boat using a Uno, which I can interrogate to give me (among other things) the leisure battery voltage. I just feed the sensor pin via a 3:1 resistor volt drop. The max voltage an Arduino can read is 5v, so this gives me a scale of 0-15v which is fine for a 12v battery. You should be able to do something similar to read +/50mV.

If it helps, my voltage reading function looks like this:

 

float getVL()
{
reading = analogRead(vlPin); //take reading
vbuffer[index1] = reading + vcor; //adjust & store current reading
index1++;
if (index1 >= bufferSize) index1 = 0;
reading = vaverage(); //reading is average of last "n" readings
float voltage = 15.0 * reading / 1023; //3:1 divider
return (voltage);
}
I suspect that for a current shunt, you will need to make use of the AREF pin.
Hope this helps,
steve

 

 

You've answered the question for voltage reading, not amps via a shunt with plus/minus 50mV output.

 

Its the resolution issue. If the gauge has a +5V input but you're using it to read 50mV (0.05V) and it has a 10 bit D-A converter (1024 points), then those readings are incredibly coarse 50A steps, because they only use the bottom 1% scale of whats readable.

 

Also its the fact that you want to convert a range of MINUS 50mV to +50mV into a 0-5V scale.

Link to comment
Share on other sites

Its the resolution ... <snip> Also its the fact that you want to convert a range of MINUS 50mV to +50mV into a 0-5V scale.

Both of the above are what I 'think' my op-amp solution would address. Can you see any flaw in the suggestion?

 

Tony

Link to comment
Share on other sites

Op-amp is definitely the circuit needed. I did "solve" the problem myself, when I was researching fitting a remote GSM monitor to the boat - amongst other inputs, it would transmit the battery voltage and current (read from the shunt) over the mobile phone network, but its analogue inputs were 0-5V so I needed a little circuit to convert the shunt's plus/minus range of 75mV into 0-5V. It wasn't a complicated thing, and I think it used a little chip though I can't remember its number.

 

http://www.ti.com/ww/en/bobpease/assets/AN-31.pdfmight help, plenty of ideas there?


£4 https://proto-pic.co.uk/opamp-breakout/?gclid=CjwKEAiApOq2BRDoo8SVjZHV7TkSJABLe2iDE-_M6C8R-UZcnFILJPYyOliNcNlNqBXcVCkdBXZDTxoCOdTw_wcB

Link to comment
Share on other sites

Definitely an Op-amp circuit needed. The things to consider are supply current - tiny in the one linked-to. Then there is input offset voltage, fairly critical for a DC application starting with mV signals. The IOV on that chip is up to 7mV which is quite a lot out of 50mV but I suppose you could compensate in software. Then you need it to drive 0-5v. Although it is described as "rail to rail" in fact it only gets within 0.2v or so of the rails (depending on the load) so again you would have to compensate in software and accept the slightly reduced resolution caused by limiting the overall total range.

 

So my suggestion for the software is to build in auto-calibration. Have a button you can press when the current is zero, so that ADC reading represents zero and is stored in NVRAM (does the arduino have any NV RAM?). Then set a known and pre-decided current (which might be tricky) and press the button again, and then again for the same reference current the other way. The Arduino would then store the gain parameters in NVRAM - if it has any! If not I would add some as otherwise you will have to twiddle trimpots or hard code the zero and gain, which is NOT the way to do it!

Edited by nicknorman
Link to comment
Share on other sites

There are a few chips designed specifically to do exactly what you need: interface to a current shunt, read the voltage and current, and send this to the Arduino over an I2C link. At least one of these is available on a little "break out" board to be easily connected to an Arduino. I've got one here somewhere as I am trying to find time to do what you are doing. I will post details a bit later.

 

(and some kind gentleman has written an aurduino library to do the low level interfacing for you)

 

...............Dave

Link to comment
Share on other sites

  • 2 months later...

This is it..................

 

https://www.adafruit.com/products/904

 

You sometimes see them on eBay.

 

It says 3 amps but that is with its on board shunt resistor.

If you use an external shunt it should handle whatever current you want.

 

..............Dave

How do I protect it from spikes >+- 32V? My knowledge of basic electronics is poor.

Link to comment
Share on other sites

This is it..................

 

https://www.adafruit.com/products/904

 

 

 

I like the way they say " We have an Arduino library right now that will do all the gain, range and math for you - just plug and go!"

 

In my case, knowing nothing about any of this, there is more chance of pigs flying than me plugging and going :)

Link to comment
Share on other sites

How do I protect it from spikes >+- 32V? My knowledge of basic electronics is poor.

 

That's not so easy. If you put the shunt in the negative battery lead (as most commercial systems do) then there should not be an issue with spikes, though not sure if the chip that I linked to does negative sensing, have a look at the data sheet. If you put the shunt in the positive lead then there might be a problem. One advantage of using the positive lead is that the system will measure volts as well as amps. These things are quite cheap so I would be tempted to try it and see how it goes. Its not easy to filter the shunt output as its all low impedance.

You could possibly use little series resistors and capacitors or transient suppressors after the shunt. A better approach might be a small resistor in the ground line and then a transient suppressor to the positive.

 

Another winter has gone without finding the time to do any work on this project, paid work rather took priority, and now its cruising time.

 

.............Dave

Link to comment
Share on other sites

 

I like the way they say " We have an Arduino library right now that will do all the gain, range and math for you - just plug and go!"

 

In my case, knowing nothing about any of this, there is more chance of pigs flying than me plugging and going smile.png

 

My experience of using Arduino libraries is that some of them really are plug in and go, and some need a LOT of effort. The Arduino library system is all a big tricky and non intuitive. Arduino is promoted as an easy to use system for non engineers; maybe non engineers are a lot cleverer than engineers because I don't find it easy at all. How anybody can describe "C" as a beginners language is beyond me.

 

.................Dave

Link to comment
Share on other sites

The INA219 is only good for 26volts which is a bit low (and I assume you are a 12volt rather than 24volt boat).

 

The data sheet does say that you can use 10 ohm resistors and a capacitor at the input to reduce noise.

Maybe you could even go a bit higher than this (100 ohm?). Rather than the capacitor you could use a pair of transorb type things down to ground for protection.

Its not an easy subject as you really need to have an idea of the size and duration of any spikes to know how much energy you will need to dissipate.

I reckon there is at least one proper automotive electronics engineer on this forum (I am just a sort of electronic/mechanical/automotive/acoustic jack of all trades) so maybe they will help. I think NickNorman knows about this stuff too. A bit of help from someone with hands on experience is a whole lot more fun than working through the data sheets and guessing at the spikes.

 

..............Dave

Link to comment
Share on other sites

This subject has come up before so if you search the forum you might find it. I would dis-regard the shunt method altogether and get a hall effect current sensor ( see link below for examples from Farnell ). I doubt they are more expensive than the shunt ( with extra electronics required ), are more accurate, more linear, provide electrical isolation, and give a simple analogue voltage output proportional to the current. ( probably 0 - 5v or similar which could be reduced with a simple divider ).

 

http://uk.farnell.com/webapp/wcs/stores/servlet/Search?catalogId=15001&langId=44&storeId=10151&categoryId=700000005923&st=current%20tansducer&beginIndex=1&showResults=true&aa=true&pf=110151160

Link to comment
Share on other sites

Lots of meters used shunts in the Forties because many measuring meters were limited to a mere 0.005 Amp. Any more current flowing through the meter and it would be damaged.

The purpose of the shunt resistor therefore is to take up any extra current.

I would probably just start from ZERO and determine how much current my meter will be safely measuring, be it digital or analogue. I'd then just work out my resistance by the usual:

R * R
/

R+R

Or, 1/R + 1/R = and so on

One golden rule is the bigger the shunt resistor the less it effects the original resistor and, of course, any 2 similar resistances in parallel equals half the original resistance.






Edited by FORTUNATA
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.