RFrftools.io
Motor

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.

Loading calculator...

Formula

Kp = 1.2τ/(K·L), Ti = 2L, Td = 0.5L

Reference: Ziegler & Nichols, 1942

KProcess gain
LDead time (s)
τTime constant (s)

How It Works

A PID (Proportional-Integral-Derivative) controller adjusts its output based on the error between setpoint and measured process value. The proportional term (K_p) provides immediate correction proportional to current error. The integral term (K_i) eliminates steady-state error by accumulating past error. The derivative term (K_d) dampens oscillation by reacting to the rate of error change. Ziegler-Nichols open-loop tuning uses the process reaction curve: measure the process step response to obtain ultimate gain (K_u) and ultimate period (T_u), then apply tabulated tuning rules.

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

Position-form PID computes the absolute output value from accumulated integral history. Velocity-form (incremental) PID computes the change in output each cycle, inherently avoiding integrator windup and giving bumpless transfer when switching between manual and automatic control. Most embedded motor controllers implement velocity-form PID.
Use PI control when the process has significant measurement noise (derivative amplifies noise), when the controlled plant already has inherent damping (making D unnecessary), or when the system response is slow enough that derivative action provides no practical benefit. Most motor current and temperature loops use PI only.
Anti-windup prevents the integral term from accumulating beyond what the output can physically deliver (e.g., motor driver at maximum duty cycle). Without it, long periods at saturation cause the integrator to grow very large, resulting in massive overshoot when the output becomes unsaturated. Common implementations include clamping the integrator, back-calculation, or conditional integration that stops accumulating when the output is saturated.

Shop Components

Affiliate links — we may earn a commission at no cost to you.

Stepper Motors (NEMA 17)

NEMA 17 bipolar stepper motors for precision motion

Motor Driver ICs

Integrated stepper and DC motor driver ICs

DC Motors (12 V)

12 V brushed DC motors for general-purpose drive applications

Related Calculators