on 2023-12-05 01:58 AM
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.
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.
The STEVAL-MKI109V3 is used to configure MEMS sensors and evaluate sensor outputs. Moreover, it has some advanced features for instance:
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.
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.
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
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.
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.
Clicking on the Start button on the top bar we are enabling communication between the STEVAL-MKI109V3 with the STEVAL-MKI227KA and our PC.
Select the Load/Save tab. Click on the load button and select the downloaded .ucf file. In this example, we are using this file.
The sensor orientation for this algorithm is ENU
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.
Now, click on the Sensor Fusion tool and then on the “Enable Sensor Fusion” button.
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 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.
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.
The current power consumption of this configuration is around 700 µA.
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.
The flow below is implemented leveraging the finite state machine (FSM).
After clicking on the FSM button, the FSM screen will open:
The first step is to align the FSM ODR to the sensors ODR, which is 120 Hz.
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.
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.
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.
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.
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.
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.
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.
What is outlined in this article can of course be extended or adapted depending on the final application and requirements.
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:
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.
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