Module 3/5 · Weeks 7–9 · 27 h

Feedback control

DRT 344 Automation, Robotics and Intelligent Control Systems

About 90 minDraft, awaiting reviewLast updated 26 September 2026

Lesson

By the end of this module you will be able to

  1. Compare open-loop and closed-loop control
  2. Explain the role of the P, I and D terms and their effect on the response
  3. Calculate the steady-state error of proportional control
  4. Tune a PID controller initially with the Ziegler–Nichols method and state its limits
  5. Explain PX4's cascaded multicopter control and the tuning order

Prerequisites: DRT 111 module 4 (derivatives and integrals) · DRT 341 module 3

Why this matters

A multirotor is not inherently stable. Without a controller adjusting motor speeds hundreds of times per second, it would flip over in a fraction of a second. The controller behind almost every system, from drones and robots to air conditioners, is feedback control, and the most widely used form is PID.

Feedback control is like keeping a car in the middle of its lane. You see how far the car has drifted (the error) and turn the wheel to correct it; the bigger the drift, the more you turn. If a crosswind keeps pushing, you gradually hold the wheel over. If you see the car drifting fast, you correct in advance. These three behaviours are P, I and D.

Open loop versus closed loop

  • Open loop acts on a plan without measuring the result, such as running motors at fixed power from a table. If wind or load changes, the result drifts and nothing corrects it
  • Closed loop measures the real output with a sensor, compares it with the setpoint, and adjusts the command using the error
Block diagram: setpoint r enters a summing junction, minus the sensor value, giving error e into the PID controller, then the actuator and plant, giving output y, which is measured by the sensor and fed back
Figure 1 A feedback control loop

The PID controller

TermResponds toEffect of increasing itCaution
P (proportional)The present errorFaster responseToo much causes oscillation; alone it usually leaves a residual error
I (integral)Accumulated past errorRemoves residual errorToo much causes oscillation and overshoot; needs anti-windup
D (derivative)Rate of change of errorDamps oscillationAmplifies noise; needs filtering

Integrator windup happens when the actuator is saturated, for example motors at full power, while the I term keeps accumulating. When the error reverses, the controller responds very slowly, so the I term must be limited (anti-windup). PX4 does this by clamping in its velocity loop.

Example 1 Why P alone does not reach the target

A first-order plant has steady-state gain and a P controller with . For a step setpoint:

The system settles about 14.3% short of the target. Raising shrinks the error but never removes it, and a real system with delay starts to oscillate. Adding an I term removes the residual error.

Ziegler–Nichols tuning

Ziegler and Nichols (1942) proposed finding initial PID values by experiment. In one method, raise gradually (with I and D off) until the system oscillates steadily; record that gain as and the oscillation period as , then use the table (Åström & Murray, Table 11.1):

Controller
P––
PI–
PID

Example 2 Calculating PID gains from an experiment

On a motor test rig, the system oscillates steadily at with period s.

  1. s, so
  2. s, so

Åström and Murray warn that the Ziegler–Nichols rules use too little process information and often give closed loops that lack robustness. These values are only a starting point, and never drive a real drone to sustained oscillation; do it only on a test rig or in simulation.

Cascaded control in multirotors

PX4 uses a cascaded control architecture, a mix of P and PID controllers in layers.

Five blocks in a row: a P position controller sends a velocity setpoint to a PID velocity controller, which sends acceleration or thrust to a P quaternion attitude controller, which sends a rate setpoint to a PID angular-rate controller, which sends torque to the mixer and motors; a dashed return arrow notes that inner loops run faster and must be tuned first
Figure 2 Cascaded multicopter control loops in PX4
LoopTypeOutputExample PX4 parameters
PositionPVelocity setpointMPC_XY_P, MPC_Z_P
VelocityPIDAcceleration setpointMPC_XY_VEL_P_ACC, MPC_XY_VEL_I_ACC, MPC_XY_VEL_D_ACC
AttitudeP on quaternionRate setpointMC_ROLL_P, MC_PITCH_P, MC_YAW_P
Angular ratePIDTorque to the mixerMC_ROLLRATE_P/I/D, MC_PITCHRATE_P/I/D

Inner loops run faster than outer loops. The rate loop takes filtered gyro data, and the gyro publication rate is set by IMU_GYRO_RATEMAX. The PX4 tuning guide stresses tuning the rate controller first, because it affects all flight modes; the attitude loop is then much easier. It suggests raising gains by 20–30% per iteration, then 5–10% for fine tuning, testing with fast step inputs in hover.

Class activity

Activity: Simulating an altitude controller

  1. Write a Python simulation of a discrete first-order plant with P, PI and PID controllers.
  2. Compare rise time, overshoot and residual error for each.
  3. Add an actuator limit and observe integrator windup, then add anti-windup.
  4. If available, read a PX4 SITL tuning log and identify which loop was tuned first.

Common mistakes

Watch out

  • Tuning outer loops before inner loops, fixing the wrong problem
  • Raising D without filtering, so motors vibrate and heat up
  • No anti-windup when actuators saturate
  • Treating Ziegler–Nichols values as final without checking robustness
  • Driving a real drone to its stability limit during tests

Summary

  • A closed loop measures the output and corrects using the error
  • P reacts to the present error, I removes residual error, D damps oscillation
  • P control of a first-order plant leaves
  • Ziegler–Nichols PID: , , , only a starting point
  • PX4 cascades P → PID → P → PID; tune the rate loop first

Check your understanding

  1. Which PID term removes residual error?
  2. A first-order plant with uses P control with . What is the steady-state error?
  3. An experiment gives and s. Calculate PID , and by Ziegler–Nichols.
  4. In PX4, which loop sends the rate setpoint to the rate loop?
  5. Why tune the rate loop before the others?
Answers
  1. The I (integral) term
  2. , about 11%
  3. ; s so ; s so
  4. The attitude loop, a P controller on the quaternion
  5. Every outer loop acts through the rate loop; if the inner loop is poor, the outer loops cannot be tuned well, and it affects all flight modes

Key formulas

PID controller
Steady-state error (first-order plant, P control)
Ziegler–Nichols ultimate-gain PID
Converting to gains

Key references

  1. Åström, K. J., & Murray, R. M. (2021). Feedback systems: An introduction for scientists and engineers (2nd ed.). Princeton University Press. link
  2. Nise, N. S. (2019). Control systems engineering (8th ed.). Wiley.
  3. Ziegler, J. G., & Nichols, N. B. (1942). Optimum settings for automatic controllers. Transactions of the ASME, 64(8), 759–765. link
  4. PX4 Autopilot. Controller diagrams; Multicopter PID tuning guide. PX4 user guide (main). link
  5. Beard, R. W., & McLain, T. W. (2012). Small unmanned aircraft: Theory and practice. Princeton University Press.
  6. Quan, Q. (2017). Introduction to multicopter design and control. Springer.

Further reading

Study the assigned knowledge units in advance, review media and take the module quiz

In class / field

Lecture, case discussion and in-class problem solving

Learning evidence: Quiz results and submitted exercises

Module quiz

This is a formative self-check, not a graded exam

Knowledge domain: Control, autopilot and navigation