Author Topic: ACS712 Current sensor resolution  (Read 22737 times)

0 Members and 1 Guest are viewing this topic.

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
ACS712 Current sensor resolution
« on: April 04, 2015, 02:13:12 pm »
Hello folks.
I'm trying to develop a home automation project with OpenHAB and I need to measure when the lamps are on or off to inform the HomeAutomation software.I bought some ACS712 current sensor that measures current with a resolution 185mV/A.
Today I wired the sensor with a lamp and my amperimeter but the sensor does not "move".My amperimeter measures 68mA, so it's way below the minimum current to make it "move" the output.
My interpretation is unless I flow at least one amp thought the sensor it will not "move".
Is this interpretation correct?
I was reading about this and I found some users telling that I can insert an op-amp on the output but I doubt about this since if I am below the minimun resolution step it will just amplify noise.
Is this also correct?
Is there any way I can solve this, or should I move to another sensor perhaps ...
Thanks for your time
« Last Edit: April 04, 2015, 02:15:51 pm by HugoPT »
Hugo Santos
 

Offline amyk

  • Super Contributor
  • ***
  • Posts: 9169
Re: ACS712 Current sensor resolution
« Reply #1 on: April 04, 2015, 02:46:37 pm »
Hall effect sensors are theoretically completely linear, but in practice there is noise and in your case the datasheet specifies 21mV of noise for 185mV/A sensitivity so you won't be able to distinguish anything below ~114mA with it.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1334
  • Country: gb
    • bitdynamics
Re: ACS712 Current sensor resolution
« Reply #2 on: April 04, 2015, 03:14:57 pm »
It rather depends upon what sort of "Noise"  you get on the output.  If that noise is "white" and equally distributed around the mean output voltage, with an ADC of sufficient resolution you SHOULD be able to DSP to get a resolution better than the noise specification!

I suspect your multimeter in dc current mode will be doing some sort of averaging, so if it can see small changes in current, then the mean output of the AC712 IS changing with those current changes!
 

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #3 on: April 04, 2015, 03:32:32 pm »
Quote
datasheet specifies 21mV of noise for 185mV/A sensitivity so you won't be able to distinguish anything below ~114mA with it.
Ok this confirms what I was suspecting.Since my lamps are low current (LED Lamps) the ACS712 will not do the job  :--
Quote
with an ADC of sufficient resolution you SHOULD be able to DSP to get a resolution better than the noise specification!
I'm using an Atmega 328 with a ADC of 10 bits.Doing DSP is out of this game.
Can you recommend any device that could do this job?
Thanks for your answers
Hugo Santos
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30230
  • Country: nl
    • NCT Developments
Re: ACS712 Current sensor resolution
« Reply #4 on: April 04, 2015, 03:39:47 pm »
You can do simple averaging. Technically it is DSP but not every DSP algorithm needs tons of processing power. For example:
Code: [Select]
in=adc
value=((value * 15 + adc)/16
This is easy for a microcontroller to do. The division by 16 is nothing more than a shift operation.

Besides that you can increase the filter capacitor on the ACS712 to reduce the bandwidth and noise.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #5 on: April 04, 2015, 04:09:05 pm »
Quote
You can do simple averaging. Technically it is DSP but not every DSP algorithm needs tons of processing power.
Yes but the value that I can get from the sensor is below the minimum sensitivity, so I can´t read nothing useful I believe. When I measure the output of it with no current I get 2.5V, when I turn the lamp ON I also get 2.5V.The lamp only needs 68mA
Even if I do the average it will be useless i believe.I need at least to move a bit on the ADC to get something useful.
Reading the datasheet I was expecting to see what is the minimum increment in current to move the output.They have there  185mV/A but how should I interpret this, can I assume each milliamp will produce 185 microVolts or it will just move when 1 amps flows producing the( 2.5V + 185mV) 2.685V?


Hugo Santos
 

Offline PeterFW

  • Frequent Contributor
  • **
  • Posts: 577
  • Country: de
    • Stuff that goes boom
Re: ACS712 Current sensor resolution
« Reply #6 on: April 04, 2015, 05:07:31 pm »
Reading the datasheet I was expecting to see what is the minimum increment in current to move the output.

Code: [Select]
Noise (VNOISE). The product of the linear IC amplifier gain
(mV/G) and the noise floor for the Allegro Hall effect linear IC
(?1 G). The noise floor is derived from the thermal and shot
noise observed in Hall elements. Dividing the noise (mV) by the
sensitivity (mV/A) provides the smallest current that the device is
able to resolve.

21/185=~110mA

That means your masurement will be "of" by +-100mA, if you have a 60mA load on it and measure 0mA on the output that is withing the +-100mA accuracy ;)
Seriously increasing the filter capacitance (Pin6) brings the noise down.

