Accelerometer Continued Troubles

Our range of tiny modules are designed to make it easy for you to quickly add functionality to your projects. [Module List]
Post Reply
avrdude
Posts:32
Joined:Mon Sep 30, 2013 3:42 pm
Accelerometer Continued Troubles

Post by avrdude » Mon Feb 24, 2014 1:10 pm

Hi
I know I had a post recently about the accelerometer, and you're probably thinking "oh no not this guy again", but after confirming my module works, I am confused as to how one actually determines the g-force from the output voltage.
Which equation should I use:

g = (v - 1.65) / 0.8

or

g = (v / 0.8) - 1.65

Or are neither of those correct and I am on the wrong path?
I have tried equation 1, and it seems to work for the x and y axis, but the z axis displays -0.4 when at 0g.
I then tried equation 2, which I'm pretty sure is incorrect, but resulted in the z axis correctly displaying all g-forces experienced. However, the x and y axis were way out.
What am I doing wrong?
Thanks

andrew
Freetronics Staff
Freetronics Staff
Posts:978
Joined:Sun Jul 14, 2013 7:06 am
Location:Melbourne, Australia
Contact:

Re: Accelerometer Continued Troubles

Post by andrew » Mon Feb 24, 2014 9:58 pm

Give this library a try, it works well:
https://code.google.com/p/mma7361-library/

avrdude
Posts:32
Joined:Mon Sep 30, 2013 3:42 pm

Re: Accelerometer Continued Troubles

Post by avrdude » Wed Feb 26, 2014 9:53 am

Hi,
Thanks for the link, that library works good, but I'd rather write my own code (and i thought people encouraged writing one's own code), so could you please tell me the correct equation to use?
Thanks

andrew
Freetronics Staff
Freetronics Staff
Posts:978
Joined:Sun Jul 14, 2013 7:06 am
Location:Melbourne, Australia
Contact:

Re: Accelerometer Continued Troubles

Post by andrew » Wed Feb 26, 2014 9:43 pm

G value = (ADC x AREF/1023) - Q;

where ADC is the raw value from analogRead(), AREF is the analogue reference voltage you're using (3.3 or 5) and Q is the value for zero-g (Voff in table 2 of data sheet) which is 1.65 at 25 degrees Celsius.

avrdude
Posts:32
Joined:Mon Sep 30, 2013 3:42 pm

Re: Accelerometer Continued Troubles

Post by avrdude » Thu Feb 27, 2014 11:19 am

Thanks, now I know definitely what to do.

Post Reply