I need to know how to eliminate gravity from my accelerometer readings, so when it is left stationary or is moving at the constant speed, the reading on all three axis should be zero.

I'm using an evaluation board from ST called STEVAL-MKI108V2 which comprises of 3D magnetometer, accelerometer and gyroscope, so basically 9 degrees of freedom.

I checked out a website: varesano.net - and it showed a pretty simple way to do that, but i have two questions:

- How is the quaternion representing the orientation of the entire sensor obtained?
- What is the math behind his algorithm?

Also, if there are better ways i can obtain accelerometer readings withou gravity, pls let me know.

Thanks!