May 29, 2026

PID Controller Explained: How It Works, Tuning Methods & Real-World Applications

Why PID Still Dominates Industrial Control

PID control remains the most widely used method in industrial automation. Even with advanced techniques like model predictive control (MPC), adaptive control, and AI-based approaches, most real-world loops still rely on PID.

The reason is simple: it works without requiring a detailed mathematical model of the process. In practice, that means engineers can tune and troubleshoot loops directly from observed behavior during commissioning and maintenance.

For most applications, the goal is not theoretical optimality. It is stability, predictability, and fast recovery from disturbances. A well-tuned PID controller usually achieves this with relatively low complexity.

Despite its simplicity, PID is often misunderstood in practice. Many people know the definitions of P, I, and D, but struggle when faced with real issues like oscillation, overshoot, or steady-state error.

This guide focuses on practical behavior using numerical examples rather than abstract theory.

Table of Contents

  1. The Core Idea: Chasing the Error
  2. Breaking Down Each Term — With Worked Examples
  3. The Full PID Output — Calculated Step by Step
  4. Ziegler-Nichols Tuning: A Complete Worked Example
  5. Lambda Tuning: Calculated Example for a Temperature Loop
  6. What the Response Curve Tells You
  7. Common Problems and How to Diagnose Them
  8. PID in Real Control Systems
  9. FAQs
  10. Related Posts

The Core Idea: Chasing the Error

At its heart, a PID controller does one thing: it looks at the gap between where you are and where you want to be, and decides how hard to push to close that gap.

That gap is called the error:

e(t)=SPPVe(t) = SP - PV

Where:

  • SPSP = Setpoint (the desired value)
  • PVPV = Process Variable (the measured value)
  • e(t)e(t) = Error at time tt

Quick example: You're controlling a water temperature loop. Setpoint is 80°C, current temperature is 63°C.

e=8063=17°Ce = 80 - 63 = 17°C

The controller sees 17°C of error and must decide how hard to drive the heater to close that gap.

PID Controller Block Diagram showing setpoint, error, PID block, process, and feedback

Figure: Classic closed-loop PID structure. The controller compares setpoint to measured process variable and adjusts the output continuously.

Breaking Down Each Term — With Worked Examples

Proportional (P)

The P term produces an output proportional to the current error:

Poutput=Kp×e(t)P_{output} = Kp × e(t)

Worked Example — Proportional Only:

Say you have a heater controller with a 0–100% output range and you set Kp = 4.0.

ScenarioSP (°C)PV (°C)ErrorP Output
Cold startup8020604.0 × 60 = 240% → clamped to 100%
Approaching SP8070104.0 × 10 = 40%
Near setpoint807824.0 × 2 = 8%
At setpoint808004.0 × 0 = 0%

Notice the last row: if the heater needs 8% output just to maintain 80°C against ambient heat losses, the controller will sit at a permanent error of 2°C. This is the classic proportional offset — the process never quite reaches setpoint unless something is adding baseline output.

Integral (I)

The I term accumulates error over time:

Ioutput=Ki×e(t)dtI_{output} = Ki × ∫e(t) dt

In discrete (digital) form, as a PLC would calculate it every scan:

Ioutput[n]=Ioutput[n1]+Ki×e[n]×ΔtI_{output}[n] = I_{output}[n-1] + Ki × e[n] × \Delta t

Worked Example — Integral Accumulation:

Continuing from above: the loop is stuck at 78°C (2°C error). The PLC scan time is Δt = 0.1 s, and Ki = 0.5.

Time (s)Error (°C)I incrementAccumulated I Output
t = 02.00.5 × 2.0 × 0.1 = 0.10%0.10%
t = 12.00.10%1.10%
t = 52.00.10%5.10%
t = 102.00.10%10.10%
t = 16~0~0~16% ← now holding SP

After 16 seconds, the accumulated integral has added enough output (~8% additional) to drive the process to setpoint and hold it there. The steady-state offset is eliminated.

Practical warning: Integral action is also the main cause of windup — a nasty condition where the integrator accumulates a huge value while the output is saturated (valve fully open, heater at 100%). When the process finally responds, it overshoots badly because the integrator is still unwinding. Most modern controllers have anti-windup protection; make sure it's enabled.

