Hi
I am using ADXL357 accelerometer, and i am trying to record sensitivity in terms of g.
here is the algorithm for taking out raw value and calculation of g through it
sensitivity = 19.5
def convert_to_g(raw_reading, sensitivity):
# Convert raw readings to acceleration in g
return (raw_reading * sensitivity) / 1000000
# Split data
xdata = (xdata1 >> 4) + (xdata2 << 4) + (xdata3 << 12)
ydata = (ydata1 >> 4) + (ydata2 << 4) + (ydata3 << 12)
zdata = (zdata1 >> 4) + (zdata2 << 4) + (zdata3 << 12)
# Apply two complement
if xdata >= 0x80000:
xdata = ~xdata + 1
if ydata >= 0x80000:
ydata = ~ydata + 1
if zdata >= 0x80000:
zdata = ~zdata + 1
# Convert raw readings to acceleration in g
acc_x = convert_to_g(xdata, sensitivity_X)
acc_y = convert_to_g(ydata, sensitivity_Y)
acc_z = convert_to_g(zdata, sensitivity_Z)
and on using this algorith, here is the plot of the acceleration in terms of FFT, RMS and with time. The mounting position of the sensor is Z-axis is perpendicular to g and X axis is aligned with the earth's gravity.
So i want to know that is this the right way, or am i doing something wrong?
I am using ADXL357 accelerometer, and i am trying to record sensitivity in terms of g.
here is the algorithm for taking out raw value and calculation of g through it
sensitivity = 19.5
def convert_to_g(raw_reading, sensitivity):
# Convert raw readings to acceleration in g
return (raw_reading * sensitivity) / 1000000
# Split data
xdata = (xdata1 >> 4) + (xdata2 << 4) + (xdata3 << 12)
ydata = (ydata1 >> 4) + (ydata2 << 4) + (ydata3 << 12)
zdata = (zdata1 >> 4) + (zdata2 << 4) + (zdata3 << 12)
# Apply two complement
if xdata >= 0x80000:
xdata = ~xdata + 1
if ydata >= 0x80000:
ydata = ~ydata + 1
if zdata >= 0x80000:
zdata = ~zdata + 1
# Convert raw readings to acceleration in g
acc_x = convert_to_g(xdata, sensitivity_X)
acc_y = convert_to_g(ydata, sensitivity_Y)
acc_z = convert_to_g(zdata, sensitivity_Z)
and on using this algorith, here is the plot of the acceleration in terms of FFT, RMS and with time. The mounting position of the sensor is Z-axis is perpendicular to g and X axis is aligned with the earth's gravity.
So i want to know that is this the right way, or am i doing something wrong?
Attachments
-
35.7 KB Views: 8
-
36.2 KB Views: 8
-
33.6 KB Views: 7
-
31.8 KB Views: 8
-
30.6 KB Views: 7
-
30 KB Views: 7