cancel
Showing results for 
Search instead for 
Did you mean: 

How to save power with LSM6DSV16X by leveraging on its adaptive self-configuration with MLC and FSM

Denise SANFILIPPO
ST Employee

Summary

The article introduces how to implement the adaptive self-configuration (ASC) function using the machine learning core (MLC) and finite state machine (FSM). The FSM automatically configures the sensor based on the detection of a specific motion pattern. It can also be based on the output of a specific decision tree configured in the machine learning core, without any intervention from an external controller. Automatic configuration optimizes the operating mode, range, and output frequency of the sensor. Combined with the MLC to determine the current state of the sensor, this feature reduces power consumption.

1. Demo functionality and definition

In this demonstration, we use the MLC to detect the status of the sensor. According to the output of the MLC, the FSM configures the sensor’s ODR, full-scale, and power mode. Detect three states of the sensor by configuring the MLC:
  • Status 0: STILL - the sensor is in a stationary state.
  • Status 4: SHAKING - the sensor is in a slightly shaking state.
  • Status 8: FASTMOVING - the sensor is in a state of significant motion.
  • Get the mlc.ucf file.
According to the status output by the MLC, the ASC configures the sensor in three operating modes:
  • STILL: XL ODR=30Hz,FS_XL=2g,gyroscope off, low-power mode.
  • SHAKING: XL ODR=120Hz,FS_XL=4g,gyroscope ODR=120Hz, FS_Gyro =125dps,high-performance mode.
  • FASTMOVING: XL ODR=480Hz,FS_XL=8g,gyroscope ODR=480Hz,FS_Gyro =4000dps,high-performance mode.
  • Get the fsm.ucf file.
Merge mlc.ucf + fsm.ucf = asc.ucf

2. Board and software setup

Hardware requirements:

The STEVAL-MKI109V3 professional evaluation board for MEMS sensors, referenced as ProfiMEMS in STMicroelectronics documentation. It is based on the STM32F401 microcontroller and features a DIL24 socket to plug in the daughterboard with the sensor under test to the motherboard. Check that the firmware is up to date (version 3.11.4 or later).

  • STEVAL-MKI227KA daughterboard with LSM6DSV16X IMU sensor (referenced as DIL24 adapter in STMicroelectronics documentation). It must be plugged into the ProfiMEMS motherboard.
  • Micro USB cable to connect the ProfiMEMS motherboard to the PC.

Software requirements:

  • STSW-MKI109W referenced as Unico-GUI, companion software to work with the ProfiMEMS motherboard. Check that your Unico-GUI version is up to date (version 9.14.6.0 has been used for this example).
  • Unico-GUI is used to make a configuration file of the MLC and ASC for LSM6DSV16X.
  1. Plug in the STEVAL-MKI227KA adapter to the ProfiMEMS motherboard and connect the motherboard to the PC using the micro-USB cable.
  2. Run Unico-GUI and select LSM6DSV16X from the iNEMO inertial modules list and confirm by pressing the select device button.

DeniseSANFILIPPO_0-1691486560344.png

3. Configuring the FSM

We use three-state machines.

  • State machine 1 is used to configure the ASC when the MLC outputs the STILL state.

  • State machine 2 is used to configure the ASC when the MLC outputs the SHAKING state.

  • State machine 3 is used to configure the ASC when the MLC outputs the FASTMOVING state.

State machine 1 configuration:

DeniseSANFILIPPO_1-1691486560354.png

  • S0 instruction is an RNC: NOP | CHKDT, configure the decision tree value to 0, used to check the MLC output value, if equal to 0, go to the next state.

  • S1 instruction is a CMD: SETR, used to enable the ASC feature.

  • S2 instruction is the device register address: 0x11, used to set the IMU CTRL2 register.

  • S3 instruction is Value:0x00, used to set the CTRL2 register value to 0x00, set the gyroscope to power-down.

  • S4 instruction is CMD: SETR, used to enable the ASC feature.

  • S5 instruction is the device register address: 0x10, used to set the IMU CTRL1 register.

  • S6 instruction is Value:0x44, used to set the CTRL1 register value to 0x44, set the accelerometer to low-power mode 1 and ODR to 30Hz.

  • S7 instruction is a CMD: SETR, used to enable the ASC feature.

  • S8 instruction is the device register address: 0x17, used to set the IMU CTRL8 register.

  • S9 instruction is Value:0x00, used to set the CTRL8 register value to 0x00, set the accelerometer FS to 2g.

  • S10 instruction is a CMD: CONTREL, used to reset the program.

State machine 2 configuration:

DeniseSANFILIPPO_2-1691486560360.png

DeniseSANFILIPPO_3-1691486560366.png

  • S0 instruction is an RNC: NOP | CHKDT, configure the decision tree value 4, used to check the MLC output value, if equal to 4, go to the next state.

  • S1 instruction is a CMD: SETR, used to enable the ASC feature.

  • S2 instruction is the device register address: 0x11, used to set the IMU CTRL2 register.

  • S3 instruction is Value:0x06, used to set the CTRL2 register value to 0x06, set the gyroscope to high-performance mode and ODR to 120Hz.

  • S4 instruction is CMD: SETR, used to enable the ASC feature.

  • S5 instruction is the device register address: 0x15, used to set the IMU CTRL6 register.

  • S6 instruction is Value:0x00, used to set the CTRL6 register value to 0x00, set the gyroscope FS to 125dps.

  • S7 instruction is CMD: SETR, used to enable the ASC feature.

  • S8 instruction is the device register address: 0x10, used to set the IMU CTRL1 register.

  • S9 instruction is Value:0x06, used to set the CTRL1 register value to 0x06, set the accelerometer to high-performance mode and ODR to 120Hz.

  • S10 instruction is CMD: SETR, used to enable the ASC feature.

  • S11 instruction is the device register address: 0x17, used to set the IMU CTRL8 register.

  • S12 instruction is Value:0x01, used to set the CTRL8 register value to 0x01, set the accelerometer FS to 4g.

  • S13 instruction is a CMD: CONTREL, used to reset the program.

  • S14 instruction is a CMD: STOP, the end of the program.

