Forum - MCS Electronics

 

FAQFAQ SearchSearch RegisterRegister Log inLog in

ACS712 for AC Current measurement
Goto page 1, 2  Next
 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive
View previous topic :: View next topic  
Author Message
tarique

Bascom Member



Joined: 19 Mar 2013
Posts: 8

blank.gif
PostPosted: Sun Jul 13, 2014 5:44 pm    Post subject: ACS712 for AC Current measurement Reply with quote

i have ACS712-30A (hall effect sensor for current measurement), it can be used for AC as well as DC currents, now the problem is that when i measure DC current it works great its normal output at 0 ampere is 2.5V and its increment is 66mV/ampere, but when i measure AC current its output remains same 2.5V even if i connect heavy load, at the time of load connection its voltage varies little bit and remains on 2.5V permenant.
i found on internet that a diode is connected at output of this module to work perfactly for AC currents, it is working on that. but it needs another signal conditioning based on OP-AMP for linearity.

but i don't want to connect any additional circuitry, and want to connect output of This module to ATMEGA8, Is it possible. to connect directly if we measure ac.

anyone help please

datasheet of acs712
http://www.allegromicro.com/~/media/Files/Datasheets/ACS712-Datasheet.ashx

(BASCOM-AVR version : yes , Latest : 2.0.7.7 )
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Sun Jul 13, 2014 8:49 pm    Post subject: Reply with quote

Plz post your schematic, you may need some smoothing of waveform.
Back to top
View user's profile
Deanus

Bascom Member



Joined: 26 May 2006
Posts: 188
Location: Adelaide

australia.gif
PostPosted: Sun Jul 13, 2014 9:44 pm    Post subject: Reply with quote

Hi Tarique,

According to the data sheet, you need to add the diode, a couple of resistors and a capacitor.
The two main items are the diode which rectifies the ac coming out of the chip, and the capacitor
which stores these pulses and provides your ADC with a voltage.
The diode and the cap are a must.
out of the other two resistors, even R1 can be removed to obtain full range.

Regards

Dean
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Sun Jul 13, 2014 10:38 pm    Post subject: Reply with quote

Deanus has shown you the way which I wanted to tell you but didn,t have the schematic at the time of my reply to your post.
Back to top
View user's profile
tarique

Bascom Member



Joined: 19 Mar 2013
Posts: 8

blank.gif
PostPosted: Mon Jul 14, 2014 11:14 am    Post subject: ACS712 for AC Current measurement Reply with quote

@Deanus, @naseerak

i have already tested with a diode, output has some variotions still value goes down and up very slowly, it seems that it has very low frequency, however i have connected load of 100W with 220V, is there any posiblity to make sampling code in bascom to detect average value of AC.
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Mon Jul 14, 2014 7:43 pm    Post subject: Reply with quote

Yes there is a sample code somewhere in this forum, containing averaging of the ADC, I am searching my PC for such a code.
Back to top
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Mon Jul 14, 2014 8:34 pm    Post subject: Reply with quote

Your measured value varies unexpectedly.
First, I would find out why!
Maybe the values are good and load or voltage at load vary.
Maybe the current to voltage converter gives bad results for any reasons.
Maybe the A/D converter is unstable for any reason.
It is not very scientific to bend unexpected values until they fit your expectations.

Second, if you are sure WHY you need to smoothen the reading, here is how I do it:
What you achieve is to build a low pass filter. It needs some math that bascom can handle easily.
But you need to find out yourself, according to your needs and circumstances, what kind of filter you need, and how to set its parameters.
I suggest to learn a bit about "moving average" and "weighted moving average". See wikipedia and google.
Once you found out how it works, it's not that difficult to implement it in bascom.
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Mon Jul 14, 2014 8:35 pm    Post subject: Reply with quote

my_amp = Getadc(x)

For I = 1 To 16 'This will add 16 ADC samples together
my_amp = my_amp + Getadc(0)
Next I
Shift my_amp , Right , 4

I am sure this should solve your problem
Regards.
Back to top
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Mon Jul 14, 2014 9:02 pm    Post subject: Reply with quote

