0
$\begingroup$

So I use accelerometer to get acceleration data. However, I have trouble understanding data. I have been reading manual, but it does not help me:

The measured acceleration data are sent to the OUTL_X, OUTH_X .....

The complete acceleration data for the X channel is given by the concatenation OUTL_X & OUTH_X
and is expressed as a 2’s complement number.

Acceleration data are represented as 12-bit numbers (left justified).

I understand the concept of 2s complement and left justified number spread in this case, however, I am unable to understand how to arrive at appropriate acceleration values.

The table with couple examples is also provided:

acc value               OUTL_X           OUTH_X
0 g                      0x00             0x00
343 mg                   0xE0             0x15
1004 mg                  0x00             0x40
-343 mg                  0x20             0xEA
-1004 mg                 0x00             0xC0

It would be really helpful if someone helped to figure out how do manufacturers of accelerometer arrive at these values. This is little endian.

$\endgroup$

1 Answer 1

2
$\begingroup$

the L and H likely represents LOWER and HIGHER. So the Numbers need to be read as

    0 --> 0x0000  -->      0
  343 --> 0x15e0  -->   5600
 1004 --> 0x4000  -->  16384
 -343 --> 0xea20  -->  59936 = 2^16 - 5600
-1004 --> 0xc000  -->  49152 = 2^16 - 16384

Left justified just means that all measured values have the lower nibble as 0; i.e. last Hex digit will always be 0.

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

From the conversion for 343 mg and 1004 mg, it appears that the conversion formula from the measured number to mg is measured number/16.32.

$\endgroup$
2
  • $\begingroup$ Two's Complement from Wikipedia $\endgroup$
    – AJN
    Commented Jul 12, 2022 at 14:59
  • $\begingroup$ That is clear enough, thank you, I understood the concepts mentioned, I was also confused, because I was getting 350 instead of 343 in the second example, I guess the reference manual is not exactly accurate, but i guess 0.343 g is close enought to 0.35. Thank you. $\endgroup$
    – Jokubas11
    Commented Jul 12, 2022 at 18:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.