I switched from the ACS712 to the INA226, awesome resolution and it has a digital interface.
 

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #7 on: April 04, 2015, 06:06:17 pm »
Thanks PeterFW.That clarifies me.
Quote
I switched from the ACS712 to the INA226, awesome resolution and it has a digital interface.
I would also prefer to use a digital interface because using analog it would need "careful" measures to immune the signal from the sensor to the ADC.Unfortunately INA226 max input voltage is 48V, my lamp works @ 230AC .
I'm wounder if there is a version for this voltage rate with a digital interface

 
Hugo Santos
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30230
  • Country: nl
    • NCT Developments
Re: ACS712 Current sensor resolution
« Reply #8 on: April 04, 2015, 06:29:00 pm »
IMHO it should be doable if you can average the noise away and filter for 50Hz or 60Hz (whatever your line frequency is). You'll need about 500Hz of bandwidth for this. I'd get some readings from the chip and save them to disk using an oscilloscope. The signal should be buried somewhere in the noise.

Another option is to use a current sense transformer for line frequencies.
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline max_torque

  • Super Contributor
  • ***
  • Posts: 1334
  • Country: gb
    • bitdynamics
Re: ACS712 Current sensor resolution
« Reply #9 on: April 04, 2015, 08:38:59 pm »
Assuming you are using a 5v reference, then your 10b adc gets you a theoretical resolution of 5/1024 volts/cnt, or 4.88mV/cnt.

With a sensitivity of 185mV/A,  each mV out of your current sensor is proportional to 5.4mA so your ADCs Lsb is equivalent to 26.4mA.

The ACS712 has 21mV of noise, so thats +- 4 counts on your adc.

A suitable averaging function should be able to resolve your 68mA current, but you may well need to use an AutoZero type strategy to get the highest accuracy, as you are dealling with just a few cnts.

If you oversample of ocurse, then you can use that noise to your advantage!  Depending on how fast you need to update your current information, you should be able to get at least 11b resolution with oversampling.  Alternatively, use a hardware low pass filter on the current sensor, to "average" out the noise floor

 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 2148
  • Country: us
Re: ACS712 Current sensor resolution
« Reply #10 on: April 04, 2015, 08:53:11 pm »
You should have purchased the 5A version  of the ACS712 instead of the 30A.  I buy only the 5A version and pair it with a shunt when I need to.  I don't see how anyone would put 30A through one of those.
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: ACS712 Current sensor resolution
« Reply #11 on: April 05, 2015, 02:05:04 am »
Since you said your device has a resolution of 185 mV/A, I will assume you have the 5A version.

Yes it's possible to use this device for your project. I built a little current monitoring device with the ACS712 that gives LED indications at 10 mA, 100 mA, 150 mA, and sounds an alarm at 200 mA. It wasn't easy though, this isn't really the right device for the task, but it was what I had on hand. I had to use a low noise opamp to amplify the signal, then carefully tweak the threshold values in the code (ATTINY85) controlling the whole thing. I seem to recall I used a low pass filter as well, and a very large cap on the filter pin of the device. Much larger than called for in the data sheet.

Use a good opamp, then carefully adjust the threshold value in your code. Since you just need to trigger at 68 mA, that's within the capabilities of the device from my experience.
 

Offline nuno

  • Frequent Contributor
  • **
  • Posts: 606
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #12 on: April 05, 2015, 12:24:00 pm »
(...) my lamp works @ 230AC .

Your signal being AC will average 0 current if you don't measure "at the right time".
 

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #13 on: April 05, 2015, 06:38:50 pm »
Dragon88 can you share your circuit?
I will do some test with my scope and an Op-amp to get some conclusions
Hugo Santos
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: ACS712 Current sensor resolution
« Reply #14 on: April 05, 2015, 08:47:29 pm »
The circuit was very similar to Sparkfun's breakout for this chip:

https://www.sparkfun.com/products/8883
http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Sensors/Current/ACS712%20Low%20Current%20Sensor%20Board%20v14.pdf

But I used a fixed gain of 100, and a much larger cap on the filter pin of the ACS712. They have a 1nF on their schematic, so I probably used like 100 nF. It made a big difference. However your requirements will be a little different with an AC signal.
« Last Edit: April 05, 2015, 08:49:51 pm by Dragon88 »
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: ACS712 Current sensor resolution
« Reply #15 on: April 06, 2015, 02:47:11 am »
It occurred to me that you should be able to do what you need with a very simple circuit. Use a lot of gain on the opamp to have a noticeable change when current is flowing. Then use a peak detector circuit with a silicon diode. This will do two things: drop the quiescent output below a logic high when no current is flowing, and also maintain the positive peak through the negative alterations (actually the other way around since the opamp is inverting). Send that to a schmitt inverter or buffer. Then you'll have a logic level you can do whatever you want with. The adjustment in the circuit will be with the gain of the opamp, to get a logic output change when the 68 odd milliamps is flowing. A rough adjustment should be enough, i.e. something over 50 milliamps or so means the lamp is on.
 

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #16 on: April 06, 2015, 11:08:17 am »
Hi Gragon88
Last night I do some measures with the scope.In my test I used the lamp I'm trying to get the status running @ 230VAC and measure the output of the  ACS712 with the scope. Like I notice before even on the scope the voltage does not change when I turn the lamp ON! I discover why does this happen when I set the channel of the scope to AC coupling. Turns out when I'm sensing AC current the hall-sensor outputs a AC signal,  that in fact changes the voltage(AC) when the lamp is ON. This explains what I was troubleshooting .
Just to confirm then I disconnect the lamp an put a DC current flowing in the sensor, and I works as expected I can see the output in DC mode changing on the scope and on the multimeter.
This solves the mystery in my head, next step I will use your suggested circuit and suppress those 2.5V base in a differential Op-Amp using a virtual ground, then I will amplify the little AC signal to a minimum of 1V(I still need to calculate the gain) and rectify the AC signal at the end of the op-amp to get something I could use.
Do you think this will work?
This is a critical detail the manufacturer should have include on the datasheet
This guy explains well the problem when probing AC signal



