Execution Timing, Jitter, and Derivative Filtering in High-Loop-Count PID Platforms

PID Timing and Control Insights

A controller that executes 1,000 PID loops in under 2 ms tells you something about throughput, but nothing about what each loop experiences. Loop quality depends on the sample period actually seen by each loop, the variation in that period, and the filter placed on the derivative term. This article derives how these three jointly erode phase margin and inflate noise on the manipulated variable, so you can decide whether a fast platform delivers what the spec sheet implies, or whether your loops still need the same scrutiny of scan timing as on a slow one.

Assumptions throughout: linear time-invariant plant approximated as first-order-plus-deadtime (FOPDT), uniform sampling at period T unless stated, zero-order-hold (ZOH) output, and SI units (seconds, rad/s).

Why execution rate is a design variable, not a spec line

A throughput figure such as “N loops per 2 ms” describes aggregate compute. It does not state:

  • the period at which each loop is scheduled (a loop in a 100 ms task does not benefit from a fast CPU);
  • the deterministic latency between the PV sample instant and the CV write instant;
  • the jitter of that latency under load (communications, HMI, diagnostics, other tasks).

From the loop’s perspective, the computation-plus-I/O path is a delay. Sampling plus ZOH adds roughly T/2 of effective delay, plus any fixed input-to-output latency, plus jitter. All of it subtracts directly from phase margin at the crossover frequency. Execution rate is therefore a design parameter that sits alongside Kc, Ti and Td, and should be chosen against the process time constants and the desired closed-loop bandwidth.

Discrete PID structure, velocity vs positional form, and anti-windup interaction

Start from the continuous parallel-form PID with first-order derivative filter:

U(s)=Kc[1+1Tis+Tds1+TdNs]E(s)U(s) = K_c \left[ 1 + \frac{1}{T_i s} + \frac{T_d s}{1 + \frac{T_d}{N} s}\right] E(s)

KcK_c = proportional gain (CV units per PV unit), TiT_i = integral time (s), TdT_d = derivative time (s), NN = derivative filter factor (dimensionless, typically 5 to 20), E=SP−PVE = SP – PV.

Discretize with backward differences for the integral and filtered derivative (s→1−z−1T)\left(s → \frac{1 – z⁻¹}{T}\right). The positional form is:

u(k)=Kc[e(k)+TTi∑j=1ke(j)+D(k)]u(k) = K_c \left[ e(k) + \frac{T}{T_i} \sum_{j=1}^{k} e(j) + D(k) \right]
D(k)=aD(k−1)+b[e(k)−e(k−1)]D(k) = a D(k-1) + b \left[ e(k) – e(k-1) \right]
a=TdTd+NTb=TdNTd+NTa = \frac{T_d}{T_d + N T} \quad b = \frac{T_d N}{T_d + N T}

The discrete filter pole can be written as a=Tf/(Tf+T)a=T_f/(T_f+T), where Tf=Td/NT_f=T_d/N. As TT becomes small relative to TfT_f, aa approaches 1, corresponding to a pole close to one in the discrete-time recursion. When T=TfT=T_f, a=1/2a=1/2. The value a=1/(1+N)a=1/(1+N) occurs when T=TdT=T_d. Because the discrete coefficients depend on the sampling period, recalculate them whenever TT changes and verify the resulting closed-loop response. This does not automatically require changing the continuous-time tuning parameters KcK_c, TiT_i, or TdT_d.

Velocity form. Take the difference u(k)−u(k−1)u(k) – u(k-1) of the positional form. The integral sum collapses to a single term:

Δu(k)=Kc[(e(k)−e(k−1))+TTie(k)+(D(k)−D(k−1))]\Delta u(k) = K_c \left[ \left(e(k) – e(k-1)\right) + \frac{T}{T_i} e(k) + \left(D(k) – D(k-1)\right) \right]
u(k)=u(k−1)+Δu(k)u(k) = u(k-1) + \Delta u(k)