Naseeraks solution returns the arithmetic average of 16 measures, that's all.
It's integration time is as short as it takes to perform 16 a/d convertions.
We do not know how long that is, nor do we know the frequency respectivly the time we need to filter. If the freq of the jitter in the values is lower than the integration-time of the filter, the filter will have little or no effect.
Further the formula is not "moving", this will lead to jumps in the results.
You see, there is no way around knowing, thinking and learning a bit.
Naseeraks shown filter btw is imho well suited to filter a +/- 1or 2 digit jitter that the ad converter has by nature.
Back to top
View user's profile
Arera

Bascom Member



Joined: 23 Sep 2007
Posts: 375
Location: Wuppertal, Germany

germany.gif
PostPosted: Mon Jul 14, 2014 9:27 pm    Post subject: Reply with quote

I edited my last post, due to the fact that I missed that naseeraks formula is not "moving".
As this is crutial, please read the edited version.
Back to top
View user's profile
naseerak

Bascom Member



Joined: 08 Nov 2008
Posts: 138

pakistan.gif
PostPosted: Mon Jul 14, 2014 10:02 pm    Post subject: Reply with quote

Using this and a little bit of tweaking with the filter (RC) will come out with satisfactory result. as for moving filter is concerned it will complicate his code with a bit of more processor resources, I may post moving average filter but he should play first with simple averaging.
regards.
Back to top
View user's profile
sidknox

Bascom Member



Joined: 30 Apr 2006
Posts: 29
Location: NorthEast Oklahoma USA

usa.gif
PostPosted: Tue Jul 15, 2014 1:05 am    Post subject: ACS712 for AC Current measurement Reply with quote

tarique, you said:

"i have ACS712-30A ..."
and
"...its increment is 66mV/ampere..."
and
"... i have connected load of 100W with 220V..."


The current for a 100W load is I = 100W / 220V = 0.45A. This is a relatively small percentage of the full-scale current of 30A. Your observed (measured) values are getting down close to the system "noise" (uncertainty, drift, offset, etc...).

Certainly the filter discussion by Arera and naseerak apply. I am simply suggesting an additional consideration.

And to the filter discussion, don't forget the effect of the existing filter on pin 6.

Sid
Oklahoma

_________________
SidK
Oklahoma
USA
Back to top
View user's profile
Tubeampman

Bascom Member



Joined: 27 Feb 2006
Posts: 97
Location: Bodo

norway.gif
PostPosted: Tue Jul 15, 2014 7:05 am    Post subject: Reply with quote

Hi

If you are using the 220vac from the wall outlet in Your house, the you can expect some varying since the voltage goes up and Down
due to varying load on the grid, in my house it drifts +-3 to 4 volt.

Řyvind
Back to top
View user's profile
MWS

Bascom Member



Joined: 22 Aug 2009
Posts: 1827

blank.gif
PostPosted: Tue Jul 15, 2014 9:13 am    Post subject: Re: ACS712 for AC Current measurement Reply with quote

tarique wrote:
but i don't want to connect any additional circuitry

Do a loop of fast AD-samples over one or a count of multiple full periods, subtract from each sample the offset (which you've measured with 2.5V). Remove the sign and add it up.
Having all the samples done, divide the result by the number of samples. If you need RMS, square it before adding up and square root it after.

The result is more exact, if the AD-sample frequency is faster. But one needs to stay below the speed, where the ADC's resolution deteriorates, and not to forget, the code in between the samples will take some time.

I would solve it with the free-running mode of the ADC, which is executed periodically and thus makes sure, that timing isn't messed up by different run-time of code. Also simulate the code and check how many cycles are needed between samples, set the ADC-prescaler accordingly of these cycles and said above.
Back to top
View user's profile
tarique

Bascom Member



Joined: 19 Mar 2013
Posts: 8

blank.gif
PostPosted: Wed Jul 16, 2014 11:58 pm    Post subject: acs712 problem is solved Reply with quote

ACS712 problem is solved with MAX function in bascom which collects different sample in an array and shows larger \peak value, no need of any external circuitry (no diode, no capacitor or resistor), now it is under observation its now set on 6.6mV/100mA ( 66mv/A), no variation found yet.
Back to top
View user's profile
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    www.mcselec.com Forum Index -> BASCOM-AVR Archive All times are GMT + 1 Hour
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum