Getting Started With Motiondi Dynamic Inclinometer Library in X-Cube-Mems1 Expansion For Stm32Cube
Getting Started With Motiondi Dynamic Inclinometer Library in X-Cube-Mems1 Expansion For Stm32Cube
User manual
Introduction
The MotionDI middleware library is part of the X-CUBE-MEMS1 software and runs on STM32. It provides real-time information
about device orientation, including tilt information, and can also perform accelerometer and gyroscope 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®-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 X-NUCLEO-IKS01A2 or X-NUCLEO-IKS01A3 expansion board
on a NUCLEO-F401RE, NUCLEO-L476RG or NUCLEO-L152RE development board.
Acronym Description
Accelerometer calibration
Accelerometer calibration can improve the accuracy of tilt angle and is recommended for applications which
demand a very accurate orientation. It aligns the system in six positions according to the gravity direction.
The accelerometer calibration can be configured to run one time since the calibration parameter drift is very low.
Calibration can be done by placing the device in 6 different directions with respect to gravity. For example, device
can be placed with ±X, ±Y, ±Z.
Gyroscope calibration
Gyroscope calibration is handled automatically by the MotionDI library by continuously compensating the zero-
rate offset effect.
Start
Initialize
GetLibVersion
getKnobs/setKnobs
SetAcc/GyrCalParam(optional)
MotionDI_update
[…]
#define VERSION_STR_LENG 35
[…]
[…]
MotionDI_setKnobs(&iKnobs);
[…]
data_in.Timestamp = CurrentTime;
[…]
}
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.
Note: It is necessary to scroll the vertical tool bar using the mouse wheel or clicking on up/down arrows to see all
icons.
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.
Step 4. Click on the Dynamic Inclin. Model icon in the vertical toolbar to open the application window displaying
the vehicle model.
To align the vehicle model, point the STM32 Nucleo board towards the screen and press the Reset
model button.
Step 5. Click on the Dynamic Inclin. Tilt icon in the vertical toolbar to open the application window displaying
tilt.
Step 6. Click on the Rotation Vector icon in the vertical toolbar to open the application window displaying the
rotation vector graph.
Step 7. Click on the Cal. Values icon in the vertical toolbar to open the application window displaying
accelerometer and gyroscope calibration status.
To switch between calibration modes click on the appropriate button.
To reset calibration press the Reset button.
Step 8. Click on the Datalog icon in the vertical tool bar to open the datalog configuration window:
you can select the various data to be saved in files. You can start or stop saving by clicking on the
corresponding button.
Step 9. To process previously captured data, click on the Off-line Data Control icon in the vertical toolbar to
open the dedicated window. The data are processed by the MCU firmware.
Step 10. Click on the Open button to select the file with offline data in CSV format.
The data are loaded into the Offline Data tab.
Other buttons in the Off-line Data Control window become active. You can click on:
– Off-line Mode button to switch the offline mode of the firmware on/off .
– Start/Stop/Step/Repeat buttons to control the data feed from Unicleo-GUI to the firmware.
– Clear button to remove the data from Unicleo-GUI.
Note: You have to stop data streaming from real sensors by using the Stop button on the top vertical tool bar to switch
to offline mode.
3 References
Revision history
Contents
1 Acronyms and abbreviations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 MotionDI middleware library in X-CUBE-MEMS1 software expansion for STM32Cube
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
2.1 MotionDI overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2 MotionDI library . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.2.1 MotionDI library description. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
3 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .15
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
List of tables
Table 1. List of acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
Table 2. Cortex-M3: elapsed time (µs) algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
Table 3. Cortex-M4: elapsed time (µs) algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 4. Cortex-M7: elapsed time (µs) algorithm. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Table 5. Document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
List of figures
Figure 1. Example of sensor orientations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Figure 2. MotionDI API logic sequence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Figure 3. Unicleo main window. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 4. User Messages tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Figure 5. Dynamic Inclinometer Model window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Figure 6. Dynamic Inclinometer Tilt window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 7. Rotation Vector window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Figure 8. Calibration Values window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 9. Datalog window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 10. Off-line Data Control window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Figure 11. Off-line Data tab . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
Figure 12. Off-line Data Control window - offline mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14