Skip to content
Tactiverge

School/□ Systems Engineer/Week 20

How fast is fast enough?

Film a spinning wheel and it can appear to turn slowly backwards. Is the camera lying, or are you?

About 30 min · 3 goals · Checked by automated tests

1.Why should I care?

Get the sample rate wrong and no amount of clever software can recover the truth: the data is already corrupted. The Nyquist limit is the first number you check when you design any data logger, audio system or control loop.

  • ◇ State the sampling theorem and the Nyquist frequency fs/2.
  • ◇ Choose a sample rate for a signal with a known highest frequency.
  • ◇ Explain why a frequency at or above fs/2 cannot be told apart from a lower one.

2.Watch

→ Listen for the condition on the sample rate and the reason it is twice the highest frequency, not equal to it.

A university lecturer explains why you must sample faster than twice the highest frequency, and what goes wrong when you don't.

Length: see YouTube · captions on YouTube · source

Nothing loads from YouTube until you press play.

The video is optional: everything you need is also in the lesson text and the interactive.

3.Predict

A guitar note contains frequencies up to 5 kHz. What is the lowest sample rate that can represent it faithfully?

Guess first. Being wrong here is how the surprise works.

4.Discover

Keep fs = 20 Hz. Raise f from 1 Hz slowly. At what f does the dashed 'what the samples show' curve stop matching the blue signal? Then set f = 20 Hz exactly and explain what you see.

Loading the interactive…

Can't use the interactive? Read a description instead

In the sampler at fs = 20 Hz, the samples follow the signal faithfully until f reaches 10 Hz (the Nyquist frequency). Above that, the dots trace a slower false wave: at 12 Hz they look like 8 Hz. At exactly 20 Hz every sample has the same value, so the alias is 0 Hz.

5.Checkpoint: guided practice

Check what you just discovered before going on. Hints appear after a wrong answer.

Practice 1

An audio system samples at 48 kHz. What is its Nyquist frequency, in kHz?

kHz

Practice 2

A signal's highest frequency is 300 Hz. Which sample rate is the smallest of these that works?

6.Understand

The sampling theorem

If a signal contains no frequencies at or above B, sampling at fs > 2B keeps all its information: the original can be rebuilt exactly from the samples (by ideal interpolation). fs/2 is called the Nyquist frequency; 2B is the Nyquist rate. Below that, information is lost and, worse, disguised.

Why twice?

To capture a sinusoid you need at least a high sample and a low sample in every cycle, more than two per period. At exactly two samples per cycle you might hit only the zero crossings and see nothing at all. That is why the inequality is strict.

Real systems add margin

CD audio samples at 44.1 kHz to cover hearing up to about 20 kHz: Nyquist is 22.05 kHz, leaving room for an anti-aliasing filter to roll off. Control loops often sample 10–20 times faster than the dynamics they control, because they need the signal's shape, not just its frequency.

Explain it another way

To know a swing's rhythm you have to glance at it at least twice per swing, once near each end. Glance less often and you could think it is swinging slowly when it is actually swinging fast.

Worked example 1

An accelerometer measures vibrations up to 400 Hz. Which of 500 Hz, 1 kHz or 2 kHz would you choose?

500 Hz fails (Nyquist 250 Hz). 1 kHz just works in theory (Nyquist 500 Hz) but leaves little room for a filter. 2 kHz gives a comfortable margin: choose it, unless storage or power rules it out.

Common mix-ups

  • Sampling at exactly twice the highest frequency is enough.
    ✓ You need strictly more than twice; at exactly 2B you can land on zero crossings and lose the signal.
  • Frequencies above Nyquist are simply missed.
    ✓ They are not missed: they reappear at a false lower frequency (an alias).

7.Practice on your own

Practice, not a test. Wrong answers get a hint and another try.

Practice 3 · a fresh version every time

A 330 Hz sinusoid is sampled at fs = 250 Hz. At what frequency (between 0 and fs/2) does it appear in the samples, in hertz?

Hz

Practice 4

A 20 Hz sinusoid is sampled at exactly 20 Hz. What do the samples show?

Practice 5

A control loop's fastest dynamics are at 8 Hz and the rule of thumb is to sample 20 times faster. What sample rate, in Hz?

Hz

8.Apply it

List three signals on a small robot (wheel encoder ticks, battery voltage, a microphone for voice commands). Estimate each one's highest useful frequency and choose a sample rate with a margin. Which one costs the most memory per minute?

9.Reflect

Concepts: Sampling rate and aliasing