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