cancel
Showing results for 
Search instead for 
Did you mean: 

LSM6DSOX read register

Sprem.1
Associate III

we are trying to configure LSM6DSOX in high-performance mode. Following configurations are done on the sensor

ODR --> 6.66khz(high performance mode) and G-Range --> 16g

Register addr(CTRL6_C) --> XL_HM_MODE --> value(0x00)

Register addr(CTRL6_XL) --> XL_FS_MODE --> value(0x00)

Register addr(CTRL1_C) --> ODR(6.66khz) and G range(16g) -->value(0xA4)

observed output values around 62242 range for x-y-z-axis

can you please confirm whether our configurations are correct and the observed value is the expected value?

1 ACCEPTED SOLUTION

Accepted Solutions
Sprem.1
Associate III

Hi TBomb,

finally, we found the solution for this thank you so much for your support

View solution in original post

9 REPLIES 9
Sprem.1
Associate III

please can anyone reply for this

TBomb.1
Senior II

Hi, the value looks too high, the conversion formula to milli-g is the one here below, from Github drivers:

float_t lsm6dsox_from_fs16_to_mg(int16_t lsb)
{
  return ((float_t)lsb) * 0.488f;
}

https://github.com/STMicroelectronics/lsm6dsox/blob/63e7471a85f2ef5992cd8c0aa653ea2f17065316/lsm6dsox_reg.c

Did you concatenate correctly the 3x2 output registers?

You should at least see some differences between x and z axis when the device is flat on a surface (x almost close to 0, y almost close to 1g).

Tom

Sprem.1
Associate III

Hi TBomb,

Thank you so much for the reply,

whether this concatenation correct for the output register?

for (i=0 ; i<6 ; i++)

{

 txBuf_1[0] = 0x28 + i | 0x80 ;// OUTX_L_A and OUTX_H_A(Reg Addr(xData,yData,zData)) + Read Commend

 txBuf_1[1] = 0x00;

 Start_SPI_Transaction_1(txBuf_1,2,rxBuf_1,2);

 xyzData_1[i]= rxBuf_1[1];

}

xData_1= ((xyzData_1[1] & 0xFF) <<8) | xyzData_1[0];

yData_1= ((xyzData_1[3] & 0xFF) <<8) | xyzData_1[2];

zData_1= ((xyzData_1[5] & 0xFF) <<8) | xyzData_1[4];

TBomb.1
Senior II

The code looks ok. Does the device returns the correct WHO_AM_I value when you read the 0Fh register?

And do you have the possibility to check another sample?

Tom

Sprem.1
Associate III

Hi TBomb,

Yes WHO_AM_I register is working fine

we are using a while loop to get the sample in all the samples we are getting the same value

we are worried about not getting the excepted sample can you please help regarding this

TBomb.1
Senior II

Hi, so it might be an issue related to the initialization of the device. Did you correctly configured the LSM6DSOX to get the data output?

There are examples on the application note and on Github, you can try for example these configurations and check:

1. Write 50h to CTRL1_XL // Turn on the accelerometer // ODR_XL = 208 Hz, FS_XL = ±2 g

2. Write 40h to CTRL2_G // Turn on the gyroscope // ODR_G = 104 Hz, FS_G = ±250 dps

https://www.st.com/resource/en/application_note/dm00571818-lsm6dsox-alwayson-3d-accelerometer-and-3d-gyroscope-stmicroelectronics.pdf

https://github.com/STMicroelectronics/STMems_Standard_C_drivers/blob/master/lsm6dsox_STdC/examples/lsm6dsox_read_data_polling.c

Tom

Sprem.1
Associate III

Hi TBomb,

Thank you so much for your reply,

we are doing CTRL1_XL --> 0xA4 //Turn on the accelerometer ODR_XL - 6.66khz and FS_XL=+-16g

is correct?

I also have another doubt to get the raw data output what are the register to be initialized?

we have initialized only these register

1) Software reset

txBuf_1[0] = 0x12 | 0x00; //Register Addr(CTRL3_C) + write command

txBuf_1[1] = 0x01; //Register Addr(CTRL3_C) -> SW_RESET

Start_SPI_Transaction_1(txBuf_1, 2, rxBuf_1, 0);

2) ODR --> 6.66Khz(High performance mode) and G-Range --> 16g

txBuf_1[0] = 0x15 | 0x00; //Register Addr(CTRL6_C) + write command

txBuf_1[1] = 0x00 ; //Register Addr(CTRL6_C) -> XL_HM_MODE

Start_SPI_Transaction_1(txBuf_1,2,rxBuf_1,0);

txBuf_1[0] = 0x17 | 0x00; //Register Addr(CTRL8_XL) + write command

txBuf_1[1] = 0x00; //Register Addr(CTRL8_XL) -> XL_FS_MODE

Start_SPI_Transaction_1(txBuf_1,2,rxBuf_1,0);

txBuf_1[0] = 0x10 | 0x00 ; //Register Addr(CTRL1_C)  + write command

txBuf_1[1]=  0xA4 ; //Register Addr(CTRL1_XL)  -> ODR(6.66Khz ) and G range(16 g)

Start_SPI_Transaction_1(txBuf_1,2,rxBuf_1,0);

3) Raw data collection

for (i=0 ; i<6 ; i++)

{

 txBuf_1[0] = 0x28 + i | 0x80 ;// OUTX_L_A and OUTX_H_A(Reg Addr(xData,yData,zData)) + Read Commend

 txBuf_1[1] = 0x00;

 Start_SPI_Transaction_1(txBuf_1,2,rxBuf_1,2);

 xyzData_1[i]= rxBuf_1[1];

}

xData_1= ((xyzData_1[1] & resolutionScreening) <<8) | xyzData_1[0];

yData_1= ((xyzData_1[3] & resolutionScreening) <<8) | xyzData_1[2];

zData_1= ((xyzData_1[5] & resolutionScreening) <<8) | xyzData_1[4];

can you please support us regarding this

Hi @Sprem.1​ , configuration should be correct. Are you facing further issues?

Tom

Sprem.1
Associate III

Hi TBomb,

finally, we found the solution for this thank you so much for your support