Electronic Gyro Drift Correction

Introduction

A magnetic compass is still a required navigation instrument in airplanes. The most common type is called a “whisky compass”, mounted at the top center of the panel. The compass is tilted toward the pilot to make it easier to read. Yet this also makes it accurate only in straight and level flight. When turning, the compass’ balance masses and tilt make its reading lead or lag the airplane’s actual heading.

Most airplanes also have a directional gyro. The gyro’s rotational inertia keeps it in a stable position as the airplane rotates around it. This means it reads accurately when turning. But gyros slowly drift over time. This means during straight and level flight, the pilot must occasionally check the gyro and manually set it to the compass heading. How often is occasionally? Depends on the gyro. For gyros that are entirely independent having no external correction, it’s about every 15 minutes. And this is true whether it is mechanical or electronic.

Gyro Drift

Gyro drift is caused by two factors: the rotation of the Earth, and friction (for mechanical) or noise/errors (for electronic).

The Earth rotates through 360* every 24 hours, which is 15* per hour. The gyro is immobile in space independent of the Earth’s rotation. Thus as the Earth rotates, the gyro “moves” relative to the Earth, and since the Earth is our frame of reference, this causes the gyro to drift. The relative motion of the Earth can make a theoretically perfect gyro drift up to 15* per hour from the pilot’s frame of reference.

Bearing friction and electronic noise are more intuitively obvious causes of gyro drift. With electronic gyros we have the advantage of being able to apply software corrections. Electronic gyros are based on accelerometer sensors, which means the sensor readings must be mathematically integrated to get position. Integration cumulatively amplifies small sensor errors. For example, even if the sensor’s readings consistently average the correct value over time, each individual reading will be slightly more or less. And these accumulate over time into increasing errors.

Drift Correction

One form of drift correction is when the pilot sets the gyro to match the compass heading. Immediately after this we can assume the gyro’s heading is correct. If we store each of these changes, we have a history of how much the gyro has been drifting and can use that to auto-correct and reduce drift.

Correcting this automatically applies only to electronic gyros, since we need a software algorithm to compute and apply this.

Bias and Variance

Errors and noise fall into two categories: bias and variance. Bias refers to anything systematic or predictable, variance is the unpredictable random portion of the errors. We can detect and correct for bias but not for variance. We must be careful, because misinterpreting variance as bias can increase errors rather than reduce them.

The basic idea is that after each pilot correction, we compute the rate of drift of the correction and continue to apply that to the gyro going forward. For example, if the most recent correction was +10* and it was made 15 minutes after the prior correction, the correction is +0.667* per minute, so we automatically apply that to the gyro going forward.

However, it’s not quite that simple so the idea needs refinement.

For example, suppose the drift that the pilot is correcting reverses direction each time. In this case, if we correct as above, we would actually amplify rather than reduce the drift, making things worse rather than better.

The problem is that errors are a mix of bias and variance, yet our idea only works to reduce bias, not variance. One simple way to differentiate bias from variance is to look at whether recent user corrections all go in the same direction. When this happens, there is a simple linear component to the gyro errors: it’s consistently drifting in the same direction, whether clockwise or counter (this is not the only form of bias, but it’s the simplest and easiest to detect). Yet even a blind squirrel sometimes finds a nut, and random errors will sometimes also go in the same direction. When you flip a coin, you will sometimes get heads several times in a row.

Consider that with variance (completely random errors), each pilot correction is 50% likely to be in either direction, like flipping a coin. If you flip a coin twice, you get 2 heads or 2 tails half the time. Similarly, with pure variance and no bias, about half the time each pilot correction will be in the same direction as the prior correction. Three consecutive corrections in the same direction would happen about 25% of the time. Conversely, we can say that in this case the error is 75% likely to have some bias.

So we should not apply our automatic correction unless the most recent N pilot corrections were all in the same direction, and N should be at least 3. Also, we should shrink the auto-corrected rate accordingly. For example when N=3 the error is 75% likely to have some bias, but it will always have some variance too. So let’s assume that 75% of the error is bias and shrink the correction applied going forward to 75% of the pilot-entered value. In the above example, the +0.667* per minute becomes 0.5* per minute.

Oscillation and Damping

At this point we have a simple algorithm that should improve the gyro accuracy. Yet we can improve it further without adding complexity. The idea is that our method to discern bias from variance is always imperfect, and if we get it wrong it makes things worse, not better. It is better not to correct errors, than to make them worse. Put differently, if we are too aggressive with error correction we can make things worse, while if we are too passive or conservative, it still improves things just not as much.

So, we will apply a damping factor to our corrections, shrinking them just a bit. Pick a constant scaling factor between 0.0 and 1.0 and apply that to the correction. For example, suppose we pick 0.85 or 85% and N=3. With the above example, suppose the last 3 pilot corrections were all in the same direction, and the most recent one was +10*, and it was made 15 minutes after the prior one.:

  • The raw error being corrected is 10* / 15 minutes = 0.667* / minute.
  • Because N=3 we are 75% confident there is bias in this error, so shrink it to 75% of its value.
  • Apply our damping factor of 85%.
  • This makes the auto-correction factor 0.667 * .75 * .85 = 0.425* / minute
  • Apply this rate correction automatically going forward

Overall, we end up with a single pilot correction rate that is maintained in cumulative fashion. For example, in the last step above we don’t just set it to 0.425* / minute, but we add 0.425* / minute to whatever the existing value is. And repeat every time the pilot sets the gyro, so the value changes over time, adapting to varying conditions during flight.

Conclusion

This practical example is over-simplified but it illustrates the basic concepts involved regarding bias vs. variance in errors, how to differentiate them and make corrections, and how to increase our confidence that our attempt to reduce errors doesn’t unintentionally make them worse.