Many Multirotor, Quadcopter software, such as Cleanflight, Multiwii, allow users to change PID values to adjust the performance of their quadcopters. In this post I will explain briefly what PID is, how it affects aircraft stability, and how to tune PID for your quadcopter.
Be warned, this article is a bit on the “academic” side. I tried to explain it in a more practical way in this simplified PID explained post, so make sure you check it out also! Apart from PID, Rates and expo are just as important to quad’s flight performance and control.
Article first created in Oct 2013, last updated Oct 2016.
What Is PID?
PID (proportional-integral-derivative) is a closed-loop control system that try to get the actual result closer to the desired result by adjusting the input. Multicopters use PID controller to achieve stability.
There are 3 algorithms in a PID controller, they are P, I, and D.
P depends on the present error; I on the accumulation of past errors; while D is a prediction of future errors based on the current rate of change.
To have any kind of control over the quadcopter we first need to measure the quadcopter sensor output (for example what angle the quad is on each axis). Knowing what desired angle we want the quad to be, we can estimate the error. We can then apply the 3 control algorithms to the error, to get the next outputs for the motors aiming to correct the error.Each of these control algorithm would introduce some unique effects to the craft’s flight characteristics, which we will explain further later.
As RC multirotor pilots, there are three parameters that we can adjust to improve better quadcopter stability based on different situations. These are the coefficients to the 3 algorithms we mentioned above. The coefficients basically would change the importance and influence of each algorithm to the output. Here we are going to look at what are the effects of these parameters to the stability of a quadcopter .
You don’t need to fully understand how PID controller works in order to fly a quadcopter. However, if you want to read more on the theory, here is a very interesting explanation of PID controller with examples. This PID tutorial is also very good and easy to understand for beginners.
The Effect Of Each Parameter
On a multirotor there are 3 axis, and each axis there is a PID controller. That means we will have a separate set of PID coefficients for each axis (Pitch, Roll and Yaw)
Generally, altering PID have the following effect on a quadcopter’s behavior:
- Proportional Gain coefficient – you quadcopter can fly with just P gain even without the other 2 parameters. This coefficient determines which is more important, human control or the sensor measurement from Gyroscopes. The higher the coefficient, the more sensitive and stronger the quadcopter reacts to angular change. If it is too low, the quadcopter will appear to be more sluggish and softer, and harder to stay steady. One negative impact when P gain is too high is oscillation and over-correcting.
- Integral Gain coefficient – this coefficient influence the precision of the angular position. This term is especially useful with in windy situation, with low I gain your quadcopter will simply drift away with the wind. However, when the I value gets too high your quadcopter might begin to have slow reaction and a decrease effect of the Proportional gain as consequence. It will also start to oscillate like having high P gain, but with a lower frequency.
- Derivative Gain coefficient – In a quadcopter, this coefficient works as a dampener and reduces over-correcting and overshoots caused by P term.
- Requires a slightly higher P
- Requires a slightly lower I
- Higher D to compensate for the P
Gentle Smooth Flight:
- Requires a slightly lower P
- Requires a slightly higher I
- Lower D
How to tune quadcopter PID Gains
It’s best to tune your quad in Rate Mode (aka Acro Mode).
Before I start, I always lower all the PID values by at least half, to make sure they are definitely not too high to start with. Then slowly increase them until you find the perfect flight characteristics.
I usually tune one axis at a time, roll, pitch then yaw. And at each axis, I adjust one value at a time starts with P gain, I and then D gain. You will need to constantly go back to fine tune the values as one value could affect the effectiveness of another value.
For P gain, I first start low and work my way up, until i notice it’s producing oscillation. Fine tune it until you get to a point it’s not sluggish and there is not oscillation.
For the I gain, again start low, and increase slowly. Roll and pitch your quad left and right and center your stick immediately. Pay attention to the angle changes. You want to get to a point where it just stays in the same angle as you release the stick. You might also want to have a stronger I gain for windier weather.
For D gain, I tend to keep this as low as I can. I use just enough to eliminate any overshooting when I am doing rolls or flips.