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.
ADXL335 analog to angle
My friend has also a problem about ADXL335 analog to angle He uses this code https://developer.mbed.org/users/shivamtripathi/code/ADXL335_3axis_Accel/docs/7cef8e5abfe5/main_8cpp_source.html
and get this putty
we have no idea QQ Thanks~
1 Answer
7 years, 5 months ago.
As before start by looking up |the parts datasheet using google.
On that it tells you that for each axis the output will be 1.5V + 300mv/g
Live would be a lot simpler if he read the adc as a float between 0 and 1 rather than a u16. You're going to need to use floating point maths here anyway so there is no way to avoid the performance hit.
That will then give you a value between 0 and 1 with 0 representing 0 V and 1 representing about 3.2V (the exact voltage depends on the mbed board used, for any reasonable accuracy you'll need to verify that voltage for your board).
Multiply the reading by the ADC maximum voltage to give you an ADC reading in volts. Subtract 1.5 and then divide by 0.3 and you get acceleration in g for each axis.