cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSOX Machine Learning Application with CubeMx to KeilMicroVision

TKCK.1
Associate III

Hi,

I'm working on lsm6dsox imu for machine learning application. MCL configs worked well on the Unico GUI. Then i passed CubeMx, made requried configurations, took the updated libraries from github(https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lsm6dsox_STdC/driver), took the example application from https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsox_STdC/example/lsm6dsox_mlc.c but mlc feature didn't work. All the other features worked well( read_data_poling, free_fall exc.)

What was that case, where is the problem?

Thanks.

13 REPLIES 13
Eleon BORLINI
ST Employee

Hi @TKCK.1​ ,

the MLC configuration on the LSM6DSOX requires some more steps compared to the other digital feature.

For this reason, I suggest you to check the already available examples in the firmware function packs, for example the FP-SNS-STBOX1.

You can refer to the BLEMLC application in the folder: \Projects\STM32L4R9ZI-SensorTile.box\Applications\BLEMLC

Here, the Example application initializes all the Components, Loading the program on MLC and outputting the LSM6DSOX MLC results for Activity Recognition (Default) or Vibration Monitoring, and moreover initializes the Library creating some Custom Bluetooth services (since the target application is the SensorTile.box tool driven by smartphone BLE app)

Please take care of the inc files lsm6dsox_activity_recognition_for_mobile.h and lsm6dsox_vibration_monitoring.h, where the MLC configuration is reported, and where they are invoked in the code.

-Eleon

TKCK.1
Associate III

Hi @Eleon BORLINI​ 

Thanks for attention. I tried the examples that you suggest but it doesn't work. I have a steval-mki109v3 main board and a steval-mki197v1 module. I opened \Projects\STM32L4R9ZI-SensorTile.box\Applications\BLEMLC example and encountered that sceenelsm6dsox_all_sources_t struct doesn't include mlc_status variable. How is it possible? On the other hand all the other code configuration and invoking is the same with https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsox_STdC/example/lsm6dsox_mlc.c .I'm stucked.

Hi @TKCK.1​ ,

I may have misunderstood the point, sorry... you wrote that the "MCL configs worked well on the Unico GUI. Then i passed CubeMx". The steval-mki109v3 main board works with Unico GUI but it is not (well) configurable with the CubeMX tool, more suitable for the X-Nucleo board family. The fact is that the ProfiMEMS is not designed for general purpose projects, but only for evaluation.

Did you configured the steval-mki109v3 with CubeMX? If so, could you please share the source code of your app?

Thanks,

-Eleon

Hi @Eleon BORLINI (ST Employee)​ 

I configured the steval-mki109v3 with CubeMX and ı can read the acc and gyro values well (with https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsox_STdC/example/lsm6dsox_read_data_polling.c ). But mlc application doesn't work. The main.c file is in below.

Eleon BORLINI
ST Employee

Hi @TKCK.1​ ,

I see you are using functions like this one:

static int32_t lsm6ds3_i2c_transmit(void *handle, uint8_t reg_to_read, uint8_t* buff, uint16_t len)

Just for my better understanding, is it a reused function or the "lsm6ds3" is a typo and should be "lsm6dsox"?

-Eleon

TKCK.1
Associate III

Hi @Eleon BORLINI​ 

Yes, "lsm6dsox" can be fine but it doesn't affect working of function, it is just a private name.

We can think like that https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsox_STdC/example/lsm6dsox_read_data_polling.c example. I just converted.

static int32_t platform_read(void *handle, uint8_t reg, uint8_t *bufp,
                             uint16_t len)
{
  if (handle == &hi2c1)
  {
    HAL_I2C_Mem_Read(handle, LSM6DSOX_I2C_ADD_L, reg,
                     I2C_MEMADD_SIZE_8BIT, bufp, len, 1000);
  }
#ifdef STEVAL_MKI109V3
  else if (handle == &hspi2)
  {
    /* Read command */
    reg |= 0x80;
    HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_RESET);
    HAL_SPI_Transmit(handle, &reg, 1, 1000);
    HAL_SPI_Receive(handle, bufp, len, 1000);
    HAL_GPIO_WritePin(CS_up_GPIO_Port, CS_up_Pin, GPIO_PIN_SET);
  }
#endif
  return 0;
}

Hi @TKCK.1​ ,

to get in more detail, which MLC example are you running? The one configured by the lsm6dsox_vibration_monitoring.h?

Could you please add this inc file too (or share if you have customized it), where the instruction for the MLC are reported?

The configuration is the code snippet below:

/* Start Machine Learning Core configuration */
  for ( i = 0; i < (sizeof(lsm6dsox_vibration_monitoring) /
                    sizeof(ucf_line_t) ); i++ ){
  
    lsm6dsox_write_reg(&dev_ctx, lsm6dsox_vibration_monitoring[i].address,
                       (uint8_t*)&lsm6dsox_vibration_monitoring[i].data, 1);
     
  } 
  /* End Machine Learning Core configuration */

And you are not getting the MLC output from this function, right?

lsm6dsox_mlc_out_get(&dev_ctx, mlc_out);
sprintf((char*)tx_buffer, "Detect MLC interrupt code: %02X\r\n",
       mlc_out[0]);

-Eleon

Hi @Eleon BORLINI​ 

First time i made lots of datasets from Unico Gui for our industrial product and converted to the .h file. And i followed the steps but it didn't get outputs. Then i thought first i should be understand how to works this MLC progress. So i tried https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsox_STdC/example/lsm6dsox_mlc.c and i realized that the problem was different.

Now at this mention i'm using

https://github.com/STMicroelectronics/STMems_Machine_Learning_Core/blob/master/application_examples/lsm6dsox/Vibration%20monitoring/lsm6dsox_vibration_monitoring.h for  lsm6dsox_vibration_monitoring.h, no customization. I coppied the lsm6dsox_vibration_monitoring.h file to the

C:\....\Core\Inc.

Yes, I can't getting output from that function.

Hi @TKCK.1​ ,

So you setup two projects, and I have some questions for you on both of them:

  1. Custom project: you acquired data with Unico GUI (right?) using steval-mki109v3 + steval-mki197v (right?), you created a dataset, you extracted the relevant features and you configured the decision tree in Weka as shown in this online tutorial, am I correct?
  2. Demo project (for setup validation): you downloaded the online available vibration monitoring LSM6DSOX MLC example, you configured the sensor and you acquired vibration patterns with the previous hardware, and you get no output on the MLC register. Are you acquiring data in the same condition with which data for the training and the validation of the MLC where generated (same ORD, etc...)? Did you used this example example_0_profi_unico_weka (if not, can you check if if it can be of any help) or this other one Activity recognition for mobile?

-Eleon