From first principles
Integrate a held command across one sample
A sampled actuator holds its command fixed until the next update. Consider a stable first-order plant \(\tau\dot y+y=Ku\) with constant coefficients and sample interval \(h\). Let \(y_k\) be the value at the start of interval \(k\) and \(u_k\) the command held throughout it. During that interval the equilibrium for the applied command is the constant \(Ku_k\). Subtract it and integrate the homogeneous decay over exactly one interval.
Set \(a=e^{-h/\tau}\). The resulting discrete plant is an exact sample-to-sample model under a zero-order hold. For proportional feedback with unit reference scale, substitute \(u_k=g(r_k-y_k)\) to see where the sampled free response pole lies.
A sample-to-sample deviation is multiplied repeatedly by \(z_{\rm cl}\), so decay requires \(|z_{\rm cl}|<1\). This condition depends on the time at which the command is applied. A full sample of computational delay changes the state update and its characteristic equation.
Background · Discrete pole
This maps a continuous modal exponent into a sampled multiplier over interval Ts. Different continuous frequencies can give the same sampled phase.
Derivation and applications
Quantify the phase and attenuation introduced by a hold
A digital controller sends a piecewise-constant command to a continuous actuator. Even ideal sampling and instantaneous arithmetic do not make the resulting fundamental sinusoid identical to the requested one. Consider samples of a complex sinusoid at period \(h\). A zero-order hold outputs each sample unchanged over the following interval. For times \(t=kh+s\) within interval \(k\), the ratio of held signal to the desired continuous sinusoid is periodic in the within-sample time \(s\).
The zero-frequency Fourier coefficient of this periodic ratio gives the component at the original sinusoidal frequency. The remaining coefficients produce spectral images spaced by the sample frequency. Integrate the ratio over one hold interval and factor out the midpoint phase.
Below Nyquist the sine factor is positive. The fundamental therefore has phase equivalent to a delay of half a sample and a frequency-dependent gain. For small \(\omega h\), the sine expansion makes the leading attenuation quadratic while phase lag is linear.
This calculation concerns the fundamental component of a held command. Additional computation latency and sensor filtering accumulate their own phase. Frequencies approaching Nyquist also require examining the sampled closed-loop dynamics directly.
Worked example
Check a servo's phase allowance
At 50.0 Hz crossover and 1.00 kHz sampling,
The hold contributes \(-9.00^\circ\) and its fundamental magnitude is 0.9959. A further full sample of computation delay contributes \(-18.0^\circ\), giving \(-27.0^\circ\) combined at that frequency. The small gain change would conceal this phase cost in a magnitude-only measurement.
Change the inputs and inspect this calculation below
Second application
Choose a sampling interval from a phase budget
At a proposed crossover of 80.0 Hz, allocate at most 6.00° lag to the hold. Since the magnitude of the phase in degrees is \(180fh\), the interval must satisfy \(h\leq6/(180\times80)=0.417\) ms, or a sample rate of at least 2.40 kHz. At this limit the fundamental magnitude is
The resulting condition addresses the hold alone.
Interactive calculation · Change the inputs of this example
Use the adjustable quantities to test the two worked calculations above. The plot recomputes this derivation’s balance or constitutive relation; its numerical readout reports the quantities needed for the forward calculation and the inverse or design question. Keep the fixed assumptions stated in the readout when comparing with the example values.
Why one sample of latency can change the stability margin
A desktop position servo has a first-order response with time constant \(\tau\). A digital controller samples position every \(h\) seconds and holds each command constant until another is applied. Two firmware versions use the same sample period and proportional gain, yet one applies the command one whole sample later. Derive their closed-loop recurrences before attributing an observed oscillation to a different physical plant.
For the unit-gain plant \(\tau\dot x+x=u\), solve the differential equation over a single interval with constant input \(u_k\). The result is
where \(a=e^{-h/\tau}\) and \(b=1-a\). Under immediate regulation to zero the command is \(u_k=-Kx_k\). Then there is one closed-loop pole, \(a-bK\), and the positive gain range is \(0\le K<(1+a)/b\). At equality the pole sits at minus one and a step-to-step sign alternation persists.
With a one-sample delay the command is \(u_k=-Kx_{k-1}\). A trial solution \(x_k=z^k\) now gives
For \(0<a<1\) and \(K\ge0\) the two roots both lie inside the unit circle exactly when \(bK<1\). One can see the source of the upper limit by following the roots. At low gain they are real, lie between zero and \(a\), and meet when \(bK=a^2/4\). Beyond that value they are conjugate and their common modulus is \(\sqrt{bK}\), since their product equals \(bK\).

