Calculating Roll & Pitch Angles with Accelerometer Data

AI Thread Summary
The discussion focuses on calculating roll and pitch angles using data from a 3-axis accelerometer. The user successfully normalizes the accelerometer data and applies equations for roll and pitch but encounters instability when angles approach ±90 degrees, leading to erratic pitch values during roll. The issue is attributed to the z-axis becoming perpendicular to gravity, complicating calculations. Suggestions include incorporating the x-axis into the calculations to improve accuracy during transitions. Alternative equations for roll and pitch using the arcsine function are also proposed as potential solutions.
para
Messages
2
Reaction score
0
Hi, I'm new to the forum.

I have a 3 axis accelerometer that I am trying to obtain roll and pitch from. Besides the accelerometer itself, I was provided the raw data values of what each axis will report when it has 0g being applied to it and when it has 1g being applied to it. Using this I am able to find and normalize how many gravity forces are currently being applied to each axis.

In the rest of this post assume x, y, and z are normalized; so if x=1 then 1g is applied to the x-axis in the positive direction.

I'm using the following equations:

roll = atan(\frac{z}{x})
pitch = atan(\frac{z}{y})

If the accelerometer is lying flat, with the z-axis facing up, and I rotate it over the y-axis (roll), then I can use the above equation to obtain the roll from 0 to 360 degrees. Same with pitch.

However I run into two problems:
  1. When either roll or pitch reach ~\pm90 degrees then the other angle experiences unusual behavior. For instance, if I roll it over to 90 degrees the pitch may suddenly become 45, 92, 120, etc (it's unstable).
  2. It also appears that if I both roll and pitch the device at the same time the values are not correct.

Is there a special way to calculate angles based on this type of data, or am I just going about this wrong? It's been a while since I've done any 3d geometric math and I don't remember a whole lot.

Thanks.
 
Mathematics news on Phys.org
How is the accelerometer constructed?
 
The chip itself is an http://www.analog.com/en/prod/0%2C2877%2CADXL330%2C00.html" .

I think the problem may be that when I roll the chip 90 degrees, the z-axis becomes perpendicular to gravity. The z-axis is used in the calculation for pitch when roll is near 0.

The solution to this is probably somehow incorporating the x-axis into the calculation in order to compensate for the transition from x to z moving towards gravity during roll, however I'm unsure of how to go about doing that. Does that make any sense?

I'm a little surprised I wasn't able to find more about this on Google seeing as how accelerometers have been around forever.
 
Last edited by a moderator:
Roll= Asin(X-axis) in radian * 180/Pi in degree
Pitch= Asin (Y/axis) in radian * 180/Pi in degree

Try these equations may be this will work for you.

I am Using LIS302DL, both equation are working fine for me.. in order to find the pitch and roll angle from raw acceleration data
 
Suppose ,instead of the usual x,y coordinate system with an I basis vector along the x -axis and a corresponding j basis vector along the y-axis we instead have a different pair of basis vectors ,call them e and f along their respective axes. I have seen that this is an important subject in maths My question is what physical applications does such a model apply to? I am asking here because I have devoted quite a lot of time in the past to understanding convectors and the dual...
Insights auto threads is broken atm, so I'm manually creating these for new Insight articles. In Dirac’s Principles of Quantum Mechanics published in 1930 he introduced a “convenient notation” he referred to as a “delta function” which he treated as a continuum analog to the discrete Kronecker delta. The Kronecker delta is simply the indexed components of the identity operator in matrix algebra Source: https://www.physicsforums.com/insights/what-exactly-is-diracs-delta-function/ by...
Back
Top