cancel
Showing results for 
Search instead for 
Did you mean: 

Strange yaw behavior in using MotionFx Library?

MChen.10
Associate II

I am trying to feed the sensor readings (gyro in dps and acceleration in G) to the MotionFx library, correctly specify the orientation (verified by ST local FAE) for 6X calculation.

At beginning I put the PCB on table, after power on and initialization/calibration, when I rotate the PCB around the roll axis (pure roll) by 45 degrees I can see both roll and yaw output change (roll angle is about 45 deg and yaw may be 30 deg).

This situation won't happen when I use the Madgwick filter with same sensor readings and procedure, is this behavior correct for MotionFx library or anything I missed?

14 REPLIES 14

I use 2.4.1, the difference is only in the compiler which was used for generation of the library.

I don't think it is the root cause of your problem, but you can try it.

 Where did you get the attitude values in your log? Is it the rotation_6X output of the library.

Yes I dump those data from element 6X in Mfx_dout which is the output of MotionFx library, normally I dump them every one second to prevent UART from buffer overrun.

dMsgLen = sprintf( (char *)dMsg, ">> Gravity: [0]=%6.5f [1]=%6.5f [2]=%6.5f\r\n",

           Mfx_dout.gravity_6X[0],

           Mfx_dout.gravity_6X[1],

           Mfx_dout.gravity_6X[2]);

 if (dMsgLen > 0) { USART1_Send( dMsg, dMsgLen ); }

 // float rotation_6X[MFX_NUM_AXES];/* 6 axes yaw, pitch and roll */

 dMsgLen = sprintf( (char *)dMsg, ">> Att: [0]=%8.5f [1]=%8.5f [2]=%8.5f\r\n",

           Mfx_dout.rotation_6X[0],

           Mfx_dout.rotation_6X[1],

           Mfx_dout.rotation_6X[2]);

 if (dMsgLen > 0) { USART1_Send( dMsg, dMsgLen ); }

 dMsgLen = sprintf( (char *)dMsg, ">> Q: [0]=%6.5f [1]=%6.5f [2]=%6.5f [3]=%6.5f\r\n\r\n",

           Mfx_dout.quaternion_6X[0],

           Mfx_dout.quaternion_6X[1],

           Mfx_dout.quaternion_6X[2],

           Mfx_dout.quaternion_6X[3] );

 if (dMsgLen > 0) { USART1_Send( dMsg, dMsgLen ); }

OK, understood.

Please double check your code, what I have seen seams to be fine, but I might miss something. It is also difficult to check it if I can't see the whole project. But so far we have confirmed the data coming from the sensor are OK and they correspond with the movement you did. The knobs settings seems to me OK as well. I'm not sure about the dT.

Btw which MCU do you use and what IDE?

MCU is STM32F401 and IDE is the uVision V5.30.0.0