# Calculating direction of acceleration from MEMS sensor

• Aug 2nd 2008, 08:54 PM
ashesman
Calculating direction of acceleration from MEMS sensor
Hi all,

I am working on an embedded software project using a 3 axis MEMS accelerometer. The accelerometer outputs an X, Y and Z value in mG's. So when level the output is X=0, Y=0, Z=1000, on its side the output is X=0, Y=1000, Z=0 and on its end the output is X=1000, y=0, Z=0. ie showing gravity. The outputs can be positive or negative.

I want to be able to measure acceleration ignoring the effect of gravity. So for example if you held the device on a piece of string and spun it around parallel to the floor it would only show acceleration in the X and Y directions and nothing on the Z axis.

This sounds reasonably simple... just ignore the Z reading. But what if you spun it around parallel to the wall?

You can measure the total acceleration by A= sqrt(X^2 + Y^2 + Z^2) but that includes the effect of gravity and does not give the direction. It is a while since I studied maths so any help would be greatly appreciated.
• Aug 3rd 2008, 12:02 AM
CaptainBlack
Quote:

Originally Posted by ashesman
Hi all,

I am working on an embedded software project using a 3 axis MEMS accelerometer. The accelerometer outputs an X, Y and Z value in mG's. So when level the output is X=0, Y=0, Z=1000, on its side the output is X=0, Y=1000, Z=0 and on its end the output is X=1000, y=0, Z=0. ie showing gravity. The outputs can be positive or negative.

I want to be able to measure acceleration ignoring the effect of gravity. So for example if you held the device on a piece of string and spun it around parallel to the floor it would only show acceleration in the X and Y directions and nothing on the Z axis.

This sounds reasonably simple... just ignore the Z reading. But what if you spun it around parallel to the wall?

You can measure the total acceleration by A= sqrt(X^2 + Y^2 + Z^2) but that includes the effect of gravity and does not give the direction. It is a while since I studied maths so any help would be greatly appreciated.

Without knowing the instantaneous orientation you cannot usualy remove g.

RonL
• Aug 3rd 2008, 12:19 AM
ashesman
From what I have figured out so far it is impossible to remove the effect of gravity. It is like having two pieces of string tied to the same point and pulling on them both with different directions and forces. You cant calculate the force on each piece of string from just measuring the force at one point. so you cant separate the effect of gravity and external acceleration when all you can measure is the combined effect of them both.

If the actual angle of the accelerometer could be measured then this would be a different story.

Does anybody agree?