Key step: the Σe(j)\Sigma e(j) term differences to e(k)e(k), so no explicit integrator state is stored. The controller output is the accumulated increment.

Anti-windup interaction. In velocity form, windup is limited by clamping u(k)u(k) to [umin,umax]\left[u_{min}, u_{max}\right] after accumulation, which is a form of integrator clamping because the output itself is the integrator. This is simple and bumpless on manual/auto transfer, but it ties the clamp to the actuator range only. With positional form you may choose conditional integration or back-calculation with tracking time TtT_t (commonly between Ti·Td\sqrt{T_i·T_d} and TiT_i). Back-calculation depends on TtT_t, which is an additional tuning dependence; velocity-form clamping has none but cannot account for downstream limits (e.g., a split-range or a rate-limited valve) unless the clamp is fed from the actual actuator position. Note that the proportional-on-error kick, SP weighting, and the choice of derivative on PV rather than error must be consistent across forms.

Sample period, zero-order-hold delay, and the phase lag it adds

A ZOHZOH of period TT has transfer function 1−e−sTs\frac{1 – e^{-sT}}{s}. At frequencies well below the sampling rate, it approximates a pure delay of T2\frac{T}{2}:

ZOH(jω)≈T·e−jωT2·sinc(ωT2)ZOH(j\omega) \approx T · e^{-\frac{j\omega T}{2}} · sinc\left(\frac{\omega T}{2}\right)

Where sinc(x)=sin(x)xsinc(x) = \frac{sin(x)}{x}. The phase is exactly −ωT2-\frac{\omega T}{2}. At the gain crossover frequency ωc\omega_c, the added phase lag is:

ΔϕZOH≈ωc·T2(rad)=57.3·ωc·T2(degrees)\Delta \phi_{ZOH} \approx \omega_c ·\frac{T}{2} \quad (rad) = 57.3 · \omega_c · \frac{T}{2} \quad (degrees)

Adding sample-and-hold delay and a fixed computational (or I/O) latency τio\tau_{io}, the total effective delay is:

τeff=T2+τio+τj\tau_{eff} = \frac{T}{2} + \tau_{io} + \tau_j

where τj\tau_j is the jitter bound (next section). Phase margin of the loop, relative to a design with no timing effects, falls as:

PM≈PM0−ωc·τeff(rad)PM \approx PM_0 – \omega_c · \tau_{eff} \quad (rad)

PM0PM_0 = phase margin of the continuous design. This is first-order: valid when ωc·T\omega_c·T is well below π\pi (rule of thumb: ωc·T<0.5\omega_c·T < 0.5). Beyond that the sincsinc magnitude droop and aliasing matter, and the delay approximation understates degradation.

Derivative filtering: N-factor, noise amplification, and the bandwidth trade-off

The derivative term with first-order filter is:

Gd(s)=Kc·Tds1+sTdNG_d(s) = K_c · \frac{T_d s}{1 + s \frac{T_d}{N}}

Derivation of the high-frequency limit: as s→∞s → \infin, the “1” in the denominator is negligible against sTdNs\frac{T_d}{N}, so

Gd(∞)=Kc·TdssTdN=Kc·NG_d(\infin) = K_c · \frac{T_d s}{s \frac{Td}{N}} = K_c · N

In the form Kd·s/(1+s·TdN)K_d·s/(1 + s·\frac{T_d}{N}) with Kd=Kc·TdK_d = K_c·T_d (the derivative gain in CV·s per PV unit), the limit is Kd·N/Td=Kc·NK_d·N/T_d = K_c·N. This is the high-frequency gain of the controller from measurement noise to CV. For PV noise of standard deviation σn\sigma_n, CV noise scales roughly as Kc·N·σnK_c·N·\sigma_n (bounded by the sampling Nyquist band). Doubling NN approximately doubles the high-frequency noise gain.

