# Quadcopter PID Explained and Tuning

Many Multirotor, Quadcopter software, such as Cleanflight, Multiwii, allow users to change PID values to adjust the performance of their quadcopters. In this post I will explain briefly what PID is, how it affects aircraft stability, and how to tune PID for your quadcopter.

Be warned, this article is a bit on the “academic” side. I tried to explain it in a more practical way in this simplified PID explained post, so make sure you check it out also! Apart from PID, Rates and expo are just as important to quad’s flight performance and control.

Article first created in Oct 2013, last updated Oct 2016.

# What Is PID?

PID (proportional-integral-derivative) is a closed-loop control system that try to get the actual result closer to the desired result by adjusting the input. Multicopters use PID controller to achieve stability.

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 the quadcopter we first need to measure the quadcopter sensor output (for example what angle the quad is on each axis). Knowing what desired angle 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.Each of these control algorithm would introduce some unique effects to the craft’s flight characteristics, which we will explain further later.

As RC multirotor pilots, there are three parameters that we can adjust to improve better quadcopter stability based on different situations. These are the coefficients to the 3 algorithms we mentioned above. The coefficients basically would change the importance and influence of each algorithm to the output. Here we are going to look at what are the effects of these parameters to the stability of a quadcopter .

You don’t need to fully understand how PID controller works in order to fly a quadcopter. However, if you want to read more on the theory, 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

On a multirotor there are 3 axis, and each axis there is a PID controller. That means we will have a separate set of PID coefficients for each axis (Pitch, Roll and Yaw)

Generally, altering PID have the following effect on a quadcopter’s behavior:

• Proportional Gain coefficient – you quadcopter can fly with just P gain even without the other 2 parameters. This coefficient determines which is more important, human control or the sensor measurement from Gyroscopes. 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 softer, and harder to stay steady. One negative impact when P gain is too high is oscillation and over-correcting.
• Integral Gain coefficient – this coefficient influence the precision of the angular position. This term is especially useful with in windy situation, with low I gain your quadcopter will simply drift away with the wind. However, when the I value gets too high your quadcopter might begin to have slow reaction and a decrease effect of the Proportional gain as consequence. It will also start to oscillate like having high P gain, but with a lower frequency.
• Derivative Gain coefficient – In a quadcopter, this coefficient works as a dampener and reduces over-correcting and overshoots caused by P term.

### Aerobatic Flight

• Requires a slightly higher P
• Requires a slightly lower I
• Higher D to compensate for the P

Gentle Smooth Flight:

• Requires a slightly lower P
• Requires a slightly higher I
• Lower D

# How to tune quadcopter PID Gains

It’s best to tune your quad in Rate Mode (aka Acro Mode).

Before I start, I always lower all the PID values by at least half, to make sure they are definitely not too high to start with. Then slowly increase them until you find the perfect flight characteristics.

I usually tune one axis at a time, roll, pitch then yaw. And at each axis, I adjust one value at a time starts with P gain, I and then D gain. You will need to constantly go back to fine tune the values as one value could affect the effectiveness of another value.

For P gain, I first start low and work my way up, until i notice it’s producing oscillation. Fine tune it until you get to a point it’s not sluggish and there is not oscillation.

For the I gain, again start low, and increase slowly. Roll and pitch your quad left and right and center your stick immediately. Pay attention to the angle changes. You want to get to a point where it just stays in the same angle as you release the stick. You might also want to have a stronger I gain for windier weather.

For D gain, I tend to keep this as low as I can. I use just enough to eliminate any overshooting when I am doing rolls or flips.

## 47 thoughts on “Quadcopter PID Explained and Tuning”

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

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.

2. 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 ??

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.

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

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.

4. Blake Manahan

Hi Oscar,

When I am on stability mode my quadcopter wants to drift to the right. Trimming does not help.

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.

5. 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?

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

1. Raha

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

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.

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

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?

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

1. moosestang

Sorry, it is symetrical, not sure what you’d call it with different motor to motor distances.

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

10. Victor Rodas

Hello friends,
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

1. Oscar Post author

sorry i am not familiar with the FC and RX you are using, maybe better to ask on a forum.

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

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.

12. 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 ?

13. 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 :|

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

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

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?

15. 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 ?

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

16. 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?

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.

17. 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!

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

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.

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

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

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.

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

1. Oscar

There is not standard range of PID values, each system or flight controller has their own value range. some wider range, some smaller.

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.

I am moving all supports to this forum IntoFPV.com (at least for now)... So if you are looking for help, or want to help people, I strongly recommend joining this community. Feel free to share your projects, builds and knowledge too!