Go Down

Topic: ac current meter using acs758 hall sensor (Read 7401 times) previous topic - next topic

hozone


1. In the plot you provided in reply #9, at the 6.4A setting, what are the ADC readings at the high and low peaks?

2. How do you know that the current is 6.4A?


1. @6.54A 547max 480min (it's 6.54A sorry)
   + @3.65A > 547max 512min
2. multimeter (not true RMS)

dc42

#16
Nov 20, 2012, 10:41 am Last Edit: Nov 20, 2012, 10:43 am by dc42 Reason: 1

1. @6.54A 547max 480min (it's 6.54A sorry)
  + @3.65A > 547max 512min
2. multimeter (not true RMS)


6.54A * 1.414 * 2 = 18.5A peak to peak

(547 - 480) * 5 / (1024 * 0.04) = 8.1A peak to peak

So, if my calculations are correct and your meter is to be believed, the sensitivity of your device is only about half what it should be. Are you sure you have the 50A version and not the 100A version of the ACS758?

I would tidy up the code like this:

Code: [Select]

 const double sensitivity = 0.04;
 const int16_t adc_zero = 512; //as read when there is no current on the load
 const uint16_t numSamples = 100;
 float current;

...

 long acc = 0;
 for(uint16_t i=0; i<numSamples ; i++) {
   int16_t adc_raw = adc_read(2);
   acc += (adc_raw - adc_zero)*(adc_raw - adc_zero);
   _delay_us(100);
 }
 const float meanSquare = ((float)acc)/((float)numSamples);
 current = sqrt(meanSquare) * (5 / (0.0016 * 1024.0)) - 0.5;


While writing this, I noticed that you were dividing by the number of samples after taking the square root instead of before. That explains a factor of 10 in why the sensitivity appeared to be incorrect.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

hozone

damned paranthesis! :)

later i will use #define or const for my code, code here is only for test purpose

my new code has a simple filter for adc to remove offset

Code: [Select]
uint16_t i = 0;
int16_t adc_raw = 0;
int16_t adc_rawlast = 0;
int16_t adc_filtered = 0;
int16_t adc_lastfiltered = 0;
for(i=0; i<100; i++) {
 adc_rawlast = adc_raw;
 adc_raw = (512 - adc_read(2));
 adc_lastfiltered = adc_filtered;
 //digital high pass filters to remove offset.
 adc_filtered = 0.996*(adc_lastfiltered+adc_raw-adc_rawlast);
 s = adc_filtered * adc_filtered;
 ssum += s;
 _delay_us(100);
}
d = sqrt(ssum/100) * 5 / (0.018 * 1024.0);
ssum = 0;


now with a sensitivity of 0.018 (0.036 (close to 0.04) /2) things seems right from 0.5A to 12A
my chip is ACS758 LCB-050B

because
d = sqrt(ssum/100) * 5 / (0.018 * 1024.0);
is like
d = 2 * sqrt(ssum/100) * 5 / (0.036 * 1024.0);

isn't that there is a 2 multiply left?


dc42

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

hozone

yes, printed on chip.

i change the ratiometric change in sesitivity derived from my voltage (page 16 acs758 datasheet)
SENSnew = (Vin / 5v) SENSdatasheet
my board supply is 4.70V so the sensitivity should be 37.6mV, next 0.036 / 2 = 0.018.. ?



dc42

The extra factor of 2 does seem odd, that's why I suspected that you might have the 100A version of the sensor. Did you get it from a reputable supplier?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

hozone


Did you get it from a reputable supplier?


Absolutely not  :smiley-eek: ebay seller from china :) did you think it is a fake or wrong printed chip?

dc42

It might be a remarked chip, perhaps a -100B that has been remarked as a -050B by mistake. How well do the markings match the ones shown on the last 2 pages of the datasheet?
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

hozone

to me seems allegro official, but may not be.
see attached pic

hozone

i've made further test
it seems that with a sensitivity of 0.034/2 it works from 4A to 12A quite well.
0.034 seems ok, because my supply is 4.7V, sensitivity should be 0.03824 +- 5mV (Electrical offset voltage from datasheet)
but i've to use half of it.

p.s checked also my multimeter and it has no problem.

have you  any suggestion, or anyone here that can test my code on other chip?

tks!

Go Up