Go Down

Topic: Problems with angle estimation using ADXL345 (Read 1 time) previous topic - next topic

hexaruby

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?

ea123

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

MarkT

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

Go Up
 

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it's been approved by a moderator.
Name:
Email:

shortcuts: alt+s submit/post or alt+p preview