EasyManua.ls Logo

ST X-CUBE-MEMS1 - Motionfx Library Operation; Motionfx Library Parameters

ST X-CUBE-MEMS1
24 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
2.2.3 MotionFX library operation
The MotionFX library integrates 6- and 9-axis sensor fusion algorithms in one library; they can even run
simultaneously to provide both rotation vector (9X) and game rotation vector (6X).
Cortex-M3, Cortex-M4 and Cortex-M7
The library implements the following critical internal functions associated with sensor fusion computation:
1.
the MotionFX_propagate is a prediction function used to estimate the orientation in 3D space; gyroscope
data is given more weight in this phase.
2. the MotionFX_update is the corrective function which adjusts the predicted value when necessary;
accelerometer and magnetometer data are given more weight in this phase.
The MotionFX_update function can be called whenever the MotionFX_propagate is invoked, or less often in
systems that have less computation power.
The MotionFX_update function takes approximately three times more MCU computation time than the
MotionFX_propagate function.
Cortex-M0+
The sensor fusion computation is concentrated in only one function MotionFX_CM0P_update.
2.2.4 MotionFX library parameters
Cortex-M3, Cortex-M4 and Cortex-M7
The library is "parameterized" using an MFX_knobs_t structure.
The parameters for the structure are:
ATime, MTime, FrTime represent the weighting stability of sensors for prediction (trust factor), from 0 to 1.
Default values are recommended.
ATime: lowering the value will increase the accelerometer weight and sensitivity towards external
acceleration. If the application experiences low acceleration (<1g) most of time, it is recommended to
increase the value.
MTime, FrTime: for 9X solution, the lower value will increase the weight of magnetometer reading. If
the application experiences low magnetic interference (<50
μT) most of time, it is recommended to
increase the value.
LMode represents the gyroscope bias learning mode; the library automatically tracks and calibrates gyro
zero-rate bias drift.
This possible parameter values are:
LMode = 0 – learning off; use this mode if the gyro is already calibrated
LMode = 1 – static learning; learning is performed only when the system is not moving
LMode = 2 – dynamic learning; learning is also performed when the system is moving
gbias_acc/gyro/mag_th_sc_6X, gbias_acc/gyro/mag_th_sc_9X represent the thresholds below
which the gbias algorithm automatically starts. These values should be established through testing (they are
different for different part numbers). The values in the example project are usually correct. The value can be
determined by enabling start_automatic_gbias_calculation, placing the device stationary for 10
seconds and reading the value of knobs.
modx represents the decimation of MotionFX_update call frequency
output_type represents the sensor fusion library output orientation: 0 = NED, 1 = ENU
start_automatic_gbias_calculation: this flag allows computing gbias_acc/gyr/
mag_sens_th_sc_6X/9x for an application, by placing the device stationary for 10 seconds and
setting this flag to 1 by calling MotionFX_setKnobs API. After 10 seconds or more, call
MotionFX_getKnobs API to get the value of these thresholds.
acc/gyro/mag_orientation is the acc/gyro/mag data orientation string of three characters
indicating the direction of each positive orientation of the reference frame used for the accelerometer
data output, in the sequence x, y, z. Valid values are: n (north) or s (south), w (west) or e (east), u (up)
or d (down).
As shown in the figure below, the X-NUCLEO-IKS01A2 accelerometer sensor has an NWU orientation
(x - East, y - North, z - Up), so the string is: “nwu”.
UM2220
MotionFX library
UM2220 - Rev 7
page 4/24

Other manuals for ST X-CUBE-MEMS1

Related product manuals