PID controllers and tuning
What the proportional, integral and derivative terms do, parallel and ideal PID forms, practical issues (derivative filtering, kick, wind-up), Ziegler–Nichols tuning and PD pole placement.
Drafted with Aria, reviewed by the AiCanCode.org team. Spotted an error? Use Give Feedback at the bottom of the page.
Why it matters
Well over nine in ten industrial loops — motor speed and position drives, temperature zones, pressure and flow loops, robot joints — run a PID controller or one of its subsets (P, PI, PD). Knowing what each term does to stability, speed and accuracy, and how to get starting gains from a quick plant test, is the most directly usable skill in this subject.
Key ideas
The control law. The controller acts on the error e(t) = r(t) − y(t):
- P (proportional) — reacts to the present error. Raising Kp speeds the response and reduces (but for a type-0 plant cannot remove) steady-state error; too much gain reduces damping and can destabilise the loop.
- I (integral) — reacts to the accumulated past error. It adds a pole at the origin, raising the system type by one, so a constant error cannot persist: step steady-state error becomes zero, and constant load disturbances are rejected. Cost: 90° of phase lag at low frequency, more overshoot, and possible integrator wind-up.
- D (derivative) — reacts to the rate of change of error (a prediction of where the error is heading). It adds phase lead and damping, reducing overshoot and allowing a higher Kp. It has no effect on steady-state error. Cost: it amplifies high-frequency noise and gives a large spike ("derivative kick") when the set point steps.
Forms. Parallel (independent gains) u = Kp·e + Ki·∫e dt + Kd·de/dt, or ideal (ISA) form u = Kp[e + (1/Ti)∫e dt + Td·de/dt], with Ki = Kp/Ti and Kd = Kp·Td. Ti (integral time) and Td (derivative time) are in seconds.
What the terms do in the s-plane. PI = Kp(1 + 1/(Ti·s)) adds a pole at s = 0 and a zero at s = −1/Ti. PD = Kp(1 + Td·s) adds a zero at s = −1/Td, which pulls the root locus left. PID adds a pole at the origin and two zeros.
Practical PID. A pure derivative is never implemented; it is filtered, Td·s/(1 + Td·s/N) with N ≈ 5–20. The derivative is often taken on the measured output instead of the error, to avoid set-point kick. Anti-wind-up (stop integrating or back-calculate when the actuator saturates) prevents large overshoot after saturation.
Discrete implementation at sample time Δt: u_k = Kp·e_k + Ki·Σ(e_j·Δt) + Kd·(e_k − e_{k−1})/Δt.
Tuning.
- Ziegler–Nichols ultimate-cycle (closed-loop) method: with I and D off, raise Kp until the output oscillates with constant amplitude. Record the ultimate gain Ku and period Pu, then use the table below. It gives an aggressive start (about quarter-amplitude decay, roughly 25 % overshoot or more) that is then fine-tuned.
- Ziegler–Nichols reaction-curve (open-loop) method: from a step test of an S-shaped plant, read the delay L and time constant T (slope R); for PID, Kp = 1.2T/(K·L), Ti = 2L, Td = 0.5L, where K is the process gain.
- Ku and Pu can also be obtained from a model with the Routh array (marginal gain and auxiliary equation), as below.
Effect summary (increasing each gain): Kp — rise time down, overshoot up, steady-state error down; Ki — rise time down, overshoot up, settling time up, steady-state error eliminated; Kd — overshoot down, settling time down, little change in rise time and steady-state error. These are tendencies, not laws.
Formulas
u(t) = Kp·e(t) + Ki·∫₀ᵗ e dt + Kd·de/dt
- u: controller output; e: error; Kp: dimensionless or output per error unit; Ki in s⁻¹ × Kp units; Kd in s × Kp units.
C(s) = Kp + Ki/s + Kd·s = Kp(1 + 1/(Ti·s) + Td·s)
Ki = Kp/Ti, Kd = Kp·Td
Ziegler–Nichols ultimate-cycle settings:
P: Kp = 0.5Ku
PI: Kp = 0.45Ku, Ti = Pu/1.2
PID: Kp = 0.6Ku, Ti = 0.5Pu, Td = 0.125Pu
- Ku: ultimate gain (dimensionless for a normalised loop); Pu: ultimate period (s); Pu = 2π/ωu.
Worked examples
Example 1 (standard — Ziegler–Nichols from a model). A plant G(s) = 1/(s(s + 1)(s + 2)) is under unity feedback. Find Ku and Pu, then the Z–N PID settings.
- With P control: s³ + 3s² + 2s + Kp = 0. Routh s¹ row: (6 − Kp)/3 = 0 → Ku = 6.
- Auxiliary equation: 3s² + 6 = 0 → ωu = √2 = 1.414 rad/s.
Pu = 2π/ωu = 2π/1.414= 4.44 s.Kp = 0.6 × 6= 3.6.Ti = 0.5 × 4.44= 2.22 s;Td = 0.125 × 4.44= 0.555 s.- Parallel gains: Ki = 3.6/2.22 = 1.62 s⁻¹; Kd = 3.6 × 0.555 = 2.0 s.
Example 2 (GATE level — PD pole placement). A motor position plant is G(s) = 1/(s(s + 1)) with unity feedback. (a) With P control only, what damping ratio does Kp = 16 give? (b) Choose PD gains C(s) = Kp + Kd·s so that the closed loop has ωn = 4 rad/s and ζ = 0.7.
- P only: s² + s + Kp = 0 → ωn = √16 = 4 rad/s, ζ = 1/(2 × 4) = 0.125 (overshoot about 67 %).
- PD: 1 + (Kp + Kd·s)/(s(s + 1)) = 0 →
s² + (1 + Kd)s + Kp = 0. - Match with s² + 2ζωn·s + ωn²: Kp = ωn² = 16; 1 + Kd = 2 × 0.7 × 4 = 5.6 → Kd = 4.6 s.
- Note: the closed loop is
(4.6s + 16)/(s² + 5.6s + 16)— the PD zero at s = −16/4.6 = −3.48 adds some overshoot beyond the 4.6 % of a pure ζ = 0.7 system, so check by simulation. - Steady-state error to a step is zero in both cases (the plant is type 1); D added damping without changing ωn.
Common mistakes
- Mixing parallel gains (Ki, Kd) with ideal-form times (Ti, Td): Ki = Kp/Ti, not 1/Ti.
- Believing derivative action removes steady-state error — only integral action (or a type increase) does.
- Forgetting Δt in a discrete derivative or integral when the sample time is not 1 s.
- Using unfiltered derivative on a noisy encoder signal.
- Taking Pu in Hz or using ωu where Pu is needed: Pu = 2π/ωu.
- Expecting Z–N gains to be final; they are starting values that usually need detuning.
For GATE ME
Expect: identifying which mode removes offset or adds damping; Z–N settings from Ku and Pu; finding Ku and Pu via Routh for a given plant; closed-loop characteristic equation with PD or PI control and matching ζ and ωn; steady-state error with and without integral action; controller output for given error values. Practise writing the characteristic equation with the controller included before matching coefficients.
Quick check
- Ku = 6 and Pu = 2 s. Find the Z–N PID Kp, Ti and Td.
- Which term eliminates steady-state error to a step for a type-0 plant?
- Kp = 2, Ki = 1 s⁻¹, Kd = 0.5 s, with e = 3, ∫e dt = 4, de/dt = 2. Find u.
- Why is the derivative usually taken on the measurement rather than the error?
- What does integral action do to the system type?
Answers: 1. Kp = 3.6, Ti = 1 s, Td = 0.25 s. 2. Integral. 3. 6 + 4 + 1 = 11. 4. To avoid a large derivative kick when the set point steps. 5. Raises it by one.
Interview questions
All Control Systems interview questionsTry answering each one aloud before you open it.
1.What is a PID controller and what are its components?Concept
A PID controller is a control loop feedback mechanism widely used in industrial control systems. It consists of three components: Proportional (P), Integral (I), and Derivative (D). The Proportional component depends on the present error, the Integral component depends on the accumulation of past errors, and the Derivative component predicts future errors based on the rate of change.
2.Explain how the Proportional component of a PID controller works.Concept
The Proportional component of a PID controller produces an output value that is proportional to the current error value. It is calculated by multiplying the error by a proportional gain constant, Kp. This component helps reduce the overall error but may not eliminate it completely, especially if there is a steady-state error.
3.Why is the Integral component important in a PID controller?Concept
The Integral component is important because it helps eliminate the steady-state error that the Proportional component alone cannot remove. It integrates the error over time, meaning it accumulates the error values and adjusts the controller output to bring the system to the desired setpoint.
4.Describe the role of the Derivative component in a PID controller.Concept
The Derivative component predicts the future behavior of the error by calculating its rate of change. It provides a damping effect, which helps reduce overshoot and improve system stability. By responding to the speed of error change, it can anticipate future errors and adjust the control output accordingly.
5.What happens if the Derivative component is set too high in a PID controller?Application
The derivative term multiplies the rate of change of the signal, so a large Kd amplifies high-frequency sensor noise and quantisation steps into large, chattering actuator commands, which can saturate the drive and wear it out. A set-point step produces a big derivative kick unless the derivative acts on the measurement. Excessive damping can also make the response sluggish. In practice the derivative is filtered, Td·s/(1 + Td·s/N), and Kd is kept moderate.
6.Why is PID tuning necessary, and what are some common methods?Application
PID tuning is necessary to ensure that the controller provides the desired response in terms of stability, speed, and accuracy. Common methods for PID tuning include the Ziegler-Nichols method, trial and error, and software-based optimization techniques. Proper tuning helps achieve a balance between fast response and minimal overshoot.
7.How does the Ziegler-Nichols method work for tuning PID controllers?Application
The Ziegler-Nichols method involves setting the Integral and Derivative gains to zero and increasing the Proportional gain until the system oscillates at a constant amplitude. The gain at this point is called the ultimate gain, and the oscillation period is the ultimate period. These values are then used to calculate the PID parameters using predefined formulas.
8.What is the effect of increasing the Proportional gain in a PID controller?Application
Increasing the Proportional gain in a PID controller generally results in a faster response to changes in error. However, if set too high, it can lead to system instability and excessive overshoot. It is important to find a balance to ensure the system responds quickly without becoming unstable.
9.A discrete PID controller with sample time Δt = 1 s has Kp = 2, Ki = 1 s⁻¹ and Kd = 0.5 s. The current error is 3, the previous error is 2 and the accumulated integral of error is 5. What is the controller output?Numerical
u = Kp·e_k + Ki·(integral of error) + Kd·(e_k − e_{k−1})/Δt. With Δt = 1 s: u = 2 × 3 + 1 × 5 + 0.5 × (3 − 2)/1 = 6 + 5 + 0.5 = 11.5. If the sample time were different, the derivative term would change as 1/Δt, so always include Δt.
Finished this topic? Mark it so your progress, study plan and readiness keep up.
Stuck on something here?