Show Posts
Pages: 1 [2] 3
16  Using Arduino / Sensors / A gyroscope calibration helper in python on: January 14, 2013, 07:22:18 am
hello,
this is my gyroscope calibration python script, hope it helps.
if something wronk in this method please let me know.

http://davidegironi.blogspot.it/2013/01/gyroscope-calibration-helper-01-for-avr.html

17  Using Arduino / Programming Questions / MQ-135 Value Conversion on: December 27, 2012, 01:55:59 pm
i've a mq135 - http://www.futurlec.com/Datasheet/Sensor/MQ-135.pdf

please anyone correct me if i'm wrong:

what i've undestand from datasheet is that

ppm  = Rs/Ro

Rs = mq135 readed resistence
Ro = sensor resistance at 100ppm of NH3 in the clean air (according to datasheet 30Kto200K)

i wire the sensor according to datasheet (see attached image, downloaded is from http://www.staceyk.org)
set RL = pulldown resistor (in the example 39K, according to datasheet any between 10KΩ to 47 KΩ)

so Rs = 1024*RL/adc - RL

the point here is to setup Ro, which means calibrate the sensor.
any help?


thank you,
davide
18  International / Hardware / Re: Amperometro con Sensore ACS758 on: December 06, 2012, 07:56:26 am
per quanto riguarda il settaggio di sensitività avete riscontrato i miei stessi problemi? (vedi post sopra)
tks
19  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 22, 2012, 09:30:15 am
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!
20  International / Hardware / Re: Amperometro con Sensore ACS758 on: November 21, 2012, 04:56:20 am
ciao,
se qualcuno fosse interessato, ne parlo in questo post, abbiamo "quasi" risolto, ci sono dei problemi con il settaggio della sensitività
http://arduino.cc/forum/index.php/topic,133144.0.html
21  International / Generale / Re: Presentazioni nuovi iscritti, fatevi conoscere da tutti! on: November 20, 2012, 09:03:16 am
ciao a tutti, sono un informatico, appassionato da qualche anno di elettronica... per questo mi ritrovo spesso su questo forum.  smiley-grin
22  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 20, 2012, 06:34:56 am
to me seems allegro official, but may not be.
see attached pic
23  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 20, 2012, 06:04:08 am
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?
24  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 20, 2012, 05:49:28 am
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.. ?


25  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 20, 2012, 05:20:48 am
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?

26  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 20, 2012, 04:16:30 am
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)
27  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 20, 2012, 03:48:12 am
it's a 1500w hair dryer with three position (stop, 3.4A, 6.4A, as read by my multimeter, which is not true rms).
i've also try attaching another heater, from 6.4A the current sucked it sine wave form BUT, and the extimated current measure is right IF i change the sensitivity A LOT.

Code:
uint16_t i = 0;
  double sensitivity = 0.0016;
  int16_t adc_raw = 0;
  int16_t adc_zero = 512; //as read when there is no current on the load
  for(i=0; i<100; i++) {
    adc_raw = adc_read(2);
    l += (adc_raw - adc_zero)*(adc_raw - adc_zero);
    _delay_us(100);
  }
  d = (sqrt(l)/100) * 5 / (0.0016 * 1024.0) - 0.5;
  l = 0;

Code:
d = (sqrt(l)/100) * 5 / (0.0016 * 1024.0) - 0.5;

with sensitivity of 0.0016 and an offset of 0.5 i've almost right result on 0A and above 3.4A (tried only 6.4A / 8A / 12A)
but from datasheet sensitivity is 0.04 ( = 25 * 0.0016)
28  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 19, 2012, 02:08:55 pm
Code:
    l += pow(adc_raw - adc_zero, 2);
You don't want to use pow() here, it uses float, double and is far too slow (it does logarithms, antilogarithms).

Code:
    long val = adc_raw - adc_zero ;
    l += val * val ;

