Go Down

Topic: MPU-9250 Problem with Calibration Topic 5000000 (Read 173 times) previous topic - next topic


Jan 17, 2019, 01:28 pm Last Edit: Jan 17, 2019, 01:30 pm by Jamezxxx
Hey together,

I started working with the MPU-9250 on an ESP 32 and found the code of Kris Winer (I owe you at least 3 Beer!)

MPU9250_MS5637_ESP32 Basic Example Code
 by: Kris Winer
 date: December 14, 2016
So I worked through the code and started working with the calibration (moving the sensor in 8`s).

Nr. 1 When I use the original code this gonna happen:

Nr. 2 So I tried a little bit and when I remove the magScale this gonna happen:

Nr. 3 And without magScale and magBias this is happening:

So when I look at Nr. 1 we see the following problem: 1.) the MagScale is not helping the Calibration, it`s destroying it, but I don`t know why, actually it should change the oval shape into a round one, but instead its making it worse, any clues why ?

2.) In Picture 2 we see, that the magBias is working, but not 100% for me, actually it should move the "ball" to 0,0,0. Even if its not completly 0,0,0 the Direction is working for me, even if its not 100% fine.
I was thinking about increases the calibration time to 20 or 25 seconds instead of 15

3.) In Picture 3 we see, that without magBias the "ball" is moved with an offset.

I hope you guys got ideas, how to fix my problem, because I tried a lot and it`s still not helping :(



It has been a while since I created this code for my MPU9255 but I believe it is the same for the MPU9250. This has a magnetometer calibration routine near the bottom for the MPU9250.
This code was derived from the manufacturer's Example code Located at:
InvenSense Developers Corner Software Downloads
You may need to register to get access to this location on their page.
Embedded MotionDriver 6.12
Embedded MotionDriver 6.12 is our first ever 9-axis solution not locked to a specific MCU.Version 6.1.2 is an update to 6.1 that includes bug fixes and new libraries. This release is supported across all ARM Mx core architectures and supports the InvenSense MPU-6000, 6050, 6500, 9150, and 9250. The release includes optimized libraries and example projects for M3 and M4 cores as well the generic ARM library for any Mx core and an additional library and project for the TI MSP430. eMD 6.1 also includes a Python client for both visualizing the sensor performance and commands for printing data. This solution will allow you to easily leverage and configure numerous features of the DMP and also benefit from dynamic features in the MPL software library. Libraries specific to IAR, Keil, and GCC are included.


In your File I can just see a Gyro and Accelero Calibration but no Magnetometer Calibration ...

For now I stay with the 8-Calibration (Magnetometer) and just increase the time by 10 seconds, that gives me almost good working data.


In your File I can just see a Gyro and Accelero Calibration but no Magnetometer Calibration ...

For now I stay with the 8-Calibration (Magnetometer) and just increase the time by 10 seconds, that gives me almost good working data.
I remember why :
InvenSense Developers Corner Software Downloads
The Motion Driver 6.12 has a self-calibration that is part of the latest binary downloaded above.
I didn't need to generate offsets for the magnetometer.
The Motion Driver 6.12 contains a binary library which contains InvenSense proprietary algorithms for sensor fusion and dynamic calibration. The MD 6.12 driver pushes the sensor data into the MPL and the MPL will handle the 9-axis sensor fusion including the compass integration.

MPL features are configured before enabling the MPL library. They can be dynamically turned off and on through API calls into the MPL.

Compass Calibration:
Run-time hard iron compass calibration for MPU9150 and MPU9250. MPL reads and builds the magnetic field environment around the device. Once enough data is present the compass offset can be applied and 9-axis quaternions can be generated. If you are in an environment with an unstable magnetic field the compass will not get calibrated. If the compass is not calibrated the quaternions will only use 6-axis. Figure 8 motions on the device will quicken the calibration.

Mag Disturbance Rejection:
After calibration, the MPL library will keep track of the magnetic field and if there is an anomy detected, the MPL library will reject the compass data and switch back to 6-axis fusion. After a magnetic disturbance is detected, the MPL library will continue to check the compass data every 5 seconds. At each check, if the disturbance is no longer there, it will switch back to 9-axis fusion…otherwise, it will continue to reject the data.

Go Up