How to get a degree value of Accelerometer MMA7455?

How to get a degree value of Accelerometer MMA7455?

help me please... :~

Trigonometry.

AWOL: Trigonometry.

how to use it? what is the formula?

thanks for help me...

sin theta = opp / hyp or cos theta = adj / hyp

Figure out what component of g you're detecting and solve appropriately.

what you want to do is look at the datasheet for your accelerometer to find values for the voltage from x,y,z at 0 gravity, then the input voltage.

then, calculate the input voltage like this voltage_x = analogRead(xpin) * Vdd / 1023; // and same for y and z

after this, you need to calculate the offset from the 0g voltage: dx = voltage_x - V0g; // same for rest

then you can calculate the components of the g vector mentioned by AWOL (s comes from "sensitivity" described in datasheet):

gx = dx / s; // etc

after you have this, you can easily calculate the angle between the axis and the vector: m = sqrt(gx*gx + gy*gy + gz*gz); // magnitude of the vector

angle_x = acos(gx / m); // same for y and z

hope this helps

for me the issue im facing is that, the raw values i get from the Accelerometer varies between 0-65 for clockwise rotations and 255-150 for anti clockwise directions, so if im to use the above mentioned code the desired output is not obtained

for me the issue im facing is that, the raw values i get from the Accelerometer varies between 0-65 for clockwise rotations and 255-150 for anti clockwise directions

For me the issue is that it sounds more like you're talking about a gyroscope.

What i have is the same one in the link but custom made http://www.parallax.com/Portals/0/Downloads/docs/prod/sens/28526-MMA7455-3axisAccel-v1.1.pdf

Why are you describing the device's reaction to rotations? What is the application, and how is the device mounted?

The values are in reference to devices reaction to rotation. Im using the library found in this website http://code.google.com/p/mma-7455-arduino-library/ .

If I'm to rotate the accelerometer along the x-axis in the clock wise direction (where zero degree is if the device is held parallel to the ground), values will change from 0-62 (where 62 is at 90 degrees, the values decrease as you further rotate it with the output becoming zero again at 180 degrees)

If i am to rotate in the anti-clockwise direction the values will vary from 255 ( at 359 degrees ) to about 150 ( 275 degrees)

The application is to use it as a tilt sensor for a robot

AWOL: sin theta = opp / hyp or cos theta = adj / hyp

Figure out what component of g you're detecting and solve appropriately.

tan (theta) = opposite / adjacent, much more relevant to converting between 3-vectors and angles, especially as the atan2 (opp, adj) function gets the quadrant right too.

to find values for the voltage from x,y,z at 0 gravity there is none zero gravity here, unless you pay $20mil for an ISS trip :) (or your robot is free falling from the sky..) The accelerometer works nice as a tilt meter provided you do not move the stuff during the measurement, otherwise you might create additional acceleration. It depends what kind of acc. you have - for measuring tilt you need max 2g one, the acc rated for larger g-s are less sensitive for such measurement. Mind on the surface based on your geographical location there is always ~1g only (no movement).

emil01: The application is to use it as a tilt sensor for a robot

A gyroscope would probably be what you need for a robot tilt sensor. If you're trying to balance a robot, a gyroscope will work for a short while, then drift will cause it to fall over. You really need both for a balancing robot.

So, do you want to measure tilt, or are you actually trying to get it to balance?