Everything so far has built the two halves that the mixer lesson kept apart. Below sits the machinery that turns a wanted rotation into motor speeds. Above sits the sensing that reports the craft's actual rotation. The piece between them, the one that decides what correction to make, is the control loop, and it runs the same small calculation thousands of times a second: compare where the craft is with where it should be, and push the motors to close the gap. The calculation almost every multirotor uses is the PID controller, three terms whose initials name what each one does.
Error, and the idea of feedback
Start with a single axis, say roll. The pilot commands a wanted roll rate, the setpoint. The gyroscope reports the actual roll rate, the measurement. Their difference is the error:
A controller's whole job is to drive that error to zero by acting on the motors, and then to keep it there as gusts and imbalances try to reopen it. This is feedback: the output is measured and fed back to correct the input, continuously, so the craft chases its target rather than being aimed once and hoping. The PID controller builds its correction from the error in three ways.
Proportional, the present
The proportional term reacts to the error right now. It multiplies the current error by a gain and pushes that hard:
Big error, big push; small error, small push. On its own the proportional term does most of the work, but it has two flaws. Set the gain too low and the craft is sluggish, sagging under a gust because a small error produces only a feeble correction. Set it too high and the craft overshoots the target and comes back past it, over and over, a self-sustaining oscillation that shakes the airframe and, in the worst case, grows until the craft is uncontrollable. The proportional gain is the first thing a tuner sets and the loudest when it is wrong.
Integral, the past
The integral term adds up the error over time and corrects for the part that will not go away:
Its purpose is to kill a steady offset. Suppose the battery sits a little off-centre so the craft always wants to drift right, leaving a small persistent error the proportional term never quite clears, because a tiny error makes only a tiny push. The integral accumulates that small error until its sum is large enough to hold the craft true. It is the term that makes the craft settle exactly on target rather than near it. Its danger is lag and a fault called windup: because it responds to the accumulated past, too much integral makes the craft slow and wallowing, and if the motors saturate the sum can grow huge and take time to unwind, so real controllers limit it.
Derivative, the future
The derivative term watches how fast the error is changing and pushes against sudden movement:
It is the damping. When the craft is racing toward its target the derivative sees the error shrinking fast and eases off early, so the craft arrives without overshooting, the way a careful driver lifts off the accelerator before the corner rather than at it. Derivative lets the proportional gain be pushed higher without oscillation, which makes the craft both crisp and stable. Its curse is noise: the derivative of a jittery signal is far jitterier, so a high derivative gain amplifies every vibration into motor twitch and heat, and this is why clean sensor mounting and filtering, from the earlier lessons, matter so much here. The derivative term is where a noisy craft punishes its builder.
The full correction is the sum, fed as the command into the mixer:
Example. A rate controller has . At one instant the roll error is 40 degrees per second. What is the proportional part of the correction, in the controller's command units?
units. If the error were only 5 degrees per second the proportional push would be 2.5 units, a tenth as much, which is the sense in which it answers the present in proportion.
Now you. With and , the error is 10 degrees per second and is falling at 300 degrees per second per second. What are the proportional and derivative parts, and do they add or oppose?
Answer
. The error is falling, so its rate of change is , giving . The derivative opposes the proportional, easing off because the craft is already correcting fast, which is exactly its damping job.
Two loops, stacked
One PID controller running on rate gives what pilots call acro mode: the stick commands a rotation rate, and when centred the craft holds whatever attitude it is in, even inverted, which is what acrobatic and racing flight wants. To make the craft self-level, so that a centred stick returns it to flat, a second, slower PID is stacked on top. This outer angle controller takes the error between the wanted tilt and the estimated tilt from the fusion lesson and produces a wanted rate, which it hands down to the inner rate controller as its setpoint. The inner loop still does the fast work against the gyro; the outer loop steers the inner one toward level. This cascade, an angle loop commanding a rate loop, is how a quadcopter offers both a stable beginner mode and a free acrobatic one from the same machinery, by switching whether the outer loop is in charge.
Tuning, and why it is never finished
The gains are not universal. They depend on the craft's weight, its motors, its propellers and its stiffness, so every build is tuned, and tuning is the craft of raising each gain until just before it misbehaves and then backing off. Too much proportional and the craft oscillates at a fast buzz; too much derivative and it heats and twitches on noise; too much integral and it wallows and is slow to settle. The loop also has a speed, its loop rate, the number of times a second it runs, commonly several thousand on a modern controller, and a faster loop can hold a twitchier craft because it corrects sooner. Underneath the numbers the idea is fixed and worth carrying out of this course whole: measure the error, and answer its present with proportion, its past with the integral, and its future with the derivative. That single pattern stabilises not just a quadcopter but most of the machines that hold themselves steady, and a builder who understands it can tune by reasoning about what each term is failing to do rather than by turning knobs at random.