cancel
Showing results for 
Search instead for 
Did you mean: 

How the edge features of LSM6DSV16X augment your smart applications

Denise SANFILIPPO
ST Employee

Summary

In this knowledge article we show how you can use the edge functionalities of the LSM6DSV16X leveraging our Unico-GUI software tool to obtain the following sequence: smart wake up, device adaptive self-configuration and the spatial motion tracking, footstep tracking and gym activity recognition.

1. Prerequisites

1.1 Software

The software tool that we use in this knowledge article is Unico-GUI.  Unico-GUI is a graphical user interface that supports a wide range of sensors and allows the evaluation of edge features of the LSM6DSV16X.

1.2 Hardware

The STEVAL-MKI109V3 is used to configure MEMS sensors and evaluate sensor outputs. Moreover, it has some advanced features for instance:

  • Programmable voltage power supply 
  • Current consumption measurement
  • Communication protocol that can be changed between SPI and I²C

The STEVAL-MKI109V3 can be used with different DIL24 adapter boards. Here we are going to use the STEVAL-MKI227KA, which is the DIL24 adapter board for LSM6DSV16X, the IMU to make any device smarter for any application.

1.3 Scope of the article

The scope of this knowledge article is to show the ASC usage advantage when more edge-embedded features need to be triggered. This includes sensor fusion low power (SFLP), the machine learning core (MLC), and the pedometer 2.0.
                                                               

Hands-on flowHands-on flow

 

 

2. Hands-on

The first step is to start configuring the MLC to run a gym activity recognition algorithm available on the ST GitHub repository.

Visit the ST GitHub repository related to the machine learning core application and configuration examples, available for many MEMS sensors.

Select the LSM6DSV16X device and download the

lsm6dsv16x_gym_activity_recognition_right.ucf file related to the gym activity recognition algorithm.

The details about the algorithm and the required sensor orientation are indicated in the readme file. For this specific case, the gym activity recognition algorithm built for the right-wrist device is used.

After opening Unico-GUI, select the device LSM6DSV16X with its adapter board, the STEVAL-MKI227KA.

 

Unico-GUIUnico-GUI

 

When pressing the “Select Device” button, it is possible to see on the left-hand side all edge functionalities of the device: FSM, MLC, pedometer, sensor fusion, Qvar.

Unico-GUI menu: explore all edge functionalities of the deviceUnico-GUI menu: explore all edge functionalities of the device

 

Clicking on the Start button on the top bar we are enabling communication between the STEVAL-MKI109V3 with the STEVAL-MKI227KA and our PC.

Unico-GUI: Start buttonUnico-GUI: Start button

 

Select the Load/Save tab. Click on the load button and select the downloaded .ucf file. In this example, we are using this file.

 

Unico-GUI: Click on the load button and select the downloaded .ucf fileUnico-GUI: Click on the load button and select the downloaded .ucf file

 

The sensor orientation for this algorithm is ENU

  • X parallel to the arm (directed towards the hand for left wrist, directed away from the hand for right wrist)
  • Y perpendicular to the arm (directed away from the user when looking at the device)
  • Z pointing up

Four features have been used (mean, peak-to-peak, min, max). One low-pass filter (IIR1) has been applied to the accelerometer input data. The MLC runs at 30 Hz, computing features on windows of 90 samples (corresponding to 3 seconds). One decision tree with around 30 nodes has been configured to detect the different classes. A metaclassifier has not been used.

  • MLC1_SRC (70 h) register values:
    • 0 = No activity
    • 4 = Bicep curls
    • 8 = Lateral raises
    • 12 = Squats

Now, click on the Sensor Fusion tool and then on the “Enable Sensor Fusion” button.

 

Unico-GUI: Enable Sensor FusionUnico-GUI: Enable Sensor Fusion

 

Data coming from the sensor in real time are now streaming and it is possible to see many graphs.
We can see the accelerometer plot (in the upper left side) and the gyroscope raw data plot (in the upper right side).

The gravity vector and the gyroscope bias are plotted in the middle:

  • The plot on the left side represents the gravity projection along the 3-axes of the device: it is computed by fusing the accelerometer and gyroscope data. This generates an acceleration signal that is not affected by linear accelerations, which is a mandatory requirement in tracking applications.
  • The plot on the right side shows the computed gyroscope bias, which is subtracted by the gyroscope signal to avoid gyroscope drift in time.

The quaternion data is displayed at the bottom. Data can be converted in the roll, pitch, and yaw angles representing the absolute orientation of the device in space.

By clicking on the 3D model tab, it is possible to see a teapot moving in real-time.

 

Unico-GUI: Sensor Fusion - 3D modelUnico-GUI: Sensor Fusion - 3D model

 

Finally, enable the pedometer 2.0 by setting the PEDO_EN bit available in the EMB_FUNC_EN_A register. To do that, go to the "Embedded Reg 1" tab and manually write the value 0A in register 04. The pedometer counts the steps very precisely.

 

Unico-GUI: PedometerUnico-GUI: Pedometer

 

 

The current power consumption of this configuration is around 700 µA.

 

Current power consumption of this specific configurationCurrent power consumption of this specific configuration

 

 

The ASC feature is now used to optimize the current consumption.

During movements, the accelerometer and gyroscopes are configured at 120 Hz in high-performance mode. During this condition, the MLC, the pedometer 2.0, and the SFLP are fully functional. The sensor provides gym activity recognition output, the number of steps and the orientation of the device.

