Understanding PID Controllers: Stable Flight in Drones and Beyond

squonk
5 min readJul 5, 2023

Suppose you have a drone you want to hover in the air at a specific altitude. The drone uses its propellers to generate an upward force that counteracts the force of gravity pulling it down.

The drone can adjust the propeller speed based on the drone’s current position and velocity with other controllers (proportional and derivative controllers) but without an integral controller, the drone would struggle to maintain a stable hover position.

But why it is that important?

Imagine the drone as a little flying robot that needs to stay at a certain height in the air, like how a helicopter hovers. To do this, it uses its propellers to create an upward force that balances out the force of gravity pulling it down.

Forces affecting a drone. Lift, thrust, motion, drag, and weight

But sometimes, there can be some small problems, can wind might push the drone up or the propellers might not work exactly as expected. This can make a small change in the force so the drone goes slightly higher or lower than the desired height.

To fix this, the drone has smart controllers. Three of these controllers are "proportional", “derivative" and "integral”. Which we will discuss later.

The PID (Proportional-Integral-Derivative) control system combines proportional, derivative, and integral controllers to achieve precise and stable drone flight. It effectively counters disturbances and maintains a steady position at the desired height. PID control is widely used in drone flight control and other applications.

PID Controller block diagram

Let’s take a look at what these controllers do:

1- Proportional Controller

A proportional controller, also known as a P-controller, is a fundamental component of many control systems. It provides control action proportional to the error between the desired setpoint and the measured process variable.

Imagine you’re piloting a drone and you want it to stay at a specific height. You set the desired height on the controller, which is like the setpoint (SP) in the proportional control system. The drone has sensors that measure the current height, which is the process variable (PV).

Now, let’s say the drone is flying too high. In proportional control, the correction applied to the drone’s height will be proportional to the difference between the desired height and the current height.

To make sure the drone stays at the desired height, its controller constantly adjusts the power of its motors based on the difference between the desired and measured height. If the drone is higher than desired, the motors are slowed down to gently bring it down. Conversely, if the drone is lower than desired, the motors are sped up to gently raise its altitude.

The amount of correction applied depends on how big the difference is between the desired and measured height, with larger differences resulting in stronger corrections.

2- Derivative Controller

A derivative controller, or D-controller, helps in controlling a system by looking at how fast things are changing. It pays attention to how quickly the difference between the desired value and the actual value is changing.

It looks at how fast the altitude is changing and calculates the derivative of this change. This helps the controller make adjustments to keep things in balance and prevent things from changing too quickly.

Let’s imagine you’re flying a drone and want it to stay at a certain height. The D-controller helps keep the drone steady by looking at how quickly the drone’s height is changing. If the drone is going up or down too fast, the D-controller will make adjustments to slow it down. This helps the drone stay at the desired height smoothly.

The D-controller is an essential component in drone flight control systems, ensuring stability and precise altitude control. Drones require steady hovering or specific heights for tasks like aerial photography, surveying, surveillance, or package delivery. Without a D-controller, external factors like wind gusts or payload changes could cause uncontrollable altitude fluctuations.

3- Integral Controller

Steady-state error is defined as the difference between the input and output of a system in the limit as time goes to infinity.

An integral controller, also known as an I-controller works by accumulating the error signal over time and using this integrated value to make appropriate adjustments to control inputs.

For example, when the drone deviates from its setpoint, the integral controller takes note of the duration and magnitude of the error and applies corrective actions proportionally. By doing so, it helps the drone correct for any differences between the desired altitude and its actual altitude, allowing for a stable and precise hover at the specified height.

Without the integral controller, the drone’s performance in maintaining the desired altitude could suffer significantly. The proportional and derivative controllers can handle immediate adjustments, but they may struggle to eliminate small, persistent errors that occur over time, leading to steady-state errors. Which I mention earlier.

As a result, the drone might experience constant oscillations around the target altitude, never settling precisely at the desired level. In the absence of the integral controller, the drone’s altitude control would lack the crucial ability to learn from past errors and could lead to a less stable and less accurate flight experience.

For example, with an integral controller in place, a drone tasked to hover at a specific altitude can efficiently maintain that height, even in the presence of slight external disturbances like wind. The integral controller detects any minor deviations from the target altitude and gradually adjusts the propeller speed or other control inputs to counteract those deviations, ultimately keeping the drone steady and on course.

Without the integral controller, the drone might experience constant altitude fluctuations, struggling to stabilize at the desired height and making its performance less reliable and less precise.

In this article, I tried to explain control theory to someone who wants to understand it without overwhelming the engineering terminology and get the basic perspective from a real-life example, DRONES! If you want to hear more about the mathematics inside these systems or go further, let me know!

--

--