mpu6050 icon indicating copy to clipboard operation
mpu6050 copied to clipboard

Calibration?

Open chrisspen opened this issue 7 years ago • 7 comments

How do you enter the offsets acquired during calibration? Otherwise, the values read from the device are raw and meaningless.

chrisspen avatar Jul 11 '16 06:07 chrisspen

Because no procedure for calibration of the hardware is given in the datasheet, there is no calibration implemented.

What this module does lack is an implementation of the self test procedure (7.12 of the datasheet).

m-rtijn avatar Jul 11 '16 07:07 m-rtijn

I'm not asking how to calibrate it. This Arduino sketch explains how to do that http://wired.chillibasket.com/2015/01/calibrating-mpu6050/

I'm asking how to enter the 6 offsets (three for the accelerometer and three for the gyroscope). These are registers on the device:

MPU6050_RA_XA_OFFS_H MPU6050_RA_YA_OFFS_H MPU6050_RA_ZA_OFFS_H MPU6050_RA_XG_OFFS_USRH MPU6050_RA_YG_OFFS_USRH MPU6050_RA_ZG_OFFS_USRH

If you don't enter these, the values read from the device will be useless.

chrisspen avatar Jul 11 '16 16:07 chrisspen

While developing this module I used the MPU-6050 Register Map and Descriptions file (Document number: RM-MPU-6000A-00, release date: 4.2, Release date: 2013-08-19) which does not include information about the offset registers. Because of this, there is currently no option to use these registers in this module, since I only just learned about their existence (thanks to you because you pointed this out).

m-rtijn avatar Jul 11 '16 18:07 m-rtijn

I've decided that because for most applications calibrating the MPU-6050 is not necessary, since the factory calibration will be precise enough, that I won't add support for these calibration features.

If you want to add these features to this project, you're welcome to do so.

EDIT (2023-04-27): I think it would be a useful feature to add, but I currently don't have working MPU6050 chips to test any code. If anybody is interested to add this via a PR, it would be really welcome :)

m-rtijn avatar Aug 16 '16 18:08 m-rtijn

@m-rtijn I am not sure if I am doing something wrong, but I get bias of 16 d/s on the X gyro data. that makes it pretty much unusable without calibration.

Would be great to understand what is the way to overcome this, right now I have done a wrapper that adjusts for errors

byapparov avatar Jan 09 '21 17:01 byapparov

@byapparov The Arduino-MPU6050 library (linked from the official site) does basically what you do: the readNormalizeGyro() function subtracts a fixed offset and performs thresholding, both set from calibration at program start calibrateGyro(). It has not been updated for the new registers, so that could be why.

Artoria2e5 avatar Apr 27 '23 14:04 Artoria2e5

It seems that there also exists a Linux kernel module that implements interfacing with the MPU6050, that code can also be used as inspiration: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iio/imu/inv_mpu6050?h=v6.3

It can even be used directly I think. You can follow for example the steps here: https://petermolnar.net/article/linux-i2c-iio-collectd/#detecting-i2c-devices (just ignore the part about using the USB i2c adapter, since the Raspberry Pi has i2c built-in).

m-rtijn avatar Apr 27 '23 15:04 m-rtijn