2025-02-05 2:03 AM - last edited on 2025-02-05 7:10 AM by Andrew Neil
Hello Community,
I am currently developing a medical device and am utilizing the LSM6DSOX IMU sensor for user activity tracking. My goal is to implement functionality that can accurately track activities such as running, walking, and being steady.
To achieve this, I’ve started by working with the MLC (Machine Learning Core) example provided in the ST GitHub repository. However, despite my efforts, we are not getting any output from the implementation.
Could anyone provide guidance or suggestions on the following:
I’d appreciate any advice or tips to help move forward with this project. Looking forward to your suggestions!
2025-02-06 2:09 AM - edited 2025-02-06 2:10 AM
Hi @Ggurjar98 ,
Use the STM32CubeMX tool to generate initialization code for the LSM6DSOX sensor.
As best practices you can experiment with different features (e.g., mean, variance, FFT coefficients) derived from the raw sensor data to improve model performance. Use data augmentation techniques to artificially increase the size of your training dataset, this can help improve model robustness. Continuously collect new data and retrain the model to adapt to changes in user behavior and improve accuracy over time.
Here is an example code snippet to initialize the LSM6DSOX sensor and read the MLC output:
// Include necessary headers
#include "lsm6dsox_reg.h"
// Define sensor context
stmdev_ctx_t dev_ctx;
// Initialize platform-specific functions (e.g., I2C/SPI read/write)
void platform_init(void);
// Load MLC configuration
void load_mlc_configuration(stmdev_ctx_t *ctx);
// Main function
int main(void) {
// Initialize platform-specific functions
platform_init();
// Initialize LSM6DSOX sensor
lsm6dsox_device_id_get(&dev_ctx, &whoamI);
if (whoamI != LSM6DSOX_ID) {
// Handle sensor initialization error
}
// Load MLC configuration
load_mlc_configuration(&dev_ctx);
// Main loop
while (1) {
uint8_t mlc_output;
lsm6dsox_mlc_out_get(&dev_ctx, &mlc_output);
// Interpret MLC output
switch (mlc_output) {
case 1:
// Running
break;
case 2:
// Walking
break;
case 3:
// Steady
break;
default:
// Unknown activity
break;
}
}
}
// Function to load MLC configuration
void load_mlc_configuration(stmdev_ctx_t *ctx) {
// Load the MLC configuration generated by Unico GUI
uint8_t mlc_config[] = { /* MLC configuration bytes */ };
lsm6dsox_mlc_config_set(ctx, mlc_config, sizeof(mlc_config));
}
2025-02-19 3:55 AM
Hello,
Thanks for your reply.
Instead of generating the MLC configuration file using the device tree parameters, we can use the following MLC configuration file directly:
File: LSM6DSOX Activity Recognition for Wrist
What are the steps to use this MLC configuration file for user activity detection?
2025-02-27 11:15 PM
@Federica Bossi Please give me update on above replay.