Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Measure AC current accurateley (100mA to 10A)

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
Hi,
I am trying to build a device which can measure the AC current accurately and with a large measuring range. I tried using ACS712 sensor with arduino, but when I tried to measure the current with a heat gun as load, the ACS712 module's output voltage is initially increasing, but when I increased the load (stepped up the level of heat gun), the voltage is decreasing. I don't understand why the voltage is decreasing as the current is increasing, because I tried measuring using a multimeter as well. For the first level of heat gun, it shows around 2A, for which the ACS712 sensor gave an output of 2.8V and when I tried the second level, the multimeter measured around 7A and the output of ACS712 goes back to 2.5V. And when I plugged in a 7W LED lamp as load, there is no change in the output voltage of ACS712.
Please help. And is there any other modules or sensors which can be used for this application. I can't use large sensors or modules. It needs to be as small as possible. Thank you in advance.
 

danadakk

Advanced Member level 5
Joined
Mar 26, 2018
Messages
1,862
Helped
295
Reputation
606
Reaction score
412
Trophy points
83
Activity points
8,343
The fact, w/o Arduino, the sensor is not behaving sounds like a defective part.
Eg. your multimeter measurements.

Note is your multimeter response extend down to 50/60 Hz ?

Its not clear to me, is the output a DC voltage or amplified ac voltage ?


Regards, Dana.
 

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
The fact, w/o Arduino, the sensor is not behaving sounds like a defective part.
Eg. your multimeter measurements.

Note is your multimeter response extend down to 50/60 Hz ?

Its not clear to me, is the output a DC voltage or amplified ac voltage ?


Regards, Dana.
Hi,
Thank you for your response. I think the output of the sensor is an ac voltage signal. Looks like it was a problem with my multimeter. Now I have checked with another multimeter and now the ac voltage is increasing.
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
50,085
Helped
14,507
Reputation
29,284
Reaction score
13,453
Trophy points
1,393
Location
Bochum, Germany
Activity points
287,704
I think the output of the sensor is an ac voltage signal.
As response to AC input current: for sure, with Vcc/2 superimposed DC. But it doesn't sound like you are measuring in ACV range. 2.7 V AC exceeds the possible output voltage with 5V Vcc.
 

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
As response to AC input current: for sure, with Vcc/2 superimposed DC. But it doesn't sound like you are measuring in ACV range. 2.7 V AC exceeds the possible output voltage with 5V Vcc.
Thank you for your response. Yes the output is an ac signal. I am thinking about taking the peak value of the reading. Do I need to clamp the output to a zero level before connecting it to the adc or can I correct it in the code?
 

FvM

Super Moderator
Staff member
Joined
Jan 22, 2008
Messages
50,085
Helped
14,507
Reputation
29,284
Reaction score
13,453
Trophy points
1,393
Location
Bochum, Germany
Activity points
287,704
Usual AC current measurement methods are either RMS or average rectified value. Peak current is very inaccurate because it depends much on mains waveform and load behaviour. Both values can be extracted in software.
 

danadakk

Advanced Member level 5
Joined
Mar 26, 2018
Messages
1,862
Helped
295
Reputation
606
Reaction score
412
Trophy points
83
Activity points
8,343
If the Arduino and sensor powered by 5V a direct connection to ADC input is
fine.

Keep in mind the response of the sensor looks like

1657104667623.png


The sensitivity is 66 mV /A nominal from the Vdd / 2 bias point.


Regards, Dana.
 
Last edited:

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
If the Arduino and sensor powered by 5V a direct connection to ADC input is
fine.

Keep in mind the response of the sensor looks like

View attachment 177248

The sensitivity is 66 mV /A nominal from the Vdd / 2 bias point.


Regards, Dana.
Thank you. I am using a wemos D1 mini board and and ADS1115 adc module for reliability and accuracy. The adc module is powered from the 3.3v and the input is fed through a potential divider. The adc value is fluctuating too much and when the load current is increased, the ac output voltage of the sensor is increasing, which is measured using a multimeter, but the adc reading is decreasing.
 

danadakk

