Quadcopter PID Explained

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.

quadcopter pid diagram

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.

quadcopter-overall-pid-process

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:

P Gain

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.

I Gain

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

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

 

Before tuning:

  • 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.

FreeStyle Flight

  • slightly lower P
  • slightly lower I
  • Higher D

FPV Racing

  • 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.

53 thoughts on “Quadcopter PID Explained

  1. Chinedu Amadi

    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

    Reply
  2. Darby

    Hello
    I have recently taken up building drones and i have just completed my first one. However when i come to the PID tuning part i struggle a bit. One of my problems is that in self leveling mode the quad starts to rock from side to side and back and forth as though it is trying to self level but is over correcting. Could you tell me what i could adjust to help fix this problem

    Look forward to your reply
    Thank you

    Reply
  3. Mrinal Kanti De

    Sir
    First of all I thank you for this precious post.
    But I have an issue with my quad. I have a f450 quadcopter with a kk2.1.5 flight controller. As I give a little thrust to it , it takes off but, it wanders of its own. I have trimmed all the channels on my FC. Also, maintaining any given height is very difficult. Do these reactions of my quad is related to the PI settings of the kk2.1.5 anyway? If not, what is the solution to this problem. Please help.

    Will eagerly wait for your reply

    Thanking you,

    Reply
  4. Damian

    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.

    Reply
  5. Paul Faugeras

    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 ?
    What’s more, I can’t find the exact date of the article : is there any way I can find it ?
    Thanks a lot, and happy new year ! ;)

    Reply
    1. Oscar Post author

      P limit and I limit is something defined by the software programmers, they don’t exist in the general PID controllers, I think you would be better off checking the specific manual, because it can mean different things from firmware to firmware.

      Reply
  6. sri

    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

    Reply
    1. Zer0

      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.

      Reply
  7. Prashanth Rajagopalan

    Hello

    I read about PID tuning of the drone. I understood the basics. I would like to go in depth and read on how to calculate P I and D values. If anyone knows any links for PID calculation of drones please share.

    Thank you.

    Reply
    1. Andres

      If you are looking for a formula that will provide you the numeric value of your PIDs based on some parameters you provide, you will not find such calculations.

      The PID values for your quad are based on the physical, mechanical and electrical configuration of your quad. The combination of parts, where you located the parts and the software of your quad will result in a unique set of PIDs for your quad.. like a fingerprint.

      The math required to accurately calculate PIDs such that you can just do the math and “plug them in” would be too complicated and require modeling based on a database of all possible parts/software and frame configurations available. Kind of like trying to predict the wether.

      Reply
    1. Oscar Post author

      could you also check rate mode? if it also drifts then it’s probably something to do with your motor/props, or weight distribution.
      if it doesn’t drift in rate, but only in self-level mode, then it’s something to do with your ACC, maybe hardware, maybe calibration..

      Do a fresh calibration, centre all your sticks and try again.

      Reply
  8. Surojit

    Hi Oscar,
    The main problm i came across is bringing all the motors upto same speed in order for the drone to lift from the ground inspite of giving adequate throttle.Can you guide me through this problm?

    Reply
  9. Mohammad Mahdi Jabbarpour

    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.

    Reply
    1. Raha

      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….

      Reply
    2. Lee

      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.

      Reply
  10. Jeremy

    Hi Oscar

    Im a fan of your page and i have learned alot but im having trouble learning and undersranding how to code.

    Ive built a 3Dof hexapod spider and im duing to get it going. Ive been using sequencers but tgey suck.

    Im pretty desperate now to get it going. Would it be possible for you to put me in touch with some one i could hire to do my IK and code my bot for me.

    I would really appreciate your help

    Jeremy Wood

    Reply
      1. Willy

        Hi Oscar! Thank you very much for this post, I have successfully made the Quad stable in Acro mode (using Gyro for rate PID). Now I’m trying to make my quad to Auto-Hover. From the picture above I assume that I will have to Calculate angles with a complementary filter for example and pass those angles in as desired rotational rates for my Rate PID? But what is confusing to me is, what is that Normalize PID?

  11. moosestang

    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.

    Reply
  12. norbert rendes

    hi !
    pls advise me .
    i tried to understand the explanation of PID. i managed to tune my mini quite well i guess, i hoovers and fly nice, but when i yaw it, at the end of the movement it looses a lot of hight at woobles badly. which of the parameters could be wrong? i could not find yaw PID tuning on google.
    also, could you pls explane a bit what are theese “things” in cleanfight PID settings :
    – ROLL (clear)
    – PITCH (clear)
    -YAW (clear)
    – ALT (?)
    – VEL (?)
    – Pos (?)
    – PosR (?)
    – NavR (?)

    thanks
    norbert

    – LEVEL
    – MAG

    Reply
  13. Victor Rodas

    Hello friends,
    I’m a newbie and just have built my first Quad from scratch with a 3D printer. It has a 2.7 flight controller and a Ar 8000 radio, etc. After the firmware was downloaded, it armed and responded well when I tried to make four or five attempts to fly it inside my house, I noticed that those short attempts to take off happened when I moved the throttle stick up while the copter was making uninterrupted beeps and the props were trembling. I tried to fix the props trembling and the noisy beeps by downloading the firmware again, but this time I downloaded it with the all the wires from the props connected to flight controller. Now the quad doesn’t take off even though all the readings are correct on the mission planner and also it is arming both in the computer at home as well with only remote control the open field. Now, it only makes one beep and one fraction of a second movement by the props, but they don’t spin anymore. The GPS works fine because I can see on the screen of my computer a Quad icon right at same spot on the open field where I tried to make it fight in stabilize mode without success. I wonder if this problem related to the PID tuning?
    Remember that I’m trying to learn and any suggestion to solve my problem and put my Quad to fly will be greatly appreciated . Thank you very much

    Reply
  14. sam

    Thanks for this introduction.

    I have never constructed a quad copter but want to have the flexibility to learn with various PID parameters. Which controller board would you suggest that would enable me to fly in the least amount of time but still afford enough flexibility to learn going forward. I realize I am asking for best of both worlds but would still appreciate your input for a common denominator.

    Thanks
    Sam

    Reply
    1. Oscar Post author

      get the Naze32, TONs of tutorials on the internet, should get you in the air in no time :) it offers a really comprehensive list of settings as well.

      Reply
  15. Ruben John

    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 ?

    Reply
  16. Siddha Kilaru

    Hello, I am using a kk 2.1.5 with a X525 frame. I have tried many different PID values and my quad just keeps oscillating. Any help :|

    Reply
    1. Oscar Post author

      any video showing the problem? some first steps to take:
      1. make sure FC is securely installed on the frame.
      2. props/motors are balanced.
      3. Factory reset your FC

      Reply
  17. BigThunder

    Hi Oscar,

    I am using your PID settings for 5040 props on the Nzae32 and on fast forward flight, it tends to yaw or kick out sometimes.

    What do you suggest on the PID to help resolve this issue?

    Thanks,
    BT

    Reply
    1. Oscar Post author

      do you have any FPV footage showing this? it’s easier to tell from video.
      maybe try increasing Yaw P to 11, drop Yaw D to 5 and try again?

      Reply
  18. JITHU GOUTHAM

    Oscar,
    i want to know about using PD controller instead of PID … can you explain the benefits or demerits of it????????
    currently am presenting a seminar on robust optimal control of quadrotor uavs is that your field of interest ?

    Reply
    1. Oscar Post author

      Hi, maybe you should tell me why use PD controller over PID controller, since you have the idea first :D
      sorry can’t be much a help, I am not an expert in control theory, only come across the subject back in college for a few months :)

      Reply
  19. Vignesh

    I have got a few doubts…..after reading this wonderful article and watching some other videos on youtube.
    1)P, I and D gain values are present for each of YAW , roll and Pitch which means there are a total of 9 values to be calibrated. But most of the videos show only P, I and D calibration and not for each of the axis. Does that mean that the SAME PID values go for each of the axis so when I calibrate the quadcopter I should set the P ,I and D values at the same time for all the three axis????
    2)I have a problem I am using the hextronik nanowii V01 and using the program Multiwii software to program it and I have set all the parameters correctly in the multiwii program and uploaded it correctly and everything is working right except for one motor output from the board (when I increase the throttle three motors increase simultaneously except for one motor which stays for a while and then increases so at maximum throttle three motors output is 1950 while one motor is 1650) these test is done without connecting the escs to the board and also connecting the escs dont change anything. And actual testing also does the same the quad topples over, and I am pretty sure its not with the ESC’s or Motors or Propellers. or the PID values , but its some problem with the transmitter or the board or the program, I have calibrated the ESC’s both individualy and using the autocalibration from the code, but all efforts in vain.
    3)Also I got a doubt should the motor output from the board change when my transmitter is at a constant throttle and nothing else and I just move the quad with my hands and no ESC’s connected to the board, I am asking this dumb question because from what I observe from the Multiwii GUI I see no change in the motor output when I change the quad in any direction?

    Reply
    1. Oscar Post author

      1) Generally you need to set P, I and D for each individual axis. But the same principle applies to all 3 axis.
      2) try doing gyro calibration, acc calibration first. use default PID and rates, make sure your radio inputs are all trimmed to the center. Now try again and place the board on a perfectly horizontal surface, test it in “Manual mode” without connecting ESCs, you should have all motor outputs increase at the same time. (if you board is tilted, the motor outputs will be different.)
      3) you should see motor outputs change in this case, make sure you have done step 2 first.

      Reply
  20. hani

    Hello everyone!
    how connect optical flow sensor to APM2.6 board ? Do the same to connect this sensor to apm2.5?

    I would be happy if the answer!

    Reply
  21. Anthony

    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

    Reply
    1. Oscar Post author

      No i don’t think so, it’s obvious that it’s hardware related, most likely to be
      – the ESC not calibrated
      – motors are damaged
      – propellers are out of balance, or damaged.

      Reply
  22. Wilson

    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

    Reply
  23. Markus

    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?

    Reply
    1. Oscar

      I guess you are using Multiwii? Do you mean it can normally fly well, but sometimes it shifts?
      there are a few things to check:

      1. sticks are all tuned to zero when not touched.
      2. sensors are calibrated correctly
      3. the motors / propellers are balanced properly

      also, if you don’t fly acrobatics, try to use Angle mode or Horizontal Mode (auto-level mode), your copter should be much stable.

      Reply
  24. bogus bob

    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!)

    Reply
      1. Tim

        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. ;-)

      2. Oscar Post author

        Hi Tim,
        you probably have a much better understanding in PID control theory than me :)
        It’s difficult to explain PID to someone who never studied control theory, easiest way to do that is by using real life examples, for example a quadcopter flight behaviour.
        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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Are you Robot? *

I don't look at blog comments very often (maybe once or twice a week), so if you have any questions related to multirotor please post it on this forum IntoFPV.com... You're likely to get a response from me faster on there.