PID is the most common algorithm used in multirotor flight control. By adjusting PID gains you can change the flight characteristics and performance on an FPV drone. In this tutorial I will try to explain what PID does in a quadcopter and how it affects stability and handling.
The Art of Quadcopter PID Tuning
Tuning PID on an FPV drone 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 the drone to feel snappy without oscillations, or maybe you want to have very smooth stick response without feeling too sloppy… The key is finding where the balance is.
Back in the early days of the hobby, flight controller firmware was not optimized. A quadcopter would always fly pretty badly with default PID values, which made PID tuning absolutely essential. But that’s no longer necessarily the case thanks to the sophisticated software noise filtering and optimized algorithms in modern FC software. These improvements have enabled quadcopters to fly pretty well right out of the box.
That’s not to say you can just forget about PID tuning, there is always room for improvement in a drone’s performance. And I am sure everyone has a different preference when it comes to handling and flight characteristics. Knowing how to tune PID provides the capability to change a drone that “flies well”, into one that “flies perfectly” for your individual style.
What does PID do in an FPV Drone?
PID stands for Proportional, Integral, Derivative, it’s an algorithm which is part of a flight controller software that reads data from sensors and takes our radio stick commands to calculate how fast the motors should spin in order to push the aircraft into the desired rotational speed.
The desired rotational speed (how fast we want the drone to rotate) is referred to as “set-point”, and the difference between the measurement from the gyro sensor (how fast the drone is actually rotating) and set-point is called “error“.
The goal of a PID controller in an FPV drone is to correct the “error” by adjusting the speed of the motors. It will repeat this control loop trying to minimize error.
From the PID controller reading sensor data to calculating the motor outputs, this whole process is called a “control loop”. The time it takes for the FC to complete a control loop, is called “looptime”. Looptime can be measured in milli-second, or more commonly, in Hz. For example:
- A loop that takes 1 second = 1 cycle per second = 1Hz
- A loop that takes 1ms (0.001 second) = 1KHz
Modern flight controller in FPV drones is capable of doing thousands of “loops” per second.
There are 3 terms in a PID controller, they are the P, I, and D, hence the name.
- P stands for proportional (it’s proportional to the error), it looks at present error, the bigger the error is, the harder it pushes
- D stands for derivative (it’s the derivative of the error), it is a prediction of future error, it looks at how fast you are approaching a set-point and counteracts P when it is getting close to minimize overshoot
- I stands for integral (it’s the integral of the error), it is the accumulation of past error, it looks at external forces that happen over time; for example if a quad constantly drifts away from a set-point due to wind or off centered weight, it will spool up motors to counteract it
Each term is assigned a gain we users can change. The higher the gain the more influential that term is and it affects the flight characteristics of our quadcopter.
These principles apply to any flight controller firmware that use a PID controller such as Betaflight, FlightOne, KISS, iNAV, Cleanflight, EmuFlight, Baseflight, etc.
The Goal of PID Tuning
What PID does, is like trying to get the golf ball into the hole (setpoint). Every time you hit the ball, it might end up too far (overshoot), or too short (undershoot), but hopefully it gets closer and closer. You repeat until you eventually get it in the hole.
The goal of PID tuning is to get the ball in the hole as quickly as we can in one strike. At this point your drone will track the stick very well and gives you the most direct feel, free from wobbles and oscillations.
The Effect Of PID Terms
Altering PID gains affects a quadcopter’s flight behaviour. You don’t need to understand how PID works, but knowing how they affect your drone is crucial.
P gain determines how hard the flight controller works to correct error.
Think of P as a responsiveness setting. The snappy response provided with a high P gain can even make it feel like you have increased your rates.
If P is too high, the quadcopter tends to over-correct and cause sharp bounce-backs when doing flips and rolls. Excessively high P gain will even cause oscillations. When P is too low your quadcopter will start to feel sloppy and slow to respond.
I gain determines how hard the FC works to hold the drone’s attitude against external forces, such as wind and off-centered CG (center of gravity).
Think of it as the stiffness setting in the stall motion of your quadcopter, and how well it holds its attitude. Higher I gain will help to track setpoint in sweeping turns, but also make your quad feel stiffer entering a move.
Same as P gain, excessive I gain will also cause bounce-backs and oscillations but those are noticeably slower (lower frequency) compared to high P gain. But when I gain is too low, your quad will have wobbles and “nose dips” during rapid throttle changes. If I gain is way too low it won’t even hold its angle well when it’s windy, feel drifty and even wander around and constantly require pilot input to correct it.
D gain works as a damper for P gain and reduces the overshoots. 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 and roll, and you will also experience worse propwash oscillations in vertical descents.
Increasing D gain can solve these problems, however, excessive D gain can really amplify vibration and noise in your quadcopter and cause trilling oscillations and overheat your motors. This post explains in detail why excessive D gain can cause vibration to a drone.
P gain is the primary control of your drone, but it’s usually not fast enough as it only reacts when there’s an error, so there’s always a delay between setpoint and gyro.
Feedforward is introduced to reduce this delay. It’s basically the FC looking at how fast you are moving the stick and help push the quad into the move earlier without relying on gyro data. This can really help your quad tracking setpoint closer. But when you set feedforward too high you could get bouncebacks at the end of a flip and roll just like excessive P gain.
What Affects the Optimal PID
Every quad will have different optimal PID, factors that affect PID are:
- Overall weight and weight distribution
- Thrust to weight ratio
- Motor torque – affects how fast it can change RPM
- How light are the propellers – same reason as above
There’s no perfect PID. For example, every time you crash, it might mess up the propeller, frame or the motor a tiny bit which might be enough to change the optimal PID value. Even the battery placement can have an effect as it shifts the mass distribution. Ideally you want to get your PID to a point that it would work for most situations.
Before Adjusting PID
- Backup your current PID values before making any change, so you can go back if something goes wrong
- Always tune your quad in Rate Mode (aka Acro Mode or manual 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
My Simple Tuning Process
See my FPV Drone tuning guide (without blackbox).
Basically, the idea is to find a good ratio between P and D, then find P and I ratio, finally maximising all PID gains. You can do all these by just dragging the sliders, no longer need to enter the numbers one by one!
It’s best to tune PID using Blackbox logs, but it’s totally doable by just watching in your FPV goggles and listening to the motors.
Not Every Problem is PID Related
Your hardware plays a big part in the performance of your quadcopter, there are a few things you should check and get right first before blaming it on PID. With a well built drone, you can set much higher P and D gains without getting vibration issues.
Not all jello and oscillations are caused by high PID gains. You need to eliminate vibration sources as much as possible on your quadcopter before tuning PID. The condition and balance of motors and propellers, properly soft-mounting flight controllers, even frame rigidity can factor in vibrations.
Center of Gravity
Ideally, the center of gravity (CG) should 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 undermine stability.
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.
What Affects PID Tuning?
Trying some new props? You might want to “re-tune” your PID.
Many factors can affect a PID tune, such as the placement of your battery, adding a GoPro camera, the condition of your motors and propellers. Wind and humidity can also affect how a quad flies.
So basically every time you make a big change on your quad, you probably want to check and adjust your PID values accordingly.
- 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
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.
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?
Bottom of the article.
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?
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?
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:
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!
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.
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.
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.
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.
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.
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.
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 ?
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
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. ;-)
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.