cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect the tilt angle of a device with ProfiMEMS tool, IIS2ICLX MLC and Unico

Eleon BORLINI
ST Employee
This article describes how to configure the Machine Learning Core (MLC) on IIS2ICLX to implement the detection of the tilt angle, i.e. the current inclination of the device, in the range of -20 to +20 degrees. The hardware used is the ProfiMEMS with IIS2ICLX adapter (STEVAL-MKI209V1K), and the MLC outputs are visualized using Unico GUI.

Table of the contents
 

  1. ​​​​Why it is important to accurately measure the tilt angle of an object?
  2. Problem Scenario
  3. Sensor Configuration
  4. Data Collection
  5. Algorithm Configuration
  6. Data visualization with Unico GUI
 

Why it is important to accurately measure the tilt angle of an object


A precise measure of the tilt angle (inclination) of an object or a structure is an application of increasingly importance, especially in the field of the industrial and structural predictive maintenance (IIoT) and in the monitoring of the good status of an asset. The continuous and real time monitoring of the infrastructures is important to prevent serious damages to people and objects. The IIS2ICLX smart inclinometer (high precision and low power bi-axial accelerometer) is the ideal sensor for this purpose, since it combines the precision of an inclinometer and the digital cores of a smart sensor.
 

Problem scenario


In this article, the general purpose reference design STEVAL-MKI109V3 (ProfiMEMS tool) together with the IIS2ICLX inclinometer STEVAL-MKI209V1K adapter and Unico-GUI interface has been used both for the data acquisition and the machine learning phase.

This MLC example implements the detection of the tilt angle, i.e. the current inclination of the device, in the range of -20 to +20 degrees.
Two decision trees with 255 nodes configured to detect different classes are generated- to detect the angle between the x-axis (1st decision tree) and the y-axis (2nd decision tree) and the horizontal plan.


The output can be read from the MLC0_SRC and MLC1_SRC registers and is expressed as a 8-bit value in two’s complement. The tilt angle in degrees is obtained by multiplying the output by a sensitivity of 0.15748 degrees/LSB.
For a detailed description of the configuration of the sensor involved and of the two decision trees, please refer to the Github documentation: LINK
 

Sensor Configuration

 

Using Unico GUI, the accelerometer is configured with ±0.5 g full scale and 26 Hz output data rate. The reference position, when both detected tilt angles are 0 degrees, is when the x-y plane of the sensor is orthogonal to the gravity vector.
794.png

Note: the angle is measured between a sensing axis and a line formed by the intersection of the horizontal plane and the vertical plane where the sensing axis lies. Generally, the two vertical planes where the sensing axes lie are not orthogonal to each other, which is not in accordance to aeronautical nomenclature. Therefore, in applications that should meet the aeronautical definition of the roll angle, the tilt must always be applied to only one axis, while the other axis is maintained perpendicular to the gravity vector. Any tilt on the other axis reduces the magnitude of the acceleration (due to gravity) on the sensing axis, resulting in an error in the angle computation.
 

Data Collection

 

After the sensor has been configured, data can be acquired directly using Unico GUI, labelling the datalog in the proper way. 
As important note, typical sensor errors (such as zero-g offset, sensitivity error, etc.) are not taken into account here. If a more accurate measurement is required, a calibration must be performed and then projected into the calculated threshold levels (then a program adjustment is required).
Referring to the AN5536 application note:
795.png
 

Algorithm configuration

 

A 2nd order low-pass IIR filter with cutoff frequency of 5 Hz and gain = 1 (for ODR = 26 Hz) is configured to filter the accelerometer data. Two features have been used for building the decision tree: the mean of the x-axis and the mean of the y-axis of the filtered accelerometer data. The MLC runs at 26 Hz, computing features on windows of 1 sample (corresponding to 38.5 milliseconds), in order to ensure maximum responsiveness. As anticipated before, two decision trees with 255 nodes were configured to detect different classes. Each class represents a tilt angle in the given range. Meta-classifiers are not used. In order to build the decision trees, Weka tool can be used (LINK), or with a dedicated built-in program (LINK).
 

  • Decision tree 1: Output values correspond to the angle between the x-axis and the horizontal plane.
  • Decision tree 2: Output values correspond to the angle between the y-axis and the horizontal plane.

The output value is expressed as an 8-bit value in two’s complement corresponding to the tilt angle in the range of -20 to +20 degrees. The output is saturated (on the maximum value), when the actual tilt angle is outside the given tilt range. The tilt angle in degrees can be obtained by multiplying the output by a sensitivity of 0.15748 degrees/LSB. The configuration generates an interrupt (pulsed and active-high) on the INT1 pin every time the register MLC0_SRC (70h) is updated with a new value. The duration of the interrupt pulse is 38.5 ms in this configuration.
More details about can be found here --> LINK
 

Data visualization with the Unico GUI

 

The easiest way to evaluate the results is using the ProfiMEMSTool with the STEVAL-MKI209V1K and Unico GUI. Run Unico GUI and connect the ProfiMEMSTool with inserted STEVAL-MKI209V1K board to the PC by using a micro USB cable. Select IIS2ICLX from the list of Device Names, keep the "Communication with the motherboard [Enabled]" option box checked and click the Select Device button. Go to the Load/Save tab, click the Load button, browse for the generated UCF file and then click the Open button. Wait until the file is Loaded, click the Start button and open the Data window by clicking the Data button from the option panel on the left side. 

796.png

The MLC output value is expressed as an 8-bit value in two’s complement and must be multiplied by the angular sensitivity mentioned in the output of the iis2iclx_tilt_angle_DT_generator.exe program (default is 0.15748 deg/LSB).

For example, in the figure above, text box 1 shows a value of 36 and text box 2 shows a value of 107. These values correspond to an inclination in the x and y axes. The values are represented as a two’s complement number, from which it can be determined that both are positive numbers. Therefore, they can be directly converted to the inclination angle value in degrees by multiplying them by the angular sensitivity:

36 * 0.15748 = 5.67 degrees
107 * 0.15748 = 16.85 degrees
 
Version history
Last update:
‎2022-03-11 06:29 AM
Updated by: