Pages: [1]   Go Down
Author Topic: Problems with angle estimation using ADXL345  (Read 1458 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 15
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

I'm currently using the ADXL345 3-axis accelerometer (part of the 6DOF IMU, incl ITG-3200 Gyro) to sense the pitch and roll angles.

Syntax:

acc_angle[0] = atan2(acc_g[0],acc_g[2]) * 180 / PI;
acc_angle[1] = atan2(acc_g[1],acc_g[2]) * 180 / PI;

where acc_g[0] = x-axis gravitational reading (g)
         acc_g[1] = y-axis gravitational reading (g)
         acc_g[2] = z-axis gravitational reading (g)

The above code makes use of the gravitational readings (g) of the accelerometer to measure the angular tilt. It works fine, however when the z-axis of the accelerometer goes parallel with the ground (ie. acc_g[2]=0), the readings goes bonkers. I figured it's because of the trigo mathematics using atan2 then causes it when acc_g[2]=0.

Any ideas on how to solve this problem?
Logged

Offline Offline
Jr. Member
**
Karma: 4
Posts: 68
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
the atan2 function should return 1.570 = PI/2 when the second argument is zero.
Logged

0
Offline Offline
Shannon Member
****
Karma: 207
Posts: 12189
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Define "bonkers"
Logged

[ I won't respond to messages, use the forum please ]

Pages: [1]   Go Up
Jump to: