2020-05-20 09:04 AM
Hi everybody,
I use the motionFX with accelerometer, gyroscope and magnetometer (9X sensor fusion) but I have a problem using the magnetometer calibration.
I proceed as mentioned in the documentation of motionFX library:
Some remarks:
Sometimes, it is impossible to get a MFX_MAGCALGOOD quality, I only get MFX_MAGCALUNKNOWN.
I have a few questions:
Thanks for your time and your help
Solved! Go to Solution.
2020-05-28 03:27 AM
Hello,
Thanks a lot for the update.
I figured out what was my problem, and it was actually.... me.
I passed a delta time to the function MotionFX_MagCal_run (like the propagate and update functions) whereas a timestamp is expected... Now I don't have random results depending on the product I am working with.
But now, I face another problem concerning the parameter "sampletime" of the MotionFX_MagCal_init function.
In my case, the magnetometer is not on the same board than accelerometer and gyroscope, and I have a quite slow sampling rate on the magnetometer data : 200ms period between two consecutive data. However I can succesfully use the sensor fusion library (even if the result may not be as good as it could be with a higher mag sampling rate).
Concerning the mag calibration, if I pass a 200ms samplingtime to the MotionFX_MagCal_init function, I never succedeed to achieve a calibration. But if I pass a fake lower sampletime (let's say 10ms), I get calibration results (even with strong hi bias around).
Do you have any idea why a high samplingrate may not work or if I do something wrong?
Thanks again for your time
2020-05-21 01:59 AM
Hello,
Usually it takes a few seconds, but it really depends on the data. If there is a lot of disturbances the algorithm won't be able calculate the calibration coefficients and won't achieved the GOOD calibration quality.
Theoretically there is not limit for hard iron bias, but your sensor might be saturated and it will impact the calibration.
Yes, rotation along all tree axis is good, you can do also do "8 shape" movement.
The best way to find the root cause is plot the magnetometer data in scatter plot 2D chart, X-Y, X-Z, Y-Z. It should give you more information what's going on.
2020-05-28 03:27 AM
Hello,
Thanks a lot for the update.
I figured out what was my problem, and it was actually.... me.
I passed a delta time to the function MotionFX_MagCal_run (like the propagate and update functions) whereas a timestamp is expected... Now I don't have random results depending on the product I am working with.
But now, I face another problem concerning the parameter "sampletime" of the MotionFX_MagCal_init function.
In my case, the magnetometer is not on the same board than accelerometer and gyroscope, and I have a quite slow sampling rate on the magnetometer data : 200ms period between two consecutive data. However I can succesfully use the sensor fusion library (even if the result may not be as good as it could be with a higher mag sampling rate).
Concerning the mag calibration, if I pass a 200ms samplingtime to the MotionFX_MagCal_init function, I never succedeed to achieve a calibration. But if I pass a fake lower sampletime (let's say 10ms), I get calibration results (even with strong hi bias around).
Do you have any idea why a high samplingrate may not work or if I do something wrong?
Thanks again for your time
2020-05-28 05:41 AM
Also, I have another question (no link with the calibration): before integrated the 9X library, my project was compiled using the "-mfloat-abi=hard" option to use hardware floating point unit of the MCU. But in order to use the library (which is precompiled with no hardware floating point unit set), I have to compile the whole project with the option "-mfloat-abi=softfp".
Are there any way to get the 9X library already compiled with the "-mfloat-abi=hard" option ? I would prefer to use this option, as my MCU supports the hardware floating point.
Thanks
2021-04-15 02:14 AM
I know this post is old,but I thought that I would answer your question as it may help someone else. I am using a STM32L471 that also has a hardware FPU. I use STM32CubeIDE and in my project I have included the X-CUBE-MEMS1.8.2.0 Software Pack and from that the MotionFX library. In my Project Explorer view if I expand: Middlewares> ST> STM32_MotionFX_Library> Lib> it shows:
MotionFX_CM4F_wc32_ot_hard.a
This leads me to believe that the hardware FPU object code is included since if I browse...
en.x-cube-mems1\STM32CubeExpansion_MEMS1_V8.2.0\Middlewares\ST\STM32_MotionFX_Library\Lib\
I find that there are 10 different object files for different processor series and there are 2 that have 'hard' as part of their names namely:
MotionFX_CM4F_wc32_ot_hard.a
MotionFX_CM7F_wc32_ot_hard.a
So it does seem that depending on your processor it includes the hard or soft FP object code for the MotionFX library.
Edit:
NB:
I was also struggling with to get the cal_quality = MFX_MAGCALGOOD. Using the X-NUCLEO-IKS01A3 sensor expansion board together with a NUCLEO-F446RE board. I used the Unicleo-GUI interface together with the DataLogFusion example:
en.x-cube-mems1\STM32CubeExpansion_MEMS1_V8.3.0\Projects\STM32F401RE-Nucleo\Applications\IKS01A3\DataLogFusion
In debug mode I was able to watch the cal_quality variable. I moved the board around slowly in figures of 8 for 10 min and then finally I saw the MFX_MAGCALGOOD appear. Then I tried again, thinking that the instruction manual says 'slowly' so I forced myself to slow down the motion, it took 21 min and still no calibration. Then I got fed up and moved it vigorously in a small figure of 8. It took 13 sec and calibration was done! I tried again and got calibration done in 6 sec. I tried again and I got it done in 4 sec! The bottom line is the more vigorously you move the board, the quicker it calibrates. If you move it slowly like I did, you better prepare for no calibration or a very long calibration time .
I really hope this helps someone. It took me days to figure this out since the documentation says to move it slowly.