by **GTBecker** » Wed Dec 09, 2009 6:06 pm

An accelerometer, when held vertically and stationary at sea level, will yield an output that corresponds to +1g. When horizontal on its sensing axis, its output is ideally zero and when vertical in the opposite rotation, the output represents -1g. That relationship makes it usable as a tilt sensor. But it also senses lateral acceleration, like a flat straight-line speed increase in an automobile, that will falsely appear to be tilt in that application, and mass-produced devices vary somewhat in sensitivity.

A rate gyro yields an output that corresponds to rotation rate, like 0.015v/degree/second, and yields an ideal zero output when it is not rotating on its sensing axis. Mass-produced devices, though, both vary in rate sensitivity, are relatively noisy, and exhibit a DC offset, the bias, at zero rate.

Neither device is ideal for sensing attitude on one axis.

The combination of a rate gyro (not a true gyroscope, BTW, which maintains an attitude; a rate gyro sensor produces change of attitude data) and an accelerometer, via a filter like a Kalman, can produce the current attitude by using one sensor to correct or compensate for the other sensor's weaknesses.

If the rate gyro bias were zero, simply integrating its output (summing successive samples at a constant rate) should produce the current attitude - which should match the tilted accelerometer ideal output. Similarly, the ideal accelerometer output should be matched by the integrated rate gyro data. In practice neither is correct at all times, but the smart math of the well-tuned Kalman (and other filters; the Kalman is not alone) is able to infer and use the errors of each to produce a correct output. The DC bias of the rate gyro is, in fact, one of the values that many Kalman implementations yield - magically, some say - even while the sensors are in constant motion.

You, I believe, are just seeing the slow high-pass correction of a typical biased rate gyro output, which must be corrected. If the bias is stable (most are temperature and shock sensitive, so the bias changes over time), all that might be necessary is to measure the bias when the sensor is stationary and subtract that value it from the output to yield a zero output at zero rotation. More sophisticated methods are usually required, though, in practical implementations that actively track the sensor changes.

There is plenty of information available on gyro/accelerometer Kalman attitude estimation implementations, although much of what you'll easily find online is often the same algorithm. There are also, though, many tomes written about these filters. "Tracking and Kalman Filtering Made Easy", a wonderfully misleading title, by Ely Brookner, is 477 pages. "Fundamentals of Kalman Filtering: A Practical Approach, Second Edition", by Paul Zarchon, et al, is 764 pages, and there are many others. Most of these require understanding some pretty heavy math, but the latter includes many Fortran, MATLAB and Basic code examples that might help.

Tom