cancel
Showing results for 
Search instead for 
Did you mean: 

Vibration detection with LSM6DSOX --- Part 1

Eleon BORLINI
ST Employee
The demo project is intended to show the capabilities of Machine Learning Core (Decision Tree model) of LSM6DSOX using the accelerometer data to detect the status of a motor in 5 different conditions.


Overall description of the demo


The demo project is intended to show the capabilities of Machine Learning Core (Decision Tree model) of LSM6DSOX using the accelerometer data to detect the status of a motor in 5 different conditions:
 

  1. Motor Stop
  2. Balanced Motor running mid speed
  3. Balanced Motor running high speed
  4. Unbalanced Motor running mid speed
  5. Unbalanced Motor running high speed


823.jpg


The demo is using the following Hardware:
 

Ø  SensorTile.box (STEVAL-MKSBOX1V1): LSM6DSOX detects motor status thanks to MLC, and when status is changed the application MCU on board (STM32L4R9) sends the updated status by BLE (SPBTLE-1S) to a BLE master.

Ø  NUCLEO-F401RE + X-NUCLEO-IDB05A1: acting as BLE Master, after establishing connection with SensorTile.box, it receives motor status information by BLE messages and re-direct as plain text to UART.

Ø  EDT 7-inch Smart Embedded Panel with STM32F746 and TouchGFX library: the motor status data received by UART are displayed on the LCD screen thanks to TouchGFX library. It’s possible also to send commands to the Motor Control Board to run, stop and change speed of the motor.

[Note] this panel is optional, it’s possible to setup the demo also using a Discovery kit of STM32F7 and applying few modifications to the code.

