Skip to main content
JPARK.2
Associate
November 3, 2020
Solved

lsm6dsox sensor data read in polling mode

  • November 3, 2020
  • 1 reply
  • 849 views

Hello, support team.

​

In my test environment, sensor data is read in polling mode at while loop.

Sensor ODR is set to 1667Hz.

So It was expected that sensor data is read every 1/1667sec.

​But it looks like sensor data is read every 1/1873sec.

(During 5 minutes, each sensor datas are read 562,000 times.)

It is much faster than I expected.

Could you check that Am I misunderstood or Do something wrong?

Below is read function, which is called in while loop.

static void motion_data_read(uint8_t index)
{
 axis3bit16_t data_raw_acceleration;
 axis3bit16_t data_raw_angular_rate;
 
 do{
 /* Read acceleration field data */
 lsm6dsox_acceleration_raw_get(&lsm_ctx, data_raw_acceleration.u8bit); 
 }while(0 == memcmp(&motion_data[0], data_raw_acceleration.u8bit, sizeof(uint8_t)*6));
 
 do{
 /* Read angular rate field data */
 lsm6dsox_angular_rate_raw_get(&lsm_ctx, data_raw_angular_rate.u8bit);
 }while(0 == memcmp(&motion_data[3], data_raw_angular_rate.u8bit, sizeof(uint8_t)*6));
 
 motion_data[0] = data_raw_acceleration.i16bit[0];
 motion_data[1] = data_raw_acceleration.i16bit[1];
 motion_data[2] = data_raw_acceleration.i16bit[2];
 motion_data[3] = data_raw_angular_rate.i16bit[0];
 motion_data[4] = data_raw_angular_rate.i16bit[1];
 motion_data[5] = data_raw_angular_rate.i16bit[2];
}

This topic has been closed for replies.
Best answer by Eleon BORLINI

Hi @Community member​ ,

please note first that the ODR nominally at 1667Hz can differ of about +-2%, so that it can actually be 1700Hz more or less.

1873Hz is a little too fast, but since you are reading the device in asynchronous mode,

To be sure of the actual value of the ODR; you should acquire the data-ready signal (for example with and oscilloscope), and check this interrupt frequency.

To enable the DRDY signal, you have to configure the LSM6DSOX device as follow:

1. Write INT1_CTRL = 01h // Acc data-ready interrupt on INT1

You can refer to the C examples on Github, and especially to the lsm6dsox_read_data_int.c file.

-Eleon

1 reply

Eleon BORLINI
Eleon BORLINIBest answer
ST Employee
November 3, 2020

Hi @Community member​ ,

please note first that the ODR nominally at 1667Hz can differ of about +-2%, so that it can actually be 1700Hz more or less.

1873Hz is a little too fast, but since you are reading the device in asynchronous mode,

To be sure of the actual value of the ODR; you should acquire the data-ready signal (for example with and oscilloscope), and check this interrupt frequency.

To enable the DRDY signal, you have to configure the LSM6DSOX device as follow:

1. Write INT1_CTRL = 01h // Acc data-ready interrupt on INT1

You can refer to the C examples on Github, and especially to the lsm6dsox_read_data_int.c file.

-Eleon