TactivergeLite

Lite / Engineering Complex Systems / 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 · Full interactive version

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.

Predict

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

  1. 5 kHz
  2. Just over 10 kHz
  3. 2.5 kHz
  4. 50 kHz
Guess first, then reveal

You need fs > 2 × 5 kHz = 10 kHz, so that 5 kHz is below the Nyquist frequency fs/2. Real systems add a margin because anti-aliasing filters are not perfectly sharp.

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.

What the interactive shows (text version)

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.

You can also open the interactive on the full site when you have a faster connection.

Watch (optional)

Watch for: 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.

“Shannon Nyquist Sampling Theorem” by Steve Brunton (opens YouTube; streaming video uses a lot of data)

The video is optional. Everything you need is in this lesson's text.

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

Intuitive

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.

Technical

Sampling makes copies of the spectrum centred on every multiple of fs. If the signal's band reaches past fs/2, neighbouring copies overlap and no filter can separate them afterwards.

Mathematical

cos(2πf·n/fs) = cos(2π(f + k·fs)·n/fs) for every integer k, and cos is even. So f, fs − f, fs + f, … all give identical samples. They are distinguishable only if we know f < fs/2.

Applied

Vibration-monitoring sensors on wind turbines sample at several kilohertz because bearing faults show up as high-frequency tones; sampling at 100 Hz would fold them into misleading low-frequency readings.

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

Practice

Practice, not a test. Answers are checked on our server; a wrong answer gets a hint and another try. Nothing is saved.

kHz

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

Hz

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

Hz

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?

Reflect

Why is aliasing more dangerous than simply missing a frequency?

Write your answer on paper or in your own notes. Lite never stores what you write.

← Rounding to the nearest stepPredicting the impostor →