Skip to content →

Flight controller

The flight controller (FC) is the brain of every multicopter, it controls the motors through the speed controllers.

The common parts in all FC are the microcontroller (uc) and a gyro. These 2 components are the minimum for every FC.KK2.1 FC

There is a program running on the uc (usually located on a flash ROM), that can be modified when new updates come out.The gyro unit tells the uc which attitude is it in any time moment. It senses in 3 axes (pitch, roll, yaw).



Usually there are more units built into the FC, allowing to extend the capabilities of it. These can be:

  • accelerometer (ACC)
  • barometer (BARO)
  • magnetometer (MAG)Naza FC with GPS
  • GPS receiver (usually as a standalone detacheable unit)
  • optical sensor
  • ultrasonic sensor


Some extended functions can be the following:

  • autolevel (ACC) = the copter levels itself automated when there is no input from the transmitter
  • heading hold (MAG) = the heading is kept the same, if there is no input
  • altitude hold (BARO) = the copter keeps the altitude automated if there is no input
  • position hold (GPS+MAG) = the copter keeps the altitude and position automated if there is no input
  • return to home (GPS+BARO+MAG) = the copter returns to the place of takeoff automated
  • waypoint navigation = the copter can fly to the preprogrammed loactions automated

and there are many more, called by different names from different vendors.


The most known FCs are the following, of course this is not the full list:



From the handling side we can differentiate the FCs for those that work “out of the box”, and for those that needs adjusting before the first flight.

The “out of the box” definition is however not 100% correct as there are some basic setting that need to be adjusted by all FCs, at least the type of multicopter used (tri, quadro, …), the additional sensors used and so on.


[ The PID controller ]


All FCs are using some kind of PID (proportional-integral-derivative) controller. That is a software loop which controls the motors through the speed controllers, by giving orders for increasing/decreasing the RPM. The loop cycle is very fast, running many thousand times per second. During one cycle, the uc checks the attitude of the copter through the sensors (gyro, ACC), do some math and give orders for the further control of the attitude. The shorter the cycle, the more times can it be run within 1 second, allowing more precise control of the copter.


The heart of any real control system has a feedback controller.  When the system’s process is unknown or hard to model, a Proportional-Integral-Derivative (PID) controller is an efficient method for control.  If the system’s process is known, a custom controller will yield higher efficiency.  However, modeling complex systems in attempt to design a custom controller may result in a much higher development time and cost than can be afforded.  In both cases, a PID controller is a very efficient method for controlling all types of systems.

PID control diagram

[ PID theory ]


PID controllers can be understood(partially) without an in depth lecture on control theory. PID controllers use 3 sub-controllers combined into 1 controller using a simple sum. The 3 controllers are:

  • Proportional:
    The proportional section of a PID controller is a basic intuitive approach to feedback control. A naive approach to feedback control would say, the farther away from perfect the system is, the more it should work to get perfect. In a perfect world without friction, momentum, etc., this system alone would work great! This is proportional control. However, our world is imperfect and we need to add smarter feedback compensation.
  • Integral:
    The integral section of a PID controller compensates environment imperfections such as friction, wind, and other such imperfections that would resist the system to reach its perfect state. An integral controller works by keeping a sum of all the error the system has seen. In calculus, this is equivalent to the area underneath the curve up to the current point. The controller increases its control signal as the summed error gets larger.
  • Derivative:
    The derivative section of a PID controller compensates environment imperfections such as momentum which causes the system to overshoot its perfect state. The derivative controller lessens its control signal as the speed in which it is achieving its perfect state increases. In calculus, this is the slope of the error signal.


[ PID @ multicopter ]


Now we’ll assume that the only objective of the control loop (the logic that uses the P and I gains) is to keep the multicopter level (centered sticks). From there, it is easy to understand that moving the sticks simply moves the desired position (attitude) and the control loop will aim for that instead of level.

Also, we’ll consider only a single axis, pitch for example. The same is duplicated 3 times for pitch, roll and yaw. For a tri-, hexa- or octo-copter, then the logic is a little more complicated in terms of the contribution of each motor to correct the attitude, but the same logic applies for the P and I gains.


What is the P gain ?

The P gain stands for Proportional. This is the gain that applies to how much we are out-of level.

  • If we are level, then each motor is driven with the current throttle position (T).
  • If we are 1 degree out of level, then each motor is driven with T + (P * 1).
  • If we are 2 degrees out of level, then each motor is driven with T + (P * 2).

If the P gain is way too low, then we simply will not be increasing the thrust enough to level the multicopter back. It will want to flip over.

If the P gain is slightly too low, then it will be controllable, but drift excessively. It will take a longer time to get back to level.

If the P gain is too high, the multicopter will wobble (oscillate) because it will compensate too much when going out of level and overshoot, meaning it will go back to level quickly, but then continue and get back out of level the other way, and so on.

Be careful to make sure the P gain is not too high not only trying to fly level, but also when the stick inputs change, when there are gusts of wind or when coming down vertically, in the turbulence of your propellers. If the P gain is just a bit on the high side, it will be rock solid flying level, but then get out of control when you try any aggressive manoeuvre.


What is the I gain?

The I gain stands for Integral, which is a fancy way of saying “over time”. This is the gain that applies to how long we are out-of level.

  • If we are level, then each motor is driven with the current throttle position (T).
  • If we are 1 degree out of level, then each motor is driven with T + (P * 1).
  • If we are 1 degree out of level for 0.5 second, then each motor is driven with T + (P * 1) + (I * 0.5).

If you hold your multicopter in your hands and tilt it, the corresponding motor should spin up. This is the P gain. If you hold it there and the motor speed keeps increasing, this is the I gain’s contribution.

