Go Down

Topic: MPU6050 Calibration  (Read 2058 times) previous topic - next topic

Hitesh_KHD

Nov 30, 2017, 07:56 pm Last Edit: Nov 30, 2017, 08:01 pm by Hitesh_KHD
Hello People!

I am completely new to this world of IOT, I am working on my very first project where I have used an MPU6050 Powered with Arduino uno to detect change in motion of an object and also the angle of change in orientation

I have Couple of questions regarding the same

1 : The angle that Gyro sensor gives when MPU6050 is rotated, is with respect to what?

2: What basically are offsets and how do I determine offset for my MPU6050

P:s I know this might seem silly Questions, But as I said earlier, I don't have much knowledge regarding this stuff!

MrMark

1) The gyro sensor measures angular rate around each Cartesian axis.

2) Without more context, I'm not clear as to which offset you are referring.

Have you looked at the Datasheet and register descriptions for the device (bottom of linked page)?

jremington


Hitesh_KHD

I'm sorry, I wanted to delete the duplicate pose but wasn't successful!

MartinL

#4
Dec 02, 2017, 10:16 am Last Edit: Dec 02, 2017, 10:30 am by MartinL
Hi Hitesh_KHD,

A good place to start understanding the MPU6050 is here: http://www.geekmomprojects.com/gyroscopes-and-accelerometers-on-a-chip/.

This article describes how use a simple complementary filter to fuse the gyroscope and accelerometer data to obtain Euler angles for pitch and roll.

The gyroscope measures rotational speed in say degrees/s or radians/s, this can be integrated to obtain the angle again in degrees or radians, however like you mention it has no reference point and additionally, like all gyroscopes, drifts to a greater or lesser extent over time.

To provide a reference point we use the accelerometer to measure gravity. Using some trigonometry we can convert these raw acceleration values to pitch and roll angle with respect to the horizontal, however the accelerometer is noisy and any acceleration other than rotation can distort the measurements.

To solve this we can fuse the integrated gyroscope and accelerometer pitch and roll angles using a complementary filter. The complementary filter takes around 99.9% of the gyroscope angle mesurements and adds this to around just 0.1% of the accelerometer. Calculating this each time around the Arduino's loop() function the complementary filter has the magical effect of providing stable angle measurements that are tied to the horizontal reference. In addition the angles are more or less acceleration invariant and compensate for the gyroscope's drift.

To calibrate the gyroscope just take the mean average of a couple of hundred raw gyro readings at start-up and subtract from the raw values taken during operation.

To calibrate the accelerometer, place it on level-ground then again take the average raw values and again subtract from the raw values during operation. It's also possible to store the accelerometer values in EEPROM to save you having to calibrate each time you start-up.

There's also the issue of yaw compensation that the article above doesn't discuss. This involves transferring any small movements in yaw rotation from pitch to roll angle or vice-versa. This is covered by Joop Brokking in his quadcopter video on Youtube: https://www.youtube.com/watch?v=j-kE0AMEWy4.

Another option is to just get the angle values using the MPU6050's in-built DMP (Digital Motion Processor). Jeff Rowberg's I2Cdev library for the MPU6050 has example code for this.

If however you require full 3D orientation then you'll also need a 3-axis magnetometer, as the accelerometer is unable to measure yaw rotation. You'll also need more complex mathematics such as Quaternions or DCM (Direction Cosine Matrix). For this reference Kris Winer's Github code: https://github.com/kriswiner.

aster94

Getting the mpu family to work isn t straigh forward but then you will have good results

I simplified the quaternion filters, see here if you need them: https://www.hackster.io/vincenzo-g/sensor-fusion-algorithms-made-simple-6c55f6

Go Up