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.
Is PID tuning necessary?
PID tuning used to be necessary, but that’s not true anymore.
Modern flight controller software has sophisticated noise filtering and optimized algorithms. Quadcopters can fly very well out of the box on stock PID values unless you are using some very poor quality parts or the quad is badly built.
Nowadays knowing PID tuning makes the difference between “flying well” to “flying perfect”.
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.
Yaw Performance and PID
The hardest part to understand in PID tuning is the yaw axis. But it’s also the easiest part because you can leave it at default in Betaflight and your quad should fly just fine.
PID can help with yaw performance of your quadcopter to certain extend, but you have to understand there many other factors that can introduce yaw destabilization too.
one of the most common bad yaw symptons is, when you do a fast yaw spin the quad shoots up and doesn’t stay level.
Quadcopter’s yaw performance depends heavily on the hardware, i.e. motors, propellers and ESC. This hardware determines your maximum yaw rate (how fast you can spin around yaw axis), until you get destabilization.
To improve yaw performance, you can try the following.
- Using Heavier Propllers: Higher pitch propellers can generate more counter-torque at the cost of efficiency
- Increase Motor RPM, by using higher kv motors or increasing battery voltage
- Using ESCs with stronger braking – Yaw destabilization can occur when a down-spinning motor cannot decrease its speed as fast as an up-spinning motor increases
- Reducing motor distance can help increase yaw authority too: A 6″ frame flying 5″ props will have worse yaw performance than a 5″ frame with the same props.
If you cannot afford to mess around with hardware, the last resort would be to lower your yaw rate, or increase yaw expo, either way will slow down the yaw spins.
My Simple Tuning Process
P on Roll
Cruise around, with good P, the control should feel precise and the quad should follow your sticks very closely.
Try to do some sharp turns, if P is too low the quad would dip to one side, but when P is too high, you will get fast oscillations. When P is right, you should get minimum oscillations when doing sharp turns.
P on Pitch
Do a slit-S, and as you increase throttle to recover, pay attention to the pitch movement. If the quad pitch up more than it should, then P is probably too low. but if you get some fast oscillations then you need to decrease P.
Fine tune it until you get to a point where the quad would feel very responsive and nimble, yet there is no excessive amount of vibration. Also listen to your motors, twitching motors are a sign of excess P gain which might not be visible in the camera.
TPA is a setting to reduce the effectiveness of P gain as throttle increases.
Do a punch out and see if there is any fast oscillations, if so then increase TPA. Good TPA will give you a relatively smooth punch out. I personally wouldn’t use TPA higher than 0.4.
D on Roll and Pitch
Now when you do aggressive maneuvers like flips and rolls, you will probably notice some overshoots (aka bounce-back) at the end of the move. Increasing D gain can help reduce that.
Be careful because excessive D gain can make motor run hot, so use just enough to eliminate the bounce-back. A good amount of D gain will also reduce propwash. D gain too high would also cause fast oscillations at the end of a roll or flip too.
I on Roll
Bank your quad to the left or right and see if it’s holding the angle well. You want it to just stay in the same attitude as you release the stick. If the quad can’t hold the angle then I gain is too low and need increasing.
Do the same for pitching forward.
Your quad can drift in windy condition, so I gain needs to be adjusted depends on wind speed.
But I would recommend increasing I term just high enough to stay level, excessively high I gain can result in stiff and robotic feeling.
Anti Gravity Gain
Fly in a straight line and do some rapid punchouts to see if pitch stays the same angle, If the quad dips down then increase Anti Gravity. I found 3 to be a good value for most of my setup’s.
Yaw PID needs to be tuned separately. Default values usually work pretty well on all setups.
Spin yaw quickly and see how it stops, if you get fast oscillations then decrease P, but if the quad dips one side, then increase P.
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 when P is too high.
When Yaw P is right the spin should be clean and snappy.
As mentioned, “I” is there to prevent drift, but excessive yaw “I” can introduce instability and actually reduces responsiveness. Yaw “I” should never be higher than is needed to prevent drift.
If nothing is wrong, just leave Yaw I at default.
D-Term Set Point Weight
If D SetPoint Weight is high, the quad would feel more locked in but more robotic as well. If it’s low, the quad feels more smooth but a bit loose and sluggish.
I personally prefer 0.6 which is a good balance.
Rate and Expo
Rates and expo are just as important to quad’s flight performance and control.
“What’s your PID?” – Wrong Question!
It’s pretty meaningless to use someone else’s PID on your quad. Every quad is unique in some way: motor, propellers, ESC, FC, weight distribution, COG, frame… Even the wind speed and climates are different where we are flying, so the ideal PID values are going to be different too.