Electronic – angle calculations

accelerometerfilterspeed

I am using a Freescale 3 axis accelerometer to build a model that flies and would like to log and calculate angles during a flight. My model can both hover and move up to 40kph as well as rotate on any axis 360 degrees. I have done some basic calculations on angles using raw data sent back but the data looks kind of weird with spikes.Right now I am just using Excel to do the calculations until I get the formulas correct for the software I'm developing. I am using:
X-data = column B
Y-data = column C
Z-data = column D
pitch = ATAN(B3/SQRT(C3^2+D3^2))
roll = ATAN(C3/SQRT(B3^2+D3^2))
theta = ATAN(SQRT(B3^2+C3^2)/D3)

The questions I have are:
Is there a way to calculate speed from the data?
Can I filter out the spikes using some sort of software filtering without skewing the data?

Thanks,

JB

Best Answer

In general, you can integrate acceleration data to obtain rates, and further integrate rates to get position/attitude information. This is known as dead-reckoning.

The model you described has what's known as 6 degrees of freedom. The six degrees are three translational: the north-south axis, east-west axis, up-down axis, and three angular: roll, pitch, and heading (and/or yaw).

Translational accelerations will show up directly as changes in one or more of the three channels. You can get angular orientation by isolating out the 'bias' acceleration due to gravity.

As for noisy spikes in the data, the easiest approach is to run a low-pass filter (LPF) of some kind on the data. This can be done in software with a moving-window time average of the last N samples. You have to be aware though, that since your speed and position data is an integration of the raw data, that any errors also get integrated. In other words, your sensor-based estimate of the vehicle's position, speed, orientation all become less accurate as time goes on, so the better you can remove the noise, the better your navigational solution will be.