Trade-off: the filter corner is at ω=N/Td\omega = N/T_d. Raising NN pushes the corner up, giving the derivative more phase lead near ωc\omega_c, but amplifies noise and actuator wear. A low NN limits noise but reduces useful lead, and the filter itself adds lag at ωc\omega_c of atan(ωc·Td/N)atan(\omega_c·T_d/N). With TT-dependent discretization, there is a further constraint: Tf=Td/N T_f = T_d/N should be at least about 2T2T, otherwise the filter is effectively bypassed and the derivative acts on a single sample difference.

Execution jitter and its effect on loop stability margins

Let τio\tau_{io} be the nominal latency between PV acquisition and CV update. Define τj\tau_j as the maximum deviation of the actual input-to-output latency from its nominal value:τj=max⁡k∣(to,k−ts,k)−τio∣\tau_j=\max_k\left|(t_{o,k}-t_{s,k})-\tau_{io}\right|

where ts,kt_{s,k} and to,kt_{o,k} are the actual PV-sampling and CV-update times for scan kk. If the sampling and output-update instants deviate from their nominal schedules by at most δi\delta_i and δo\delta_o, respectively, a conservative bound is:

τj≤δi+δo\tau_j \leq \delta_i + \delta_o

Where δi\delta_i is the maximum absolute input sampling-time deviation, in seconds, and δo\delta_o is the maximum absolute output update-time deviation, in seconds. PM degradation from jitter, to first order:

ΔPMjitter≈ωc·(δi+δo)\Delta PM_{jitter} ≈ \omega_c · (\delta_i + \delta_o)

Jitter also perturbs the discrete integral and derivative: the integral accumulates Kc·(T/Ti)·e(k)K_c·(T/Ti)·e(k) assuming nominal TT, so a late sample under-integrates and an early one over-integrates, while the derivative difference e(k)−e(k−1)e(k) – e(k-1) divided by the nominal TT misreports slope by the factor Tactual/T T_{actual}/T. Derivative noise from jitter is proportional to the PV rate of change, so it matters most during setpoint moves and disturbances rather than steady state. If your platform exposes the true elapsed time per scan, compute TactualT_{actual} and use it in the algorithm.

Worked example: T = 10 ms vs T = 100 ms on an FOPDT process

Process: G(s)=Kp·e−θs/(τs+1) G(s) = K_p · e^{-θs} / (τs + 1), with Kp=1K_p = 1, τ=20s\tau = 20 s, θ=2s\theta = 2 s.

Tune a PI controller by a lambda/IMC rule with closed-loop time constant λ=2θ\lambda = 2θ. Here choose λ = 4 s:

Kc=τKp(λ+θ)=206=3.33K_c = \frac{\tau}{K_p (λ + θ)} = \frac{20}{6} = 3.33
Ti=τ=20sT_i = \tau = 20 s

Approximate crossover: ωc≈1/(λ+θ)=1/6≈0.167 rad/s\omega_c \approx 1/(\lambda+\theta)=1/6\approx0.167\ \text{rad/s}. Since Ti=τ=20 sT_i=\tau=20\ \text{s}, the PI controller and first-order process contribute a combined phase lag of 90∘90^\circ at crossover. The process dead time contributes an additional lag of θωc=2/6=0.333 rad=19.1∘\theta\omega_c=2/6=0.333\ \text{rad}=19.1^\circ. Therefore, the continuous-time phase margin before sampling, I/O latency, and jitter is: PM0​≈180°−90°−19.1°=70.9°PM_0​≈180\degree−90\degree−19.1\degree=70.9\degree.

Case A, 𝐓=𝟏𝟎𝐦𝐬\bold{T = 10 \enskip ms}, 𝛕𝐣=𝟏𝐦𝐬\bold{\tau_j = 1 \enskip ms}, 𝛕𝐢𝐨=𝟐𝐦𝐬\bold{\tau_{io} = 2 \enskip ms}:

τeff=0.005+0.002+0.001=0.008s\tau_{eff} = 0.005 + 0.002 + 0.001 = 0.008 s
ΔPM=0.167·0.008=0.00134rad=0.08°\Delta PM = 0.167 · 0.008 = 0.00134 rad = 0.08°
PM≈70.8°PM \approx 70.8\degree

