Skip to main content
Visitor II
June 11, 2021
Solved

What is the meaning of 12-bit high resolution mode in the LIS2DH accelerometer, and how do I use it?

  • June 11, 2021
  • 1 reply
  • 1658 views

I just want some clarification of the data output of the different modes.

For example, it states in the data sheet that low power mode has an 8 bit data output.

I assume that this means registers LIS2DH_OUT_X_L and LIS2DH_OUT_X_H are 8 bits each, and I can read the raw accelerometer data into a 2 byte integer.

Given that the high resolution mode has a 12 bit data output, it would mean that I need 3 bytes to get all the data. It would also mean that I need to read from another register (besides low and high registers), which I don't see specified. Therefore, I believe my thought process is wrong.

Can someone explain how to use high resolution mode? Thanks.

Isaac

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

    Hi Isaac @IC.1​ ,

    >> For example, it states in the data sheet that low power mode has an 8 bit data output.

    I assume that this means registers LIS2DH_OUT_X_L and LIS2DH_OUT_X_H are 8 bits each, and I can read the raw accelerometer data into a 2 byte integer.

    Your statement about the low power is correct: in this case the only register to be considered is the MSB, i.e. the LIS2DH_OUT_X_H one. You have, in general, to concatenate the two registers and consider only the first 8 bits (for LP mode), 10 bits (for NM mode) and 12 bits (for HR mode), as defined in the datasheet.

    Taking as example the FS +-2g, you can refer to the C drivers on Github (lis2dh_reg.c:( concatenate the two registers, convert the value into decimal via two's complement, shift the bits (divide by 2^8=256) and multiply for the sensitivity, i.e. 16mg/LSB in this case.

    float_t lis2dh_from_fs2_lp_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 256.0f) * 16.0f;
    }

    >> Given that the high resolution mode has a 12 bit data output, it would mean that I need 3 bytes to get all the data. It would also mean that I need to read from another register (besides low and high registers), which I don't see specified. Therefore, I believe my thought process is wrong.

    Check please the comment above, and consider the following conversion formulas:

    float_t lis2dh_from_fs2_hr_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 16.0f) * 1.0f;
    }

    In normal mode only the first 10 bits have to be considered, and the conversion formula is the following one:

    float_t lis2dh_from_fs8_nm_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 64.0f) * 16.0f;
    }

    If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.

    -Eleon

    1 reply

    ST Employee
    June 14, 2021

    Hi Isaac @IC.1​ ,

    >> For example, it states in the data sheet that low power mode has an 8 bit data output.

    I assume that this means registers LIS2DH_OUT_X_L and LIS2DH_OUT_X_H are 8 bits each, and I can read the raw accelerometer data into a 2 byte integer.

    Your statement about the low power is correct: in this case the only register to be considered is the MSB, i.e. the LIS2DH_OUT_X_H one. You have, in general, to concatenate the two registers and consider only the first 8 bits (for LP mode), 10 bits (for NM mode) and 12 bits (for HR mode), as defined in the datasheet.

    Taking as example the FS +-2g, you can refer to the C drivers on Github (lis2dh_reg.c:( concatenate the two registers, convert the value into decimal via two's complement, shift the bits (divide by 2^8=256) and multiply for the sensitivity, i.e. 16mg/LSB in this case.

    float_t lis2dh_from_fs2_lp_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 256.0f) * 16.0f;
    }

    >> Given that the high resolution mode has a 12 bit data output, it would mean that I need 3 bytes to get all the data. It would also mean that I need to read from another register (besides low and high registers), which I don't see specified. Therefore, I believe my thought process is wrong.

    Check please the comment above, and consider the following conversion formulas:

    float_t lis2dh_from_fs2_hr_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 16.0f) * 1.0f;
    }

    In normal mode only the first 10 bits have to be considered, and the conversion formula is the following one:

    float_t lis2dh_from_fs8_nm_to_mg(int16_t lsb)
    {
     return ((float_t)lsb / 64.0f) * 16.0f;
    }

    If my reply answered your question, please click on Select as Best at the bottom of this post. This will help other users with the same issue to find the answer faster.

    -Eleon

    IC.1Author
    Visitor II
    June 14, 2021

    Thank you Eleon. I see what you mean now, high resolution is only 12 bits, not 24 bits like i was thinking.

    However, only low power mode and normal power mode seem to be working. When I turn on bit 4 of ctrl reg 4 to turn on high resolution mode, the accelerometer is not responsive, as in the interrupts are not working. I don't see anything wrong with the way I set up my registers, and I made sure to turn off the LP bit in ctrl reg 1.

    The registers are in hex, do you see anything wrong? Thank you.

    -Isaac

    CTRL_REG1: 37

    CTRL_REG2: 03

    CTRL_REG3: 40

    CTRL_REG4: 08

    CTRL_REG5: 00

    CTRL_REG6: 28

    LIS2DH_INT1_CFG: 2a

    LIS2DH_INT1_THS: 6b

    LIS2DH_INT1_DURATION: 01

    LIS2DH_INT2_CFG: 2a

    LIS2DH_INT2_THS: 6b

    LIS2DH_INT2_DURATION: 01

    LIS2DH_CLICK_CFG: 00

    LIS2DH_CLICK_THS: 00

    LIS2DH_TIME_LIMIT: 00

    LIS2DH_TIME_LATENCY: 00

    LIS2DH_TIME_WINDOW: 00

    IC.1Author
    Visitor II
    June 15, 2021

    I did a bit more testing, and it seems that when it is set at a higher resolution it needs to be set at a lower threshold in order to have the same responsiveness as low power or normal mode. My interrupts trigger with the above configuration with CTRL_REG4 set to 0 (normal mode), but it is not as responsive when it is set to 8 (HR bit). Is this normal behavior? Thanks.

    -Isaac