Go Down

Topic: Calibrar o acel. ADXL335 (Read 651 times) previous topic - next topic

eltonsf

Bom dia estou tentando calibrar o acelerômetro ADXL335, e estou encontrando dificuldades, de acordo com o datasheet dele a posição que estou testando, deveria mostrar algo como "x = 0g, y = 1g e z = 0g", só que no serial monitor aparece "x = -2, y = -2 e z -1".

As fórmulas utilizadas são as seguintes:

1) x = Vout * Vs / 1023.0;
2) X = x - ZeroG // sendo 1.65 para os eixos x e y, e 1.8 para o eixo z.
3) X(g) = X / Sensitivity;


const int xPin = 0;
const int yPin = 1;
const int zPin = 2;

//
double Sensitivity  = 0.330;

//
const int baudRate = 9600;
const int timerDelay = 1000;

void setup() {

  Serial.begin( baudRate );
  Serial.println( "Iniciado" );

}

void loop() {

adxl335();

}

void adxl335() {

  //
  float xRead = analogRead( xPin );
  float yRead = analogRead( yPin );
  float zRead = analogRead( zPin );

  //
  xRead = (( xRead * 3.3 ) / 1023.0 );
  yRead = (( yRead * 3.3 ) / 1023.0 );
  zRead = (( zRead * 3.3 ) / 1023.0 );

  //
  float X = ( xRead - 1.65 );
  float Y = ( yRead - 1.65 );
  float Z = ( zRead - 1.8 );
 
  //
  xRead = ( X / Sensitivity );
  yRead = ( Y / Sensitivity );
  zRead = ( Z / Sensitivity );

  Serial.print( "x: " );
  Serial.print( xRead, 0 );
  Serial.print( " | y: " );
  Serial.print( yRead, 0 );
  Serial.print( " | z: " );
  Serial.println( zRead, 0 );
 
  delay( timerDelay );

}




Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy