Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
7 years, 5 months ago.
ADXL345 output data convert to angle
i use ADXL345 to measure the data and its output is like this +-16g
but i have no idea about the data unit and convert it to angle it maybe need some formula
Thanks~
1 Answer
7 years, 5 months ago.
See the datasheet for the part
On page 4 there is an entry of Scale Factor at Xout, Yout, Zout. Multiply the reading you are getting by the scale factor and you will get the acceleration in each axis in mg.
Going by the values you are getting you are either in 2g mode already or are in full resolution mode which gives the same scale factor for all operating ranges.
To calculate orientation the first thing to do is verify that your total acceleration (sqrt (x*x + y*y + z*z)) is close to 1g. If it is then the chances are you are static, if it isn't then you're moving and the orientation value is unreliable. This isn't a foolproof check but it's better than nothing.
If you are stationary then the only acceleration is 1g down due to gravity. Therefore acos(x reading/total acceleration) will give the angle between the x axis and vertical, repeat for the other two axes.