Getting started with MotionTL tilt measurement library in X-CUBE-MEMS1
expansion for STM32Cube
Introduction
The MotionTL middleware library is part of the X-CUBE-MEMS1 software and runs on STM32. It provides real-time information
about the tilt angles of the user device, i.e. cell phone. The library is also able to perform accelerometer 6-position calibration.
This library is intended to work with ST MEMS only.
The algorithm is provided in static library format and is designed to be used on STM32 microcontrollers based on the ARM
Cortex®-M0+, ARM® Cortex®-M3, ARM® Cortex®-M4 or ARM® Cortex®-M7 architecture.
It is built on top of STM32Cube software technology to ease portability across different STM32 microcontrollers.
The software comes with a sample implementation running on an X-NUCLEO-IKS01A2, X-NUCLEO-IKS01A3 or X-NUCLEO-
IKS02A1 expansion board on a NUCLEO-F401RE, NUCLEO-L476RG, NUCLEO-L152RE or NUCLEO-L073RZ development
board.
®
UM2277 - Rev 8 - April 2021
For further information contact your local STMicroelectronics sales office.
www.st.com
1Acronyms and abbreviations
Table 1. List of acronyms
AcronymDescription
APIApplication programming interface
BSPBoard support package
GUIGraphical user interface
HALHardware abstraction layer
IDEIntegrated development environment
UM2277
Acronyms and abbreviations
UM2277 - Rev 8
page 2/20
UM2277
MotionTL middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
2MotionTL middleware library in X-CUBE-MEMS1 software expansion
for STM32Cube
2.1MotionTL overview
The MotionTL library expands the functionality of the X-CUBE-MEMS1 software.
The library acquires data from the accelerometer and provides real-time tilt information with multi-mode support
for 3-axis accelerometer. This library is suitable for static inclinometer where system acceleration is negligible,
such as in industrial applications, leveling, satellite antennas, solar panels, and automotive.
The library is also able to perform accelerometer 6-position calibration.
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.
A sample implementation is available for X-NUCLEO-IKS01A2, X-NUCLEO-IKS01A3 and X-NUCLEO-IKS02A1
expansion boards, mounted on a NUCLEO-F401RE, NUCLEO-L476RG, NUCLEO-L152RE or NUCLEO-L073RZ
development board.
2.2MotionTL library
Technical information fully describing the functions and parameters of the MotionTL APIs can be found in the
MotionTL_Package.chm compiled HTML file located in the Documentation folder.
2.2.1MotionTL library description
The MotionTL pedometer library manages the data acquired from the accelerometer; it features:
•calculation of pitch, roll and gravity inclination angles (Pitch-Roll-Gravity-Inclination mode)
•calculation of theta, psi and phi tilt angles (Theta-Psi-Phi mode)
–performs MotionTL library initialization and setup of the internal mechanism
–the CRC module in STM32 microcontroller (in RCC peripheral clock enable register) has to be enabled
before using the library
•mcu_type is the type of MCU:
–MFX_CM0P_MCU_STM32 is a standard STM32 MCU
–MFX_CM0P_MCU_BLUE_NRG1 is BlueNRG-1
–MFX_CM0P_MCU_BLUE_NRG2 is BlueNRG-2
–MFX_CM0P_MCU_BLUE_NRG_LP is BlueNRG-LP
•*acc_orientation is the reference system of the accelerometer raw data
UM2277 - Rev 8
page 3/20
Note:This function must be called before using the tilt library.
•void MotionTL_SetKnobs(MTL_knobs_t *knobs)
–sets the knobs
–the parameters for the structure type MTL_knobs_t are:
◦fullscale is the full scale of accelerometer (in g). It is recommended to set full scale >1g for
the sensor. A lower full scale can be selected if the tilt variation is limited and higher resolution is
required for the application.
◦k is the filtering coefficient. The range of k is [0.1 to ODR]. The lower value of k increases the
filtering and removes the noise. For systems with high vibration, it is recommended to reduce the
value of k.
◦orn[3] is the accelerometer 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)
(see Figure 1). The orn is defined to bring the sensor into the X-NUCLEO-IKS01A3 frame.
◦mode is the operational mode where:
•MODE_PITCH_ROLL_GRAVITY_INCLINATION enables angle representation in Euler
angles (Roll, Pitch and Phi) form
•MODE_THETA_PSI_PHI enables angle computation of theta, psi and phi angle which
measure the angle individually on each axis
Note:The API can be called after MotionTL_Initialize() but before MotionTL_Update()
UM2277
MotionTL library
•void MotionTL_GetKnobs(MTL_knobs_t *knobs)
–gets the knobs setting
–for the parameters for the structure type MTL_knobs_t refer to the MotionTL_SetKnobs() function
–this function is used to set the accelerometer data orientation
–configuration is usually performed immediately after the MotionTL_Initialize () function call
–*acc_orientation parameter is a pointer to a string of three characters indicating the direction of
each of the positive orientations of the reference frame used for 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 (x-North,
y-West, z-Up), so the string is: “nwu”.
UM2277 - Rev 8
page 5/20
Figure 1. Example of sensor orientations
UM2277
MotionTL library
2.2.3Orientation
The MotionTL library works with ENU orientation system, which means device X axis going to East, Y axis going
to North, Z axis going Up.
Any sensor orientation is internally transformed into device ENU orientation system. For this reason the sensor
orientation must be defined using MotionTL_SetOrientation_Acc() function. All the outputs (angels) are
then calculated relative to the ENU orientation system.
Figure 2. Device ENU orientation system
UM2277 - Rev 8
The MotionTL library has different types of outputs angles as detailed in the following tables.
page 6/20
Loading...
+ 14 hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.