kriswiner / MPU9250

Arduino sketches for MPU9250 9DoF with AHRS sensor fusion
1.03k stars 472 forks source link

Magnetometer Calibration to limit yaw error #104

Open evinramadeen opened 7 years ago

evinramadeen commented 7 years ago

Good day Kris, This may come across as a weird or trivial question but I have noticed great discrepancies based on which method I use so I thought it was best for me to ask. When you designed the magnetometer calibration and said to wave device in a figure 8, did you intend for the device to be flipped upside down whilst going across the x axis y axis, did you intend for it to be always facing up whilst being waved along both axes in a figure 8 pattern(essentially making two figure 8 that intersect at the origin), did u intend for it to be moving upside down and rightside up whilst in the x axis only or finally, did u intend for it to be waved in one axes right sided up only? I hope this is not an extremely dumb question, being my first time interacting with magnetometers and having to calibrate them, I thought it best to ensure I was on the right track. Thank you in advance.

kriswiner commented 7 years ago

Please read this:

https://github.com/kriswiner/MPU-6050/wiki/Simple-and-Effective-Magnetometer-Calibration

The purpose of the magnetic calibration is to sample as much of the 3D response surface as possible so the magnetic response can be (re)centered on the origin and spherized. So the magnetometer has to be moved to gather readings from all possible orientations during the calibration. The calibration in the sketches is a demonstration of the method. There is no guarantee the specific length of time programmed for the calibration will be sufficient for your use case. Once the calibration is known, it is pretty stable and you can hard code it into the program so as to avoid having to calibrate each time the device is powered on, but the calibration is device specific and cannot be applied to a different device, etc. This is all commmon sense I hope.