# How to interpret accel data from ADXL372

Hi,

My sensor is put in a table, with no motion.

I expect that 0g in X, Y axis. And 1g in Z axis.

But It doesn't work as I expected.

Scale in graph is mg. Scale in terminal is g.

ADXL372 is configured to 1.6K ODR, 800Hz bandwidth, 370 filter settle time.

Could you check what is wrong with it?

And there is one more thing that I wanna check.

Accel data from ADXL372 is signed 12 bit. But it received as 16 bit.

So I convert it in python with twos complement.

I want you to check is it right rule?

sign_x = (accel_x & 0x800) >> 11
sign_y = (accel_y & 0x800) >> 11
sign_z = (accel_z & 0x800) >> 11

temp_x = (accel_x & 0x7FF)
temp_y = (accel_y & 0x7FF)
temp_z = (accel_z & 0x7FF)

if sign_x == 1:
convert_x = -((temp_x^0x7FF) + 1) / 10
else:
convert_x = temp_x / 10

if sign_y == 1:
convert_y = -((temp_y^0x7FF) + 1) / 10
else:
convert_y = temp_y / 10

if sign_z == 1:
convert_z = -((temp_z^0x7FF) + 1) / 10
else:
convert_z = temp_z / 10

print("(%d) accel(X, Y, Z) : (%f, %f, %f)\r\n" %(count, convert_x, convert_y, convert_z))

• Hi Jiyeon,

I just looked at your code and it seems okay to me. what I don't see in the code you shared is how accel_x/y/z are defined.

I use python as well, Here is my routine, in case you find it useful:

def get_acc(self):

x_raw = (data[0]<<4 | data[1]>>4)&0x0FFF
y_raw = (data[2]<<4 | data[3]>>4)&0x0FFF
z_raw = (data[4]<<4 | data[5]>>4)&0x0FFF

x_acc = (twos_complement(x_raw,12))*0.1
y_acc = (twos_complement(y_raw,12))*0.1
z_acc = (twos_complement(z_raw,12))*0.1

acc = [x_acc,y_acc,z_acc]
return acc

def twos_complement(value,bits):
int(value)
if value & (1 << (bits-1)):
value -= 1 << bits
return value

regards,

Pablo.

• Hello,

Thanks for your check!

The cause of problem was high pass filter. It was enabled by default.

After disable high pass filter, It works as I expected.