Negligible. The timing contributes essentially nothing relative to θ=2sθ = 2 s.

Case A, 𝛕𝐣=𝟐𝟎𝐦𝐬\bold{\tau_j = 20 \enskip ms}, 𝛕𝐣=𝟐𝟎𝐦𝐬\bold{\tau_j = 20 \enskip ms}, 𝛕𝐢𝐨=𝟏𝟎𝐦𝐬\bold{\tau_{io} = 10 \hspace{0.5em} ms}:

τeff=0.05+0.01+0.02=0.08s\tau_{eff} = 0.05 + 0.01 + 0.02 = 0.08 s
ΔPM=0.167·0.08=0.0134rad=0.77°\Delta PM = 0.167 · 0.08 = 0.0134 rad = 0.77°
PM≈70.1°PM ≈ 70.1°

Also small. Conclusion for this slow loop: T=100msT = 100 ms is adequate, and the 10 ms platform buys almost nothing. A useful screen: sample at T≤θ/10T ≤ θ/10 or T≤(λ+θ)/20T ≤ (λ+θ)/20 here, either gives roughly 100 to 300 ms.

Contrast: a fast loop. Pressure or flow loop with θ=0.2s,τ=1s,λ=0.4s\theta = 0.2 s, \enskip \tau = 1 s, \enskip \lambda = 0.4 s gives ωc≈1/0.6≈1.67rad/s\omega_c ≈ 1/0.6 \approx 1.67 rad/s. With T=100msT = 100 ms, jitter 20 ms, τio=10ms\tau_{io} = 10 ms: τeff=0.08s,ΔPM=1.67·0.08=0.133rad=7.6°\tau_{eff} = 0.08 s, \enskip \Delta PM = 1.67 · 0.08 = 0.133 rad = 7.6\degree. With T=10msT = 10 ms (τeff=0.008s\tau_{eff} = 0.008 s): 0.8°. Here the scan period matters: a 7.6° loss from 70.9° is tolerable but eats into the margin intended for model error. If τ\tau shrinks further, the approximation ωcT<0.5 \omega_cT < 0.5 and the loss grows linearly.

Derivative noise at the same two rates. For a PID with Kc=3.33,N=10K_c = 3.33, N = 10, PV noise σn=0.2%\sigma_n = 0.2 \% of span: high-frequency CV noise ≈Kc·N·σn=3.33·10·0.2%=6.7%\approx K_c·N·\sigma_n = 3.33 · 10 · 0.2\% = 6.7\% of span, at either TT, bounded by Nyquist. Faster sampling does not reduce this; it increases the bandwidth over which noise reaches the valve. Reduce NN or filter the PV first.

Tuning rules for a fast-scan platform and commissioning checks

  • Choose TT from the process: T≈θ/10T \approx \theta/10 to θ/5 θ/5, or T≤λ/10T \leq \lambda/10 for tight loops. Faster than this adds noise bandwidth and load without margin benefit.
  • Budget phase: require ωc·(T/2+τio+τj)\omega_c·(T/2 + \tau_{io} + \tau_j) below roughly 5° to 10° (0.09 to 0.17 rad) of the planned margin.
  • Set Tf=Td/N≥2TT_f = T_d/N ≥ 2T to 5T5T. If TdT_d is small relative to TT, disable derivative.
  • Consider retuning after any change of TT: aa, bb and the integral increment all depend on it.
  • Verify, do not assume: log the actual scan interval (min/max/mean), the time from PV acquisition to CV write, and CV noise standard deviation in auto at steady state.
  • Step test in both directions at two operating points and compare observed overshoot and settling with the model-based prediction.

Implementation notes

Velocity-form PID with filtered derivative on PV, measured elapsed time, and output clamping (Structured Text, IEC 61131-3):