Note that how the I gain is implemented can vary, but the effect described here is valid nonetheless.

If the I gain is way too low (or 0), then the multicopter may not be able to get back to level and drift if an external force (like wind) is applied. This is not a major problem and this is why you should start tweaking the gains with I set to 0.

If the I gain is too high, the effects are similar to having the P gain to high, but even more dramatic. The multicopter will wobble (oscillate) because it will compensate too much when going out of level and overshoot, meaning it will go back to level quickly, but then continue and get back out of level the other way, and so on.

The effect will be more dramatic because the I gain applies over time, so it will take longer to realize it is past level and reduce (and reverse, by then) its effect.

If the I gain is just a bit on the high side, your multicopter will be stable, but you’ll notice that if you try to move in one direction (forward hopefully) for some time it will tend to gradually level off and automatically pitch back when you center the controls. While stable, this will make it more difficult to precisely control the final position of your multicopter when you stop.


What is the D gain?

Some controllers may have an additional D gain. It is not extremely useful for multicopters (the mathematical proof of this is outside the scope of this article), but may be present in some controllers

The D gain stands for Derivative, which is a fancy way of saying “over speed”. This gain works differently than the previous two in that it will work against them to prevent the problems (oscillations) that occur if they (the P and the I gains) are too high, while still keeping the benefits of their high values: stability and speedy recovery. This can be seen as a damping factor.

  • If we are level, then each motor is driven with the current throttle position (T).
  • If we are 1 degree out of level, then each motor is driven with T + (P * 1).
  • If we are 1 degree out of level for 0.5 second, then each motor is driven with T + (P * 1) + (I * 0.5).
  • If we are 1 degree out of level for 0.5 second but in the process of getting back to level at a speed of 2 degrees per second, then each motor is driven with T + (P * 1) + (I * 0.5) – (D * 2).

In plain English: If you are out of level, the P and I gains kick in to bring it back. As you multicopter start moving back to level (but not there yet), the D gain will turn down the throttle to partially cancel out the P and I gains’ effect so that it doesn’t overshoot and start wobbling.

If the D gain is low (or doesn’t exist), then the multicopter will wobble if the P and I gains are too high.

If the D gain is too high, then while stable, your multicopter will feel like there is a big delay between your stick inputs and the corresponding reaction (remember: damping).


How does auto-level work?

The overall logic described above applies to both the stabilization and auto-leveling, and to anything that uses PID really, but the specific behaviors described in the “What happens when…” sections refer mainly to the stabilization. This is what we would call the “fast loop”. The behaviors for the auto-leveling are similar, but will be on a longer time frame (slow “rocking” oscillations for example).

You can think of the stabilization and auto-leveling as two nested loops. The stabilization is the inner, fast, loop which needs to adjust and compensate any deviation from the desired position (being stable) very fast. The auto-level is a secondary, slower loop that will modify the “desired position” input of the inner stabilization loop in order to get achieve a secondary goal, being level.

As you can imagine, because of the nested condition of the control loops, without the inner loop (stabilization) working well, the outer-loop can’t do much since it depends on it.

Correspondingly, setting the gains of the auto-leveling is a much less sensitive affair, since its reaction time is much longer (being the slower, outside loop). The P gain will affect how quickly the multicopter snaps back to level, while the I gain should be increased only if the multicopter fails to reach a level state in some conditions (doesn’t correct enough).


Baseflight Configurator PID tab


[ PID tuning for auto-level mode ]


The best practice is to set the PIDs always starting from the beginning, shortly described here:

Tune one parameter at a time start with P gain, I and then D gain. You can also go back to fine tune the values if need to.

For P gain, start low and work your way up, until you 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, pay attention to the how long does it take to stop and stabilize. You want to get to a point where it stabilize very quickly as you release the stick and it doesn’t wander around for too long. You might also want to test it under windy condition to get a reliable I-value.

For D gain, it can get into a complicated interaction with P and I values. When using D gain, you need to go back and fine tune P and I to keep the plant well stabilized.

Quadcopters are symmetric so you can set the same PID Gain values for Pitch, and Roll. The value for Yaw is not as important as those of Pitch and Roll so it’s probably OK to set the same values as for Pitch/Roll to start with (even it might not be the best).After your multicopter is relatively stable, you can start alter the Yaw gains. For non-symmetric multicopter like hexacopter or tricopter, you might want to fine tune the pitch and roll separately, after you have some flight experience.


[ PID tuning for acro mode ]

Set I and D values to zero.
Start at relatively low P values. Increase value for P until oscillations start, then back of slightly.
Try to do sudden right/left banks and check whether the copter oscillates when finishing the bank. If it oscillates then raise D a bit and repeat.
The setting should be fine when after a sudden bank there is no bouncing.
Get the copter in the air, lean it to a small angle and check if it keeps the angle for some time. If the angle is quickly lost, then increase I value. Repeat this until there is a developing wobble, then decrease I slightly.
Decrease value for D until recovery from dramatic control changes results in unacceptable recovery oscillations, then increase D slightly.
Be sure to keep D down as much as possible, to allow sharp and responsive control.
Note that by increasing the D value you will be able to increase P and I as well, but sharp control will be lost.


Note that the PID setting on different multicopters is different, that is why it is hard to simply copy a good PID setting from another multi and have the bird fly the same way. The settings are affected by many factors, such as frame type, material, rigidity and weight, M2M distance, motor power, torque, propeller size, pitch and material, and so on.

Note that not all the FCs use the PID controller with all 3 parameters, for example the HK KK2.0 controller uses just P and I parameter value setting and does very well just with those.


Leave a Reply

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