4 years, 9 months ago.

How to interpret accelerometer data?

Hi Sir/Ma'am

I am developing a tilt sensor for which I am using the ADXL313.

I am confused with the data I am getting because I can not do further process If I will not understand the reading of accelerometer.

I am dealing with all the 3 axes of accelerometer and the data I got on rest are as follows--

X-Axis Y-axis Zaxis -256, 2240, 32704, -256, 2240, 32704, -256, 2368, 32704, -128, 2240, 32704, -256, 2304, 32704, -192, 2304, 32704, -192, 2240, 32704, -192, 2240, 32704, -128, 2368, 32704, -256, 2368, 32704, -256, 2304, 32704, -256, 2368, 32704, -256, 2304, 32704, -192, 2304, 32704, Here I want to make clear some of the setting of accelerometer so that it will be more clear to ask.

I am using 0.5 g sensitivity level and the data rate is 50 Hz, Here I am including some information please take a look--

Go into standby mode to configure the device. accelerometer.SetPowerControl(0x00);

Full resolution, +/-0.5g, 1024LSB/g. accelerometer.SetDataFormatControl(0x04); 0b 0000 0100 ;

100Hz data rate. accelerometer.SetDataRate(ADXL313_100HZ);

Measurement mode. accelerometer.SetPowerControl(0x08); 0b 0000 1000

I am very confused that what I am getting from accelerometer When I read the datasheet then in that it is given that the accelerometer gives the output in mg/LSB form but according to that when I converti it into gravity I got the wrong data.

I also want to know that the data is in 16 bit or 10 but since the range is weird so I can not understand what it is and in which form?

I do not belong to an engineering background so I am struggling a lot.

Please make me clear all there things.

1 Answer

4 years, 9 months ago.

The data looks very stable and normal to me. The part puts out 10 bit data so take your values and divide by 64 From there you will get data that looks like: -256, 2240, 32704 => -4, 35, -1

Each "bit" represents 0.5mg so you are slightly tilted from horizontal -4/511g(X), 35/511g(Y), -1/511g (Z)

Thank You for the Answer. I apologize for bothering you again but I am a little bit confused again from your answer. Why we have to divide the number from 64, as far as I know, to convert 16 bit into 10 we should divide by 65536. Further, if we will divide the reading by 64 we got -4,35 and 511 how you got -1. Sorry again but please make clear the last line more. Waiting for your response.

posted by Nivedita Singh 27 Jul 2019

16 bit to 10 bit is a shift of 6 bits, 2^6 = 64.

However that still doesn't give sensible results if it's 1024 LSB /g like you state.

The value of the z axis should be around 1 g which would represent a divide by 32.

-256, 2240, 32704 => 8, 70, 1022

1024 LSB/g so divide by 1024 to get g = 7.8 mg, 68.4 mg, 998 mg

Which gives you a total of 1000.4 mg, well within tolerance.

This implies that you are around 3.5 to 4 degrees off level with the +y direction pointing very slightly up.

Not sure exactly why it's 32 not 64, it could be some configuration register issue. For a commercial product I'd say dig into it and figure out just in case it comes back to bite you but if this is for a home project then don't worry about it.

posted by Andy A 29 Jul 2019

Output data is formatted as 16-bit two's complement:

  • Span is 2^16 = 65536
  • Range is from -32768 to 32767

---------------
16-bit two's complement
Hex		 Dec
---------------
7FFF	32767
7FFE	32766

...

0001		1
0000		0
FFFF	   -1
FFFE	   -2

...

8001	-32767
8000	-32768
---------------

At 10-bit resolution:

  • Span is 2^10 = 1024
  • Range is from -512 to 511

So to map the 16-bit range to 10-bit range we should divide by 64 (=65536/1024). If the device range is set to +/-0.5g (span=1g) then -512 (=-32768/64) corresponds to -0.5g and 511 (=32767/64) to 0.5g. Hence, to get the final value we should divide by 1024 (=1024/1g).

We can summarize it as:

-------------------------------------------------------------------
16-bit						10-bit						Results
(two' complement)	 		resolution			 		(g) 
-------------------------------------------------------------------
-256			/ 64			-4			/ 1024		-0.00390
2240			/ 64			35			/ 1024		0.03418
32704			/ 64			511			/ 1024		0.49902 (clipped)
...
-------------------------------------------------------------------

Because Earth gravity is 1g the Z axis results should be close to 1g. But because that's beyond the selected range (+/-0.5g) they are clipped to the limit (0.5g).

To avoid clipping try to select the +/-1g range (span=2g). But then you should divide by 512 (=1024/2g) rather than by 1024.

posted by Zoltan Hudak 29 Jul 2019