Advanced Member level 5
Joined
Mar 26, 2018
Messages
1,862
Helped
295
Reputation
606
Reaction score
412
Trophy points
83
Activity points
8,343
Not a noise issue.....? What is AC source look like, true sine or complex
waveform input ? Meter is AC speced for sinusoidal, sometimes crest factor
included.

Does a scope give you same results as meter ?

The fact you know you have an increasing input yet readings decline says something
in measurement loop quite non linear. If it had saturated thats expected. But phase
reversal a clue....


Regards, Dana.
 

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
22,244
Helped
4,613
Reputation
9,242
Reaction score
4,878
Trophy points
1,393
Activity points
146,954
Hi,

AC measurement is not the same as DC measurement.

Some informations about AC measurement, if you are interested in details:

AC means continously changing the instantaneous current value.
A simple ADC measures the instantaneous value. Thus the ADC reading of a 1A RMS sine waveform gives (all) values from -1.414A to +1.414A.

In most cases one wants to know the RMS value.
Thus one needs to do the conversion from the instantaneous values to the RMS values.
Clean solutuions can be:
* AC_in --> RMS_to_DC conversion (hardware) --> ADC --> digital processing (microcontroller)
* AC_in --> ADC -->RMS_to_DC conversion (software) --> further digital processing (microcontroller)

The RMS_to_DC conversion (hardware or software) needs to be defined:
* lower input frequency of interest (like: including_DC or excluding_DC)
* upper input frequency of interest
* squaring circuit performance
* averaging time / filtering of squared values (how long may it take to get to 99% of end value, how much ripple is allowed)
* square root performance. (sw: how often do you need an output value)

Not that clean solutions are
* rectified average method (analog or digital)
* peak method
As already mentioned they are not that accurate and gernerate (huge) errors when the waveform (overtones, duty cycle) changes.

You talk about accuracy: I guess you know that there are also "precision" and "resolution". All three of them don´t neccessary relate to each other.

Talking about "accuracy" without giving a value is useless. Every one has a different definition of "accuracy".
For the one t´s good if it´s within 1% of error tolerance, the other at 0.1% and the next at 0.01%.

Good accuracy at AC measurement is more difficult than on DC measurement. Often there is an uncertainty because of noise. For DC measurements you can simply do averaging to cancle out noise.
But with noise (or overtones) at AC measurement the RMS value always becomes positive. Thus you can´t cancel it out with the averaging method.

And timing behaviour has big influence on design complexity. I´ve designed an RMS meter that is fast and has less than 1% error rising and falling within 30ms. (falling in most cases is much slower than rising because of average at the squared side and then square_root).
For industrial measurement devices a rising delay of 2000ms and more is not unusual.

There´s alot more to consider to really get accurate AC measurement results.

Klaus
 

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
Hi,

AC measurement is not the same as DC measurement.

Some informations about AC measurement, if you are interested in details:

AC means continously changing the instantaneous current value.
A simple ADC measures the instantaneous value. Thus the ADC reading of a 1A RMS sine waveform gives (all) values from -1.414A to +1.414A.

In most cases one wants to know the RMS value.
Thus one needs to do the conversion from the instantaneous values to the RMS values.
Clean solutuions can be:
* AC_in --> RMS_to_DC conversion (hardware) --> ADC --> digital processing (microcontroller)
* AC_in --> ADC -->RMS_to_DC conversion (software) --> further digital processing (microcontroller)

The RMS_to_DC conversion (hardware or software) needs to be defined:
* lower input frequency of interest (like: including_DC or excluding_DC)
* upper input frequency of interest
* squaring circuit performance
* averaging time / filtering of squared values (how long may it take to get to 99% of end value, how much ripple is allowed)
* square root performance. (sw: how often do you need an output value)

Not that clean solutions are
* rectified average method (analog or digital)
* peak method
As already mentioned they are not that accurate and gernerate (huge) errors when the waveform (overtones, duty cycle) changes.

You talk about accuracy: I guess you know that there are also "precision" and "resolution". All three of them don´t neccessary relate to each other.

Talking about "accuracy" without giving a value is useless. Every one has a different definition of "accuracy".
For the one t´s good if it´s within 1% of error tolerance, the other at 0.1% and the next at 0.01%.

