PID Controller Tuning (Ziegler-Nichols)
Calculate PID controller gains using the Ziegler-Nichols open-loop (reaction curve) method from process gain, dead time, and time constant.
Formula
Kp = 1.2τ/(K·L), Ti = 2L, Td = 0.5L
Reference: Ziegler & Nichols, 1942
How It Works
Worked Example
Tune a PID controller for a DC motor speed loop using Ziegler-Nichols closed-loop method. Step 1 — Find Ultimate Gain (K_u): Disable I and D terms (K_i = 0, K_d = 0). Increase K_p from zero until the output oscillates with constant amplitude. Measured K_u = 12.0 Step 2 — Measure Ultimate Period (T_u): Measure the period of the sustained oscillation: T_u = 0.80 s Step 3 — Apply Ziegler-Nichols PID tuning rules: K_p = 0.60 × K_u = 0.60 × 12.0 = 7.2 T_i = 0.50 × T_u = 0.50 × 0.80 = 0.40 s T_d = 0.125 × T_u = 0.125 × 0.80 = 0.10 s Step 4 — Convert to standard form: K_i = K_p / T_i = 7.2 / 0.40 = 18.0 K_d = K_p × T_d = 7.2 × 0.10 = 0.72 Step 5 — Fine-tune: ZN initial values often give 25% overshoot. Reduce K_p to 5.0 and K_i to 12.0 to achieve < 5% overshoot in this application. Result: Starting parameters are K_p = 7.2, K_i = 18.0, K_d = 0.72. Expect to reduce K_p by 20–40% during fine-tuning to meet overshoot and settling time requirements.
Practical Tips
- ✓Start with a P-only controller until the response is stable with acceptable steady-state error, then add I to eliminate offset, and finally add D only if additional damping is needed
- ✓Implement derivative filtering (low-pass filter on the D term with cutoff 5–10× the controller bandwidth) to prevent noise amplification — raw derivative of a noisy encoder signal causes jitter and heating
- ✓For position control of a DC motor, a PD controller with feedforward velocity term often outperforms a full PID with less tuning effort and without integrator windup issues
Common Mistakes
- ✗Applying Ziegler-Nichols gains directly to production code without fine-tuning — ZN rules are a starting point and almost always require adjustment; they typically produce 25% overshoot
- ✗Tuning the PID on the bench at no load and deploying to a loaded system — the process gain changes significantly with load, requiring re-tuning or gain scheduling
- ✗Forgetting integrator anti-windup — when the output saturates (e.g., motor at max duty cycle), the integrator accumulates unbounded error, causing large overshoot when the setpoint is reduced
Frequently Asked Questions
Shop Components
Affiliate links — we may earn a commission at no cost to you.
Related Calculators
Motor
DC Motor
Calculate DC motor speed, torque, power, and efficiency from electrical parameters
Motor
Encoder Resolution
Calculate encoder counts per revolution, angular resolution, and maximum frequency for quadrature and single-channel encoders.
Motor
Motor Slip
Calculate induction motor slip, synchronous speed, slip frequency, and rotor speed for AC induction motors.
Motor
Stepper Motor
Calculate stepper motor speed, step frequency, and travel per revolution
Motor
BLDC Motor
Calculate brushless DC motor no-load RPM, stall torque, maximum efficiency, input power, and propeller thrust from Kv rating and electrical parameters
Motor
Servo Motor
Calculate servo motor torque, speed, efficiency, and back-EMF from electrical and load parameters.