cancel
Showing results for 
Search instead for 
Did you mean: 

MotionFX Azimuth Detection Issues with ISM330DHCX - Seeking Configuration Guidance

mfo
Associate

Problem Summary

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.

Hardware Setup

  • Sensor: ISM330DHCX (accelerometer + gyroscope)
  • Orientation: WDS mounting (X-West, Y-Down, Z-South)
  • Sample Rate: 104Hz
  • Application: Rotational motion detection system that detects motion over longer periods in time. (No real time updates needed)

Current Configuration

MotionDI Parameters (working well for altitude):

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;

MotionFX Parameters (issues with azimuth):

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;

Observed Issues

1. Gyroscope Bias Drift

  • MotionDI: Shows significant X-axis bias drift (0-60+ dps over time)
  • MotionFX: Maintains stable bias (~-0.42 dps constant)
  • Question: Is this normal behavior, or should I adjust calibration parameters?

mfo_0-1753696764024.png

mfo_1-1753696784019.png

 

2. Angle Calculation Method

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. 

3. Temperature Influence

  • Temperature varies 33-35°C during operation
  • Correlation with bias drift observed (very minimal changes, but changes still)
  • Question: Should I implement temperature compensation? (Even though the ism has built-in compensation)

test_2_temperature.png

Analysis Results

From my data analysis:

  • Accelerometer magnitude stable around 1000mg (1g)
  • Gyroscope magnitude around 1.0-1.2 dps
  • MotionFX quaternion trajectory shows more circular pattern
  • MotionDI quaternion trajectory shows more linear segment\

test_2_quat_motionfx_analysis.png

test_2_quat_motionfx_analysis.png

Specific Questions

  1. Bias Calibration: Why does MotionDI show significant X-axis bias drift while MotionFX remains stable? Should I adjust gbias_gyro_th_sc parameter?

  2. 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.

  3. WDS Orientation: Are there specific considerations for WDS mounting that affect MotionFX performance?

  4. Library Parameters: Given my 104Hz sample rate and WDS orientation, are my current parameters optimal?

  5. Temperature Compensation: Should I implement additional temperature-based bias correction?

Expected Behavior

I need to detect:

  • Altitude changes: ±5° threshold (working with MotionDI)
  • Azimuth changes: ±10° threshold (struggling with MotionFX)

Code Initialization

// 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.

0 REPLIES 0