2025-07-28 3:08 AM - edited 2025-07-28 3:15 AM
I'm experiencing challenges with MotionFX library for azimuth rotation detection using the ISM330DHCX sensor. While MotionDI works well for altitude detection, MotionFX shows inconsistent behavior for azimuth (rotational) measurements.
I have done a test where I have collected samples over the entire weekend (about 65 hours). I am aware of the difficulties in detecting rotational movement using only accelerometer and gyroscope, however, the issues below do not seem to stem from this, but rather with issues in the MotionFX library or parameters.
mdi.move_thresh_g = 0.25f; mdi.cal_type = 1; mdi.acc_thr_g = 0.01f; mdi.gyro_thr_dps = 0.01f; mdi.max_gyro_dps = 15.0f; mdi.gyro_cal_type = 2; mdi.sf_atime = 2.0f; mdi.sf_frtime = 2.0f; mdi.modx = 1; mdi.output_type = 1;
mfx.atime = 2.0f; mfx.mtime = 0.01f; // not used in 6X mode mfx.frtime = 2.0f; mfx.lmode = 1; // static learning - if we put this to 2, I see immediate drift/changes mfx.gbias_acc_th_sc = 0.00153f; // from library mfx.gbias_gyro_th_sc = 0.1f; // library had 0.004f mfx.modx = 1; // AN suggests setting it to 2, but this is causing issues as well (does this change the refresh rate?) mfx.output_type = 1;
Currently extracting angles from quaternion differences:
Quaternion relative = QuaternionMath::relativeRotation(current, reference); float roll, pitch, yaw; QuaternionMath::toEulerAngles(relative, roll, pitch, yaw); // Using pitch for altitude (MotionDI) altitude_angle = fabsf(pitch); // Using roll for azimuth (MotionFX) azimuth_angle = fabsf(roll); // This is the correct axis for what we are trying to detect.
From my data analysis:
Bias Calibration: Why does MotionDI show significant X-axis bias drift while MotionFX remains stable? Should I adjust gbias_gyro_th_sc parameter?
Azimuth vs Altitude: Is my approach of using MotionFX for azimuth and MotionDI for altitude detection appropriate, or should I use a single library? The reason I am using both libraries is because during initial testing, I found MotionDI to be way more reliable in altitude angle tracking than MotionFX, but MotionFX showed good results for altitude.
WDS Orientation: Are there specific considerations for WDS mounting that affect MotionFX performance?
Library Parameters: Given my 104Hz sample rate and WDS orientation, are my current parameters optimal?
Temperature Compensation: Should I implement additional temperature-based bias correction?
I need to detect:
// MotionFX initialization MotionFX_initialize(static_cast<MFXState_t>(_mfx_state_buffer)); MotionFX_getKnobs(static_cast<MFXState_t>(_mfx_state_buffer), &_mfx_knobs); // Set knobs... MotionFX_setKnobs(static_cast<MFXState_t>(_mfx_state_buffer), &_mfx_knobs); MotionFX_enable_6X(static_cast<MFXState_t>(_mfx_state_buffer), MFX_ENGINE_ENABLE);
If anyone would want to check out the full code, I can definitely share some snippets later on.
Any insights on proper MotionFX configuration for azimuth detection in this setup would be greatly appreciated!
ST Library Versions: Using latest MotionDI and MotionFX libraries from X-CUBE-MEMS1 package.