Advertisement

Quick Links

UM2277
User manual
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
www.st.com
For further information contact your local STMicroelectronics sales office.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the MotionTL and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Summary of Contents for ST MotionTL

  • Page 1 UM2277 User manual 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.
  • Page 2: Acronyms And Abbreviations

    UM2277 Acronyms and abbreviations Acronyms and abbreviations Table 1. List of acronyms Acronym Description Application programming interface Board support package Graphical user interface Hardware abstraction layer Integrated development environment UM2277 - Rev 8 page 2/20...
  • Page 3: Motiontl Middleware Library In X-Cube-Mems1 Software Expansion For Stm32Cube

    NUCLEO-L152RE NUCLEO-L073RZ development board. MotionTL 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.1 MotionTL library description The MotionTL pedometer library manages the data acquired from the accelerometer; it features: •...
  • Page 4 UM2277 MotionTL library 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.
  • Page 5 UM2277 MotionTL library • uint8_t MotionTL_GetLibVersion(char *version) – retrieves the library version – *version is a pointer to an array of 35 characters – returns the number of characters in the version string • void MotionTL_CalibratePosition(float cal_data[][3], uint32_t num_records, MTL_cal_position_t cal_position) –...
  • Page 6: Orientation

    2.2.3 Orientation 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.
  • Page 7: Table 2. Pitch, Roll And Gravity Inclination Output Angles

    UM2277 MotionTL library Table 2. Pitch, Roll and Gravity Inclination output angles Value Pitch Roll Gravity Inclination Formula arctan2 (-Y/Z) arcsin (X) arccos (Z) Range -180°, +180° -90°, +90° 0, 180° Angle between Y axis and horizontal Angle between X axis and horizontal...
  • Page 8: Api Flow Chart

    UM2277 MotionTL library 2.2.4 API flow chart Figure 3. MotionTL API logic sequence (main program) Start Initialize GetLibVersion Wait Expiring Timer Data Read Interrupt Read Accelerometer Data Update Get Angles Figure 4. MotionTL API logic sequence (calibration) If calibration command received Collect calibration data Calculate calib.
  • Page 9: Demo Code

    UM2277 MotionTL library 2.2.5 Demo code The following demonstration code reads data from the accelerometer sensor and gets the tilt angles. […] #define VERSION_STR_LENG […] /*** Initialization ***/ char lib_version[VERSION_STR_LENG]; char acc_orientation[3]; acc_orientation[0] = 'n'; acc_orientation[1] = 'w'; acc_orientation[2] = 'u';...
  • Page 10: Sample Application

    8.32.3 1719 1744 1727 2607 2619 Sample application The MotionTL middleware can be easily manipulated to build user applications; a sample application is provided in the Application folder. It is designed to run on a NUCLEO-F401RE, NUCLEO-L476RG, NUCLEO-L152RE NUCLEO-L073RZ development board connected to an X-NUCLEO-IKS01A2,...
  • Page 11: Figure 6. User Messages Tab

    UM2277 Unicleo-GUI application Step 3. Start and stop data streaming by using the appropriate buttons on the vertical tool bar. The data coming from the connected sensor can be viewed in the User Messages tab. Figure 6. User Messages tab UM2277 - Rev 8 page 11/20...
  • Page 12 UM2277 Unicleo-GUI application Step 4. Click on the Motion Tilt icon in the vertical tool bar to open the dedicated application window. Figure 7. Motion Tilt Sensing window 1 You can switch between two angle modes. In the first mode the Pitch, Roll and Gravity Inclination angles are displayed, in the second mode the Theta, Psi and Phi angles are displayed.
  • Page 13: Figure 7. Motion Tilt Sensing Window 1

    UM2277 Unicleo-GUI application Step 5. Click on the Tilt Calibration icon in the vertical toolbar to open the dedicated application window Figure 9. Motion Tilt calibration window 1 This window first shows currently used calibration values calculated and stored during the previous calibration or default values if the calibration has never been performed.
  • Page 14: Figure 11. Datalog Window

    UM2277 Unicleo-GUI application Figure 10. Motion Tilt calibration window 2 Step 6. Click on the Datalog icon in the vertical tool bar to open the datalog configuration window: you can select which sensor and activity data to save in files. You can start or stop saving by clicking on the corresponding button.
  • Page 15: References

    UM2277 References References All of the following resources are freely available on www.st.com. UM1859: Getting started with the X-CUBE-MEMS1 motion MEMS and environmental sensor software expansion for STM32Cube UM1724: STM32 Nucleo-64 boards (MB1136) UM2128: Getting started with Unicleo-GUI for motion MEMS and environmental sensor software expansion...
  • Page 16: Revision History

    Updated Table 4. Cortex -M4 and Cortex-M3: elapsed time (µs) algorithm and Table 5. Cortex -M0+: elapsed time (µs) algorithm. 21-Feb-2019 Added X-NUCLEO-IKS01A3 expansion board compatibility information. Updated Introduction, Section 1.1 MotionTL library description and Section 2.2.6 Algorithm performance. 25-Mar-2020 Added ARM Cortex-M7 architecture compatibility information.
  • Page 17: Table Of Contents

    MotionTL library description ........
  • Page 18 UM2277 List of tables List of tables Table 1. List of acronyms ..............2 Table 2.
  • Page 19 MotionTL API logic sequence (main program)........
  • Page 20 ST’s terms and conditions of sale in place at the time of order acknowledgement. Purchasers are solely responsible for the choice, selection, and use of ST products and ST assumes no liability for application assistance or the design of Purchasers’...

Table of Contents