Multi-rotor Control System – Part II
This post illustrates the implementation of a multi-rotor flight control system. If you missed the first post, you can find it here.
The PID Controller
PID stands for proportional-integral-derivative and is a technique that employs a feedback mechanism to vary the output of the control system. Essentially, it works by measuring the difference (error) between a process variable and a desired setpoint. It then uses this error value to manipulate the output in an attempt to minimize the error.
In the case of the quadcopter, we use one PID controller for each axis (pitch, roll and yaw). The desired setpoint is the control signal set by the operator via the remote control. Here, the operator is specifying the desired angle of the quadcopter. The error becomes the difference between this receiver signal and the angle actually measured by the IMU. The PID controller varies the control process output (motor speeds in our case) by applying an algorithm using the measured error over time to achieve a minimum output error.
The PID controller algorithm involves three separate parameters: the proportional, the integral and derivative coefficients. Each of these components is calculated and then applied (gain or attenuation) to adjust the process input. By applying a constant multiplier (coefficient) to each component, a weighted sum is calculated and can be applied to the process.
Proportional Term – The proportional component produces an output value that is proportional to the current error value. The proportional response can be adjusted by multiplying the error value by a constant (kP), called the proportional gain coeffiient.
Proportional Term – The integral component represents both the magnitude of the error and the duration of the error. The integral in a PID controller is the sum of the instantaneous error over time and gives the accumulated offset that should have been corrected previously. The accumulated error is then multiplied by the integral gain (kI) and added to the controller output.
Proportional Term – The derivative component represents a prediction of future errors, based on current rate of change. The derivative of the process error is calculated by determining the slope of the error over time and multiplying this rate of change by the derivative gain Kd. The magnitude of the contribution of the derivative term to the overall control action is termed the derivative gain, (kD).
Note: Not all PID components are always necessary. The requirements are dependent on the application. In many cases, a PI or even a P controller can be employed successfully simply by using a zero value for the unneeded component.
For more info on PID controllers and PID tuning see this excellent reference by Oscar Liang.