Pages: 1 [2]   Go Down
Author Topic: ac current meter using acs758 hall sensor  (Read 6239 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 1
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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)
Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
 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.
« Last Edit: November 20, 2012, 04:43:49 am by dc42 » Logged

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.

0
Offline Offline
Newbie
*
Karma: 1
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

damned paranthesis! smiley

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:
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?

Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

my chip is ACS758 LCB-050B

Is that actually printed on the chip?
Logged

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.

0
Offline Offline
Newbie
*
Karma: 1
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


Logged

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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.

0
Offline Offline
Newbie
*
Karma: 1
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Did you get it from a reputable supplier?

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

United Kingdom
Offline Offline
Tesla Member
***
Karma: 224
Posts: 6593
Hofstadter's Law: It always takes longer than you expect, even when you take into account Hofstadter's Law.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

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.

0
Offline Offline
Newbie
*
Karma: 1
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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


* acs758_board_pic.jpg (107.29 KB, 800x1067 - viewed 88 times.)
Logged

0
Offline Offline
Newbie
*
Karma: 1
Posts: 35
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Pages: 1 [2]   Go Up
Jump to: