cancel
Showing results for 
Search instead for 
Did you mean: 

Why LSB register is always giving ZERO in LSM3DH accelerometer?

NMale.1
Associate III

HI,

In LSM3DH accelerometer sensor datasheet given output of accelerometer is 16 bit

they are divided into two 8bit registers. MSB, LSB registers. LSB register is always giving ZERO as output. only MSB register is giving output.

Why LSB register is always giving ZERO results. Please send your answer

Thank u

1 ACCEPTED SOLUTION

Accepted Solutions
Eleon BORLINI
ST Employee

Hi @NMale.1​ ,

the LIS3DH output is on 16 bit in the sense that it is divided on 2 registers of 8 bit each one, for each axis.

However, as reported in the datasheet p. 16, the dataout for each mode is defined as follows:

0693W0000059rURQAY.pngCan you please check which mode you have enabled?

More in detail, I suggest you to check the lis3dh_reg.c file on Github for the right conversion of the acceleration dataout.

Taking as example the +-2g full scale, you have:

  • High-resolution mode (on 12-bit, so only 4 bits of the LSByte are significant):
float lis3dh_from_fs2_hr_to_mg(int16_t lsb)
{
  return ( (float)lsb / 16.0f ) * 1.0f;
}
  • Normal mode (on 10-bit, so only 2 bits of the LSByte are significant):
float lis3dh_from_fs2_nm_to_mg(int16_t lsb)
{
  return ( (float)lsb / 64.0f ) *  4.0f;
}
  • Low-power mode (on 8-bit, so only the MSByte is meaningful):
float lis3dh_from_fs2_lp_to_mg(int16_t lsb)
{
  return ( (float)lsb / 256.0f ) * 16.0f;
}

-Eleon

View solution in original post

3 REPLIES 3
Eleon BORLINI
ST Employee

Hi @NMale.1​ ,

the LIS3DH output is on 16 bit in the sense that it is divided on 2 registers of 8 bit each one, for each axis.

However, as reported in the datasheet p. 16, the dataout for each mode is defined as follows:

0693W0000059rURQAY.pngCan you please check which mode you have enabled?

More in detail, I suggest you to check the lis3dh_reg.c file on Github for the right conversion of the acceleration dataout.

Taking as example the +-2g full scale, you have:

  • High-resolution mode (on 12-bit, so only 4 bits of the LSByte are significant):
float lis3dh_from_fs2_hr_to_mg(int16_t lsb)
{
  return ( (float)lsb / 16.0f ) * 1.0f;
}
  • Normal mode (on 10-bit, so only 2 bits of the LSByte are significant):
float lis3dh_from_fs2_nm_to_mg(int16_t lsb)
{
  return ( (float)lsb / 64.0f ) *  4.0f;
}
  • Low-power mode (on 8-bit, so only the MSByte is meaningful):
float lis3dh_from_fs2_lp_to_mg(int16_t lsb)
{
  return ( (float)lsb / 256.0f ) * 16.0f;
}

-Eleon

NMale.1
Associate III

Thank you for your answer,

Can we configure it to 16 bit data mode?. What is the selection combination for 16 bit data output.

Thank you

Unfortunately the maximum actual "bit depth" is 12-bit in high resolution mode (this means, taking x-axis as example, 8 effective bits in OUT_X_H (29h) register and 4 effective bits in OUT_X_L (28h) register).

You can configure it by enabling the HR bit of CTRL_REG4 register.

-Eleon