cancel
Showing results for 
Search instead for 
Did you mean: 

MotionFX blocked in MFX_MAGCALUNKNOWN state

Gabriel Gabor
Associate II
Posted on February 23, 2018 at 16:00

Hi,

I'm trying to use the MotionFX library with the LSM9DS1. I can initialise the library and I start to send updates using the MotionFX_MagCal_run method then I get the params with MotionFX_MagCal_getParams but the cal_quality is always 0, I tried multiple times. Also, I double checked that I set the sample time and timestamp correctly.

Not sure what I'm missing, is there any way to debug the behaviour of the library?

Regards,

Gabriel

10 REPLIES 10
Miroslav BATEK
ST Employee
Posted on February 23, 2018 at 16:16

Please check this thread firts

https://community.st.com/0D50X00009XkWhLSAV

If you are able to plot X, Y, Z during sensor rotation it would be helpful.

Posted on February 26, 2018 at 14:57

Thanks again for the quick response!

Here's the magnetometer data that I send using the MotionMC_Update function:

https://gist.github.com/gpgabriel/c0f55be9f32c0d548629d0525e79450e

 

The data above is calculated as follows:

calcMag(mx) * 1000 * FROM_MGAUSS_TO_UT50

where calcMag returns Gs.

I'm still blocked in the MFX_MAGCALUNKNOWN state. I'll try to add a video with an actual plot asap.

Posted on February 26, 2018 at 15:28

Here's a scatterplot with the data: 

https://www.youtube.com/watch?v=sUYUVuT1m_0

 

blue: xy; pink: xz; yellow: yz

PS. It's not exactly the same data as the one from the gist but it was produced in the same conditions. The values from the video are multiplied with 1000.

Posted on February 26, 2018 at 17:11

Your data seems OK to me.

0690X00000609p7QAA.png

Can you check that you use ms in the time stamp?

Maybe you can share you project or part of it, so I can check it.

Posted on February 26, 2018 at 18:53

Hi,

The calibration runs in a FreeRTOS task. I created my own time stamp which initially is 0 and then is being increased with 8 at every iteration. Each iteration reads the sensor, runs MotionMC_Update, runs MotionMC_GetCalParams and adds a vTaskDelay of a few ticks. In total each iteration takes 8ms and runs in a while(true) loop. I call MotionMC_Initialize(8, 1); before the task starts.

I'll be back with the code. Thanks

Posted on February 26, 2018 at 21:10

The timing could be the problem.

Firts the maximum ODR of the magnetometer in LSM9DS1 is 80Hz, so it doesn't make sense to read and call the update function in higher rate.

Second, I think the maximum update rate for magnetometer calibration library is 100Hz, so 8ms wont be valid parameter.

Can you please try to reduce the speed and align all the parameters (timestamp, sample rate in init function and your OS task frequency)?

Posted on February 27, 2018 at 12:07

My bad, I wrote it wrong. I was running at 80Hz, not sure why I said 8ms there.

I reduced the speed to 20Hz.

Here's part of the code which handles the calibration.

https://gist.github.com/gpgabriel/1f6ea9f7364dfb925fa48b98d8401a25

 

Thanks for all the replies.

EDIT: Quick question, the MotionFX library says that I should send the gyroscope values as dps but I noticed that I get better results if I send them as radians. What should I send?

Posted on February 27, 2018 at 16:25

The MotionFX needs angular rate in dps.

kkia
Associate II

Hi to all

I exactly have the same problem.

I use MPU9250 and I update the library in the main function, (I do not use any RTOS), and also my code is blocked in MMC_CALQSTATUSUNKNOWN state. I do not use MotionFX, I only use MotionMC, my compass data is correct. what happens is that the library always report MMC_CALQSTATUSUNKNOWN and after moving my compass in a 3D 8 shape path, the library hangs and I have to reset my micro controller.

I also appreciate it if we could solve this problem.