FUNCTION_BLOCK FB_PidVel
VAR_INPUT
    SP, PV   : REAL;
    Kc       : REAL;   // gain
    Ti, Td   : REAL;   // seconds, Ti > 0
    N        : REAL;   // derivative filter factor
    Ts       : REAL;   // measured elapsed time, seconds
    OutMin, OutMax : REAL;
    Auto     : BOOL;
    ManOut   : REAL;
END_VAR
VAR_OUTPUT
    CV : REAL;
END_VAR
VAR
    ePrev, pvPrev, dPrev : REAL;
    a, b, dNow, du : REAL;
    first : BOOL := TRUE;
END_VAR

IF NOT Auto THEN
    CV := ManOut;               // track for bumpless transfer
    ePrev := SP - PV; pvPrev := PV; dPrev := 0.0; first := TRUE;
    RETURN;
END_IF

IF (Ts <= 0.0) OR (Ti <= 0.0) OR (N <= 0.0) OR
   (Td < 0.0) OR (OutMin > OutMax) THEN
    RETURN;  // Set a diagnostic or alarm in production code
END_IF

a := Td / (Td + N * Ts);
b := Td * N / (Td + N * Ts);

IF first THEN
    ePrev := SP - PV; pvPrev := PV; dPrev := 0.0; first := FALSE;
    Return; // Hold CV for this scan and skip the initial integral increment
END_IF

// derivative on PV (sign: reverse acting on measurement)
dNow := a * dPrev - b * (PV - pvPrev);
du   := Kc * ((SP - PV) - ePrev + (Ts / Ti) * (SP - PV) + (dNow - dPrev));

CV := LIMIT(OutMin, CV + du, OutMax);   // clamping = anti-windup

ePrev := SP - PV; pvPrev := PV; dPrev := dNow;
END_FUNCTION_BLOCK

Note that the proportional term here acts on error; use setpoint weighting if SP kick is unacceptable.

Pitfalls

  • Mixed scan rates. A PID in a fast task fed by a PV updated in a slow task, or by a fieldbus value refreshed slower than the loop, samples stale data; the true delay is the slowest link in the chain, not TT.
  • Unscheduled or event-driven loops. Loops executed on demand, or in a task that overruns under load, have uncontrolled TT. Algorithms using a fixed constant T in the gain terms then mis-integrate.
  • Filter misconfiguration. NN left at a default of 10 or higher on a noisy PV, or Td/NT_d/N below the scan period, gives CV chatter or a derivative that does nothing. Dual filtering (analog input filter plus PID filter) adds lag that was not in the tuning model.
  • Retuning blindness. Copying tuning constants between platforms with different T or different discretization (backward vs trapezoidal, filtered vs unfiltered derivative) changes effective gains.
  • Treating aggregate throughput as per-loop latency. Loops-per-millisecond says nothing about jitter under communication load.
  • Ignoring actuator dynamics. A valve with a deadband or rate limit makes small-signal phase analysis optimistic regardless of scan rate.

Key takeaways

  • Sample-and-hold contributes about ωc·T/2\omega_c·T/2 of phase lag; add I/O latency and jitter bounds to get the total ωc·τeff\omega_c·\tau_{eff}.
  • Relative to a slow process (θ of seconds), scan rates below 100 ms cost under a degree; for fast loops (θ of a few hundred ms) the same period costs several degrees.
  • The derivative filter sets the high-frequency gain at Kc·NK_c·N, so noise on the CV scales with N, not with sample rate.
  • Faster execution beyond about T=θ/10T = \theta/10 yields little margin and widens the noise bandwidth; choose TT from the process, not from the CPU.
  • Measure actual scan interval, I/O latency, and CV noise on the running plant before adjusting gains.

Further reading

  • Beijer Electronics Nexto XF Combines PLC Control With Linux OS: Link & Link
  • Åström, K. J. and Hägglund, T., Advanced PID Control, 2006.
  • Åström, K. J. and Wittenmark, B., Computer-Controlled Systems, 3rd ed., 1997.

Looking to improve process stability, optimize production, or modernize your control systems? Contact InduSphere Controls to discuss practical automation and process control solutions tailored to your operation.