
•
heading_6/9X
represents the heading of the device in degrees. Heading 0 degree represents the
magnetic North direction for 9-axis sensor fusion, while, for 6-axis sensor fusion, it represents heading of
device at the algorithm start.
•
headingErr_6/9X
represents the heading error of the device in degrees.
2.2.5
MotionFX library output data rate
It is important to set up the sensor fusion library output data rate properly; 100 Hz is recommended.
The output data rate for:
•
the gyroscope and the accelerometer should be equal to or greater than 100 Hz;
•
the magnetometer can be lower - 20/40 Hz is typically good for a magnetic field sensor.
Cortex-M3, Cortex-M4 and Cortex-M7
It is possible to scale the library system requirements in terms of MCU/MPU load. As the
MotionFX_update
function requires approximately three times more computation power than the
MotionFX_propagate
function, it
can be called at a lower frequency than the library output data rate if the system resources are limited (e.g., in
embedded systems).
Use the
modx
parameter in
MFX_knobs_t
structure to decrease the frequency of
MotionFX_update
function
calls. For example, setting
modx
to 2 calls the
MotionFX_update
function once every two
MotionFX_propagate
function calls.
The recommended settings are:
•
modx
= 1, for tablets or other systems with MCU/MPU and for STM32F4;
•
modx
= 2, for STM32F1.
2.2.6
Sensor calibration in the MotionFX library
Gyroscope and accelerometer calibration
Accelerometer calibration is not necessary for sensor fusion except for applications demanding very high
orientation precision; it involves aligning the system in several positions according to the gravity direction.
Gyroscope calibration is handled automatically by the MotionFX library by continuously compensating the zero-
rate offset effect.
Magnetometer calibration
The MotionFX library contains routines for magnetometer hard iron calibration.
The magnetometer is affected by the hard-iron and soft-iron phenomena described below.
Hard-iron distortion
Hard-iron distortion is normally generated by ferromagnetic material with permanent magnetic fields that are part
of the object (e.g., a tablet) in use. These materials can be permanent magnets or magnetized iron or steel. They
are time invariant and deform the local geomagnetic field with different offsets in different directions.
As each board can be magnetized differently, the hard iron effect is specific to the individual board.
If you move the board around a space approximating (as much as possible) a 3D sphere in an ideal environment
(no hard-iron/soft-iron distortion) and plot the collected magnetic sensor raw data, the result is a perfect sphere
with no offset.
The hard-iron distortion effect offsets the sphere along the x, y and z axes; in the x-y plane, the hard-iron
distortion is identified by an offset of the origin of the ideal circle from (0, 0), scatter plots for XY and XZ axes are
sufficient to determine if there is an offset.
Soft-iron distortion
Soft-iron distortion is generated by magnetically soft materials or current carrying PCB traces. While hard-iron
distortion is constant regardless of the orientation, the soft-iron distortion changes with the orientation of the
object in the Earth’s field (soft magnetic materials change their magnetization direction).
The local geomagnetic field is deformed with different gain on different directions. The effect of the soft-iron to
distort the ideal full round sphere into a tilted ellipsoid; in the x-y plane, the soft-iron distortion is identified by a
tilted ellipse with the origin at (0,0) for the XY axis (XZ).
The soft iron effect is the same across all boards of the same design, which is why a good PCB design which
takes magnetometer placement (high current traces/other component clearance) into account can generally avoid
any soft iron effects (valid for X-NUCLEO-IKS01A2 expansion board).
Calibration procedure
UM2220
MotionFX library
UM2220
-
Rev 7
page 6/24