Skip to main content
Graduate
April 15, 2021
Solved

MotionFX magnetometer calibration never finishes

  • April 15, 2021
  • 4 replies
  • 2080 views

I am using STM32CubeIDE with a STM32L471VET micro. I have included the MotionFX library and have 9DOF orientation output working, but I can't seem to get the magnetometer calibration completed. It continuously shows: MFX_MAGCALUNKNOWN even after 5 to 10 min of rotating my development board around at every conceivable angle even making figures of 8 does not seem to work. I have followed the MotionFX documentation carefully. I hope there is someone out there that has got this to work successfully. If so please help me to get the calibration working.

    This topic has been closed for replies.
    Best answer by PNewm.1

    Hi Peter. Thank you for your reply. I did exactly what you said even before you replied and I was able to get the calibration done in less then 10 seconds. The problem I had was the the documentation said to move the device in a figure of 8 'slowly'. This is where the problem is. If one moves it slowly then it simply does not calibrate. After struggling for a long time, in fact many days, I got so fed up, I just moved the board vigorously and wildly and voila! It worked. I tried many times to calibrate it afterwards and even got it done in 4.5 seconds while moving it vigorously. To spare many other people the same trouble, I would update the documentation by removing the word 'slowly' as this is misleading in my opinion. Perhaps others have had a different experience, but I certainly struggled for many days because of the word 'slowly'. I hope this helps someone.

    4 replies

    ST Employee
    April 19, 2021

    Hello,

    Please verify your data feed into library, including units and timing. I recommend to inspire in the DataLogFusion sample application included in X-CUBE-MEMS1 package, especially all initialization sequences and data feed. In mentioned application I usually get MFX_MAGCALGOOD in less then 10 seconds. You can use STM32CubeMX tool to generate this application for HW similar to your one.

    Regards,

    Petr

    PNewm.1AuthorAnswer
    Graduate
    April 20, 2021

    Hi Peter. Thank you for your reply. I did exactly what you said even before you replied and I was able to get the calibration done in less then 10 seconds. The problem I had was the the documentation said to move the device in a figure of 8 'slowly'. This is where the problem is. If one moves it slowly then it simply does not calibrate. After struggling for a long time, in fact many days, I got so fed up, I just moved the board vigorously and wildly and voila! It worked. I tried many times to calibrate it afterwards and even got it done in 4.5 seconds while moving it vigorously. To spare many other people the same trouble, I would update the documentation by removing the word 'slowly' as this is misleading in my opinion. Perhaps others have had a different experience, but I certainly struggled for many days because of the word 'slowly'. I hope this helps someone.

    ST Employee
    April 20, 2021

    Hi @PNewm.1​ ,

    thank you for reporting your "vigorous" solution.

    -Eleon

    PNewm.1Author
    Graduate
    April 27, 2021

    Hi Peter. Thank you for being willing to help us. Unfortunately it's no so easy for me to send any motion data to you presently. I am actually logging the motion data at 20 FPS even though the IMU accel, gyro and mag data as well as the MotionFX methods are run at 100 FPS. We run the IMU at 100 FPS so that we can get better gyro related motion control. At this point in time I cannot get the logged data from the QSPI 1MB flash chip as I have not yet written code to do so. I do believe that providing you with the data log may help you to help us come up with some sort of calibration solution. I'm just tied down with other work related to the same project, so I can't spend any time on this now. It may take a few weeks before I can provide you with the motion data.

    ST Employee
    April 28, 2021

    No problem, just let me know when you have something.