Derivative (D)

The D term reacts to the rate of change of error:

Doutput=Kd×de(t)/dtD_{output} = Kd × de(t)/dt

In discrete form:

Doutput[n]=Kd×(e[n]e[n1])/ΔtD_{output}[n] = Kd × (e[n] - e[n-1]) / \Delta t

Worked Example — Derivative Braking:

The temperature is climbing fast toward setpoint. With Kd = 2.0 and Δt = 0.1 s:

t (s)PV (°C)ErrorΔ Error / ΔtD Output
4.07010
4.1728(8−10)/0.1 = −202.0 × (−20) = −40%
4.2746(6−8)/0.1 = −20−40%

Because the temperature changed by 2°C in only 0.1 seconds, the controller interprets this as a very rapid approach to setpoint.

The derivative is subtracting 40% from the output because the process is moving toward setpoint at 20°C/s — it's braking to prevent overshoot. Without this, the heater would still be pushing hard even as it overshoots 80°C.

This is why derivative is essential in precision temperature chambers but dangerous with noisy sensors — a 0.5°C noise spike per scan creates a huge fake derivative signal.

The Full PID Output — Calculated Step by Step

The full combined output:

u(t)=Kp×e(t)+Ki×e(t)dt+Kd×de(t)/dtu(t) = Kp × e(t) + Ki × ∫e(t) dt + Kd × de(t)/dt

Full Worked Example — One PLC Scan:

Given: Kp = 4.0, Ki = 0.5, Kd = 2.0, SP = 80°C, scan time Δt = 0.1 s

At time t = 10 s:

  • PV = 73°C → e[n] = 80 − 73 = 7°C
  • Previous PV = 71°C → e[n−1] = 80 − 71 = 9°C
  • Accumulated integral so far = 15%

Calculate each term:

P=Kp×e=4.0×7=28%P = Kp × e = 4.0 × 7 = 28\% I=Iprev+Ki×e×Δt=15+(0.5×7×0.1)=15+0.35=15.35%I = I_{prev} + Ki × e × Δt = 15 + (0.5 × 7 × 0.1) = 15 + 0.35 = 15.35\% D=Kd×(e[n]e[n1])/Δt=2.0×(79)/0.1=2.0×(20)=40%D = Kd × (e[n] − e[n−1]) / Δt = 2.0 × (7 − 9) / 0.1 = 2.0 × (−20) = −40\%

Total output = P+I+D=28+15.3540=3.35%P + I + D = 28 + 15.35 − 40 = 3.35\%

The output drops to 3.35% at this moment because:

  • The process is already moving fast toward setpoint (D is braking hard)
  • The proportional term still sees 7°C of error (pushing)
  • The integral has been accumulating and is supporting the bias

This is exactly how the controller prevents overshoot — not by accident, but by actively reducing drive as the process variable moves fast toward target.

Up to now we've focused on understanding what PID terms do. The next sections move into real industrial tuning methods used during commissioning.

Ziegler-Nichols Tuning: A Complete Worked Example

The Ziegler-Nichols (Z-N) Ultimate Gain method is the most widely taught PID tuning technique. Here's how it works end to end with numbers.

The Process: A water temperature loop. You disable I and D, then slowly increase Kp until the loop oscillates continuously at constant amplitude.

Step 1 — Find Ultimate Gain (Ku) and Period (Pu)

After testing, the loop sustains continuous oscillation at:

  • Ku = 8.0 (proportional gain at oscillation)
  • Pu = 40 seconds (period of one full oscillation cycle)

Step 2 — Apply Z-N Formulas

ControllerFormulaResult
Kp (PID)0.6 × Ku0.6 × 8.0 = 4.8
Ti (integral time)0.5 × Pu0.5 × 40 = 20 s
Td (derivative time)0.125 × Pu0.125 × 40 = 5 s

If your controller uses Ki and Kd (parallel form) instead of Ti and Td:

Ki=Kp/Ti=4.8/20=0.24Ki = Kp / Ti = 4.8 / 20 = 0.24 Kd=Kp×Td=4.8×5=24Kd = Kp × Td = 4.8 × 5 = 24

