Arduino Mega Adc Problemi

hkn_blt

Üye
Katılım
31 Ağu 2009
Mesajlar
1,160
Puanları
31
Arduino mega ile adc den gelen verileri okuyorum. Adc me veri Ad536A true rms to dc convertor entegresinden geliyor ve gelen voltaj çok stabil herhangi bir dalgalanma mevcut değil fakat arduino adc de okuma yaptığımda dalgalanma oluyor. Gelen verilerin ortalamasını alsam bile dalgalanma devam ediyor. Bu sorunu nasıl çözebilirim ?
Kod:
const int numReadings = 20;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int inputPin = A0;
float Vout = 0.00;
float Vin = 0.00;
float R1 = 100000.00; // resistance of R1 (100K)
float R2 = 2183.00; // resistance of R2 (10K)
int val = 0;
void setup() {
  // initialize serial communication with computer:
  Serial.begin(9600);
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {
  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(inputPin);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  Vout = (average * 5.034) / 1023.00;
  Vin = Vout / (R2/(R1+R2));
  // send it to the computer as ASCII digits
  Serial.println(Vin);
  delay(100);        // delay in between reads for stability
}
 
Arduino mega ile adc den gelen verileri okuyorum. Adc me veri Ad536A true rms to dc convertor entegresinden geliyor ve gelen voltaj çok stabil herhangi bir dalgalanma mevcut değil fakat arduino adc de okuma yaptığımda dalgalanma oluyor. Gelen verilerin ortalamasını alsam bile dalgalanma devam ediyor. Bu sorunu nasıl çözebilirim ?
Kod:
const int numReadings = 20;

int readings[numReadings];      // the readings from the analog input
int readIndex = 0;              // the index of the current reading
int total = 0;                  // the running total
int average = 0;                // the average
int inputPin = A0;
float Vout = 0.00;
float Vin = 0.00;
float R1 = 100000.00; // resistance of R1 (100K)
float R2 = 2183.00; // resistance of R2 (10K)
int val = 0;
void setup() {
  // initialize serial communication with computer:
  Serial.begin(9600);
  // initialize all the readings to 0:
  for (int thisReading = 0; thisReading < numReadings; thisReading++) {
    readings[thisReading] = 0;
  }
}

void loop() {
  // subtract the last reading:
  total = total - readings[readIndex];
  // read from the sensor:
  readings[readIndex] = analogRead(inputPin);
  // add the reading to the total:
  total = total + readings[readIndex];
  // advance to the next position in the array:
  readIndex = readIndex + 1;

  // if we're at the end of the array...
  if (readIndex >= numReadings) {
    // ...wrap around to the beginning:
    readIndex = 0;
  }

  // calculate the average:
  average = total / numReadings;
  Vout = (average * 5.034) / 1023.00;
  Vin = Vout / (R2/(R1+R2));
  // send it to the computer as ASCII digits
  Serial.println(Vin);
  delay(100);        // delay in between reads for stability
}
Sistemde röle veya buton kullandınız mı ?
 
Okuduğum değerler şöyle gelen veri lineer olmasına karşın adc de okuduğum lineer değil.
Ad536A output pin lineer; example;
input voltage : 20V Ad536 output: 0.200V ADC=39
input voltage : 40V Ad536 output: 0.400V ADC=81
input voltage : 60V Ad536 output: 0.600V ADC=123
input voltage : 80V Ad536 output: 0.801V ADC=165-166
 
çok fazla dalgalanma olmuyorsa takmayın. arduino'nun adc'sinin çok hassas oluşundan olabilir. yaa arduino'nun kendi iç dalgalanmalarından.
isterseniz bir if-else if- else if.... - else yapısı kurun ve değer ... değeri ile ... değeri arasındaysa değeri ... yap diyerek yuvarlama işlemi yaptırabilirsnz.
 

Forum istatistikleri

Konular
128,179
Mesajlar
915,658
Kullanıcılar
449,940
Son üye
yavuzturan

Yeni konular

Çevrimiçi üyeler

Geri
Üst