You need to be sampling the waveform at 1000Hz or more for good accuracy so its important
the maths isn't too slow.  Lose the delays - if you want to control the timing you should use millis() or
micros() so you can synchronize to a multiple of 50 or 60Hz.


First look at a set of raw values from the sensor to check they are what you'd expect (sample a
bunch into an array, then print out the array, printing out is too slow also).  You should see a
clear sinusoidal pattern with the correct amplitude.

Then test your calculation code with known correct raw values to see if the arithmetic is correct.

attached a plot of raw values, just analogRead of the pin.
it has a strange behavior
+ the first part (y=512) is a line, device is power off.
+ the second part, some sort of 1/2 sine wave, only + part is present, device @ 3.4Amp, [strange here, why??]
+ the third part is a sine wave, device @ 6.4Amp

sensor has the same circuit as the datasheet propose, it does not change if Cf and / or Rf are present or not.
29  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 19, 2012, 11:11:57 am
Almost. You need to convert (adc_raw - adc_zero) to type 'long' before you square it, because the square may exceed the range of an int. You will need to declare currentac with type 'long' too. After taking the sqrt, you need to adjust it for the sensitivity etc. just as you do for DC.

i've left all untyped i know smiley-wink
typed code is below.


i've tried two ways, but it doesn't seams to works.

test 1------------------
subtract the zero-current value (512 or thereabouts) from the raw readings, square that, and add it to an accumulator variable. When you have accumulated enough samples, take the square root if the accumulator and divide by the number of readings.

Code:
double d = 0; long l = 0;
for(;;) {
  uint16_t i = 0;
  int16_t adc_raw = 0;
  int16_t adc_zero = 512;
  for(i=0; i<100; i++) {
    adc_raw = adc_read(2);
    l += pow(adc_raw - adc_zero, 2);
    _delay_us(100);
  }
  d = (sqrt(l)/100) * 5 / (0.04 * 1024.0);
  l = 0;


test 2------------------
average the square of the current, and take the square root of the average

Code:
double c = 0, d = 0;
for(;;) {
  uint16_t i = 0;
  int16_t adc_raw = 0;
  int16_t adc_zero = 512;
  for(i=0; i<100; i++) {
    adc_raw = adc_read(2);
    adc_raw = adc_raw - adc_zero;
    c += pow(adc_raw * 5 / (0.04 * 1024.0), 2);
    _delay_us(100);
  }
  d = sqrt(c)/100;
  c = 0;
 
  ... print c...
}



i'm testing a 6.4 Amp 220V 50hz device
both code i obtain almost the same value, which is 0.27Amp, but is not correct smiley-sad
30  Using Arduino / General Electronics / Re: ac current meter using acs758 hall sensor on: November 19, 2012, 09:49:03 am
The max value you can read is indeed 1023, but the correct value to use in the calulation is 1024. See section 24.7 of the atmega328p datasheet.
Thank you for this info!

Are you trying to measure alternating current? If so, you need to average the square of the current, and take the square root of the average (that's what RMS means). Easiest way is to subtract the zero-current value (512 or thereabouts) from the raw readings, square that, and add it to an accumulator variable. When you have accumulated enough samples, take the square root if the accumulator and divide by the number of readings.
Yes ac current.

so,
for AC current something like this
Code:
samplesnum = 100;
adc_zero = 512; //as read when there is no current on the load
sensitivity = 0.04; //as read from datasheet
for(i=0; i<samplesnum ; i++)
  adc_raw = analogRead(1);
  currentacc += (adc_raw - adc_zero) * (adc_raw - adc_zero); //subtract the zero-current value (512 or thereabouts) from the raw readings, square that, and add it to an accumulator variable
}
currentac = sqrt(currentacc)/samplesnum; //take the square root if the accumulator and divide by the number of readings.

for DC current something like this
Code:
adc_zero = 512; //as read when there is no current on the load
sensitivity = 0.04; //as read from datasheet
currentdc = (adc_raw - adc_zero) * 5/(sensitivity * 1024)

right?
Pages: 1 [2] 3