Current sensing using arduino - Page 1
Forum section: electronics / beginners

author: LarsT
author_rank: Contributor
timestamp: June 23, 2015, 12:01:48 pm
content: I apologise if the subject title is a little vague, but what I'm trying to do is measure the current running through my circuit using an arduino (analogRead) to read the voltage drop across a shunt resistor. The shunt is rated at 75mV/10A, and the current I want to measure will normally be between a couple of amps at most and higher than about 0.5A. The load for now is just a lightbulb, but will later be exchanged for power resistors. The shunt is between the load and ground.According to my understanding the voltage drop across the shunt will be between 15mV @ 2A, and 4mV @ 0.5A, while the arduino will have a "resolution" of about 5V / 1024 = 5mV.I've tried amplifying the voltagedrop using opamp (lm358), but I run into trouble because the measured voltage drop is too close to the negative rail voltage. Is there a way I can get around this, and be able to amplify the voltage drop for instance 200 times so that the arduino will read it more accurately?

author: Simon
author_rank: Unknown
timestamp: June 23, 2015, 12:03:46 pm
content: you can set the ADC reference in the arduino to 1.1V giving you much more resolution. What is the final output of this ?

author: opty
author_rank: Regular Contributor
timestamp: June 23, 2015, 12:33:08 pm
content: Quote from: LarsT on June 23, 2015, 12:01:48 pm

author: Simon
author_rank: Unknown
timestamp: June 23, 2015, 12:38:07 pm
content: Quote from: opty on June 23, 2015, 12:33:08 pmThing is the arduino platform probably does not give access to those, thats why I ended up moving on to "straight" C and atmel studio so that I could do more with the hardware.

author: Psi
author_rank: Super Contributor
timestamp: June 23, 2015, 12:46:21 pm
content: you can also set your own external ADC Vref using a external reg. 0.5V for example.(There probably is a lower limit but i've not checked)

author: kizzap
author_rank: Unknown
timestamp: June 23, 2015, 12:48:24 pm
content: Quote from: LarsT on June 23, 2015, 12:01:48 pmA couple of silly questions to ask here:Are we talking High side or Low side current measurement? (Is the sense resistor between the load and +ive supply, or between the load and -ive terminal?)From the values you have given us, it seems your sense resistor is somewhere in the realms of 0.0075 Ohms. Could you clarify this for us?Simon was leading towards the right idea here with using the alternate voltage reference level for the comparator vreg. Personally what I would do is use a differential amplifier, and probably bias the output voltage so you dont have to measure zero current as zero volts, and just factor this bias voltage into your coding.-kizzap

author: LarsT
author_rank: Contributor
timestamp: June 23, 2015, 01:09:16 pm
content: Quote from: Simon on June 23, 2015, 12:03:46 pmI'm using the UNO, Duemillanove or Nano for this, which don't (as far as I know) have a 1.1V reference. However, I might be able to set an external reference of 1.1V by using external resistors? I will try this!

author: tszaboo
author_rank: Super Contributor
timestamp: June 23, 2015, 02:05:21 pm
content: Quote from: LarsT on June 23, 2015, 12:01:48 pmUse a current shunt monitor (there are different names for it). Shameless self advertising:http://www.nandblog.com/current-shunt-monitors/For a gain of 100 you should use something like an INA195

author: rs20
author_rank: Super Contributor
timestamp: June 23, 2015, 02:14:53 pm
content: Quote from: Simon on June 23, 2015, 12:38:07 pmYou can just type standard "straight" C into the Arduino IDE, and use all the peripherals directly. Atmel Studio is nice because it has in-circuit debugging and such, but don't confuse two orthogonal issues.

author: zapta
author_rank: Super Contributor
timestamp: June 23, 2015, 02:18:35 pm
content: You may want to check thishttp://www.adafruit.com/product/904They also have a version for 60V 5A.Edit: more infohttps://learn.adafruit.com/adafruit-ina219-current-sensor-breakout

author: Richard Crowley
author_rank: Super Contributor
timestamp: June 23, 2015, 02:22:14 pm
content: Have you considered using something more 21st century? Like INA169https://www.sparkfun.com/products/12040

author: PSR B1257
author_rank: Frequent Contributor
timestamp: June 23, 2015, 03:09:46 pm
content: Since you already have a shunt resistor you just need a differantial amplifier, like INA122 (works with a single supply).QuoteSingle ended, I suppose. That does not work, you need a differential amplifier (see above). Furthermore the LM358 is anything but precise and therefore not suited at all for this application.What about the question regarding high- or low-side measurement? The total supply voltage of the load is also of interest.

author: LarsT
author_rank: Contributor
timestamp: June 23, 2015, 06:12:20 pm
content: Quote from: kizzap on June 23, 2015, 12:48:24 pmLow side sensing. Shunt is between the load and ground. I was thinking of a way to bias the diff.amp, but wasn't sure how to do it or if it even would work.

author: idpromnut
author_rank: Unknown
timestamp: June 24, 2015, 02:13:40 am
content: The 'duinos you're looking at do have an INTERNAL Vref of 1.1V, but that's not going to help you much as the resolution will still only be about 1mV. And no, the mega328 family don't have a PGA in front of the ADCs, so no amplification help there. Your best bet will be to add some external amplification, or if your circuit can tolerate the larger voltage drop (+power dissipation), a larger value sense resistor.

author: zapta
author_rank: Super Contributor
timestamp: June 24, 2015, 03:50:55 am
content: Quote from: Richard Crowley on June 23, 2015, 02:22:14 pmFor 21st century technology I would go with an IC that has digital interface, for example the LTC2943.