Good accuracy at AC measurement is more difficult than on DC measurement. Often there is an uncertainty because of noise. For DC measurements you can simply do averaging to cancle out noise.
But with noise (or overtones) at AC measurement the RMS value always becomes positive. Thus you can´t cancel it out with the averaging method.

And timing behaviour has big influence on design complexity. I´ve designed an RMS meter that is fast and has less than 1% error rising and falling within 30ms. (falling in most cases is much slower than rising because of average at the squared side and then square_root).
For industrial measurement devices a rising delay of 2000ms and more is not unusual.

There´s alot more to consider to really get accurate AC measurement results.

Klaus
Thank you very much for your reply. I tried using a variance equation to find out the current and that way we dont't need to cosider the offset DC voltage.
σ^2 = Σx^2/n-(Σx)^2/n^2; where x is the adc reading and n is the number of samples.
Since mean will be the dc offset voltage, I think, from this equation the standard deviation will give the ac voltage. Here I am using a Wemos D1 min and ADS1115 adc. I have managed to get a better reading using this equation with ADS1115 differential input method. One input is connected to the signal and the other to half of the supply voltage using a potential divider. Now I need to find a way to calculate the current from the reading. Also I believe the reading will be better if I can take a more samples. For now, I have managed take maximum of 105 samples in the code, and more than that, it is producing an error. I think the ADS1115 needs to be set up to it's maximum speed.
 
Last edited:

KlausST

Super Moderator
Staff member
Joined
Apr 17, 2014
Messages
22,244
Helped
4,613
Reputation
9,242
Reaction score
4,878
Trophy points
1,393
Activity points
146,954
Hi,

your math seems to calculte "RMS value excluding DC" over n samples.
So far so good.

I´m worried, because you talk about 150 samples ... but nothing about sampling frequency.

With your math it is very important that
* your measurement window: n / sampling_frequency
* is an exact integer multiple of your mains period time.

Else your RMS values may be not precise (while still being accurate). It will ripple around the expected value.

But also the samples need to be in equal distance. Very equal. So if the sampling timing is controlled by the microcontroller, best method is to use the microcontroller´s hardware (periferal) to generate the timing, independent of the executed code.
Next best is to control the timing with an ISR. But mind that an ISR may be delayed (unequally) depending on the code in the main loop. So it will be more jittery than the solution above.
Avoid to generate the tim ing by using delay functions like "delay_us()". You won´t get good results this way.

So your code has big impact on the RMS result.

Klaus
 

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
Hi,

your math seems to calculte "RMS value excluding DC" over n samples.
So far so good.

I´m worried, because you talk about 150 samples ... but nothing about sampling frequency.

With your math it is very important that
* your measurement window: n / sampling_frequency
* is an exact integer multiple of your mains period time.

Else your RMS values may be not precise (while still being accurate). It will ripple around the expected value.

But also the samples need to be in equal distance. Very equal. So if the sampling timing is controlled by the microcontroller, best method is to use the microcontroller´s hardware (periferal) to generate the timing, independent of the executed code.
Next best is to control the timing with an ISR. But mind that an ISR may be delayed (unequally) depending on the code in the main loop. So it will be more jittery than the solution above.
Avoid to generate the tim ing by using delay functions like "delay_us()". You won´t get good results this way.

So your code has big impact on the RMS result.

Klaus
Thank you for your help. I have managed to get a pretty consistent reading out of the sensor by adjusting the sampling frequency of adc. I hope I can get an accurate measuremet by calculating using that value. I am yet to find out an equation to calculate that. Thank you so much. Will let you know the status after that is done.
 

anandhuskumar

Junior Member level 1
Joined
May 14, 2014
Messages
17
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,454
Hi, It is working and I can get a pretty consistent reading. But if I increase the number of samples (to take mean) in the for loop (for(i=0; i<250; i++) readadc()), the watchdog timer is getting reset. I think it is because the time to get a reading from the ads1115 is too long. And the waiting time to get the reading is too long, around 30 seconds or so (after taking mean). Is there any way to solve this problem?
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top