Step 3 — Apply 30–50% Detuning (Real-World Adjustment)

Z-N settings are intentionally aggressive. For a temperature loop where mild overshoot is acceptable but cycling is not:

Kpadjusted=4.8×0.65=3.1Kp_{adjusted} = 4.8 × 0.65 = 3.1 Tiadjusted=20×1.2=24s (longer Ti=slower integral=less oscillation)Ti_{adjusted} = 20 × 1.2 = 24 s \text{ (longer Ti} = \text{slower integral} = \text{less oscillation)} Tdadjusted=5×0.8=4sTd_{adjusted} = 5 × 0.8 = 4 s

These detuned values typically give a smoother response with 5–10% overshoot instead of the 25%+ that raw Z-N produces.

In real projects: I've used Z-N as a starting point on dozens of loops. The raw values almost always need detuning. On fast loops (flow, pressure), 30% detuning. On slow loops (temperature, level), sometimes 50%. Never implement Z-N raw on a critical process without watching the first few setpoint changes.

Lambda Tuning: Calculated Example for a Temperature Loop

Lambda tuning is the preferred method in process industries. You choose how fast you want the loop to respond (λ), then calculate the gains from a step test.

Step 1 — Run an Open-Loop Step Test

With the loop in manual, step the output from 40% to 60% (+20%) and observe:

  • Process gain (Kprocess): Temperature rises from 65°C to 75°C → ΔPV = 10°C
  • Time constant (τ): Time for PV to reach 63.2% of the change = 90 seconds
  • Dead time (θ): Delay before PV starts moving = 15 seconds

Think of dead time as the delay before the process reacts, and the time constant as how quickly it responds once it starts moving.

Calculate process gain:

Kprocess=ΔPV/ΔOutput=10°C/20%=0.5°C/%K_{process} = \Delta PV / \Delta Output = 10°C / 20\% = 0.5 \, °C/\%

Step 2 — Choose Lambda (λ)

Lambda is your desired closed-loop time constant. A safe rule: λ = 2 to 4 × θ

λ=3×θ=3×15=45 secondsλ = 3 × θ = 3 × 15 = 45 \text{ seconds}

Step 3 — Calculate Tuning Parameters

For a first-order-plus-dead-time (FOPDT) process — which covers most industrial loops:

Kp=τ/[Kprocess×(λ+θ)]=90/[0.5×(45+15)]=90/30=3.0Kp = τ / [Kprocess × (λ + θ)] = 90 / [0.5 × (45 + 15)] = 90 / 30 = 3.0 Ti=τ=90sTi = τ = 90 s

Td=0Td = 0 (Lambda tuning typically skips D for robustness)

Summary of Lambda-Tuned Parameters:

ParameterValue
Kp3.0
Ti90 s
Ki (= Kp/Ti)0.033

This gives a sluggish but very stable loop — the PV will reach setpoint in roughly λ + θ = 60 seconds after a step change, with essentially no overshoot. For a batch reactor or a critical process where stability matters more than speed, this is exactly right.

What the Response Curve Tells You

When you do a step test — suddenly jumping the setpoint and watching how the process responds — the curve tells you everything about your tuning.

PID step response showing underdamped, overdamped, and critically damped responses

Figure: Step response comparison. Underdamped (oscillating), overdamped (slow), and well-tuned (fast with slight overshoot).

Response TypeWhat It Looks LikeLikely Cause
Oscillating / UnderdampedProcess hunts around setpointKp too high, Kd too low
Overdamped / SluggishTakes forever to reach setpointKp too low, Ti too long
Steady-state offsetLevels off below setpointNo integral, or Ki too low
Spiking then settlingSharp overshoot then recoversKd too low, or Ti too short

A well-tuned PID typically shows about 5–10% overshoot and settles in 3–5× the dominant process time constant. If you're seeing clean first-order approach with zero overshoot, the loop is probably slower than it needs to be — conservative, not optimal.

Common Problems and How to Diagnose Them

Hunting / Cycling — The output oscillates continuously even at steady-state. Usually Kp too high or Ti too short. Check if the process itself has a dead band that's interacting with the controller.