State machine 3 configuration:

DeniseSANFILIPPO_4-1691486560373.png

DeniseSANFILIPPO_5-1691486560379.png

  • S0 instruction is an RNC: NOP | CHKDT, configure the decision tree value 8, used to check the MLC output value, if equal to 8, go to the next state.

  • S1 instruction is a CMD: SETR, used to enable the ASC feature.

  • S2 instruction is the device register address: 0x11, used to set the IMU CTRL2 register.

  • S3 instruction is Value:0x06, used to set the CTRL2 register value to 0x08, set the gyroscope to high-performance mode and ODR to 480Hz.

  • S4 instruction is a CMD: SETR, used to enable the ASC feature.

  • S5 instruction is the device register address: 0x15, used to set the IMU CTRL6 register.

  • S6 instruction is Value:0x0C, used to set the CTRL6 register value to 0x0C, set the gyroscope FS to 4000dps.

  • S7 instruction is a CMD: SETR, used to enable the ASC feature.

  • S8 instruction is the device register address: 0x10, used to set the IMU CTRL1 register.

  • S9 instruction is Value:0x08, used to set the CTRL1 register value to 0x08, set the accelerometer to high-performance mode and ODR to 480Hz.

  • S10 instruction is a CMD: SETR, used to enable the ASC feature.

  • S11 instruction is the device register address: 0x17, used to set the IMU CTRL8 register.

  • S12 instruction is Value:0x02, used to set three CTRL8 register value to 0x02, set the accelerometer FS to 8g.

  • S13 instruction is a CMD: CONTREL, used to reset the program.

  • S14 instruction is a CMD: STOP, the end of the program.

In the end, we successfully configured three state machines. Click on the save device configuration button. Save it to the PC (for example save it as the filename fsm.ucf).

4. Configuring the MLC

Configuration parameters of the MLC

  •          MLC ODR: 120Hz

  •          Window length: 52 samples

  •          Filters: No

  •          Selected features:

  •          MEAN_on V and V2

  •          Meta classifier: No

DeniseSANFILIPPO_6-1691486560382.png

DeniseSANFILIPPO_7-1691486560389.png

Finally, the user is prompted to select the target UCF files and, by clicking next, it is automatically generated by Unico-GUI. Save it to the PC (for example, use the filename mlc.ucf).

5. Merge MLC and FSM configurations

DeniseSANFILIPPO_8-1691486560399.png

  • Select the advanced MLC+FSM button.

DeniseSANFILIPPO_9-1691486560405.jpeg

  • Load the MLC ucf file (for example, mlc.ucf)

  • Load the FSM ucf file (for example, fsm.ucf)

  • Click on the merge MLC + FSM configurations button and save it to the PC (for example, asc.ucf)

DeniseSANFILIPPO_10-1691486560416.png

  • Select the load button to load the asc.ucf files to the evaluation board.

6. Demonstration on the evaluation board

DeniseSANFILIPPO_11-1691486560451.png

  • Enables the FSM to access the CTRL registers. Configure FUNC_CFG_ACCESS (01h) to 0x08.

DeniseSANFILIPPO_12-1691486560458.png

  • Data when the board is in STILL status, MLC output 0 and the ASC configures the IMU at XL ODR=30Hz,FS_XL=2g,gyroscope off, low-power mode:

DeniseSANFILIPPO_13-1691486560464.png

  • Data when the board is in SHAKING status, MLC output 4, and the ASC configures the IMU at XL ODR=120Hz,FS_XL=4g, gyroscope ODR=120Hz,FS_Gyro=125dps, high-performance mode:

DeniseSANFILIPPO_14-1691486560469.png

  • Data when the board is in FASTMOVING status, MLC output 8, and the ASC configures the IMU at XL ODR=480Hz,FS_XL=8g,Gyro ODR=480Hz,FS_Gyro=4000dps, high-performance Mode.

The result shows that when the device is in a STILL state, the current is 19.46 µA.

When the device is in a FASTMOVING state, the current is 689.70 µA.

DeniseSANFILIPPO_18-1691487245335.png

7. Conclusion

This article described how to implement the ASC function using the MLC and FSM on the STEVAL-MKI109V3 professional evaluation board and STEVAL-MKI227KA daughterboard with the LSM6DSV16X IMU sensor.

To develop the ASC demo, we used Unico-GUI, which is a free-to-use tool downloadable from st.com. Thanks to the powerful functions of Unico-GUI, the configuration of the MLC and FSM has become easier. Users can easily develop their own ASC demo according to actual scenarios, achieving excellent power management and greatly reducing system power consumption.

Version history
Last update:
‎2023-08-17 05:08 AM
Updated by: