A Simple Explanation to PID Controller
In this article I will explain the PID control in a simple non-mathematical way on a flying drone.
What is the PID Control?
The PID (proportional integral derivative)control is a closed loop control which means that the input to the system is an error which is the subtraction between the desired value and the actual value.
Moving the Drone in one direction
For simplicity, let’s say that the drone moves only in one direction which is up and down ( Z-axis) so the error will be the subtraction between the target altitude and the actual altitude.
Resting the Drone on the ground
If the drone is resting on the ground and you want it to fly 100 meters high, the difference between the actual and the target altitude will be 100, this input in the system will control the thrust of the drone’s propellers so the thrust force will increase to fly the drone, what happened now is the ‘P’ part of the PID controller which is the Proportional part.
But what will happen when the drone reaches the target altitude? Since we’re controlling the thrust force of the propellers, the thrust force then will be zero because we reached the target altitude and this will cause the drone to oscillate around the target altitude.
Hovering the Drone
This means having the drone at constant height. In order to know this, I will introduce the Proportional Gain which is the ratio between the output and the error signal, which in this example, will be Kp =Thrust/Error.
Assuming, the drone will hover when the thrust force equals to 100N and the Kp equals to 1, so when the drone is still on the ground the Error is equals to 100 and Kp is one that means that the thrust will be 100N, which means it will hover when still on the ground.
So let’s increase the value of the gain (Kp) let’s make it 5 so now the error will be 100/5=20, which means that the drone will start hovering at altitude 80 meters.
What I’m trying to conclude is that you will never reach the target altitude. The error may increase but will never reach the exact target altitude and the drone will be in a Steady State which leaves you wondering if there is anything that can be done.
The answer is Yes! This is where the Integral Part (I) comes in.
As explained previously, the Proportional part uses only the present information about the drone, but the integrator sums up the input signal over time, it has a memory of what had happened before, so when the drone reaches the Steady-State below the target altitude, so the error is not zero and whenever the error is not zero the integrator increases the output.
In this case it will increase the thrust force above 100N to reach the target altitude. The proportional and integrator works in parallel together but when the drone is hovering; which means it reached the target altitude and the error is zero so the proportional path is doing nothing. But the integral path has been summing and subtracting values until the thrust reaches 100N.
In order to reach the target altitude, the integrator may have summed to a value bigger than 100N, which will keep the drone rising since the drone is still below the target altitude, so to remove that excess propeller thrust the drone have to go higher than the target altitude to create a negative error and when this negative error is summed it lowers the output of the integrator and slows the propellers down.
To exceed the target altitude is called Overshoot which we don’t want it to happen. To prevent this overshooting is by adding a path to the controller that predicts the future and responds how fast the drone is close to the target altitude.
The derivative measures the rate of change of the error, to elaborate more let’s say that now the drone is flying high quickly and reaching the goal, so this means that the error is quickly decreasing and since it is decreasing that means that it has a negative value through the derivative path and that negative value will add to our controller output, and therefore lowering the propeller thrust so that will make the drone to overcome the overshooting.
Thanks for reading my first article. Let me know your feedback in the comments below.