Skip to main content
TKCK.1
Associate II
October 14, 2020
Question

LSM6DSOX Machine Learning Application with CubeMx to KeilMicroVision

  • October 14, 2020
  • 5 replies
  • 3333 views

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.

This topic has been closed for replies.

5 replies

Eleon BORLINI
ST Employee
October 14, 2020

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
TKCK.1Author
Associate II
October 16, 2020

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.

Eleon BORLINI
ST Employee
October 16, 2020

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

TKCK.1
TKCK.1Author
Associate II
October 16, 2020

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
October 16, 2020

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
TKCK.1Author
Associate II
October 16, 2020

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;
}

Eleon BORLINI
ST Employee
October 16, 2020

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

TKCK.1
TKCK.1Author
Associate II
October 16, 2020

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.

Eleon BORLINI
ST Employee
October 21, 2020

Hi @TKCK.1​ ,

a brief question to for my recap... did you try your .ucf file (the one you generated for your MLC application) with the default steval-mki109v3 firmware (3.7.35 version)?

If so, and if it's working, can you please share it to us?

You may send the file to eleon.borlini@st.com

-Eleon