Understanding how PID works is a vital aspect of unlocking your FPV drone’s true potential. In this comprehensive guide, we’ll dive into the world of PID tuning, exploring how it affects flight performance, stability, and handling. Learn the ins and outs of P, I, and D gains and how they impact your FPV drone’s flight characteristics. We’ll also cover when to re-tune your PID settings and provide insights into the various factors that influence tuning.
Table of Contents
PID Tuning vs Betaflight Presets
Using Betaflight presets can be a convenient option, and might deliver results right away (sometimes), especially for beginners and those flying five-inch freestyle or racing quads. Presets offers better tune than the Betaflight Default (most of the times), providing a good overall tune for most situations. They are well-suited for pilots who prioritize a smooth and enjoyable flying experience without delving into the intricacies of PID tuning. If you’re content with a good tune and don’t feel the need to delve deeper, sticking with presets can save you time and effort. Learn about Betaflight Presets here: https://oscarliang.com/betaflight-presets/
However presets don’t always work on all quads because every quad is different in some way. And as you venture beyond the realm of five-inch quads or explore different types of drones, such as long-range, larger or smaller rigs than 5-inch, you may encounter challenges in finding presets that work optimally. In such cases, you may need to fine-tune the PIDs yourself. Knowing how to tune PID also enables you to troubleshoot specific problems such as excessive prop wash or overshoot that presets can’t address.
The Art of Quadcopter PID Tuning
PID tuning for an FPV drone is truly an art form. Learning how to balance various flight characteristics to achieve the ideal response for your specific flying style requires time, patience, and practice.
Whether you want the drone to feel snappy without oscillations, or a smooth stick response without feeling sluggish, the key lies in finding the perfect balance.
In the early days of the hobby, flight controller firmware were less refined, causing FPV drones to perform poorly with default PID values. This made PID tuning an absolute necessity. However, thanks to advancements in noise filtering and optimized algorithms in modern flight controller software, quadcopters can now fly reasonably well with default settings.
While these improvements don’t negate the importance of PID tuning, they have made it less critical for basic flight. Still, there’s always room for improvement, and individual preferences for handling and flight characteristics vary. Mastering PID tuning enables you to transform a drone that “flies well” into one that “flies perfectly” according to your unique style.
Understanding PID in FPV Drones
PID, which stands for Proportional, Integral, Derivative, is an algorithm within a flight controller’s software that reads data from sensors and processes radio stick commands to calculate the required motor speed for achieving the desired rotational rate.
There are a few key terms that you should familiarize yourself with before delving deeper into this article: set-point, error, control loop, and looptime.
The desired rotational rate is called “set-point”. The “error” is the difference between set-point (how fast we want the drone to rotate), and the gyro sensor’s measurement (how fast the drone is actually rotating).
A PID controller’s primary goal in an FPV drone is to correct the “error” by adjusting motor speeds. The control loop continuously reads sensor data and calculates motor speeds to minimize the error. Betaflight can perform up to 8000 control loops per second (by setting PID Loop Frequency to 8KHz in the software).
The PID algorithm is a crucial part of the control system. There are three terms in a PID controller: Proportional (P), Integral (I), and Derivative (D).
- P (Proportional) relates to the present error. The larger the error, the harder it pushes – in math term, it’s proportional to the error.
- D (Derivative) predicts future error. It considers how quickly the set-point is approached and counteracts P to minimize overshoot when nearing the target – in math term, it’s the derivative of the error.
- I (Integral) accumulates past errors. It addresses external forces that occur over time, such as a drone drifting away from set-point due to wind or an off-centered weight, by adjusting motor speeds to counteract it – in math term it’s the integral of the error.
Users can assign a gain to each term, with higher gains increasing the term’s influence on flight characteristics.
These principles apply to any flight controller firmware that uses a PID controller, such as Betaflight, Ardupilot, KISS, iNAV, Cleanflight, EmuFlight, Baseflight, etc.
The Objective of PID Tuning
Imagine trying to get a golf ball into the hole (setpoint). Each time you hit the ball, it might overshoot or undershoot the target, but with every attempt, it gets closer. You continue until the ball reaches the hole.
The objective of PID tuning is to achieve the perfect strike that gets the ball into the hole as quickly as possible. When tuned correctly, your drone will track the stick movements accurately, providing a direct and responsive feel without wobbles or oscillations.
The Impact of PID Terms
Tweaking PID gains influences a quadcopter’s flight behavior. While understanding the inner workings of PID is not necessary, it is crucial to know how changing these gains affect your drone’s performance.
P Gain
P gain determines the intensity with which the flight controller works to correct errors.
Consider P gain as a responsiveness setting. A high P gain creates a snappy response, making it feel as though your rates have increased.
If P gain is too high, the quadcopter tends to over-correct, resulting in sharp bounce-backs during flips and rolls. Excessively high P gain can even cause oscillations. Conversely, when P gain is too low, the quadcopter feels sloppy and slow to respond.
I Gain
Think of I gain as a stiffness setting, it determines the flight controller’s effort in maintaining the drone’s attitude against external forces, such as wind and off-centered CG (center of gravity). A good amount of I gain will prevent the drone from drifting.
Similar to P gain, excessive I gain can cause bounce-backs and oscillations, although at a noticeably slower rate (lower frequency). If I gain is too low, the quad will experience wobbles and “nose dips” during rapid throttle changes. Extremely low I gain results in poor angle-holding during windy conditions, causing the drone to feel drifty and requires constant pilot input for corrections.
P gain can damper I gain induced oscillations therefore there’s a ratio to be met between P and I gains.
D Gain
D gain acts as a damper for P gain, reducing P gain induced overshoots. Like a shock absorber dampens suspension bounce, D gain softens and counteracts oscillations caused by excessive P gain and minimizes propwash oscillations.
When D gain is too low, the quadcopter will exhibit significant bounce-backs after flips and rolls and experience worse propwash oscillations during vertical descents.
Increasing D gain can mitigate these issues; however, excessive D gain can amplify vibrations and noise in the quadcopter, causing trilling oscillations and motor overheating. A separate post details why excessive D gain can lead to drone vibration: https://oscarliang.com/excessive-d-gain-cause-oscillations-motor-overheat/
Feedforward
P gain is the primary control of the drone, but it’s often not fast enough, as it only reacts to errors, creating a delay between setpoint and gyro.
Feedforward aims to reduce this delay. Essentially, the flight controller observes how quickly you move the stick and helps initiate the quad’s movement earlier without relying on gyro data. This can significantly improve setpoint tracking. However, setting feedforward too high may cause bounce-backs at the end of flips and rolls, similar to excessive P gain.
Factors Influencing Optimal PID
Each quadcopter will have unique optimal PID values, influenced by various factors, including:
- Overall weight and weight distribution
- Thrust-to-weight ratio
- Motor torque, which affects how fast RPM can change
- Propeller weight and pitch, which impacts motor response
No PID setting is universally perfect. For instance, crashes may slightly damage propellers, frames, or motors, altering the resonance frequency and optimal PID values. Additionally, battery placement can affect mass distribution. Ideally, you want to fine-tune your PID settings to accommodate a wide range of situations.
Precautions Before Adjusting PID
Before you start making any changes to your PID settings, follow these steps to ensure a smooth tuning process:
- Back up your current PID values: This allows you to revert to previous settings if something goes wrong during the tuning process. And you have something to compare to if you are unsure about your final tune.
- Always tune your quad in Acro Mode: this ensures accurate tuning without interference from auto-leveling features.
- Balance your quadcopter’s center of gravity (CG): Proper CG significantly affects flight performance. Adjust your battery placement to shift the CG forward or backward until it is centered.
A Simplified Tuning Process
For a more in-depth look, refer to my FPV Drone Tuning Guide in 10 steps without using Blackbox: https://oscarliang.com/fpv-drone-tuning/
The basic idea of this simplified tuning process is to find the optimal ratios between P, I, and D gains. This can be achieved by following these steps:
- Find a good balance between P and D gains.
- Determine the right ratio between P and I gains.
- Maximize all PID gains.
You can easily adjust these settings by using the sliders in Betaflight, eliminating the need to input numbers manually.
While it’s ideal to tune PID values using Blackbox logs, it’s still possible to achieve decent results by closely observing your drone’s flight behavior through your FPV goggles and listening to the motor sounds. But if you want to tune your quad as perfect as it can get, using Blackbox is the way to go: https://oscarliang.com/pid-filter-tuning-blackbox/
Tuning Tiny Whoops
For whoops, switch to RP mode in PID tuning tab, so you can set Yaw PID separately. Tiny whoops tend to have little yaw authority due to the ducts, so you want to set it really high. Set Yaw P and I to 100.
Also if you get yaw washouts coming down, try running props in, sometimes it fixes it.
Remember, Not Every Problem is PID-Related
While PID tuning plays a significant role in your quadcopter’s performance, it’s essential to recognize that hardware factors can also affect it. Before blaming PID values for performance issues, check the following aspects of your drone:
Vibration
Not all jello and oscillations are due to PID gains being too high. It’s crucial to eliminate as many vibration sources as possible in your quadcopter before tuning PID. Factors that contribute to vibrations include motor and propeller condition, proper soft-mounting of flight controllers, and frame rigidity.
Center of Gravity
Ideally, your quadcopter’s center of gravity (CG) should be right in the middle, where the four motors intersect on a horizontal plane, and as close as possible to the propeller line on the vertical plane.
An off-centered CG causes some motors to work harder than others, negatively affecting stability.
Mass Distribution and Moment of Inertia
FPV drones with centralized mass generally feel more precise, snappy, and responsive. When there’s more mass on the outside of a quad, it takes more force to rotate and longer to accelerateto the desired velocity. Due to higher angular mass and inertia, stopping the rotation becomes more challenging as well.
When to Re-tune PID?
Making changes to your drone? You may need to revisit your PID tuning.
Various factors can impact PID tuning, such as using a different battery, adding a GoPro camera, using different motors and propellers, or even external factors like wind, humidity and altitude.
In essence, whenever you make significant changes to your quadcopter, it’s a good idea to check and adjust your PID values as needed.
Conclusion
Mastering PID tuning is an essential skill for any advanced FPV drone enthusiast seeking to optimize their quadcopter’s flight performance. By understanding the intricacies of P, I, and D gains and their impact on your drone’s behavior, you can tailor your drone’s responsiveness to suit your flying style and preferences. Don’t forget to consider hardware changes when fine-tuning your PID settings. With this knowledge at your fingertips, you’re now equipped to transform a well-flying drone into a perfectly-tuned machine, ready to deliver an unparalleled FPV flying experience. Happy flying!
Edit History
- 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
- Sep 2022 – Revised
- Mar 2023 – Revisited
44 comments
I use the Superfly preset in beta flight for myn5″. It flies very smooth…too smooth. What do I have to change to make it feel more snappy like my Nazgul5 v2?
is it the Preset that made it not snappy? or was it not snappy to begin with?
I have a guide explaining how to tune a drone without blackbox: https://oscarliang.com/fpv-drone-tuning/
Thank you for the information on your site. I’m using it to setup my first FPV and this gives me more confidence. You are appreciated.
Thanks.
Hi Oscar, I have a quick question. I’ve made 6 builds over the years and have used the skystars 722 hd pro stack which when flashed with betaflight program produces a pretty aggressive drone. My 12 year old niece wants to get into the sport and as a ” dotting Uncle ” I want her first drone to be one of mine since I have the know how and the the parts to “fix it “. I’ve read your pid tutorial over and over to try and understand the trial and error principal but she will be in her 20’s by the time I” get it !” My question is this; some new Quads have pre-programmed FC’s that allow the buyer to use the tx and toggle between “beginner” and ” expert ” quad movements . Is there any” ONE VALUE ” setting in the configuration, pid, or perhaps motor window sections of the betaflight program that I can INCREASE or DECREASE to over-all make the Quad fly in a stable “beginner” type mode instead of the current ” advanced ” type mode ? If I can change ONE VALUE instead of SEVERAL I can get it to her before her birthday in November. Thanks for your help if you can, Respectfully Yours; Darryl
What you asked is not available in Betaflight, and it has little to do with PID or the related tuning parameters really.
To make the quad more beginner friendly, the first thing you can do is to enable Angle mode (self stabilizing), and make the rate a little slower, increase expo to reduce stick sensitivity. Perhaps also reduce maximum throttle to make it go a little slower.
What I would really recommend, is to get her to fly in a simulator first, only when she’s ready then try on a real quad.
Good advice !!! A simulator for her birthday it shall be ! In the mean time I’ll work on the build that I’m planning tp give her. Thanks for the advice and I will forever be a fan. Darryl
Is there anyway to tell will your articles were published?
Dates are at the bottom of the article.
Hi Oscar,
have you ever heard of this symptom:
When I give more throttle or do little punch outs, the quad would yaw a bit to the left. I think I replaced the motors at least twice and am using a new ESC and FC. Before switching the FC I wanted to ask you if you know what my could be. My guess is fried gyro due to soldering.
Also check the spring tension of your transmeter for yaw. I set the spring tension as low as possible for the sticks for my own preference but the drawback is since there is little resistance as to which ways you are moving the sticks, you sometimes make unwanted moves. For example, you might be doing little bit of yaw moving when you do the punch out.
Hello Oscar! First of all thank you for all this informations.
I wanted to ask if you know how works the graupner gr16 (with build in FC) and your opinion about it? So, here I have a ROLL FACTOR, and it says for true X quads it can be 100%, if not simmetrical(usually longer than wider) it must be reduced. So if the distance between the side motors is half the distance of front and rear motors it should be 50%? How is this called in betaflight? I have been driving for half year now, and now I saw it was on 100%(totally non simmetric quad:D). How will affect the quad this change now?
Any information would help.
Thank you and goodbye.
Sorry I am not familiar with the Graupner radios.
Maybe try asking on IntoFPV.com?
Thank you, Oscar, for sharing knowledge.
Could you, please, expand it to real examples on which axis PIDs should be adjusted depending on X-quad flight errors/issues?
Cheers
Vlad
People keep talking about PID settings here and on different websites and youtube videos. I understand now better than before thanks to Oscar (big fan) and other contributors to the hobby.
However no one tackles the GUI of Betaflight, so while I understand PID values I dont understand which settings I am changing. ie. Profiles.
Which profile am I supposed to set PIDS on and doe they relate to Acro/Horizon mode? Should I just change the PIDS on profile 1? Whats Profile 2 for and how do I select it? In flight or before flight?
Thanks oscar much help!
Is there still much to pid tuning with the feedforward option since 3.5? And will u update this guide with that in mind?
Btw great work on all your articles!
Yes I will update this when 4.0 comes out :)
At the moment I am still trying to catch up with all the changes they made since!
Dear Oscar, we are building a huge drone with a cage around props to have protection total mass is ca 60 kg. So inertia is quite high. Currently with arducopter we if we use eg PID as 1.35 0.135, 0.004 it is sluggish and can come into a slow oscillation! We can increase the values but slow oscillation is still not solved. We are close to ground flying to be safe. Ground effect? Having such high distributed mass, is there any recommendation for this on PID settings?
Best regards, Winfried
I have read many articles and seen many youtube videos but this is the first that makes it really understandble for newbees.
Great work !!!!
Hi Oscar I’m your super fan I
Love your work, written articles are way better than infinite YouTube videos where peoples never get to the point ?. One question, I’m tuning my quad and it flies amazing but when is windy I get tiny jello vibrations in the hd footage in the sunny days, someone told me that playing with I gain could fix it?, is that the value I have to work on?
Thank you
One dirty fix to this kind of tiny oscillation is to use “ND filter” :)
It’s hard to say, better to check Blackbox log to find out which term is causing vibration. It could also be filters…
Join our forum for further troubleshoot:
IntoFPV.com
I am not sure if I understood correctly – I do get oscillations on low throttle “drops”, when I’m at let’s say 30 metres and drop the throttle really low. Should the D increase help this?
You mean prop wash? If so then yes increasing D term helps reduce prop wash.
I just ordered my first tuneable 65 mm quad from China. This article is very clear and concise and is an excellent primer for a nubee like me. Thanks!
Hello Oscar,
This article has been invaluable in my research. I am working on designing and implementing a model predictive controller on a quadcopter. The current controller on the quadcopter is PID so I needed to grasp the interactions before implementing mine. My question is how do you determine the “desired rotational rate” for the rate PID? I have looked around but so far I have come up short.
The PID rate controller on the quadcopter I am using simply multiplies the euler angle error by a constant to get the desired rate. I did not understand that. Any assistance will be greatly appreciated. Thank you.
Regards,
Chinedu Amadi
Hello,
Thanks for this article. As an experiment, I installed a F3 brushed into quadcopter with geared rotors. Using the method as described, I have observed some interesting reactions made by this relatively slow aircraft. Surprisingly, it flies well. It has unusually high P & D settings which took many tries to get right.
Hello Oscar,
Thank you so much for this amazing article, I would like to use it as a source for my engineering project this year (I’m a french student) : What would you like me to cite it as ?
Thanks a lot, and happy new year ! ;)
Excellent post for PID sir,
For the PID algorithm, one input is from sensors that will give Yaw,Pitch,roll angles and another input is PWM widths(calculated) from the Receiver.
How can we find the error from angles and PWM widths ??
Thanks in advance
For that you have to convert your PWM widths in angles. In rate mode you say like 1500 (wich should be the middle position of your sticks) is 0 degrees per second. If you have 1000, we wan’t maybe 500 degrees per second, wich should be eonugh for most acrobatic maneuvers. At 1250 we should have 250 degrees now. All thoose numbers are the desired angular motion!
Now your gyro gives you the actual angular motion of your quad. Whats left is simply calculating the difference between both of them. That is the value you have to use for feeding your pid loop.
Hopefully I understood your question right and helped you a bit, sry for my english, school’s long ago.
Hello
I have a quad copter with t-motor mn-3508 motors and t-motor air 25A speed control and t-motor carbon propeller and naza m-lite without GPS flight control.
my quad copter not flight. and only motors rotate with speed.
what is the best setting for this quad copter ?
and how can I fix this.
Thank You.
Hi Mohammad Mahdi,
Size of propellers seems to be the issue here…since you are using 700kv motors, use bigger props from 11-12 inch…use a 3s battery…it should get you to hover at respectable throttle provided your set up isnt too heavy…but its still a matter of experimentation….
Check your motors are going the correct way for they’re position. Front left CW. Front right CCW. Back right CW. Back left CCW. Then check Props are up the correct way and are in the correct position for they’re rotation.
Hi, to tune the pid’s which mode we have to use? Stabilized or Non-Stabilized? Thanks
PID tuning should be done under Acro mode (rate mode) which is not stabilized.
Hi Oscar, I can see why tuning should be done in Acro mode, so that you are only observing the effect of stick inputs, rather than additional corrections by the flight controller in angle mode.
I have a question, how do you would set up the rates to fly a 250 size quad copter really really slowly with a 3 axis gimbal on? I have tried using Angle mode and really slowing all of the rates down, but i cannot get it to work. I loose control of it and the quad just drifts. Do you have any tips for me please? I am using an Omnibus F3 with a barometer and Betaflight. Once I have mastered flying it really really slowly round a warehouse at work I plan to add the GPS in and try it outside.
Thanks Oscar.
I’m trying to correct a wobble i get when making sharp turns at speed. this maybe inherent to this particular quad copter and i think it’s mostly cause by yaw. I first thought it was from hitting the max angle in angle mode, so i increase it to 90, thanks for clueing me in to that. Increasing max angle did seem to help. I tried lowering the level pid and also the overall leveling in angle mode. The thing weighs 140grams with battery and is only 122mm, so it might just be too heavy for it’s size.
It also is not symetrical, see pic. pbase.com/paulyoly/image/160538758 The one on the left, the rear motors are closer together than the fronts.
See the wobble i’m talking about at 39 seconds. youtube.com/watch?v=uIm0-dQ908s&feature=youtu.be
These are the pids used in the flight video above. pbase.com/paulyoly/image/160638362 I’m going to try lowering the yaw rate first and see how it changes. The hermit pictures with it above doesn’t share this wobble issue and it has a 1.00 yaw rate. I wanted to get an experts thoughts.
hi Oscar..
could you go into yaw pid tuning in more detail. Because of the horizontal axis it works on in it seems harder to know what to look for when turning up the P, I or D. eg…something like the integral on the pitch and roll axis I can put in a command at a steep angle and see how long it flies hands off that way. How do you do something like that for yaw ?
Hi,
PID theory is really well explained !
I’m facing the problem of PID tuning. I’ve implemented the cascaded PID shown in this post. How can I adjust P values of cascaded PID? Should I start from the “Stabilise PID” with P = someValue and “Rate PID” with P = 1 ?
Thank you for your help
Nice explanation. I have a yaw problem with my quad. On fast forward flight, it tends to turn sideways on its own. More to the left but sometime to the right. I think I need to increase the P and I setting to the yaw. It hovers solid
Hey,
thanks for this great article.
When i was flying my quadcopter (scratchbuild with nanowii) it sometimes began to oversteer and crashed.
But with the I parameter set to 0 it doesn’t happen.
What’s your thought about it?
Nice article, thank you. I like the tuning part. Might I suggest expanding it with an example of PID values? Right now I have no idea which order of magnitude I’ll be looking for. 1? 0.001? 1000? (Although your description helps to find out, kuddos!)
There is not standard range of PID values, each system or flight controller has their own value range. some wider range, some smaller.
My experience is all chemical process control, BUT the pitch/roll/yaw and maybe altitude are all integrating processes. Meaning if you’re slightly off the error will keep growing (and therefore the P term will keep increasing/decreasing to reach set point). It’s similar to filling a tank that you’re also draining and trying to control level. If the in-flow and out-flow aren’t exactly the same the level will continue rising or falling forever. It’s integrating the error of the two flows on its own. On a quadcopter, if the left/right, front/back, diagonals aren’t perfectly producing the same thrust it will continue to pitch/roll/yaw forever. That would be different than a heater, For a given heat input, the temperature won’t rise or fall forever, it’ll get to a temperature and line out (the other type of control scenario, a self regulating process).
I’ve never done it, but you could do PD control (or just P) if the integrating error is large (e.g. a small tank or large flows in my tank example where a small difference would quickly change the level) or you don’t care about tight control (you don’t mind if the level swings a bit for the process to naturally integrate to the point the P term corrects things. We have the former for multicopters, but definitely not the latter. Therefore I would be really surprised if you could find some tuning work without I. You’d want to catch that small difference before the multicopter pitched/rolled/yawed to the point the P would catch it.
What I haven’t figured out yet is why multicopters use D (along with PI). I think of D as undoing all of the I windup as it approaches set point (SP). The process “sees” that it’s on its way to reaching SP, therefore the P term is shrinking but the I term is now really large and still growing because it’s still below SP (or above…). If unchecked, it would likely overshoot and then the I term would start shrinking and eventually it would settle in after a few oscillations. We only use D in chemical process control when there is large deadtime or lag between a change in an input to the process and seeing the response. I’m talking many minutes, if not hours, for us to want D tuning (along with PI). For example, the temperature on a very large tank or distillation operation. In fact these are the only two loops that we would usually even consider D and they’re both self-regulating. I can’t think of any integrating process examples using D. I wonder why it’s used for multirotors since things are moving so quickly? The “I term” should not have “wound up” since it shouldn’t have been off SP for very long.
After logging some data, I want to approach tuning as we do at work and see what it suggests. The problem is that we’ll usually hold an output fixed, change it, and then watch for a response. Most notably watching how long it takes to see the response to begin to move (the deadtime), and how much it changed by (the process gain). That’s not much of an option for a flying quadcopter, it would be quickly on the ground. There are some on-the-fly tuning tricks but with modern computers and process data collection, it’s become passe. I’ll have to find some old timers to teach me. ;-)
Hi Tim,
you probably have a much better understanding in PID control theory than me :)
It’s easier to explain PID to someone using real life examples, for example how PID affects the flight behaviour of a quadcopter.
PID might be slightly different when it comes to implementation, thus how P,I and D affects the system (there are now 6 PID controllers). Not sure how good you are with coding, if you can check out how PID controller is implemented in Baseflight/cleanflight that should help your multirotor tuning.