Skip to main content
Explorer
February 6, 2024
Solved

LIS2DH12 Acceleration values

  • February 6, 2024
  • 1 reply
  • 2793 views

Hello,

LIS2DH12 accelerometer. AN5005 datasheet. How is the data in the table in column 1 (Acceleration values) calculated? (See Figure 1). I read the calculation process in the datasheet above, but did not understand it. (See Figure 2).

    This topic has been closed for replies.
    Best answer by Federica Bossi

    Hi @MykolaLevun ,

    The Numbers need to be read as:

    0 --> 0x0000  -->      0
    350mg --> 0x15e0  -->   5600
    1g --> 0x4000  -->  16384
    -350mg --> 0xea20  -->  59936 = 2^16 - 5600
    -1g --> 0xc000  -->  49152 = 2^16 - 16384

     

    Two complement means that to find the magnitude of a negative number, you need to do two's complement once more, or do 2^16 - number as shown above.

    1 reply

    Super User
    February 6, 2024

    Which bit did you not understand?

    Key terms are:

    • 2's complement
    • The Most- and Least-significant part of a number
    • Left-justified
    Explorer
    February 7, 2024

    I did not understand how the values in 28h and 29h registers  are formed (see Figure 1). And how the first column of the table (Acceleration values) is formed from the values ​​in the registers.

    Super User
    February 7, 2024

    But you understand those 3 key terms?

    1. "Most" and "Least" Significant

    The most significant part of a number if the left-most part;

    The least significant part of a number if the right-most part.

    2. two's complement

    Negative numbers are represented by using the most-significant (left-most)  bit as a sign bit:

    +350 (decimal) = 0001 0101 1110 (binary) = 0x15E;

    -350 (decimal) = 1110 1010 0010 (binary) = 0xEA2.

    3. Left Justified

    The 28h and 29h pair of registers holds 16 bits, but the acceleration values are (at most) only 12 bits - so there are four "spare" bits.

    "Left Justified" means that 12 left-most bits are used, and the 4 right-most bits are the spares.

    Therefore the numbers become:

    +350 (decimal) --> 0001 0101 1110 0000 (binary) = 0x15E0;

    -350 (decimal) --> 1110 1010 0010 0000 (binary) = 0xEA20.

    Which are the values you see in the table:

    AndrewNeil_0-1707299238999.png