Personal tools

PID controller

From Gluonpilot

Jump to: navigation, search

Theory

A PID loop calculates the ouput used for steering a process, by using an error value as input:



The error value is the difference between the target value, and an actual value. For example, if the roll angle is 14 degrees and we want an roll angle of 45 degrees, the error is 31 degrees. This error is used to update 3 terms:

Proportional term: Equal to the error. Use to directly correct the error.

In this example it is 31 degrees.

Derivative term: Change in error. Used to correct sudden changes, away from the correct position. When the position starts moving away from the correct position, the error itself might still be too small for the proportional term to take enough action. The derivative term will notice this change and will change the output accordingly.

If this error value is 31 degrees, and the last error was 15 degrees, the error change is 16 degrees. If we update our PID-loop at 50Hz (20ms), the change in error is 16 degrees / 0.02s = 800 degrees per second.

Integration term: The accumulated/integrated ("sum") error. Will correct for long time small errors, just as you would when trimming your plane!

If the accumulated value until now is 12, the new value will be 12 + 31 * dt (0.02s) = 43 degrees * s.


In schematic form, this looks like:


The actual implementation can be seen in this file on the SVN server. The actual implementation is equal to this block diagram:

On wikipedia, you can find some useful information.

Gluonpilot
Automating your flight!

Contact page

Products Documentation ForumShop
Copyright (C) Gluonpilot.com