Jump to content
I2Cdevlib Forums
HipT

How to decide Gyro and Accelerometer offsett

Recommended Posts

Hi everyone,

 

After searching in forums i found out that people have different values for the "setXGyroOffset/setYGyroOffset/setZGyroOffset/setZAccelOffset" functions.

But i can't understand how i can find what values i need to use.

 

Can somebody explain me how do i choose the parameters for  those functions?

 

Thanks in advance.

Share this post


Link to post
Share on other sites

What I do to get calibration values using Arduino is the following:

 

- Put the MPU6050 in a flat and horizontal surface. Use an inclinometer to check that it is as horizontal as possible.

 

- Modify the RAW program to put every offset to 0. ("setXGyroOffset/setYGyroOffset/setZGyroOffset/setZAccelOffset"  =0 ).

 

- Upload the RAW program to your arduino and open serial monitor so you can see the values it is returning.

 

- Leave it operating for a few minutes (5-10) so temperature gets stabilized.

 

- Check the values in the serial monitor and write them down.

 

- Now modify your program again updating your offsets and run the sketch, with updated offsets.

 

- Repeat this process until your program is returning 0 for every gyro, 0 for X and Y accel, and +16384 for Z accel.

 

Once you achieve this, those are the offsets for that MPU6050, you will have to repeat this for every MPU6050 you use.

 

*NOTES:

- If you stop the sketch for a while, sensor's temperature will get lower. If you only stop it to reprogram new offsets, you dont need to wait those 5-10 minutes every time.

 

- What you should try to achieve is to get the average of every gyro and XY accel to those values mentioned, so it is best if you modify the sketch to take, for example, 10000 measures, and just show on the serial monitor the average, because there is always some noise.

 

- It is not so straigthforward to update your offset every time. In my case, I had to put my initial readings, negated (change sign) and divided by 4 (gyros) and by 7.8 (accels).

Share this post


Link to post
Share on other sites

Clear and easy to follow explaniation,much appreciated.

Now i've another problem with the orientation of the quaternion output but i'll try to solve it myself before asking.

 

Thanks a lot!

Share this post


Link to post
Share on other sites

Hi ,

 

I know this is a very old thread and am a newbie with IMUs. I know this may seem like stupid question, do we need to calibrate the IMUs every time you use it or is setting the offsets one time sufficient.

 

Thank you

Share this post


Link to post
Share on other sites

- It is not so straigthforward to update your offset every time. In my case, I had to put my initial readings, negated (change sign) and divided by 4 (gyros) and by 7.8 (accels).

 

Can someone explain why we have to divide by 4 for gyro and divide by 8 (assuming that's a type and not 7.8)  for accel

Share this post


Link to post
Share on other sites

Hi, i know this is a very old thread but i just wanted to share my code that can auto calibrate the Gyroscope and Accelerometer of MPU6050. The code is increment based and after calibration all the values comes down to zero or close to it. I want to share this code so others can also test it and improve it. One of the things i haven't done is in z axis of accelerometer i haven't used +16384 offset.  Calibration can be more fine tuned but the cost of doing it would be time. It will take more time to calibrate it closer to zero. Fining tuning is discussed in comments in code. I also noticed that the DMP takes 20secs(approx) to stabilize. So if you are using Yaw pitch Roll output then values of first 20 seconds are useless.  Another problem is that this code sometimes work other times it fails. So do check. anyway here are the before and after calibration graph.
2nv8bvn.jpg

 

jjqqab.jpg

 

This sketch output raw data (Time(in miliseconds) AX Ay Az Gx Gy Gz)

https://www.dropbox.com/s/t0u4sv3nkoplnoz/MPU6050_auto_calibrationl_raw_data_output.ino.ino?dl=0

This sketch uses DMP and Output data in YAw pitch Roll or other formats. waits 20 seconds for stability before giving data.
https://www.dropbox.com/s/hh2750l8x115eib/MPU6050_auto_calibration_output_yaw_pitch_roll.ino?dl=0

Share this post


Link to post
Share on other sites

Hi Eqbal Khan,

 

Thank you for sharing your experiment.

 

I am doing an experiment where the MPU9250 DMP processing is going to sleep (after certain time of no activity) to save power, and wake up where there is a accelerometer motion.

In Invensense eMPL library there is a function called mpu_lp_motion_interrupt(500, 1, 5); which put motion processing to sleep, uses accelerometer threshold only to wake up the system.

 

Like what you have said, I observed the DMP (Quaternion / Euler / fusion data) needs certain time above 10 seconds to stabilize after the wake up interrupt.

 

Up to this experiment, I have not done any calibration on the gyro or accel. I assumed the bias offset to be minimum and not to have significant effect.

 

= In your opinion, do you think calibrating the gyro and accel would help to stabilize the fusion data faster when it wakes up from sleep?

= Have you done experiment on sleep and wake up before, and measure how fast it stabilizes?

 

Thank you

 

Handi

Share this post


Link to post
Share on other sites

Hi, I'm trying to understand what the accel offset are doing and which algorithm is used.

Unfortunately, I didn't find the answer yet, neither in the forums nor in the data sheet.

Since my MPU6050 is not mounted "flat" I need to transform the coordinate system.

 

Can this be done with the functions to set the offset (accelgyro.setXAccelOffset(xAccelOff);) ?

 

Thanks for your support,

 

Regards

Andreas

Share this post


Link to post
Share on other sites
On 3/15/2017 at 11:26 PM, renaud said:

when i try to use Eqbal Khan calibration I got the error : Average.h: No such file or directory any idea?

 

 

Sorry to reopen this old topic and not sure if you already fixed this but doesn't that mean that you don't have the Average.h library. Where would you be able to find the Average.h library?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×