Many quadcopter software such as Betaflight and KISS allow users to adjust PID values to improve the flight performance. In this post I will explain what PID is, how it affects aircraft stability, and finally go through how to tune PID for your quadcopter.
After reading this PID guide, I also suggest to go ahead and read the more in-depth PID tuning guide. I tried to simplify the concept and explain it in a more practical way, so if you have any trouble understanding what PID is in this article, the other post might help.
What Is PID for a Quadcopter?
PID is a function in flight controllers. It reads the data from sensors, and tells the motors how fast they need to spin. Ultimately this is how to stability is achieved on a quadcopter.
PID stands for proportional-integral-derivative. PID controller is a closed-loop control system that tries to get the actual result closer to the desired result by adjusting the input. The error is fed back to the beginning, and the same process repeats.
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 a quadcopter:
- We first need to measure the quadcopter’s angular rate (how fast the quadcopter is rotating in each axis)
- Knowing what the desired angular rate 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
That really just is the “academic description” of how PID controller works. In practice, each of these three parameters presents some unique effects to the craft’s flight characteristics and stability.
These parameters are numbers we can play around with. They are basically just the coefficients to the 3 algorithms we mentioned above. The coefficients change the influence of each algorithm to the output. Here we are going to look at what the effects of these parameters have to a quadcopter .
A multirotor can rotate in 3 axis, and for each axis there is a PID controller for it. That means we will have a separate set of PID coefficients for each axis (Pitch, Roll and Yaw), in total 9 values we can tune.
You don’t need to fully understand how PID controller works in order to fly a quadcopter. However, if you’re interested in the theory and background, 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
Generally, altering PID values (gains) have the following effect on a quadcopter’s behavior:
Probably the most fundamental value in PID, because you quadcopter can fly and stabilize with only just P gain without the other 2 parameters (I and D).
This coefficient determines the strength of correction. 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 soft, harder to stay steady. One negative impact though when P gain is too high is over-correcting and oscillations.
This coefficient influences the precision of angular position. Higher I gain is especially beneficial in windy environment. With low I gain your quadcopter will simply drift away with the wind because it won’t hold the angle.
In a perfect environment, I gain is not required. However the real world isn’t perfect, there are many variables such as CG in the aircraft, wind and gravity.
However, when I value gets too high your quadcopter might start to feel stiff and doesn’t respond to your stick that well. It’s similar to having a slower reaction and a decrease effect of the Proportional gain. In more extreme cases with excess I gain, the copter might even oscillate in a lower frequency.
D gain works as a dampener and reduces the over-correcting and overshoots caused by P term. It makes your quad fly smoother and potentially can minimize propwash oscillations as well.
However excessive D value can introduce vibration in your quadcopter because it amplifies the noise in the system. In the attempt to make your quadcopter fly smoother it will tell the motors to spin faster or slower in a very fast rate that the motor cannot keep up, and eventually cause motor overheat.
Another side effect of high D term is increased latency in the quad’s control and reaction.
How to tune quadcopter PID Gains
- Always tune your quad in Rate Mode (aka Acro Mode)
- Make sure your quadcopter’s CG (centre of gravity) is right in the middle, CG has a significant effect on how good your quad can fly, and can be tuned
There is no right or wrong way of tuning PID, whatever works for you is the right way.
I normally start out by using default PID when I tune my quad. With modern flight controller software such as Betaflight and KISS, the stock values work very well for most setups out of the box.
I fly around, notice any undesired behaviour and then adjust PID accordingly. If the quad flies really badly with default PID values, for example, lots of vibrations, you can try tuning PID from low values. Just lower all the PID values half or more, to make sure they are definitely not too high to start with.
Every time when you adjust PID, you should ask yourself: “is it getting better or worse?” Find the point where it has the best flight characteristics before it goes down hill again.
Tune one axis at a time: first roll, then pitch, and finally yaw. And at each axis, I adjust one value at a time starts with P gain, then D gain, and finally I gain. You will need to constantly go back to fine tune the values as one value could affect the effectiveness of another.
My Simple Tuning Process
For P gain, I first start low and work my way up. The quad would first feel sluggish, then getting more and more precise and follows your sticks control really well. When P is right, you should get the minimum propwash oscillations when doing a sharp turn. Because when P is too low, you get lots of slower oscillation, and when it’s getting too high, you start to get faster oscillations.
Fine tune it until you get to a point where the quad would feel very responsive and nimble, yet there is no vibration. Also listen to your motors, twitching motors is a sign of excess P gain which might not be visible in the camera.
Now when you do aggressive maneuvers like flips and rolls, you will probably notice some overshoots at the end of the move. This is time to increase D gain. However I personally use just enough to eliminate the over-correcting, because the more D means more latency in your system making your quad feel unresponsive. A good amount of D gain will also fix or reduce the propwash you previous have.
Finally for the I gain, again start low, and increase slowly. Bank your quad to the left or right and see if it’s holding the angle well. Do the same for pitching forward. You want it to just stay in the same orientation as you release the stick. Another good test to do is some short punchouts and see if the quad can stay level at all.
PID Tuning For Yaw
The above is mainly for roll and pitch axis, and you need to tune Yaw axis separately. Default values usually work pretty well, but same principle applies here. With high Yaw P gain the copter feels more precise.
Excessive Yaw P won’t cause as much vibrations like roll and pitch because yaw movement is much weaker on a quadcopter (lack of yaw authority). But look for any twitching and oscillations in the yaw axis. Also you might notice the quadcopter would tend to gain altitude when doing rapid yaw movements.
Next tune the Yaw D gain and it should bring more smoothness to the end of a yaw movement, but not too much that it feels mushy.
Flying Style and Weather Affects PID
Wind can have an effect on your PID values. If you tune your quad in a calm day, it might require a bit lower P gain and higher I gain.
Depending on which type of flying you do, this is generally how I would tune my copters. But of course PID can be hugely a personal taste and preference.
- slightly lower P
- slightly lower I
- Higher D
- slightly higher P
- slightly higher I
- Lower D
Rate and Expo
Rates and expo are just as important to quad’s flight performance and control.
What is TPA
TPA is a setting to reduce the PID effectiveness as throttle increases. It adds smoothness to your flight throughout the whole throttle range. More detail: What is TPA for PID.
If your quad flies perfectly fine at lower throttle, but has vibration at higher throttle, you might be able to fix it with TPA.
“What’s your PID?”
It’s a common question we see a lot on Youtube. But IMO it’s pretty meaningless to copy someone’s else PID for your quad. Every quad is unique in some way: motor, props, ESC, FC, weight distribution, COG, frame… Even the climates are different where people are flying, so the resulted PID values are going to be different too.