Go Down

Topic: MPU-6050's Linear Acceleration is Way Off (Read 5695 times) previous topic - next topic

georgelue321

Jul 07, 2013, 10:45 am Last Edit: Jul 07, 2013, 10:27 pm by georgelue321 Reason: 1
Hello!

I have installed Jeff Rowberg's i2cdevlib library 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:

Code: [Select]
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:

Code: [Select]
           // 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("areal\t");
           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:

Code: [Select]
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

Erdin

It removes the offset of the gravity.
Did you set the gravity at some point, while the sensor was held still ?

georgelue321


It removes the offset of the gravity.
Did you set the gravity at some point, while the sensor was held still ?


Thanks for the reply!

However, I am not sure what you exactly mean by set the gravity while the sensor was held still.
All I did was just run the code on the Arduino to my MPU-6050. I held my MPU-6050 still for the whole time; I didn't move it, and I got werid values that are way off.
Thanks,
-George

Erdin

Did you use the fifoBuffer like in the example ?
https://github.com/jrowberg/i2cdevlib/blob/63e04ba4030f04244dbc3417bca5fefd7778cd5e/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino

It should be filled with "mpu.getFIFOBytes(fifoBuffer, packetSize)".

The "mpu.dmpGetGravity(&gravity, &q)" converts the quaternions to gravity. You could print the gravity after calling that function.

A value of 8192 is 1g.
Your values are in the 500 range, that is 0.06g
The sensor is noisy, so it is close to zero.

georgelue321


Did you use the fifoBuffer like in the example ?
https://github.com/jrowberg/i2cdevlib/blob/63e04ba4030f04244dbc3417bca5fefd7778cd5e/Arduino/MPU6050/Examples/MPU6050_DMP6/MPU6050_DMP6.ino

It should be filled with "mpu.getFIFOBytes(fifoBuffer, packetSize)".

The "mpu.dmpGetGravity(&gravity, &q)" converts the quaternions to gravity. You could print the gravity after calling that function.

A value of 8192 is 1g.
Your values are in the 500 range, that is 0.06g
The sensor is noisy, so it is close to zero.



I used that exact example, MPU6050_DMP6.

I also did try printing the gravity values. The gravity values look fine though. I got gravity values like: -0.14, -0.04, 0.99 when I was holding the MPU-6050 still. However, I wonder why the linear acceleration calculations are still way off, even though the gravity readings look fine. Also, here are some of the raw accelerometer values I got when I held my MPU-6050 still, in case if they can help:

Code: [Select]
areal -1084 -351 7515
areal -1079 -347 7522
areal -1076 -346 7523

Erdin

That offset and that noise looks normal to me.
But I still don't understand why your linear acceleration values are in the 500 range.

georgelue321


That offset and that noise looks normal to me.
But I still don't understand why your linear acceleration values are in the 500 range.


That's also what I'm wondering about, since the raw accelerometer data and gravity values look fine. However, the linear acceleration calculations are way off.

Erdin

I don't know.
Is this about it ?
http://forum.arduino.cc/index.php?topic=133273.msg1247326#msg1247326
Jeff Rowberg is the author of the I2Cdevlib.

georgelue321


I don't know.
Is this about it ?
http://forum.arduino.cc/index.php?topic=133273.msg1247326#msg1247326
Jeff Rowberg is the author of the I2Cdevlib.


Can the odd linear acceleration readings be due to the sensitivity values..?

Thanks.
-George

Go Up