PID practice

01 / EXPLANATION

How a PID controller works

You need to heat a process to 60 °C, but it is currently at 55 °C. Follow the 5 °C error through the controller to see how it becomes a command to the heater.

After reading. You will distinguish SP, PV and MV, explain P/I/D and calculate how Ti changes the integral contribution.

Three signals and one error

SP is the setpoint: the target is 60 °C. PV is the measurement: the sensor reads 55 °C. Error e = SP − PV = 5 °C. SP, PV and error share the same units, so they can be compared.

MV is the manipulated variable: heater power in %, for example. In heating, positive error should increase power. If increasing MV reduces PV, as in cooling, the action direction must differ. Gain adjustments cannot fix the wrong direction.

How a heating feedback loop closesThe 60 °C setpoint SP is compared with a 55 °C measurement PV. The 5 °C error enters the PID, which changes heater power MV. The new measurement feeds back into the comparison. Temperature and power use different units.SetpointSP = 60 °CError: SP − PVe = 60 − 55 = 5 °CPID controllercalculates MVPlant: heatingpower MV, %MeasurementPV = 55 °CMVSP, PV, e: °C · MV: % power
Reading the loop: the target is 60 °C and the measurement is 55 °C. The controller changes power, not the measurement itself. Arrows show signal direction.

P, I and D look at different things

P responds to the error now. With Kp = 2 %/°C, a 5 °C error gives a 10 % P contribution. More gain produces stronger action but can cause oscillation; P alone can leave a residual error.

I accounts for how long the error persists. While error is positive, the integral contribution grows. In stable operation without saturation, this helps remove a constant offset. At the output limit, protection against integral accumulation, or anti-windup, matters.

D accounts for how fast a signal changes. In the heating example shown, derivative on PV adds braking action while temperature rises. Noise also changes quickly, making D sensitive to it and requiring a filter. Derivative on PV avoids the kick specifically caused by an SP step; derivative on error responds to that step too.

Three different sources of PID actionP uses the current error, marked by a point. I uses the accumulated area under error over time. D uses the slope of the measurement PV; for heating, rising PV gives a braking contribution when Kp and Td are positive.P · error now5 °C → actionpoint: e nowI · error historyerror persistsarea: ∫e dtD · rate of PVPV rises → D < 0slope: dPV/dt
A concept sketch, not three measured responses. D is shown acting on PV: with positive Kp, rising temperature contributes a negative D term. For constant PV, this term decays to zero as the filter settles.

Read Kp, Ti and Td in the formula

Below is the ideal continuous-time ISA form with derivative on error e. It explains the three contributions. For derivative on measurement, replace the last term with −Td·dPV/dt. An implemented algorithm also accounts for the calculation interval, filter, limits, output bias and operating mode.

u(t) = Kp · [e(t) + (1/Ti) ∫e(t)dt + Td · de(t)/dt]

Ti and Td have units of time. With Kp fixed, a smaller positive Ti strengthens I. A larger Td strengthens D. In the ISA form, Kp multiplies all three enabled contributions, so changing Kp affects more than P.

The parallel form uses Kp, Ki and Kd. For matching ideal forms: Ki = Kp/Ti and Kd = Kp·Td. Ti is a time; Ki is an integral gain. They are not interchangeable numbers. Before transferring a tuning, check the form, units and signal scaling.

Find the PID parameters in the interface

Example: what changes when Ti is halved

Hold the error at 5 °C for this calculation. Let Kp = 2 %/°C, Ti = 10 s, Td = 0 and the initial I contribution be zero. The P contribution is 10 %, while I grows by (2/10)·5 = 1 percentage point per second.

With Ti = 5 s, I grows by 2 percentage points per second. After 5 s the I contribution is 5 % in the first case and 10 % in the second. This shows the strength of integration; on a closed-loop plot, error will not remain constant.

A smaller Ti accumulates the I term fasterCalculation with a constant 5 °C error, Kp of 2 %/°C and zero initial integral. With Ti of 10 seconds, I grows by 1 percentage point per second to 5 % at 5 seconds. With Ti of 5 seconds, I grows by 2 points per second to 10 %. Only the integral contribution is shown, not total MV.I contribution to output, %e = 5 °C · Kp = 2 %/°C · I(0) = 00510Ti = 10 sTi = 5 s05 stime, sTi = 10 s: ━ Ti = 5 s: – –
An ideal I-term calculation at constant error: I(t) = (Kp/Ti)·e·t. This is not a heater step response: PV and error change in a closed loop. The 10 % P contribution is not included in the plot.

What to check besides the coefficients

Dead time delays the visible plant response. Saturation limits available power. Noise can provoke unnecessary output movement. PV being close to SP is therefore not enough to establish good tuning.

Read PV and MV together; test a setpoint step and a disturbance separately. Then compare two tunings on the same model. The numbers above illustrate the formula; they are not recommended gains for a particular heater.

Continue to the tuning comparison

See how PID controls a pump

In your first PIDLAB experiment, open a ready-made stand, change the setpoint SP, compare the measurement PV with the setpoint and observe how the controller output MV changes. You can read the lesson without an account. Running the stand requires sign-in; practice is currently free.

Start your first experiment

PIDLAB — an engineering laboratory for PID loops. Simulation does not replace validation on the real plant.