2 MotionFX middleware library in X-CUBE-MEMS1 software
expansion for STM32Cube
2.1 MotionFX overview
The MotionFX library expands the functionality of the X-CUBE-MEMS1
software.
The library acquires data from the accelerometer, gyroscope (6-axis fusion) and magnetometer (9-axis fusion)
and provides real-time motion-sensor data fusion.
The MotionFX filtering and predictive software uses advanced algorithms to intelligently integrate outputs from
multiple MEMS sensors, regardless of environmental conditions, for an optimum performance.
The library is designed for ST MEMS only. Functionality and performance when using other MEMS sensors are
not analyzed and can be significantly different from what described in the document.
The complexity of the library dedicated to the Cortex-M0+ core is reduced due to the performance limitation of
Cortex-M0+ architecture. This library uses different APIs and has less features in comparison with the version for
Cortex-M3, Cortex-M4 and Cortex-M7 (for further details, see the following chapters).
A sample implementation is available on X-NUCLEO-IKS01A2 and X-NUCLEO-IKS01A3 expansion board,
mounted on a NUCLEO-F401RE, NUCLEO-L476RG, NUCLEO-L152RE or NUCLEO-L073RZ development
board.
2.2 MotionFX library
Technical information fully describing the functions and parameters of the MotionFX APIs can be found in the
MotionFX_Package.chm compiled HTML file located in the Documentation folder
.
2.2.1 MotionFX library description
The MotionFX sensor fusion library manages data acquired from accelerometer, gyroscope and magnetometer
sensor; it features:
•
real-time 9-axis motion-sensor data fusion (accelerometer, gyroscope, magnetometer)
• real-time 6-axis motion-sensor data fusion (accelerometer, gyroscope)
• computation of rotation, quaternions, gravity and linear acceleration data
• gyroscope bias calibration
• magnetometer hard iron calibration
• recommended sensor data sampling frequency of 100 Hz
• resources requirements:
– Cortex-M0+: 15.8 kB of code and 2.1 kB of data memory
– Cortex-M3: 53.8 kB of code and 7.9 kB of data memory
– Cortex-M4: 48.8 kB of code and 7.9 kB of data memory
– Cortex-M7: 46.8 kB of code and 7.9 kB of data memory
• available for ARM Cortex-M0+, Cortex-M3, Cortex-M4 and Cortex-M7 architecture
2.2.2 MotionFX 6-axis and 9-axis sensor fusion modes
The MotionFX library implements a sensor fusion algorithm for the estimation of 3D orientation in space. It uses a
digital filter based on the Kalman theory to fuse data from several sensors and compensate for limitations of
single sensors. For instance, gyroscope data can drift and this impacts the orientation estimation; this issue can
be fixed by using the magnetometer to provide absolute orientation information.
Similarly
, the magnetometer does not have a very high bandwidth and suffers from magnetic disturbance, but
these weaknesses can be compensated with a gyroscope.
9-axis sensor fusion uses data from the accelerometer, gyroscope and magnetometer and provides absolute
orientation in 3D space including heading (i.e., the magnetic North direction).
6-axis sensor fusion uses the accelerometer and gyroscope data only. It has lower computational requirements,
but does not provide information about the device absolute orientation.
6-axis sensor fusion is fit for fast movements (e.g., for gaming) and when absolute orientation is not necessary.
UM2220
MotionFX middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
UM2220 - Rev 7
page 3/24