Subsections

PID Algorithm Implementation

The PID algorithm used for the FlightGear autopilot was provided by Roy Ovesen. It is more sophisticated and approaches the problem a bit differently than the what I describe earlier. Rather than dealing in absolute terms, it calculates a change in output based on the change in error. It is able to ease into large control inputs rather than slam the controls full stop if there is a larger error term when it is activated.

Finally it handles the problem of integrator windup. Integrator wind up can occur when the system simply can't get to the target value, even at full control input. For instance a large truck commanded to go 90km/hr might slow to 70km/hr on a steep hill even at full throttle. During this time while climbing the hill, the integrator term is accumulating a tremendous amount of error. This is called integrator windup. Once you hit the crest of the hill you have to overshoot the target speed for a while to ``unwind'' the integrator term (which at this point may have grown very large.) This can cause you to significantly over-speed for as long as you were undershooting the target. This can lead to many unsafe and unstable situations so ``integrator windup'' is generally considered an undesirable effect.

Mathematical Formula

The change in output, $ \Delta u_{n}$, for the current time step is calculated as follows:

$\displaystyle \Delta u_{n} = K_{P} \cdot \left[ (eP_{n} - eP_{n-1}) + \left(\fr... ... + \frac{T_{d}}{T_{s}} \cdot (eDf_{n} - 2 \cdot eDf_{n-1} + eDf_{n-2}) \right] $

The absolute output, $ u_{n}$ is then calculated as:

$\displaystyle u_{n} = u_{n-1} + \Delta u_{n} $

Where:

Variable Description
$ \Delta u_{n}$ The incremental output
$ K_{P}$ Proportional gain
$ eP$ Proportional error with reference weighing
  $ eP = \beta \cdot r_{n} - y_{n}$
  where:
  $ \beta$: Weighing factor
  $ r_{n}$: Reference (setpoint)
  $ y_{n}$: Process value, measured
$ e_{n}$ Error, $ e_{n} = r_{n} - y_{n}$
$ T_{s}$ Sampling interval (i.e. $ \Delta t$)
$ T_{i}$ Integrator time
$ T_{d}$ Derivator time
$ eDf$ Derivate error with reference weighing and filtering
  $ eDf_{n} = eDf_{n-1} / (\frac{T_{s}}{T_{f}} + 1) + eD_{n} \cdot \frac{T_{s}}{T_{f}} / (\frac{T_{s}}{T_{f}} + 1)$
  where:
  $ T_{f}$: Filter time
  $ T_{f} = \alpha \cdot T_{d}$ where $ \alpha$ usually is set to 0.1
  $ eD$: Unfiltered derivate error with reference weighing
  $ eD = \gamma \cdot r_{n} - y_{n}$
  where:
  $ \gamma$: Weighing factor
$ u_{n}$ absolute output

Algorithm inputs

Variable Description
$ y_{n}$ Current process value
$ r_{n}$ Reference point
$ \beta$ Proportional weighing factor (default = 1)
$ \gamma$ Unfiltered derivative error weighing factor (default = 0)
$ \alpha$ Filter time weighing factor (default = 0.1)
$ K_{P}$ Proportional gain
$ T_{s}$ Sampling interval (i.e. $ \Delta t$)
$ T_{i}$ Integrator time
$ T_{d}$ Derivator time
$ u_{min}$ Minimum output value for $ u_{n}$
$ u_{max}$ Maximum output value for $ u_{n}$

Algorithm output

Variable Description
$ u_{n}$ Absolute output value
Curtis L. Olson 2004-02-04

Google Advertisements - Click to support FlightGear

Latest Version

v2.0.0 - 18 Feb 2010

A new major update of the FligtGear simulator. Please check the readme

Notam

Notam image file

Would all pilots try and avoid mpserver02 as its often overloaded.