cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DH12 Acceleration values

MykolaLevun
Associate III

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).

1 ACCEPTED SOLUTION

Accepted Solutions

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.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

View solution in original post

6 REPLIES 6

Which bit did you not understand?

Key terms are:

  • 2's complement
  • The Most- and Least-significant part of a number
  • Left-justified

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.

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

 

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.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

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.

In order to give better visibility on the answered topics, please click on 'Accept as Solution' on the reply which solved your issue or answered your question.

Thank you, yours and the @Andrew Neil's  answers were useful and there was an understanding.