cancel
Showing results for 
Search instead for 
Did you mean: 

MotionFX: Different between implementation for M0 vs. M3

drozel
Associate II

Hi,

i am trying to use the MotionFX library on M0 MCU for LSM9DS1. As result i read the rotation_9X structure and use yaw as heading for compass result. The result showing the rotation but i see the offset on the Z axis of the gyro and the heading result changing according to this offset (i hold the PCB in one position but angle changing).

I was analyzing the library and found that the MotionFX implementation for M3 has an additional field: heading_9X. What is the difference between rotation and heading? If heading is the rotation around Z, why this field is an array?

Is it correct to use rotation9X as the compass output on the M0 implementation?

Thx

6 REPLIES 6
Miroslav BATEK
ST Employee

The rotation_9X is array of yaw, pitch and roll. Yaw is basically heading, so you can use it for compass.

The library should be able to compensate the gyroscope offset.

Did you perform the 8 shape movement with the board to calibrate the magnetometer?

Uncalibrated magnetometer could cause the issue.

drozel
Associate II

Hi, Miroslav,

i did, but i did't receive CAL_GOOD status, only CAL_OK. I cancel the calibration after 10 sec, period of the MagCal_run call is 100ms, so, i pass the magnetometer value 10*10 = 100 times.

I have one more question about the calibration library: MagCal_init(int, bool) - what is the second argument? Have i set it to 0 after the calibration? Must the mail library init function being called before the calibration?

Thank you!

Miroslav BATEK
ST Employee

Please try to draw calibrated magnetometer data in X-Y plot and check if it creates circles with center in [0,0] when you move with the board. If not the calibration is not well done. 10 second for calibration is, I think, not enough.

The second argument of the MagCal_init function enable/disable the calculation of the calibration parameters.

You can set is to 0 after the calibration is performed.

Yes, the MotionFX_CM0P_initialize must be called before MotionFX_CM0P_MagCal_init.

drozel
Associate II

Thanks, Miroslav,

i got it, it working with M0 version perfect.

Then i tried to make it working with the M4 version, it is little bit different, i took the default knob values from the example project and left the period as before - 10ms (update and propagate calls are being called together, decimation is 1) and it working worse than M4: heading has a drift ~0.5° per second and the north has an offset ~50° CW.

Could you please take some hints why can the M4 work worse than M0 and what is to be tuned?

Thanks.

Miroslav BATEK
ST Employee

I'm sorry for the late reply.

Did you successfully performed the magnetometer calibration also for the M4 version?

drozel
Associate II

Thank you, Miroslav, everything working perfect!

Many thanks for your help!