Author Topic: Current sensing using arduino  (Read 5637 times)

0 Members and 1 Guest are viewing this topic.

Offline LarsTTopic starter

  • Contributor
  • Posts: 40
Current sensing using arduino
« on: June 23, 2015, 12:01:48 pm »
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?
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Current sensing using arduino
« Reply #1 on: June 23, 2015, 12:03:46 pm »
you can set the ADC reference in the arduino to 1.1V giving you much more resolution. What is the final output of this ?
 

Offline opty

  • Regular Contributor
  • *
  • Posts: 55
  • Country: ie
Re: Current sensing using arduino
« Reply #2 on: June 23, 2015, 12:33:08 pm »
Probably wont help but some atmegas (ie 32) have programmable 10x/200x gain ADCs
 

Online Simon

  • Global Moderator
  • *****
  • Posts: 17816
  • Country: gb
  • Did that just blow up? No? might work after all !!
    • Simon's Electronics
Re: Current sensing using arduino
« Reply #3 on: June 23, 2015, 12:38:07 pm »
Probably wont help but some atmegas (ie 32) have programmable 10x/200x gain ADCs

Thing 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.
 

Offline Psi

  • Super Contributor
  • ***
  • Posts: 9946
  • Country: nz
Re: Current sensing using arduino
« Reply #4 on: June 23, 2015, 12:46:21 pm »
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)
Greek letter 'Psi' (not Pounds per Square Inch)
 

Offline kizzap

  • Supporter
  • ****
  • Posts: 477
  • Country: au
Re: Current sensing using arduino
« Reply #5 on: June 23, 2015, 12:48:24 pm »

A 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
<MatCat> The thing with aircraft is murphy loves to hang out with them
<Baljem> hey, you're the one who apparently pronounces FPGA 'fuhpugger'
 

Offline LarsTTopic starter

  • Contributor
  • Posts: 40
Re: Current sensing using arduino
« Reply #6 on: June 23, 2015, 01:09:16 pm »
you can set the ADC reference in the arduino to 1.1V giving you much more resolution. What is the final output of this ?

I'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!
 

Offline tszaboo

  • Super Contributor
  • ***
  • Posts: 7377
  • Country: nl
  • Current job: ATEX product design
Re: Current sensing using arduino
« Reply #7 on: June 23, 2015, 02:05:21 pm »
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?
Use 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
 

Offline rs20

  • Super Contributor
  • ***
  • Posts: 2318
  • Country: au
Re: Current sensing using arduino
« Reply #8 on: June 23, 2015, 02:14:53 pm »
Thing 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.

 ??? You 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.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6190
  • Country: us
Re: Current sensing using arduino
« Reply #9 on: June 23, 2015, 02:18:35 pm »
You may want to check this

http://www.adafruit.com/product/904

They also have a version for 60V 5A.

Edit: more info https://learn.adafruit.com/adafruit-ina219-current-sensor-breakout
« Last Edit: June 23, 2015, 02:22:41 pm by zapta »
 

Offline Richard Crowley

  • Super Contributor
  • ***
  • Posts: 4317
  • Country: us
  • KJ7YLK
Re: Current sensing using arduino
« Reply #10 on: June 23, 2015, 02:22:14 pm »
Have you considered using something more 21st century?  Like INA169  https://www.sparkfun.com/products/12040
 

Offline PSR B1257

  • Frequent Contributor
  • **
  • Posts: 330
  • Country: de
Re: Current sensing using arduino
« Reply #11 on: June 23, 2015, 03:09:46 pm »
Since you already have a shunt resistor you just need a differantial amplifier, like INA122 (works with a single supply).

Quote
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.
Single 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.
In theory, there is no difference between theory and practice. But, in practice, there is.
 

Offline LarsTTopic starter

  • Contributor
  • Posts: 40
Re: Current sensing using arduino
« Reply #12 on: June 23, 2015, 06:12:20 pm »

A 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

Low 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.
 

Offline idpromnut

  • Supporter
  • ****
  • Posts: 613
  • Country: ca
Re: Current sensing using arduino
« Reply #13 on: June 24, 2015, 02:13:40 am »
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.
 

Offline zapta

  • Super Contributor
  • ***
  • Posts: 6190
  • Country: us
Re: Current sensing using arduino
« Reply #14 on: June 24, 2015, 03:50:55 am »
Have you considered using something more 21st century?  Like INA169  https://www.sparkfun.com/products/12040

For 21st century technology I would go with an IC that has digital interface, for example the LTC2943.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf