Most quadcopter software including Betaflight and KISS allows users to adjust PID values to improve flight performance. In this post I will try to explain what PID is, how it affects stability and handling of a drone, and also share some tips on how to tune PID.
The Art of Quadcopter PID Tuning
Quadcopter PID tuning really is an art form. Understanding how to balance different aspects of the flight characteristics to make the craft respond perfectly for your particular flying style, doesn’t happen over night.
You might want a quad to feel snappy, but without oscillations, or maybe you want to have very smooth stick response, but without feeling too sloppy… The key is finding where the balance is.
A working knowledge of PID tuning will help you achieve this, and the more you work with PID settings, the easier it will become to tune your quads to fly exactly the way you want them to.
Back in the early days of the hobby, flight controller firmware was not optimized. A quadcopter would always fly badly with default PID values, which made PID tuning absolutely essential. But that’s no longer necessarily the case (at least for mini quads), thanks to the sophisticated noise filtering and optimized algorithms in modern FC software. These improvements have enabled quadcopters to fly great out of the box. Unless you are using some poor quality parts or flying a model that is badly built.
That’s not to say you can forget about PID tuning, there is always room for improvement in a quad’s performance. And everyone has a different preference when it comes to the handling characteristics of a mini quad. Knowing how to tune PID provides the capability to change a quad that “flies well”, into one that “flies perfectly” for your individual style.
What Is PID in a Quadcopter?
PID stands for Proportional, Integral, Derivative, it’s part of a flight controller software that reads the data from sensors and calculates how fast the motors should spin in order to retain the desired rotation speed of the aircraft.
The goal of the PID controller is to correct the “error“, the difference between a measured value (gyro sensor measurement), and a desired set-point (the desired rotation speed). The “error” can be minimized by adjusting the control inputs in every loop, which is the speed of the motors.
There are 3 values in a PID controller, they are the P term, I term, and D term:
- “P” looks at present error – the further it is from the set-point, the harder it pushes
- “D” is a prediction of future errors – it looks at how fast you are approaching a set-point and counteracts P when it is getting close to minimize overshoot
- “I” is the accumulation of past errors, it looks at forces that happen over time; for example if a quad constantly drifts away from a set-point due to wind, it will spool up motors to counteract it
PID Tuning is like Playing Golf :)
One less accurate but easy to understand analogy I often use is playing golf. What PID does, is like trying to get the golf ball into the hole. Every time you hit the ball, it might end up too far, or too short, but hopefully it gets closer and closer. You repeat until you eventually get it.
PID tuning is like improving your golf skills, so you can get the golf ball into the hole in as few strikes as possible.
What is Looptime?
From the PID controller reading sensor data to calculating the output, this whole process is called a “loop”. Modern flight controllers in racing drones are capable of doing thousands of “loops” per second.
The time it takes for the FC to complete a loop, is called “looptime”. Looptime can be measured in milli-second, but more commonly it’s measured in Hz. For example:
- A loop that takes 1 second = 1 cycle per second = 1Hz
- A loop that takes 1ms (0.001 second) = 1KHz
It is now quite common to see flight controllers that are capable of doing 8KHz looptime, some can even do up to 32KHz. But whether faster is better or not, that’s another long topics. There are pro’s and con’s doing 32KHz, so many people prefer to stick with 8KHz or even lower looptime.
Further Reading: Is faster looptime better for a quadcopter?
The Effect Of Each PID Parameter
Altering PID values affects a quadcopter’s behavior in different ways.
P gain determines how hard the flight controller works to correct error and achieve the desired flight path (i.e. where the pilot wants the quad to go by moving the transmitter sticks).
Think of it as a sensitivity and responsiveness setting. The snappy response provided with a high P gain can even make it feel like you have increased your rates.
Generally speaking, higher P gain means sharper control while low P gain means softer control.
If P is too high, the quadcopter becomes too sensitive and tends to over-correct, eventually it will cause overshoots, and you will have high frequency oscillations.
You can lower P to reduce the oscillations, but reduce it too much and your quadcopter will start to feel sloppy.
I term determines how hard the FC works to hold the drone’s attitude against external forces, such as wind and off-centered CG.
Think of it as the stiffness setting in the stall motion of your quadcopter, and how well it holds its attitude.
In Betaflight, default I gain works pretty well on most setups. But if you notice some drifting without user command, then increase it. When I is too low you might find yourself having to correct the quad’s flying path a lot more with your sticks, especially when you are active with the throttle.
When I gain gets too high, your quadcopter will be overly constrained by this, and start to feel stiff and unresponsive. It’s similar to having a slower reaction and a decreased P gain. Excessive I gain in extreme cases can create a low frequency oscillation.
Another issue that I gain can address or improve is “throttle dips“.
In the real world, no two ESC’s, motors or propellers are identical, thus they will provide different levels of thrust even when spinning in the same air. When you do a punch out and immediately lower your throttle, one motor might increase and decrease RPM faster than the others, this will cause an unwanted dip movement.
You can increase I gain to “fix” these tiny details in the flight performance. To avoid bringing in undesired “stiffness” to our quads with high I gain, a new feature was introduced in Betaflight called “Anti Gravity“. In a nutshell it allows you to have lower I gain when cruising, and only increase your I gain when doing punchouts.
D gain works as a damper and reduces the over-correcting and overshoots caused by P term. Like a shock absorber stops the suspension from being bouncy, adding D gain can “soften” and counteract the oscillations caused by excessive P gain, as well as minimizing propwash oscillations.
When D is too low, your quad will have bad bounce-backs at the end of a flip or roll, and you will also experience the worst propwash oscillations in vertical descents.
Increasing D gain can improve these problems, however, an excessive D value can introduce vibration in your quadcopter because it amplifies the noise in the system. Eventually this will lead to motor overheat and quad oscillation.
Another side effect of excessive D term is the decrease in the quad’s response, this effect is often described as “mushy”.
Before Adjusting PID…
- Backup your current PID values, so you can go back if something goes wrong
- 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 an effect on how well your quad will fly, and how easy it is to tune. You can simply shift your battery to move the COG forth and back
Remember, PID tuning is subjective !
There is no right or wrong way of tuning PID, whatever works for you is the right way. Give two people the same quad, they will most likely come up with different PID values that suit their individual flying style.
My Simple Tuning Process and Techniques
I always set RC rates, super rates and expo first, to roughly how I normally like them. Then you can focus on tuning PID and avoids any confusions in the process.
I normally try flying a new build with default PID before starting to tune it just to see how it feels. With modern FC software such as Betaflight, Raceflight and KISS, the stock values usually work quite well for most setups. Take notes of any undesirable behaviour and then adjust PID accordingly.
The other popular method is to to start with really low values – e.g. lower all the values by at least half or more, then increase each one until you see undesired behaviour.
Every time you change a value, you should ask yourself: “is it getting better or worse?” Try to find the peak where the quad has the best flight characteristics before performance starts to degrade again.
Tune one axis at a time: first roll, then pitch, and finally yaw. I adjust one value at a time on each axis, starts with P, then D, and finally I. You might need to go back and forth to fine tune each value because changes to one, will affect the others.
Tuning a quad can take time, it might take 10 mins, an hour or even days to get a perfect tune. It really depends on the quality of the parts, the build, and especially your expectation!
Pro Tip: Always backup your PID, rates and other necessary settings before updating FC firmware which might reset all the settings to default.
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 (where you use both the throttle and roll), if P is too low the quad will dip to one side (like a wobble), 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 split-S (where you move both the throttle and pitch sticks), and as you increase throttle to recover, pay attention to the pitch movement. If the quad pitches 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 feels very responsive and nimble, making sure 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, increase TPA. Good TPA will give you a relatively smooth punch out. I personally wouldn’t use TPA higher than 0.4, otherwise your quad might feel “loose” at high throttle.
D on Roll and Pitch
When you do aggressive maneuvers like flips and rolls, you will probably notice some prop wash and overshoots at the end of the move. Increasing D gain can help reduce that.
Be careful because excessive D gain can introduce oscillations to your quad, and also make motors run hot, so use just enough to minimize propwash. Another sign of too much D term is fast oscillations at the end of a roll or flip.
Note that to eliminate bounces at the end of a flip or roll, you can also use Setpoint Transition which we will talk about next.
I on Roll
Bank your quad to the left and right to see if it’s holding the angle well. You want it to just stay at the same attitude as you release the stick. If the quad can’t hold the angle then I gain is too low and needs increasing.
Do the same for pitching forward.
Your quad can drift with the wind, so you can increase I on a windy day depending how bad it is.
I recommend setting I term just high enough to stay level, excessively high I gain can result in a stiff, robotic feeling.
Anti Gravity Gain
Fly in a straight line and do some rapid punchouts to see if pitch stays at 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.
P on Yaw
Yaw PID needs to be tuned separately. Default values usually work pretty well on all setups.
Spin quickly on the yaw axis 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 vibration as on roll and pitch because yaw movement is much weaker on a quadcopter (aka. lacking yaw authority). Look for any twitching and oscillations on the yaw axis. Another sign of Yaw P being too high, is the quadcopter gaining altitude when doing rapid yaw movements.
When Yaw P is right the spin should be clean and snappy.
I on Yaw
“I” is there to prevent drift, but excessive yaw “I” can introduce instability and actually reduces responsiveness. Yaw “I” should not be higher than just enough to prevent drift.
In most cases just leave Yaw I at default if there is no issue.
Yaw Performance VS. PID
The hardest part to understand and recognize in PID tuning, is probably the yaw axis. However, because you can normally just leave the default Betaflight settings, tuning yaw can wait until you are confident that you can recognize how the changes you make are affecting the characteristics.
PID tuning can help with yaw performance of your quad to certain extent, but you have to understand there are many other factors that can introduce yaw destabilization too.
One of the most common problem with yaw is, when you do a fast yaw spin, the quad shoots upwards and fails to maintain its altitude.
A quadcopter’s yaw performance depends heavily on the hardware, i.e. your motors, propellers and ESC, which determines your maximum yaw rate – how fast you can spin around yaw axis, until you get destabilization.
Apart from PID, there are other things you can do to improve yaw performance:
- Using Heavier Propellers: 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 (e.g. higher cell count LiPo)
- Using ESC’s with stronger braking – Yaw destabilization can occur when an accelerating motor increases its speed faster than a decelerating motor can slow down
- Reducing motor distance can help increase yaw authority too: A 6″ frame running 5″ props will have worse yaw performance than a 5″ frame with the same props because of moment of inertia
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 beginning and the end of a yaw spin to improve stability.
D-Term Setpoint Weight and Setpoint Transition
Setpoint Weight is extremely important, it can totally mask a bad tune, and changes the handling of the quad just as much as PID’s. Therefore I recommend spending a bit more time tuning it.
I have a whole article to explain what Setpoint Weight and Transition is and how they affect flight characteristics of a quad, please check it out. Here is the short version :)
If Setpoint Weight is high, the quad will feel more snappy, robotic, precise and locked-in, but it will also feel rougher. When it’s low, the quad feels smoother but also looser and more sluggish. Racers prefer to have it higher, while freestyle pilots prefer a lower value. I personally use 0.9-1.0, which I believe is a good balance and should work for most people.
For Setpoint Transition, a high value will feel slower, mushier, but smoother between acro moves. A lower value will make the quad accelerate into the next move more aggressively.
The default Setpoint transition of 1 should give you maximum smoothing effect and will help reduce bounces at the end of a flip or roll. I recommend a lower value such as 0.1 to 0.3 which is a good balance between response and smoothness IMO.
ESC Idle Throttle Value
Default is 4% for DShot which is a good starting point for most builds. I usually lower it as much as I can which gives me longer “hang time”, the time you can spend inverted in the air :) But when you set this too low you might get a dip at the end of a roll or flip because it takes longer to get RPM up to speed again.
Not Every Vibration Problem is related to PID
Your hardware configuration plays a big part in the performance of your quadcopter, there are a few things you should check and get right first.
Not all oscillations are caused by high P or D gains. You need to eliminate vibration sources as much as possible on your quadcopter before tuning PID. The balance of motors and propellers, soft-mounting flight controllers and motors, even frame rigidity, can factor in vibrations. With a vibration-free copter, you can set much higher P and D gains for smoother yet more locked-in flight characteristics.
Center of Gravity
Ideally, the center of gravity (CG) to be right in the middle of your quadcopter, where the 4 motors intersect on a horizontal plane, and be as close as possible to the line of propellers on the vertical plane.
When your CG is off-centered, some motors will have to work harder than others, which will affect stability, cause motors to overheat, and limits your maximum speed.
For example – if the LiPo battery is mounted too far back in a quad, it shifts the CG further towards the rear. Now the 2 rear motors might be pushing at 100%, while the 2 front motors are only at 80%. At this point, if you want to push the throttle harder, you can’t! You quad might wobble back and forth, but it will fail to deliver any extra power because the rear motors have already maxed out.
Mass Distribution and Moment of Inertia
Quadcopters with more centralized mass tend to feel more precise, snappy and responsive. When there is more mass on the outside of a quad, it takes more force to rotate it, and longer to accelerate to the desired velocity. Likewise, due to the higher angular mass and inertia, it’s also harder to stop it from rotating.
That’s why X frames (mini quad frame shape) have taken over the racing drone industry from “H designs” when people realized the benefits. Apart from the frame design, lighter motors and ESC’s also help to reduce rotational inertia.
“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.
What Affects PID Tuning?
Trying some new props? You might want to “re-tune” your PID.
In fact most parts in our quadcopters can have certain effect on the optimal PID. For example frame, propellers, motors, ESC’s etc… So when you swap out components for a different brand or model, it’s a good idea to adjust your PID values accordingly.
In Betaflight and Cleanflight, changing Looptime or ESC protocol can also have an impact on PID. It’s good practice to “re-tune” PID when you change these settings for the best possible performance.
- Oct 2013 – Article created
- Dec 2015 – Added examples how PID affects flight characteristics in Cleanflight/Betaflight
- Jan 2018 – Updated article for the latest Betaflight firmware, simplified section “What’s PID Tuning”, and merged with article “My Simple PID Tuning Guide”
- Feb 2018 – Added info about Setpoint Weight/Transition
- July 2018 – Added Golf Analogy
I hope you find this tutorial useful. Please consider supporting me on Patreon.