5 years, 4 months ago.

How to calculate angle by accelerometer readings?

Hi, I am working on a project with ADXL313. My goal is to convert the accelerometers into an angle. Previously I used the formula as --

FltAlgX = asin(X[0]/65536.0f)*Rad2Deg; FltAlgY = acos(Y[0]/65536.0f)*Rad2Deg; FltAlgZ = asin(Z[0]/65536.0f)*Rad2Deg;

(Rad2Deg=180.0f/3.141592f & dividing by 65536 is to get the value in mg form not mg/LSB). I came to know that this formula is wrong. When I googled for another formula I got a number of different formulas to get angle like somewhere it's given like Ax=arctan(X/sqrt(Y^2+Z^2)) Ay=arctan(Y/sqrt(X^2+Z^2)) Az=arctan(Z/sqrt(X^2+Y^2))

So finally, I am totally confused that what the exact formula we should take to calculate the angle from accelerometer readings. Please help me to come out from this confusing scenario.

Thanks

Be the first to answer this question.