Ø  Motor Control Nucleo Pack (P-NUCLEO-IHM03:( the motor control kit is receiving simple commands for motor run/stop and speed by two GPIO inputs.

Ø  [Optional] Plastic Spacer of 7mm to create an unbalance.

Ø  [Optional] Current meter to display current consumptions of SensorTile.box.

Ø  [Recommended] Vibration Absorber to isolate mechanically vibration of motor from the table.


When the demo is powered on, the Sensortile.box is in BLE advertising mode and is consuming 25-30mA, when connection is established with the BLE master, the application MCU goes in low power mode and only LSM6DSOX is running. While the LSM6DSOX is running the MLC, the power consumptions of the device is only 1mA, and the main MCU present in the SensorTile.box is consuming only few uA (sleep mode); additional 5mA power consumptions are due to analog circuit of the SensorTile.box board and eventually may be removed by few HW modifications.

The Decision Tree of the MLC has been trained with a dataset of acquisitions for the 5 different classes (Motor Stop, Balanced Motor mid speed, Balanced Motor high speed, Unbalanced Motor mid speed, Unbalanced Motor high speed), when a new status is identified, the LSM6DSOX generates an interrupt to wake up the STM32, that will MLC status information and send by BLE before going back to sleep mode.

The unbalanced condition is created simply by adding a spacer in one of the motor screw holes.
 

824.jpg
 

DEMO SETUP – SensorTile.box

The FW project for the SensorTile.box is based on the Functional Pack FP-SNS-STBOX1.

Few modifications in the code have been applied for the following functions:
 

Ø  Put the STM32 in sleep mode until new MLC status available (raise of interrupt from LSM6DSOX to wake up the MCU): merge of BLEMLC and BLELowPower projects. You may find in the code the added code for low power mode under the:

#ifdef ET2019_USE_STOP_MODE

 

Ø By default the BLE Master is connecting only to a BLE Slave board, in this case the SensorTile.box with manufacturing code equal to 0x76. If it's needed to connect the BLE master to other boards you may change this value in

sensor_service.c file >> setConnectable function >> manuf_data[26]

Ø  MLC supporting the detection of 5 classes:
 

  1. Motor Stop
  2. Balanced Motor running mid speed
  3. Balanced Motor running high speed
  4. Unbalanced Motor running mid speed
  5. Unbalanced Motor running high speed


Here are the basic steps to follow when trying to replicate the demo with own Mechanical configuration:
 

STEP1 Installation of Unico and Unicleo GUI on PC

STEP2 Download DataLogger FW project on SensorTile.box

STEP3 Configure the LSMDSOX with Unico GUI

STEP4 Log Motion MEMS sensor RAW data (ACC+GYR)

STEP5 Extract the Features from log files with Unico GUI

STEP6Decision Tree model training on WEKA

STEP7Configure the LSM6DSOX MLC with Unico GUI

STEP8Update the STM32 FW project with new Decision Tree configuration
 

 

STEP1 - Installation of Unico and Unicleo GUI on PC


At first it's needed to install both the Unico GUI (Windows version) and Unicleo GUI on the PC, in order to can write the configuration registers of the LSM6DSOX device, log the data from the accelerometer and configure the MLC part.
The installer program should also install the Virtual COM driver for the PC, in order to can connect the SensorTile.box to the PC via USB cable and seen as a COM port. If any issue with the driver after the installation, please proceed to install manually launching the driver installer from the following path:
 

825.jpg


 

STEP2 Download DataLogger FW project on SensorTile.box
 

We need to download at first a DataLogger FW project on the STM32 of the SensorTile.box so that, when connected to the PC with USB cable, it will be seen as VCOM and it will be possible to communicate with Unico GUI SW.
Ø  Download the FP-SNS-STBOX1 FW project for SensorTile.box at following:
Ø  You can download the DataLogExtended binary file or compile with your preferred IDE and download to the STM32 using an STLink, you can find the project in the linked folder.
 

STEP3 - Configure the LSMDSOX with Unico GUI

 

Ø  Launch Unicleo GUI on the PC and click on button Connect and Apply:
 

826.png
 

Ø  Enable Accelerometer and Gyroscope sensors and configure the following settings:
Accelerometer ODR = 104Hz
Accelerometer FS = 2g
Gyroscope ODR = 104Hz
Gyroscope FS = 245dps

 

Ø  Click on the Start button on the top Tab.

 

STEP4 - Log Motion MEMS sensor RAW data (ACC+GYR)

 

It’s possible now to log the data of the accelerometer for the different classes to be identified.
 

827.png
 

Ø  Run the motor accordingly to the class to be identified

Ø  Click on the Datalog tab

Ø  Enable Accelerometer in the Data and Datalog period source tabs

Ø  Decide a meaningful name for the data log file. It should be easy later to understand the class from the file name.

Ø  Click on Start button

Ø  Wait few seconds to log enough data samples and then click Stop.

Ø  Repeat the procedure few times for each class, in order to create the desired dataset.

 

828.png


 

STEP5 - Extract the Features from log files with Unico GUI

 

The Machine Learning Core of the LSM6DSOX is not designed to process as input directly RAW sensors data, for the Decision Tree algorithm used we need to extract from the log data the Features needed: Mean, Variance, Peak-to-Peak, ...

The Unico GUI will calculate automatically these Features from the log files taking in account values of LSM6DSOX filters settings and how the same Features are calculated in HW inside the sensor. The Unico GUI will then create an ARFF file with all the needed information, that will be used by the Machine Learning tools to train the model.

 

Ø  Connect to the PC the STEVAL-MKI109V3 + STEVAL-MKI197V1 boards with a USB cable, open the Unico GUI and select the iNemo Inertial Modules >> STEVAL-MKI197V1:
 

829.png
 

Ø  Select MLC Tab, start loading all the .csv log files relative to one class, assign a “Result” name (name of the class that will be identified) and push the “Load button”. The Unico GUI will import all the RAW data and split automatically between ACC and GYR data.
 

832.png

 

835.png
 

Ø  Repeat the same operation for the other classes to be identified

839.png

 

Ø  Configure the parameters in the Configuration tab: iNemo Inertial Modules >> STEVAL-MKI197V1:

841.png

 

Ø  Configure the Accelerometer and Gyroscope settings as following:
Machine Learning Core: 104Hz
Accelerometer: Full scale 2g, ODR 104Hz
Number of Decision trees: 1
Window length: 208 samples (104Hz, 2sec)
 

Ø  Configure the Features as following:
Variance (AX,AY,AZ,AV,AV^2, GX,GY,GZ,GV,GV^2).
HP Filtered Energy (AX,AY,AZ,AV,AV^2, GX,GY,GZ,GV,GV^2).
Peak to Peak (AX,AY,AZ,AV,AV^2, GX,GY,GZ,GV,GV^2).
HP Filtered Peak Detector (AX,AY,AZ,AV,AV^2, GX,GY,GZ,GV,GV^2).
 

Ø  Save the .ARFF file in a desired folder.

 

843.png

 

Ø  At the Next step the Unico GUI will ask you to load the Decision Tree file. Keep the window open and proceed to the next step to train the DT model.


--> GO TO PART 2

Version history
Last update:
‎2020-06-29 07:10 AM
Updated by: