Linear Acceleration Readings Are Way Off

By chriscummins , 9 July 2013

Hello!

I have installed Jeff Rowberg's i2cdevlib library for Arduno which I can use for my MPU-6050 to make it interact with Arduino.

However, I have an odd problem with one of its functions.

It's got a function to turn the accelerometer & gyroscope readings into linear acceleration. This is the definition of the function:

uint8_t MPU6050::dmpGetLinearAccel(VectorInt16 *v, VectorInt16 *vRaw, VectorFloat *gravity) {
   // get rid of the gravity component (+1g = +8192 in standard DMP FIFO packet, sensitivity is 2g)
   v -> x = vRaw -> x - gravity -> x*8192;
   v -> y = vRaw -> y - gravity -> y*8192;
   v -> z = vRaw -> z - gravity -> z*8192;
   return 0;
}



However, whenever the function is called in the example code:

            // display real acceleration, adjusted to remove gravity
           mpu.dmpGetQuaternion(&q, fifoBuffer);
           mpu.dmpGetAccel(&aa, fifoBuffer);
           mpu.dmpGetGravity(&gravity, &q);
           mpu.dmpGetLinearAccel(&aaReal, &aa, &gravity);
           Serial.print("arealt");
           Serial.print(aaReal.x);
           Serial.print("t");
           Serial.print(aaReal.y);
           Serial.print("t");
           Serial.println(aaReal.z);


I get values way off, when I'm not even moving my MPU-6050!

These are a few of the values I get:

areal	-473	423	-425
areal -460 400 -450
areal -471 522 -458
areal -322 276 -582


Do you know how I can fix this?
Thanks!
-George
phpbb Topic ID
15435