Digital pressure sensors hardware guidelines for system integration (24 pages)
Summary of Contents for ST X-CUBE-MEMS1
Page 1
UM2220 User manual Getting started with MotionFX sensor fusion library in X-CUBE-MEMS1 expansion for STM32Cube Introduction The MotionFX is a middleware library component of the X-CUBE-MEMS1 software and runs on STM32. It provides real-time motion-sensor data fusion. It also performs gyroscope bias and magnetometer hard iron calibration.
UM2220 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 UM2220 - Rev 7 page 2/24...
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.
UM2220 MotionFX library 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: the MotionFX_propagate is a prediction function used to estimate the orientation in 3D space;...
UM2220 MotionFX library Figure 1. Example of sensor orientations Cortex-M0+ Only the sensor orientation must be set using MotionFX_CM0P_setOrientation function. The parameters of this function are orientation strings which are composed in the same manner as for Cortex-M3, Cortex-M4 and Cortex-M7 (see above).
UM2220 MotionFX library • 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.
UM2220 MotionFX library The MotionFX library magnetometer calibration library compensates for hard-iron distortions. The magnetometer calibration can be performed at a slower frequency than the sensor fusion output data rate (e.g., 25 Hz). To run the calibration: initialize magnetometer calibration library (MotionFX_MagCal_init or MotionFX_CM0P_MagCal_init) call periodically calibration function (MotionFX_MagCal_run or MotionFX_CM0P_MagCal_run) until the calibration is successfully performed check if calibration was successful (MotionFX_MagCal_getParams or...
UM2220 MotionFX library 2.2.7 MotionFX APIs The MotionFX APIs are: • Cortex-M3, Cortex-M4 and Cortex-M7 – uint8_t MotionFX_GetLibVersion(char *version) ◦ retrieves the version of the library ◦ *version is a pointer to an array of 35 characters ◦ returns the number of characters in the version string –...
Page 9
UM2220 MotionFX library – void MotionFX_propagate(MFX_output_t *data_out, MFX_input_t *data_in, float *eml_deltatime) ◦ runs the Kalman filter propagate ◦ *data_out parameter is a pointer to output data structure ◦ *data_in parameter is a pointer to input data structure ◦ *eml_deltatime parameter is a pointer to delta time between two propagate calls [sec] –...
Page 10
UM2220 MotionFX library • Cortex-M0+ – uint8_t MotionFX_CM0P_GetLibVersion(char *version) ◦ retrieves the version of the library ◦ *version is a pointer to an array of 35 characters ◦ returns the number of characters in the version string – void MotionFX_CM0P_Initialize(void) ◦...
Page 11
UM2220 MotionFX library – void MotionFX_CM0P_update(MFX_CM0P_output_t *data_out, MFX_CM0P_input_t *data_in, float deltatime) ◦ runs the sensor fusion algorithm ◦ *data_out parameter is a pointer to output data structure ◦ *data_in parameter is a pointer to input data structure ◦ deltatime parameter is a delta time between two propagate calls [sec] –...
UM2220 MotionFX library 2.2.8 API flow chart Figure 3. MotionFX API logic sequence Start Initialize GetLibVersion getKnobs/setKnobs MagCal_Init Wait Expiring Timer Data Read Interrupt Read Acc+Gyr+Mag Data MagCal_run / MagCal_getParams Propagate Update Get MotionFX Outputs 2.2.9 Demo code The following demonstration code reads data from the accelerometer, gyroscope and magnetometer sensors and gets the rotation, quaternions, gravity and linear acceleration.
Page 13
UM2220 MotionFX library #define MFX_STR_LENG 35 #define ENABLE_6X 1 float LastTime; […] /*** Initialization ***/ char lib_version[MFX_STR_LENG]; MFX_knobs_t iKnobs; /* Sensor Fusion API initialization function */ MotionFX_initialize(); /* Optional: Get version */ MotionFX_GetLibVersion(lib_version); MotionFX_getKnobs(&iKnobs); /* Modify knobs settings & set the knobs */ MotionFX_setKnobs(&iKnobs);...
2.3.1 Unicleo-GUI application The sample application uses the Windows Unicleo-GUI utility, which can be downloaded from www.st.com. Step 1. Ensure that the necessary drivers are installed and the STM32 Nucleo board with appropriate expansion board is connected to the PC.
UM2220 Sample application Step 2. Launch the Unicleo-GUI application to open the main application window. If an STM32 Nucleo board with supported firmware is connected to the PC, it is automatically detected and the appropriate COM port is opened. Figure 5. Unicleo main window Step 3.
UM2220 Sample application Step 4. Click on the Fusion icon in the vertical toolbar to open the dedicated application window. To switch between 9-axes and 6-axes sensor fusion click on the appropriate button. To align the tea pot position point the Nucleo board towards the screen and press Reset model button. Figure 7.
Datalog window 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 board UM2128: Getting started with Unicleo-GUI for motion MEMS and environmental sensor software expansion...
Acronyms and abbreviations ............2 MotionFX middleware library in X-CUBE-MEMS1 software expansion for STM32Cube .
Page 22
UM2220 List of tables List of tables Table 1. List of acronyms ..............2 Table 2.
Page 23
UM2220 List of figures List of figures Figure 1. Example of sensor orientations ............5 Figure 2.
Page 24
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’...
Need help?
Do you have a question about the X-CUBE-MEMS1 and is the answer not in the manual?
Questions and answers