Subsections
The first two theory and algorithm sections are there for people who
want a bit of a deeper understanding of control theory and our
particular PID implementation. The xml and tuning sections are for
people that just want to make the autopilot work. The good news is
that you can make workable autopilots without needing to understand
the theory.
I would recommend that aircraft designers start by copying the
autopilot configuration file from an existing similar aircraft. In
many cases you are done. However, if there is no existing similar
aircraft, or something doesn't work stably for you, you will most
likely need to tune your autopilot modules.
The most basic method of tuning is the trial and error method. This
method involves adjusting the proportional gain, the integral time and
the derivative time until the performance is satisfactory. The three
settings are often adjusted separately in order to see the effects of
the different settings. This process can be time consuming.
It can be difficult to get started using the trial end error
method. What kind of gains and times should one start out with? A
typical approach for tuning a PID controller can be summarized as
follows:
- Eliminate integral and derivative action by setting the
derivative time,
, to its minimum value (zero) and the
integral time,
to its maximum value.
- Set the proportional gain,
to a low value
(0.5) and enable the controller.
- Increase the proportional gain by small increments until
continuous cycling occurs after a small set-point or load
change. The term "continuous cycling" refers to a sustained
oscillation with constant amplitude. At first it might be useful to
increment
by an order of magnitude (i.e. multiply or divide
by 10) just to get yourself in the right ball park. Then you might
consider doubling or dividing by two to get closer.
- Reduce the gain by a factor of two.
- Decrease the integral time until continuous cycling occurs
again. Set integral time,
to three times this value. Note
that because of the way the formulas are constructed, a smaller
integral time means a larger integral component.
- Increase derivative time,
until continuous cycling
occurs. Set derivative time to one-third of this value. Note that
because of the way the formulas are constructed, a larger derivative
time means a larger derivative component (which is opposite from the
effect of changing
.
The proportional gain that results in continuous cycling in Step 3 is
called the ultimate gain. In performing the experimental test to find
the ultimate gain, it is important that the output does not
saturate. If saturation occurs it is possible to get continuous
cycling even though the gain is higher than the ultimate gain. This
would then result in a too high gain in Step 4.
Disadvantages of the trial and error method include:
- It is quite time consuming if a large number of trials are
required in order to find the ultimate gain and the integral and
derivative times that result in continuous cycling.
- The method is not applicable to processes that are open-loop
unstable because such processes are typically unstable at both high
and low gain values and are stable for intermediate gain values.
- Some simple processes do not have an ultimate gain.
The Ziegler-Nichols methods of controller tuning are the "closed loop"
and the "open loop" method. The closed loop method is quite similar to
the trial and error method:
Steps 1-3 are the same as in the trial and error method.
Step 4. Take note of the ultimate gain
, and the ultimate
period
. The ultimate period is the period of the oscillations.
Step 5. Calculate controller settings according to this table:
| Controller |
 |
 |
 |
| P |
 |
inf. |
0 |
| PI |
 |
 |
0 |
| PID |
 |
 |
 |
For more info on tuning and PID control systems follow this link:
http://www.jashaw.com/pid
I will include a few more tuning tips here as I learn more about how
the algorithm works. Here are a few things to consider.
- The algorithm is written in ``velocity form''. This means
that for the proportional component, the change in error from the
previous iteration is used, rather than the absolute error. For the
integral and differential components, the absolute error is used.
- If the initial change in error is outside the range of the
min/max values, the anti-integrator windup will chop this to zero.
The next iteration the error probably won't have changed much so you
can get a system that doesn't track the target very well. In this
case you simply need to increase the integral component to get the
change in error (i.e. velocity) moving a bit.
- You can set
<debug>true</debug> to get console
debugging output for a particular PID module. This will show you
things like the target value, the input value, some of the internal
error terms calculated and finally the output value. This can be a
very useful sanity check.
- If the system starts with an sane initial output value, but
then drops the output to a small value way too soon and hovers at a
stable, but wrong value, you likely do not have enough integral
component.
- The proportional gain,
, is multiplied by against all
the error terms so it is really a ``global'' gain rather than just a
proportional gain. If you change
substantially, you may
also need to change
and
. Note that in the tuning
procedure described previously, you are instructed to initially set
to
and
to nearly zero, then tune
first.
You do not need to restart FlightGear each time you tweak an autopilot
parameter. You can edit the configuration file and then have FG
reload the config file on the fly. The general procedure is as follows
- Edit the autopilot configuration file with your favorite text
or xml editor. Save your changes.
- Select
Reload Autopilot from the Debug menu.
FG will immediately reload your autopilot configuration file.
- It is a good idea to only change one parameter at a time.
Curtis L. Olson
2004-02-04