« Last Edit: April 06, 2015, 11:12:00 am by HugoPT »
Hugo Santos
 

Offline nctnico

  • Super Contributor
  • ***
  • Posts: 30230
  • Country: nl
    • NCT Developments
Re: ACS712 Current sensor resolution
« Reply #17 on: April 06, 2015, 12:19:53 pm »
I'd AC couple the signal from the current sensor to the opamp. There is no way you can match the 2.5V accurate enough to not cause a large DC offset in the output. Just watch out for the frequency dependant behaviour (simulate first).
There are small lies, big lies and then there is what is on the screen of your oscilloscope.
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: ACS712 Current sensor resolution
« Reply #18 on: April 06, 2015, 09:02:01 pm »
There is no way you can match the 2.5V accurate enough to not cause a large DC offset in the output.

This is true. I was just making a one off device, so I didn't need to correct for the offset precisely. I used a small trimmer resistor added in the 10k/10k divider setting the reference voltage, and this was close enough. The remaining offset was corrected in software, or actually just ignored because my threshold values took them into account. Sparkfun went with trimmers for their board, which is ok. But I bet a lot of people that buy that product don't calibrate it correctly.

HugoPT, since you just need to know when current is flowing, I would completely ignore the negative alteration. The ACS712 already has the 2.5V offset on the output, so there's really no need to couple that to AC just to rectify and go back to DC. If you go with the peak detector I described above or something similar, the presence of the positive peak will be held long enough for the micro to read it and know the lamp is on. When the lamp is off the DC value will fall back to 2.5V minus the diode drop.

Again I'm saying this assuming that you don't care exactly how much current is flowing, just that something around 70 mA is flowing meaning the lamp is on. Otherwise the lamp is off. That's very simple and I would keep the circuit simple.
 

Offline HugoPTTopic starter

  • Contributor
  • Posts: 15
  • Country: pt
Re: ACS712 Current sensor resolution
« Reply #19 on: April 06, 2015, 10:23:19 pm »
Hey friends
I already make some progress.I mount on the breadboard the circuit you recommend to me with the peak detector. It can produce something useful to get the lamp status.I still need to try different gains in the op-amp since right now the difference between Off and ON are just about 640 mV on the output. This is fine to get the lamp status but I would like to get the output more saturated when the lamp is ON to get a larger hysteresis.I notice on the scope that when I switch the lamp ON the signal spikes a bit.
I don't want get multiple samples on the micro controller because it will be busy on other things, I will just ask the lamp status to the sensor about every 2 seconds.
Just to confirm the formula to calculate the gain I'm using is:
Gv=(R1+R2)/R1
Is this correct?
Thanks for your great help and support

Hugo Santos
 

Offline Dragon88

  • Regular Contributor
  • *
  • Posts: 88
Re: ACS712 Current sensor resolution
« Reply #20 on: April 07, 2015, 12:25:45 am »
Gain equation for an inverting opamp is -Rf/Ri.

http://www.elexp.biz/tips/invert.gif

Once you get the circuit working, you'll have to consider how long the peak detector takes to discharge, or more specifically the cap. That's going to depend on the size of the cap, the load, and if you add a bleeder resistor in parallel. You'll need a balance between holding the peak during negative alterations, and the delay before being able to detect the lamp was switched off.

If you get the voltage levels right you should be able to sample this with a digital input instead of analog. Though a single reading of either is pretty trivial unless you have some really tight timing.
 

Offline Seekonk

  • Super Contributor
  • ***
  • Posts: 2148
  • Country: us
Re: ACS712 Current sensor resolution
« Reply #21 on: April 07, 2015, 06:31:27 pm »
I would do a non inverting op amp with a fairly low gain  36K/10K with the low side resistor going to a 100uF electrolytic to common.   That will keep the DC output nicely at half the supply voltage and slightly amplify the AC portion.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf

 

-->