Sample time, discretisation and jitter
How a PID runs in a PLC: sample time Ts, difference equations for the integral and the filtered derivative (backward Euler and Tustin), the effect of Ts on performance, call jitter and how to avoid it.
In short. In a PLC the controller computes the output once every Ts seconds and holds it in between. This adds about Ts/2 of delay to the loop. For a process with dead time θ choose Ts no larger than θ/10 and call the controller strictly periodically — then the discrete controller behaves like the continuous one you designed. The discretisation tool computes the coefficients of the difference equations.
Effect of the sample time
Section model (K = 1.8 °C/%, τ = 45 s, θ = 12 s), SIMC PI Kc = 1.042 %/°C, Ti = 45 s:
| Ts | Ts/θ | Overshoot | Settling |
|---|---|---|---|
| 1 s | 0.08 | 5.5 % | 74 s |
| 6 s | 0.5 | 14.9 % | 114 s |
| 12 s | 1 | 32.3 % | 156 s |
The settings were calculated for a continuous controller. If Ts is comparable to θ, either reduce Ts or add Ts/2 to θ in the calculation.
Difference equations
Controller in parallel form (Kp, Ki, Kd — see forms), derivative with a first-order filter Tf. Error e[k] = SP[k] − PV[k].
Backward Euler:
i[k] = i[k−1] + Ki·Ts·e[k]
d[k] = p·d[k−1] + c·(e[k] − e[k−1]), p = Tf/(Tf + Ts), c = Kd/(Tf + Ts)
u[k] = Kp·e[k] + i[k] + d[k]
Tustin (trapezoidal): i[k] = i[k−1] + Ki·Ts/2·(e[k] + e[k−1]); p = (Tf − Ts/2)/(Tf + Ts/2), c = Kd/(Tf + Ts/2). With Tf < Ts/2 the pole p is negative and the D term changes sign from sample to sample.
Example
Ideal form Kc = 2.5, Ti = 40 s, Td = 4 s, filter N = 10 (Tf = Td/N = 0.4 s), Ts = 0.1 s. Parallel form: Kp = 2.5; Ki = 0.0625 1/s; Kd = 10 s.
| Ts | Method | Ki·Ts (ki0) | p | c |
|---|---|---|---|---|
| 0.1 s | backward Euler | 0.00625 | 0.8 | 20 |
| 0.1 s | Tustin | 0.003125 + 0.003125 | 0.7778 | 22.22 |
| 1 s | backward Euler | 0.0625 | 0.2857 | 7.143 |
| 1 s | Tustin | 0.03125 + 0.03125 | −0.1111 | 11.11 — negative pole |
Backward Euler check at Ts = 0.1 s: p = 0.4 / 0.5 = 0.8; c = 10 / 0.5 = 20.
Open the example in the discretisation tool
Jitter
The formulas assume exactly Ts between calls. If the controller is called from the main cycle, the interval "floats" with the scan time:
- the integral accumulates Ki·Ts_design·e while a different time has actually passed — the effective Ki changes from call to call;
- the derivative divides the difference by the design Ts — with a short scan the D term jumps.
What to do:
- call the controller from a cyclic task with a fixed period (cyclic interrupt, periodic task), not from the free-running cycle;
- if that is impossible — measure the actual interval and use it in the formulas;
- match Ts to the input update: if the analog module updates PV every 100 ms, computing the controller every 10 ms is useless — the derivative sees "steps".
How the period is set in a particular block and environment (Siemens, CODESYS, OWEN, …) — check the documentation of its version.
Typical mistakes
- Ts differs from the real call period (the block is called from elsewhere or less often than configured).
- Coefficients calculated for one Ts, then the task period was changed.
- Tustin without a D filter — undefined; with a small Tf — a "ringing" D term.
- Too small a Ts with a noisy PV: derivative noise grows as 1/Ts (D filter).
Limits
The Ts table comes from a simulation with the output held between samples, without jitter or ADC quantisation. Other blocks may discretise differently (e.g. forward Euler or a different order of filter computation).
Connections
Open in Knowledge Graph →Loading the map…
Sources
- MathWorks — Discrete-Time Proportional-Integral-Derivative (PID) Controller: integrator and filter methods ForwardEuler / BackwardEuler / Trapezoidal (R2026b) — MathWorks
- Åström & Murray — Feedback Systems, 2nd ed. (2020), ch. 11 «PID Control», §11.5 Implementation: discretization, sampling — Caltech / Lund University
Updated 2026-10-12