2024-02-06 01:56 AM
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).
Solved! Go to Solution.
2024-02-07 06:33 AM
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.
2024-02-06 03:04 AM
Which bit did you not understand?
Key terms are:
2024-02-06 10:08 PM
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.
2024-02-07 01:17 AM - edited 2024-02-07 01:47 AM
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:
2024-02-07 06:33 AM
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.
2024-03-04 02:55 AM
Hi @MykolaLevun ,
If if my answer or @Andrew Neil's answer was helpful, please use the accept as solution button to help other users who might have the same doubt find the solution faster. Thank you.
2024-03-04 03:26 AM - edited 2024-03-04 03:26 AM
Thank you, yours and the @Andrew Neil's answers were useful and there was an understanding.