Take \(\tau=0.50\) s, \(h=0.10\) s and \(K=4.5\). The exact hold gives \(a=0.81873\), \(b=0.18127\). Immediate application produces a pole near 0.0030, while the delayed poles are about \(0.4094\pm0.8051i\), of modulus 0.903. Starting at unit displacement with the old stored sample equal to zero, the delayed plant first decays naturally. If the old sample had instead already equalled one, the first two data points would differ even though the subsequent recurrence and its poles were unchanged.
The complex argument of a delayed pole supplies another quantity to measure. At the default gain the pole angle is approximately 1.10 radians per sample. The damped oscillation therefore takes \(2\pi/1.10\) samples per cycle, approximately 0.57 s of physical time. Its envelope shrinks to about \(0.903^{10}=0.36\) of its original value over one second. Estimate both quantities from a simulated sequence. Divide the measured period by the sampling interval before comparing with the pole angle. When the response is sampled sparsely, looking only at the step-to-step change of sign can obscure an oscillation that takes nearly six samples to repeat.
Choose a gain for which immediate feedback is stable and delayed feedback is unstable, and quantify the growth.
Work through the solution
The two limiting gains are 10.033 and 5.517. At \(K=7\), the immediate pole is
The delayed conjugate pair has modulus \(\sqrt{7(0.18127)}\simeq1.126\), so its envelope grows by about 12.6% per sample. In the notebook, compare these predictions using the same physical-time horizon. If an actual processor has a fixed time delay, shortening \(h\) changes the delay in samples; the one-sample derivation must then be replaced with the actual timing model.
Interactive calculation · Sample delay motion
Vary the notebook inputs and compare both plotted observables. The same equations generate the browser curves and the notebook reference; fixed material, geometry and model assumptions are stated in the readout.
Interactive calculation · Sample delay poles
Vary the notebook inputs and compare both plotted observables. The same equations generate the browser curves and the notebook reference; fixed material, geometry and model assumptions are stated in the readout.
Derive the held-input model
A processor reads a sensor every \(h\) seconds and holds its most recent command until the next sample. Solve \(\tau\dot y+y=Ku_k\) exactly from \(kh\) to \((k+1)h\) with this constant input. The result is
where \(a=e^{-h/\tau}\). This recursion is exact at the sampling instants for the assumed hold. Taking a large Euler step through the continuous closed-loop equation describes a different experiment. A real controller has only the sampled information available when it computes \(u_k\).
With proportional control \(u_k=K_p(r_k-y_k)\) the discrete pole is \(z=a-KK_p(1-a)\). Stability requires \(|z|\lt1\). A negative pole of modulus less than one alternates sign each update while decaying. For \(K=1,\ \tau=1\) s and \(K_p=3\), \(h=0.2\) s gives \(z=0.275\); \(h=0.8\) s gives \(z=-1.203\). The same nominal continuous design gives radically different sampled records. For positive gain the upper gain limit is \((1+a)/[K(1-a)]\). Additional computation and transport delays lower the available margin further.

Locate the sampling limit in a computed trace
Keep the plant integration at 40 RK4 substeps per hold. Predict which sample intervals give a monotone response, a decaying oscillation or a growing one. Compare the stored OneSimulation traces on either side of 0.69 s. Estimate the discrete pole from two successive output increments; their ratio removes the unknown equilibrium.
| Update | Time (s) | Output |
|---|
At 0.65 s the measured pole is −0.9118, while at 0.70 s it is −1.0137. The latter increasingly overshoots even though the internal integration resolves each hold. Try 0.69 s and 0.70 s with python sampled-feedback.py --period 0.69, then double --substeps to check that the stability change is a sampling effect. Download the runnable OneSimulation model.
Why a saturated integrator remembers the past
Let \(v_k=K_p e_k+I_k\) be the requested command, and \(u_k\) its value clipped to the actuator range. An unconstrained integrator adds \(hK_i e_k\) to \(I_k\) at every sample. While an unreachable command holds a heater at its upper limit, positive error keeps accumulating; when the command becomes reachable again the stored integral may keep the heater fully on. This delayed recovery is called windup. Logging only actual heater power hides the growth of the internal demand. Log both signals and the integral state.
A back-calculation update feeds the clipping discrepancy back to the integrator:
When the request exceeds the upper stop, the second term is negative. At fixed error and fixed clipping level, this update attracts the requested command toward a value consistent with saturation, provided its discrete tracking dynamics are stable. For example, with \(h=0.1\) s, \(K_i=1\), \(e=2\), \(u=5\), \(v=8\), and \(T_t=0.5\) s, the integral increment is \(-0.4\), compared with \(+0.2\) without correction. Tuning \(T_t\) must account for the sample interval and actuator dynamics. Anti-windup cannot make an infeasible steady torque available.
Use a numerical result to distinguish two errors
Return to the OneSimulation tracking experiment. It models a continuous, unsaturated proportional loop and reports the error at a finite time. For a unit step from rest with loop gain \(g=KK_p\), the error after \(N\) closed-loop time constants is \(e_N=(1+g e^{-N})/(1+g)\). With \(g=8\) and \(N=6\), predict \(0.11331\). Its difference from the equilibrium \(1/9\) is transient motion. Halving the plant speed changes the physical time needed to reach the same dimensionless sample, while this sampled error stays fixed.
Test the interpretation by recording at three and six time constants and taking the ratio of the two deviations from equilibrium. Predict \(e^{-3}\) for the later deviation divided by the earlier. A persistent discrepancy warrants checking the recorded timestamps, the implementation of the step and whether a limit was active. To examine sampling or clipping, explicitly add these mechanisms to the model before comparing with the equations above. The logged linear-loop runs answer the finite-record question directly.
Derive an exact sampled stability boundary with a delayed command
A digital controller may acquire a sample at the start of an interval but only deliver its computed command at the following update. The one-sample computation delay then introduces an additional dynamic state. Consider a first-order plant \(\tau\dot y+y=Ku\) with an ideal zero-order hold and sampling period \(T\). Its exact sample-to-sample relation is
with \(a=e^{-T/\tau}\) and \(b=K(1-a)\). Assume proportional negative feedback about a zero reference and express gains with dimensions chosen so that \(bg\) is dimensionless.
With negligible computation delay, \(u_k=-gy_k\) yields one pole \(a-bg\), so stability requires \(|a-bg|<1\). With a one-sample delay the applied command is \(u_k=-gy_{k-1}\), giving \(y_{k+1}=a y_k-bg y_{k-1}\). Substitution of a trial sequence \(z^k\) gives the characteristic polynomial \(z^2-az+bg\). For a real monic quadratic \(z^2+c_1z+c_0\), the unit-disc conditions are \(1+c_1+c_0>0,\ 1-c_1+c_0>0,\ 1-c_0>0\). For \(0<a<1,\ b>0,\ g>0\) only the last condition limits increasing gain: \(bg<1\).
Once the delayed poles form a complex pair, their product equals their squared modulus. That makes the bound physically transparent: as \(bg\) reaches one the oscillation no longer decays between samples. This mechanism is invisible if a continuously implemented controller is analysed and merely evaluated at plotting intervals.
Compare two software schedules at the same sampling rate
Take \(K=1\),
The exact coefficients are
Without delay the positive gain limit is
With a delayed command it is \(1/b=5.52\). A gain of 7.0 gives a stable immediate pole \(0.8187-7(0.1813)=-0.450\). The negative sign predicts an alternating error whose sample values decrease in magnitude.
Apply the same gain through the delayed schedule. The characteristic polynomial becomes \(z^2-0.8187z+1.2689\). Its roots are complex with modulus \(\sqrt{1.2689}=1.126\), implying about 12.6% growth per sample in the envelope. An input limit may eventually bound the motion or produce a limit cycle, but it does not restore local linear stability around the unsaturated equilibrium. A controller test that records sensor samples and commanded values with separate timestamps can distinguish this delay from a sign error or an incorrectly discretised plant. Reduce the delayed gain to 4.0 and the predicted modulus becomes 0.852; the same clock can operate stably with a different response speed.
To recognise the delayed oscillation in a recorded trace, compute its angle as well as its modulus. At gain seven each real part is
Dividing by the modulus 1.126 gives \(\cos\theta=0.364\), so \(\theta=1.20\,\mathrm{rad/sample}\). The apparent oscillation period is about \(2\pi(0.10)/1.20=0.52\) s. By comparison the immediate negative real pole produces a two-sample alternating pattern with period 0.20 s. A controller log showing roughly five samples per growing cycle accords with the delayed implementation, whereas alternating every sample points towards the immediate model operating too aggressively. This interpretation uses the synchronised physical actuator output; a software variable computed today for application tomorrow may have a different timestamp from the hardware.
Why a fast vibration can appear as a slow feedback error
An analogue position sensor may detect a genuine low-frequency displacement and a much faster frame vibration. Sampling can make the two contributions indistinguishable. For a sampling interval \(T_s=1/f_s\), evaluate a complex sinusoid at sample \(n\):
A real cosine is also unchanged by reversal of frequency, so its apparent frequency can be folded into \(0\le f_a\le f_s/2\). At \(f_s=100\,\mathrm{Hz}\), a 92 Hz cosine gives precisely the samples of an 8 Hz cosine with reversed phase angle. If both are present, their sampled amplitudes combine according to phase. Removing 8 Hz in software would remove the true 8 Hz motion as well. Filter the continuous sensor signal before sampling if the higher component must be attenuated independently.
Suppose an encoder sees an unwanted sinusoidal displacement of amplitude \(0.50\,\mathrm{mm}\) at 92 Hz, while feedback must track motion through 8 Hz. A fourth-order analogue Butterworth low-pass filter with cutoff 20 Hz has magnitude \(|H(f)|=[1+(f/20\,\mathrm{Hz})^8]^{-1/2}\). At 92 Hz the ratio is 0.00223, or approximately \(-53.0\,\mathrm{dB}\): the folded displacement amplitude is only \(1.12\,\mathrm{\mu m}\). At 8 Hz the ratio is 0.99967, so a \(0.10\,\mathrm{mm}\) desired component retains about \(99.97\,\mathrm{\mu m}\). These are separate amplitude tests on the analogue filter. If both vibrations persist, the sampled 8 Hz component can vary with their relative phase.
A passband magnitude close to one does not bound the filter's phase lag. A controller designed with substantial gain near 8 Hz must also include the filter's complex frequency response in its phase-margin calculation. Aliasing, sample-and-hold delay and computational delay are three different contributions to the observed loop dynamics.
Practise on sheet 3 · Choose an analogue filter order against a folding vibration. Further reading · University of Pennsylvania · ESE 1500 Digital Audio Basics · Lecture 5, Anti-Aliasing, Parts 1–2.
Find the stability boundary from three measured outputs
Sample the unit first-order plant three times with gain 3 and a constant reference. A one-pole response gives \(\Delta y_{k+1}=z\Delta y_k\), so the ratio of increments identifies the discrete pole without knowing the final value. Here the plant uses forty RK4 substeps per controller interval.

Read values from the plot
| Controller hold period (s) | OneSimulation plant | Alternating stability boundary |
|---|---|---|
| 0.45 | −0.44949 | −1 |
| 0.57 | −0.7379 | −1 |
| 0.67 | −0.95317 | −1 |
| 0.77 | −1.1479 | −1 |
| 0.89 | −1.3574 | −1 |
Download the OneSimulation model (Python)
Interactive calculation · change the inputs of this example
Change controller gain and plant time constant, then find the sample interval where the discrete pole crosses minus one.
The curves below are recalculated from this section’s equations in your browser. The fixed reference plot above remains available for comparison.