After 5 seconds of stationarity, the gyroscope is turned off and the accelerometer is configured in low-power mode.

Some SETR commands are added to disable the MLC and the pedometer 2.0 during the stationarity, and to enable them after a wake-up is detected. The output of the MLC, the pedometer 2.0 and the SFLP are not affected by the change of the sensor power mode and the algorithms enable/disable state.

3. Finite state machine flow

The flow below is implemented leveraging the finite state machine (FSM).

 

Hands-on flowHands-on flow

 

After clicking on the FSM button, the FSM screen will open:

Unico-GUI: FSM windowUnico-GUI: FSM window

 

The first step is to align the FSM ODR to the sensors ODR, which is 120 Hz.

 

The FSM ODR is aligned to the sensors ODR (120 Hz)The FSM ODR is aligned to the sensors ODR (120 Hz)

 

4. Building the program

Now, we can start building the program. Since the device starts in a wake state, where the accelerometer and gyroscopes are in high-performance mode, we need the device to enter in a sleep state. This means that only the accelerometer is kept on in low-power mode. The sleep state is enabled when the device is kept stationary for a while, for example 5 seconds.

To enter the sleep state, the first instruction of the FSM is a GNTH1 | TI1 condition. The configured threshold is 1.1 g applied on the accelerometer norm signal. The timer is 600 samples (which means 5 seconds at 120 Hz). Refer to the application note AN5882 to get more details about the FSM conditions.

The next instruction will be reached when the device is stationary for 5 seconds. When it happens, we want to turn off the gyroscope and to set the accelerometer in low-power mode. For this purpose, two consecutive SETR commands are issued, one for changing the accelerometer power mode, and one for turning off the gyroscope.

Unico-GUI: FSM - two SETR commands to change the accelerometer power mode and to turn off the gyroscopeUnico-GUI: FSM - two SETR commands to change the accelerometer power mode and to turn off the gyroscope

A SETR command is used to disable the pedometer 2.0 during the stationarity. The SETR command in this case takes as first argument the byte 01, which means register embedded function enable A. As the second argument, the byte 02, which means that the pedometer 2.0 is disabled while the SFLP is kept on.

 

Unico-GUI: FSM - SETR command to disable the pedometer 2.0 during the stationarityUnico-GUI: FSM - SETR command to disable the pedometer 2.0 during the stationarity

 

 A SETR command is used to disable the MLC during the stationarity. In this case the SETR command takes as the first argument the byte 02, which means register embedded function enable B. As the second argument is the byte 01, which means that the MLC is disabled while the FSM is kept on.

 

Unico-GUI: FSM - SETR command to disable the MLC during the stationarity.Unico-GUI: FSM - SETR command to disable the MLC during the stationarity.

 

A SETR command is used to enable the pedometer 2.0 after the smart wake up is detected. In this case, the SETR command takes as first argument the byte 01, which means register embedded function enable A. As the second argument is the byte 0A, which means that the pedometer 2.0 is enabled together with the SFLP.

Unico-GUI: FSM - a SETR command to enable the pedometer 2.0 after the smart wake up is detectedUnico-GUI: FSM - a SETR command to enable the pedometer 2.0 after the smart wake up is detected

 

 A SETR command is used to enable the MLC after the smart wake up is detected. In this case, the SETR command takes as first argument the byte 02, which means register embedded function enable B. As the second argument is the byte 11, which means that the MLC is enabled together with the FSM.

Unico-GUI: FSM - SETR command to enable the MLC after the smart wake up is detectedUnico-GUI: FSM - SETR command to enable the MLC after the smart wake up is detected

 

To allow the FSM to write the device registers using SETR commands (meaning to enable the ASC feature), set the FSM_WR_CTRL_EN bit available in the FUNC_CFG_ACCESS register. Go to the "Registers" tab to set manually this bit to 1.

Unico-GUI: Enable the ASC featureUnico-GUI: Enable the ASC feature

 

Open the "Fusion" tab again and the "Advanced Features" tab. During movement, we can see that the current consumption of the device is the same as before. But, when the board is stationary for more than 5 seconds, the current consumption drops significantly from almost 700 µA when moving, to 70 µA when stationary.

 

The current consumption drops significantly to almost 700 µA when movingThe current consumption drops significantly to almost 700 µA when moving

 

 

The current consumption drops significantly to 70 µA when stationaryThe current consumption drops significantly to 70 µA when stationary

 

What is outlined in this article can of course be extended or adapted depending on the final application and requirements.

Conclusion

We have seen how it is possible to use the in-the-edge features of the LSM6DSV16X to quickly develop your application flow consisting in:

  • smart wake up
  • device reconfiguration
  • triggering of sensor fusion low power (SFLP), the machine learning core (MLC) and the pedometer 2.0

The output of the MLC, the pedometer 2.0 and the SFLP are not affected by the change of the sensors power mode and the algorithm enable/disable state.

Relevant links

Application note:  AN5882 - LSM6DSV16X: finite state machine

You can find a dedicated webinar on the topic at this link:
Anyone can build smarter applications with this intelligent IMU

You may also be interested in reading the following knowledge article:
How to use a six-axis MEMS device and build applications while processing in-the-edge

STMEMS Machine Learning Core GitHub 

Version history
Last update:
‎2023-12-05 01:58 AM
Updated by:
Contributors