Calculating Roll & Pitch Angles with Accelerometer Data

  • Context: Undergrad 
  • Thread starter Thread starter para
  • Start date Start date
  • Tags Tags
    Accelerometer Angles
Click For Summary

Discussion Overview

The discussion revolves around calculating roll and pitch angles using data from a 3-axis accelerometer. Participants explore the challenges associated with angle calculations, particularly when the device is oriented in certain ways, and consider different mathematical approaches to resolve these issues.

Discussion Character

  • Technical explanation
  • Debate/contested
  • Mathematical reasoning

Main Points Raised

  • One participant describes their method for calculating roll and pitch using the equations roll = atan(z/x) and pitch = atan(z/y), noting issues when angles approach ±90 degrees.
  • Another participant questions the construction of the accelerometer, suggesting that the orientation of the z-axis may complicate calculations when it becomes perpendicular to gravity.
  • A later reply proposes alternative equations for calculating roll and pitch using arcsine functions, indicating that these worked well for their own accelerometer model.
  • There is a suggestion that incorporating the x-axis into the calculations may help address the instability observed when transitioning between roll and pitch angles.

Areas of Agreement / Disagreement

Participants express differing views on the appropriate methods for calculating roll and pitch angles, with no consensus reached on a single solution. Some methods are proposed, but the effectiveness of these methods remains uncertain.

Contextual Notes

Participants highlight potential limitations in their approaches, such as the dependence on the accelerometer's orientation and the mathematical transitions between axes. There are unresolved questions about the best way to integrate multiple axes into the calculations.

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:

[tex]roll = atan(\frac{z}{x})[/tex]
[tex]pitch = atan(\frac{z}{y})[/tex]

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 ~[tex]\pm[/tex]90 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
 

Similar threads

  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 47 ·
2
Replies
47
Views
5K