# Compensating for accelerometer values

1. Aug 22, 2008

### turban2k

This is my first post, so forgive me if I'm in the wrong place!!!

I know this topic has come up before, but I haven't seen quite what I need. I am basically looking for the math behind de-rotating the 3-D vectors (x,y,z) that I read out of an accelerometer, in order to compensate for gravity.

So I'll try to use an example. I have an accelerometer mounted on a surface, but it may be slightly tilted on the X axis (roll) and slightly tilted on the Y-axis (pitch). I'm assuming X axis points forward/back. Due to these slight rotations, I will have gravity components in the X and Y readings from the accelerometer.

So at steady state, I read out a relatively constant vector v1 = (x,y,z), where z is close to 1, but not quite since x and y are non-zero.

Given that vector v1, how do I de-rotate future readings (v2,v3 etc..) to compensate for this?? I have read lots of quaternions lately, and can sort of use them... but I can only use them to do a straight rotation about the X-axis lets say. I'm not sure how I can apply them for this example..

Any helps much appreciated!!

2. Aug 23, 2008

### D H

Staff Emeritus
A nitpick first: You do not have gravity components in any of the readings from the accelerometer. Accelerometers (in fact, no device at all) can directly sense the acceleration due to gravity.

Think about it this way: An accelerometer stationary on the surface of the Earth gives a reading of about 9.8 meters/second2 upward. That stationary accelerometer has two forces acting on it: A downward gravitation force and an upward normal force (the force that keeps the accelerometer from sinking into the table). You accelerometer is measuring the normal force but not the gravitational force. Bottom line: Because of misalignments, what you have are normal force components in the X and Y readings from the accelerometer.

That said, take a look at IEEE standard IEEE Std 1293-1998, "IEEE standard specification format guide and test procedure for linear, single-axis, nongyroscopic accelerometers". Link: http://ieeexplore.ieee.org/xpl/standardstoc.jsp?isnumber=16982 [Broken].

Last edited by a moderator: May 3, 2017
3. Aug 23, 2008

### turban2k

Yes, that's true.. I was assuming that when I said compensating for gravity, people would know it's the normal force. But you are correct.. what I need is to remove the normal component of gravity from X and Y.

Unfortunately, I Am not an IEEE member so I cannot view the full article :(

Last edited by a moderator: May 3, 2017