hideakitai / MPU9250

Arduino library for MPU9250 Nine-Axis (Gyro + Accelerometer + Compass) MEMS MotionTracking™ Device
MIT License
279 stars 92 forks source link

Magnetometer is not being calibrated correctly #94

Closed sherrykarim closed 1 year ago

sherrykarim commented 1 year ago

Environment

IDE: Arduino IDE Board: Arduino Nano MPU-9250 Library Version: 0.4.7

Issue

every time i calibrate i get different exact results and the yaw angles are inaccurate. i tried different ways in waving the magnetometer to calibrate.

i got the following results when i waved in an 8-shape:

Accel Gyro calibration will start in 5sec. Please leave the device still on the flat plane. Mag calibration will start in 5sec. Please Wave device in a figure eight until done. Mag Factory Calibration Values: X-Axis sensitivity offset value 1.16 Y-Axis sensitivity offset value 1.17 Z-Axis sensitivity offset value 1.12 Mag Calibration: Wave device in a figure eight until done! mag x min/max: 0 312 mag y min/max: -391 0 mag z min/max: -35 339 Mag Calibration done! AK8963 mag biases (mG) 272.28, -341.49, 256.40 AK8963 mag scale (mG) 1.14, 0.90, 0.98 Mag Factory Calibration Values: X-Axis sensitivity offset value 1.16 Y-Axis sensitivity offset value 1.17 Z-Axis sensitivity offset value 1.12 < calibration parameters > accel bias [g]: 53.90, 8.81, 20.68 gyro bias [deg/s]: -0.25, 0.47, 0.87 mag bias [mG]: 272.28, -341.49, 256.40 mag scale []: 1.14, 0.90, 0.98 Write calibrated parameters to EEPROM Load calibrated parameters from EEPROM calibrated? : YES load calibrated values

and the following when i rotated around the 3 axes:

Accel Gyro calibration will start in 5sec. Please leave the device still on the flat plane. Mag calibration will start in 5sec. Please Wave device in a figure eight until done. Mag Factory Calibration Values: X-Axis sensitivity offset value 1.16 Y-Axis sensitivity offset value 1.17 Z-Axis sensitivity offset value 1.12 Mag Calibration: Wave device in a figure eight until done! mag x min/max: -20 307 mag y min/max: -359 0 mag z min/max: -10 356 Mag Calibration done! AK8963 mag biases (mG) 249.59, -313.47, 291.82 AK8963 mag scale (mG) 1.06, 0.96, 0.98 Mag Factory Calibration Values: X-Axis sensitivity offset value 1.16 Y-Axis sensitivity offset value 1.17 Z-Axis sensitivity offset value 1.12 < calibration parameters > accel bias [g]: 241.36, -242.35, -38.59 gyro bias [deg/s]: -0.64, 1.21, 1.44 mag bias [mG]: 249.59, -313.47, 291.82 mag scale []: 1.06, 0.96, 0.98 Write calibrated parameters to EEPROM Load calibrated parameters from EEPROM calibrated? : YES load calibrated values

first of all the zero degree is not centred on the magnetic north or the real north. second of all when going 90 degrees to the left it is giving -90 (as expected), 90 degrees to the right gives +100. when i go to 180 degrees it gives +160 degrees and in that neighbourhood. so basically the further we go from -90 degrees the more the error gets accumulated. i am using the standard calibration_eeprom example code then printing out the yaw roll and pitch. the only way that i got the right values was when i manually calibrated and hard-coded the results in the library .h file (that was just for the purpose of testing and i returned everything to the factory settings). there are electronics that are around the magnetometer but i am testing in the same area of calibration and eventually when implementing there will be electronics around.

hideakitai commented 1 year ago

I will drop the support for this library anymore. I recommend using other active developing libraries.