Integral Windup — After a large setpoint change or long saturation period, the loop overshoots badly and takes a long time to recover. Enable anti-windup, or limit the integrator range in software.

Noise on the Derivative — The control output is chaotic, valves are chattering. D is amplifying sensor noise. Add a derivative filter (typically τf=Td/5 to Td/10τ_f = Td/5 \text{ to } Td/10), or disable D entirely.

Slow Recovery from Disturbance — Process gets knocked off setpoint and recovers slowly. Decrease Ti (faster integral action).

Setpoint Kick on SP Change — Rapid spike in output when the setpoint changes. Fix: apply derivative to the process variable only, not to the error. This is called "derivative on PV" and most industrial controllers support it as a configuration option.

PID in Real Control Systems

Temperature control — The most common PID application. Thermocouple or RTD as the feedback, output to a heater SSR or control valve. The worked examples in this post are all based on temperature loops because they're slow enough that you can see every term acting clearly.

Flow control — Fast-response loops, generally easy to tune. Typical parameters: Kp = 0.5–2.0, Ti = 5–20 s, D = 0. The challenge is usually valve hysteresis and deadband, not the PID itself.

Pressure control — Watch for process nonlinearity. A valve 10% open near setpoint behaves very differently than one at 90%. Nonlinear processes sometimes need gain scheduling — different Kp values depending on operating region.

Speed control on VFDs — The VFD has its own internal PID loop. When you add an outer PLC loop (for tension, winding, or process control), you have cascade PID. The inner loop must be tuned at least 5× faster than the outer loop. Violate this rule and the cascade becomes unstable.

Cascade example (calculated):

  • Outer loop (tension): λouter=5sTiouter=5sλ_{outer} = 5 s → Ti_{outer} = 5 s
  • Inner loop (VFD speed): must respond in λinner1sTiinner1sλ_{inner} ≤ 1 s → Ti_{inner} ≤ 1 s
Cascade PID control diagram with inner and outer loop

Figure: Cascade PID — the master controller's output becomes the slave controller's setpoint. The slave loop must always be the faster of the two.

In real projects, the biggest commissioning mistakes aren't with PID math — they're with the engineering around it: bad sensor placement, valve hysteresis, inadequate sample rates, or commissioning PID on a process that's mechanically unstable to begin with. Fix the process first, then tune the controller.

FAQs

What does a PID controller actually do? A PID controller continuously calculates an error value — the difference between a desired setpoint and a measured process variable — and applies three corrective actions (proportional, integral, derivative) to adjust the output and bring the process to the setpoint with minimal overshoot and steady-state error.

What happens if you only use P control without I or D? With proportional-only control, you'll almost always end up with a steady-state offset — the process never quite reaches setpoint. The system stabilizes at some point below (or above) the target. Adding integral action eliminates this offset, as shown in the examples above.

How do I know when a PID loop is tuned correctly? A well-tuned PID loop reaches setpoint quickly with minimal overshoot (typically less than 5–10%), settles without excessive oscillation, and recovers quickly from load disturbances. Do a step test and watch the response curve — it should look like a response that reaches setpoint quickly with only small overshoot and no sustained oscillation.

Can a PID controller be used with PLCs? Yes. Most modern PLCs — Siemens S7, Allen-Bradley, Schneider — have built-in PID function blocks. You configure the setpoint, feedback input, output range, and tune the gains either manually or through auto-tune features. Some advanced PLCs support cascade PID and feedforward additions.

What is the difference between series and parallel PID? In parallel form, each term (P, I, D) acts independently and their outputs are summed. In series (interacting) form, P multiplies the I and D terms. Tuning parameters are NOT interchangeable between forms — a common source of errors when migrating controller platforms.


Helpful Calculators


Credits

⭐ Was this article helpful?

IDAR Mohamed

IDAR Mohamed

Electrical Engineer

Electrical Engineer specialized in power systems, electrical installations, and energy efficiency. Passionate about simplifying complex electrical concepts into practical guides. (University of applied sciences graduate, with experience in HV/LV systems and industrial installations.)

  • PLC Programming
  • Motor Control
  • SCADA Systems
  • Sensors and Measurement
Share it: