Skip to content
Tutorials Center
My learning

Topics

Lesson 32 of 37 · Digital Control

Sampling and the Z-Transform

Understand how computers sample and hold signals, what aliasing does, how the z-transform maps s-plane poles to the unit circle, and why slow sampling destabilizes a loop.

So far every signal in this track was continuous. Real controllers are programs: an analog-to-digital converter (ADC) samples the sensor every T seconds, the processor computes the next control value, and a digital-to-analog converter (DAC) holds that value constant until the next sample. Between samples the controller is blind. This sampled-data setting changes the math: differential equations become difference equations, the Laplace transform becomes the z-transform, and the stability boundary moves from the imaginary axis to the unit circle.

flowchart LR
    R["r[k]"] --> E(("+/-"))
    E -->|"e[k]"| C["Digital controller (difference equation)"]
    C -->|"u[k]"| H["DAC + zero-order hold"]
    H -->|"u(t)"| P["Plant (continuous)"]
    P -->|"y(t)"| S["Sampler / ADC every T seconds"]
    S -->|"y[k]"| E

A sampled-data loop: the controller lives in discrete time, the plant in continuous time.

Sampling and aliasing

Sampling at period T (frequency fs = 1/T) keeps only the values x(kT). Two sinusoids whose frequencies differ by a multiple of fs produce identical samples, so after sampling you cannot tell them apart. This is aliasing. The Nyquist limit fs/2 is the highest frequency that can be represented unambiguously; anything above it folds back.

Python Aliasing: a 9 Hz wave looks like 1 Hz

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

The 9 Hz and 11 Hz signals both appear at 1 Hz. In a control loop this means sensor noise above fs/2 shows up as a slow, spurious disturbance that the controller will happily try to cancel. Hence real systems put an anti-aliasing filter (an analog low-pass) before the ADC, and choose fs well above the loop bandwidth. A common rule is 10 to 30 times the closed-loop bandwidth.

The zero-order hold

A DAC keeps the last value until the next one, a staircase signal called a zero-order hold (ZOH). On average the staircase lags the intended signal by half a sample, which acts like a delay of T/2. This small delay is why slower sampling erodes phase margin: each extra sample period costs about ωc·T/2 radians of phase at crossover.

The z-transform

The z-transform turns a sequence x[k] into X(z) = Σ x[k] z^(-k). The key property is the shift: z⁻¹ means "delay by one sample". A difference equation such as

TEXT
y[k] = 0.8·y[k-1] + 0.2·u[k-1]

becomes Y(z) = 0.8 z⁻¹ Y(z) + 0.2 z⁻¹ U(z), so the pulse transfer function is

TEXT
H(z) = Y(z)/U(z) = 0.2 z⁻¹ / (1 - 0.8 z⁻¹) = 0.2 / (z - 0.8)

Poles and zeros work as before, with one different map. A continuous pole s = p becomes a discrete pole z = e^(pT).

s-plane z-plane
Left half plane (Re s < 0) Inside the unit circle (`
Imaginary axis Unit circle
Right half plane Outside the unit circle
s = 0 z = 1
Far left (very fast) Near z = 0 (fast: dies in a sample or two)

A discrete system is stable exactly when all poles are inside the unit circle.

Python Mapping s-plane poles to z = exp(sT)

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Note the last two lines: an s-plane point and the same point shifted by 2π/T land on the same z. The s-plane is "rolled up" onto the z-plane, and the whole left half strip |Im s| < π/T maps onto the inside of the unit circle exactly once.

Discrete-time stability: the Jury test and roots

You can always compute roots with np.roots and check |z| < 1. For a quick hand test on a second-order polynomial z² + a₁z + a₂, the Jury conditions reduce to three inequalities: |a₂| < 1, 1 + a₁ + a₂ > 0 and 1 - a₁ + a₂ > 0. They are the discrete counterpart of the Routh-Hurwitz test.

Slower sampling destabilizes a loop

The continuous loop L(s) = 5/(s(s+1)) with unity feedback is stable for every gain. Sample the plant with a ZOH at different periods T, close the loop with the same gain, and look at the closed-loop poles.

Python Sample time versus stability

Press Run (or Ctrl + Enter) to see the result here.

Program input · what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

At T = 0.05 and 0.2 the poles are inside the unit circle, but at T = 0.5 they have moved outside: a loop that is unconditionally stable in continuous time diverges because the controller reacts to stale information. The conclusion is practical: choose the sample time from the loop bandwidth, and re-check stability after discretization.

Choosing the sample time. Aim for T such that there are 10 or more samples per rise time (or fs of 10 to 30 times the closed-loop bandwidth). Faster is usually better for control quality but costs CPU, ADC bandwidth and noise.

Check your understanding

Quick check · 4 questions

of 4 answered You scored / 4 · perfect!

  1. 1. A 9 Hz sine is sampled at 10 Hz. At what frequency does it appear?

    Frequencies differing by a multiple of fs give identical samples; 9 Hz aliases to |9 - 10| = 1 Hz.
  2. 2. A discrete system is stable when all poles satisfy:

    Poles must be inside the unit circle for the response to decay.
  3. 3. A continuous pole at s = -2 and sample time T = 0.5. Where is the discrete pole?

    z = e^(sT) = e^(-2 * 0.5) = e^-1, about 0.368.
  4. 4. Why does a zero-order hold reduce phase margin?

    The staircase output lags the ideal signal by about half a sample, adding phase lag that grows with frequency.

Summary

  • Sampled control uses ADC, a discrete controller and a zero-order hold DAC; the zero-order hold acts like a delay of about T/2.
  • Sampling folds frequencies above fs/2 back (aliasing); use an anti-aliasing filter and sample fast enough.
  • The z-transform turns difference equations into polynomials in z, with z⁻¹ = one-sample delay.
  • s-poles map to z = e^(sT); stability means all z-poles inside the unit circle.
  • A loop that is stable in continuous time can go unstable when sampled too slowly.

Next: Discretization Methods