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

int sensitivity = 19.5
float 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 algorithm

, 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?

this is the complete python script.
I have mounted the sensor on a diesel engine using magnetic mounting. I am trying to calculate the rpm using vibrations in a engine but i feel my FFT values are wrong as when i measure peak of FFT its similar for all rpm.

actually the code was in python, i just changed it into C. I have posted the complete python script. I forgot to put their data types. both of them are integer type.

...then it's in a nice microgQ28.4 which you convert to g with xdata/16000000.0

Something definitely looks wrong with the sign handling, since your Y & Z graphs look like the readings have been abs(??) -filtered, and your X graph looks like it's centered around -19.5.