28 Sampling and Aliasing: Nyquist and Filters
More
Depth: Practitioner
Progress saves as you read. Mark sections complete as you go; your progress appears in the sidebar.
When fast vibration becomes a false slow wave
Follow the continuous signal, its sample dots, and the wave those dots imply. Play follows the recorded narration with captions. Choose a beat or Reduced motion for a still. The motor arithmetic is exact; unlabeled rates and filter attenuation are schematic.
Full transcript — Nyquist and filters (8 beats)
B1 — Fast vibration, false reading
You are designing a motor vibration monitor for a factory. Your job is to detect bearing trouble before a breakdown. A fast vibration can turn into a slow false reading when sampling is too slow. The sampling error could make a bearing problem resemble normal motor vibration.
B2 — Readings over time
Sampling means taking readings from a changing signal. The sampling rate tells you how many readings you take each second. Aliasing is an error: a fast real wave appears slower in sampled data. The readings can describe a frequency the motor never produced.
B3 — Retain a bounded band
The Nyquist rule starts with a signal whose frequency range has been limited. Sample at more than twice the highest frequency you retain. Half the sampling rate is called the Nyquist frequency. Keep the retained signal frequencies lower than the Nyquist ceiling so the samples can represent them faithfully.
B4 — Exactly at the ceiling
For your motor monitor, suppose the bearing defect produces a peak at five hundred hertz. Hertz measures cycles per second. Consider taking one thousand readings per second. Half of one thousand is five hundred, so the wanted peak sits exactly at the Nyquist ceiling.
B5 — 800 Hz becomes 200 Hz
Include an unfiltered vibration component at eight hundred hertz. At one thousand readings per second, subtract eight hundred from one thousand to get two hundred hertz, the apparent frequency. Normal motor vibration in this example ranges up to two hundred hertz. The false component lands in that range and could hide a bearing problem.
B6 — The whole signal matters
A common mistake is to assume sampling at exactly twice the wanted frequency reliably captures the peak, but at one thousand readings per second, the five hundred hertz bearing peak sits exactly at the sampling ceiling. Its samples depend on where in the wave each reading falls, so they cannot reliably describe the peak. The eight hundred hertz component lies above that ceiling and appears as a false slower vibration. Both effects matter when choosing the sampling rate.
B7 — Filter before sampling
An analogue anti-alias filter reduces unwanted high frequencies before an analogue-to-digital converter turns the signal into numerical samples. A low-pass filter lets lower frequencies through while weakening higher ones. Set its cutoff below the Nyquist ceiling because the filter weakens frequencies gradually rather than stopping them all at once. Sampling faster leaves more room for that gradual filtering.
B8 — Rate and filter together
Choose the rate for the signal you keep, and filter unwanted fast components before they become false slow readings.
28.1 Start With the Decision
This section: Start With the Decision — A sensor can report a slow false wave when it samples a fast real signal.
A sensor can report a slow false wave when it samples a fast real signal. Sampling rate and filtering must protect the measurement before analysis begins.
28.2 Route Overview
This section: Route Overview — This is part 1 of 3.
This is part 1 of 3. Continue with Sampling Design: Product Scenarios.
28.3 Part Objectives
This section: Part Objectives
- Apply the Nyquist condition to a bounded sensor signal.
- Explain how aliasing and anti-alias filters change sampled evidence.
28.4 Start Simple
This section: Start Simple — Picture a vibration monitor that reports a gentle wobble while the machine is shaking much faster.
Prove a Fast Signal Does Not Become a Slow Lie
Picture a vibration monitor that reports a gentle wobble while the machine is shaking much faster. The stored trace may be neat and still be false.
Sampling rate means how many measurements are taken each second. State the fastest signal of interest and what the input filter removes before choosing that rate.
Apply a known slow tone, a near-limit tone, and one above the limit. Keep the source frequency, filter, sampling rate, raw samples, spectrum, and false component so another person can repeat the check.
This check covers chosen tones and one signal path, not every transient. The deeper sections develop aliasing, limits, filtering, oversampling, and reconstruction.
Imagine measuring vibration but sampling so slowly that a fast wobble appears as a slow false pattern. Nyquist sampling is the rule that prevents a changing signal from pretending to be something else. Start with the highest frequency you need to trust, then choose sample rate and filtering before collecting data.
- Nyquist–Shannon Sampling Theorem: A band-limited continuous signal can be reconstructed from samples when fs is chosen above 2 × fmax with alias-producing components filtered before sampling.
- Aliasing: The distortion that occurs when a signal is sampled below the Nyquist rate; high-frequency components above fs/2 fold back into the spectrum and appear as false low-frequency components that do not exist in the original signal
- Nyquist Frequency: Half the sampling rate, fs/2. A component exactly at this limit is phase-ambiguous, so sample above twice the highest retained signal frequency and attenuate higher components before conversion.
- Anti-Aliasing Filter: A low-pass filter applied before the ADC to attenuate signal components above the Nyquist frequency before sampling; prevents aliased components from entering the digital data; cutoff frequency is typically set to 0.4 x fs or below
- Oversampling: Sampling above the Nyquist minimum can spread quantization noise over a wider band; with suitable uncorrelated noise and filtering, 4× oversampling followed by decimation can add about one effective bit.
- Sample-and-Hold Circuit: The analog input circuit that captures (samples) the input voltage at a precise instant and holds it stable during the ADC conversion period; settling time of the S/H circuit limits the maximum usable sampling rate
- Quantization Noise: The error introduced by representing a continuous voltage as one of 2^N discrete levels; quantization noise is approximately white noise with amplitude +-0.5 LSB; SNR improvement = 6.02 dB per additional bit of resolution
- Signal Reconstruction: Recovering the original continuous signal from discrete samples using an ideal reconstruction (sinc interpolation) or practical low-pass filter; the reconstructed signal is an accurate replica of the original only if the Nyquist criterion was satisfied during sampling
28.5 Learning Objectives
This section: Learning Objectives
- Apply Nyquist Theorem: Calculate minimum sampling rates for different signals
- Diagnose Aliasing: Explain why undersampling causes incorrect frequency representation and predict aliased frequencies
- Design Anti-Aliasing Filters: Specify hardware low-pass filter parameters to prevent high-frequency contamination before ADC
- Evaluate Sampling-Power Trade-offs: Select optimal sampling rates that satisfy Nyquist while minimizing energy consumption in battery-powered IoT devices
- Implement Oversampling: Use extra samples to improve effective resolution and reduce anti-aliasing filter complexity
Imagine trying to draw a smooth wave by only placing a dot every few seconds — if you place dots too infrequently, you get a distorted picture that looks nothing like the original wave. Sampling theory tells us exactly how often we need to measure a changing signal to capture it faithfully. The key rule is simple: sample at least twice as fast as the signal changes. This concept applies every time a sensor reads the physical world.
28.6 Prerequisites
This section: Prerequisites
Before diving into this chapter, you should be familiar with:
- ADC Fundamentals: Understanding how ADCs convert analog to digital
- Binary Fundamentals: Understanding of resolution and bit depth
- Basic Signal Concepts: Understanding of frequency (Hz) and waveforms
28.7 Why This Chapter Matters
This section: Why This Chapter Matters — Follow these connections in order: Sampling theory sounds mathematical, but it answers a brutally practical question: how often do I need to read a sensor so the data still represents reality.
Follow these connections in order: Sampling theory sounds mathematical, but it answers a brutally practical question: how often do I need to read a sensor so the data still represents reality. In real IoT systems, bad sampling choices create fake signals, missed events, wasted battery, and misleading analytics. The device may still produce numbers, but the numbers no longer describe the real world. This chapter gives students a way to choose sampling rates intentionally instead of guessing.
28.8 How To Use This Chapter
This section: How To Use This Chapter
- Start with the Nyquist rule and the aliasing examples. Those are the ideas you must keep.
- Read the tables with real signal types slowly and compare them to devices you already know: temperature sensors, microphones, ECG signals, accelerometers, and vibration monitors.
- When you finish a section, ask yourself what would happen in a real product if the sampling rate were cut in half.
- Start Simple
- In 60 Seconds
- Key Concepts
- For Beginners: Sampling Theory
- Prerequisites
- Why This Chapter Matters
- How To Use This Chapter
- Nyquist-Shannon Sampling Theorem
- Phoebe’s Field Notes: Why Aliases Fold Back
- Deep dive: Putting Numbers to It
- Practical Sampling Rate Examples
- Checkpoint: Rate Selection
- Understanding Aliasing
- Vibration Monitor Check
- Sampling Tradeoffs for Vibration
- Sampling Rate vs Power Consumption
- Sampling Rate vs Power
- Checkpoint: Aliasing and Power
- Anti-Aliasing Filters
- Anti-Aliasing Filter Strategies
- Knowledge Check: Anti-Aliasing Filter Strategies
- RC Anti-Aliasing Calculator
- ADC Sampling and Aliasing Demo
- Sampling Rate Design Calculator
- Nyquist Rate Calculator
- Checkpoint: Filters and Calculators
28.9 Nyquist-Shannon Sampling Theorem
This section: Nyquist-Shannon Sampling Theorem — Sampling means taking readings from a changing signal.
Sampling means taking readings from a changing signal. If the readings are too far apart, a fast real wave can look like a slow false one; that error is aliasing. Sampling rate is the number of readings each second. An input filter reduces fast parts that the chosen rate cannot represent. Check both before analysis begins.
The first design question is simple: what is the fastest part of the signal you must preserve. Nyquist turns that question into the minimum sampling rate.
To accurately digitize an analog signal, you must sample at least TWICE the highest frequency component.
For audio sampling human voice (max frequency Hz), Nyquist requires Hz minimum. Telephony uses 8 kHz (18% margin). For music ( kHz), CD audio samples at kHz = , providing a 10% guard band for the anti-aliasing filter’s roll-off. If you undersample a 1 kHz tone at 1.5 kHz (below Nyquist 2 kHz), it aliases to Hz — you hear the wrong pitch. Power cost: sampling at 10 kHz vs 1 kHz increases ADC energy significantly (ESP32: ~2mA base + ~0.001mA per sample/s).
Inspect Figure 28.1 at this point because its depiction of nyquist-Shannon sampling theorem summary supplies the physical context for the prose.
Figure 28.1 gives separate roles to Nyquist-Shannon Sampling Theorem, pn = period of the “fastest” sine wave, and fn = frequency of the “fastest” sine wave. Following those roles reveals nyquist-Shannon sampling theorem summary. That reading provides the evidence needed for the section’s next calculation, comparison, or field check.
For verification, record the fastest sine-wave period pn, derive fn = 1/pn, and compare the sampling interval with half that period.
The theorem has direct implications for how we choose sampling rates in practice. Bare Nyquist is the mathematical minimum, but real devices usually need extra margin for noise, timing uncertainty, and anti-aliasing filter roll-off.
Trace Figure 28.2 before continuing. It turns how sample rate changes the reconstructed signal from a verbal claim into labelled evidence.
Figure 28.2 gives separate roles to How Sample Rate Changes, Teal is the true signal, dots are the samples,, and 1. Undersampling. Following those roles reveals how sample rate changes the reconstructed signal. That reading provides the evidence needed for the section’s next calculation, comparison, or field check.
28.9.1 Why This Matters
Undersampling (too slow) causes aliasing - high frequencies appear as low frequencies!
Inspect Figure 28.3 before why this matters; its labelled elements make aliasing in a real sampling scenario concrete enough to test against the circuit narrative.
Anchor Figure 28.3 on True waveform: period = 20 ms, which corresponds to the stated Shaft speed = 3000 RPM. Under Signal Aliasing and Sampling, compare that real motion with the more slowly changing sample sequence. The mismatch shows how sparse observations can imply a false shaft speed or direction, connecting the sampling theorem to a concrete monitoring failure rather than an abstract waveform exercise.
28.10 Practical Sampling Rate Examples
This section: Practical Sampling Rate Examples — Compare the examples by moving from the stated input to the resulting electrical behavior: Maximum sample rate: ~9,600 Hz (9.6 kHz).
| Signal Type | Frequency | Minimum Sample Rate | Typical Rate | Reason |
|---|---|---|---|---|
| Temperature | ~0.01 Hz (slow) | 0.02 Hz | 1 Hz | Changes very slowly |
| Audio (human voice) | 300-3,400 Hz | 6,800 Hz | 8,000 Hz | Phone quality |
| Audio (music) | 20-20,000 Hz | 40,000 Hz | 44,100 Hz | CD quality |
| ECG (heart) | 0.5-100 Hz | 200 Hz | 250-500 Hz | Medical-grade clarity |
| Vibration | 10-1,000 Hz | 2,000 Hz | 5,000-10,000 Hz | Safety margin for harmonics |
| Accelerometer (gesture) | 50 Hz | 100 Hz | 200 Hz | Oversampling for noise |
Arduino Uno ADC:
Compare the examples by moving from the stated input to the resulting electrical behavior: Maximum sample rate: ~9,600 Hz (9.6 kHz). Practical rate: ~1-5 kHz for stable readings.
ESP32 ADC:
Compare the examples by moving from the stated input to the resulting electrical behavior: Maximum sample rate: ~83 kHz. Practical audio sampling: 16-48 kHz.
This section:
Checkpoint: Rate Selection
You now know:
- A 500 Hz signal needs at least 1000 Hz sampling.
- A 500 Hz vibration design usually uses 1250-2500 Hz instead of the bare minimum.
- A 3400 Hz voice band needs at least 6800 Hz; telephony uses 8 kHz.
28.11 Understanding Aliasing
This section: Understanding Aliasing — Meeting the minimum is only half the story.
Meeting the minimum is only half the story. Out-of-band frequencies can still make sampled data look clean but wrong.
28.12 Sampling Rate vs Power Consumption
This section: Sampling Rate vs Power Consumption — Once the signal is sampled honestly, every extra sample must justify its current, storage, and transmission cost.
Once the signal is sampled honestly, every extra sample must justify its current, storage, and transmission cost.
Option A: High-frequency sampling (1000 Hz): Captures fast transients below a practical bandwidth of 500 Hz after anti-alias guard band; assume ~5 mW continuous ADC-path power. At 32 bits per sample, 86.4 million samples/day require about 346 MB/day.
Option B: Low-frequency sampling (1 Hz): Adequate for slow environmental signals (temperature, humidity), power draw ~0.005mW with sleep between samples, generates 86,400 samples/day, requires 345 kB/day storage
Decision Factors: For battery-powered environmental sensors where signals change over minutes or hours, 1 Hz sampling can reduce sampling work while preserving relevant variation; battery-life gain depends on the full power budget. For vibration analysis, motor monitoring, or audio capture, 1000+ Hz is mandatory to avoid aliasing. A smart approach uses adaptive sampling: high rate during detected events, low rate during quiet periods.
Power vs Sampling Rate:
- ESP32 ADC power: ~2mA base + 0.001mA per sample/sec
- @ 100 Hz: 2.1mA
- @ 1 kHz: 3mA
- @ 10 kHz: 12mA
- For battery-powered devices: Sample only as fast as needed!
Checkpoint: Aliasing and Power
You now know:
- Sampling 500 Hz at 500 Hz fails: the Nyquist frequency is only 250 Hz, and the defect can fold to 0 Hz.
- A 1000 Hz design has no margin for an 800 Hz harmonic, which can appear as 200 Hz.
- Cost scales quickly: 1 Hz creates 86,400 samples/day and about 345 kB/day; 1000 Hz creates 86.4 million samples/day and about 345 MB/day.
28.13 Anti-Aliasing Filters
This section: Anti-Aliasing Filters — Why?
Problem: Real-world signals have infinite frequency components (noise, harmonics). How to ensure f_max before ADC?
Solution: Hardware Anti-Aliasing Filter
-
Passive RC low-pass filter:
- R = 10k ohm, C = 1uF → f_cutoff = 15.9 Hz
- Attenuates 50 Hz by only about 10.4 dB before 100 Hz sampling; stronger rejection is needed if a 50 Hz component must not alias
- Cost: $0.15 (resistor + capacitor)
-
Active Sallen-Key filter:
- Op-amp based, sharp roll-off
- 4th-order Butterworth: -80 dB/decade above cutoff
- Cost: $1-2 (op-amp + passives)
Best Practice:
- Specify the required stopband attenuation from the out-of-band signal level and allowed error; f_cutoff = f_sample / 4 is only a starting point
- Sample at 2.5-5x desired f_max
- Apply digital low-pass filter in software for extra margin
Example: 500 Hz vibration monitoring
- Hardware filter: f_cutoff = 600 Hz (Sallen-Key 4th-order)
- ADC sampling: 2500 Hz (5x oversampling)
- Digital filter: 500 Hz FIR low-pass
- Result: Check the 4th-order filter’s attenuation against the measured out-of-band vibration spectrum and the allowed in-band error; the stated rates alone do not quantify aliasing risk.
Anti-Aliasing Filter Design Rule:
Before the ADC, use a low-pass filter to attenuate frequencies above the Nyquist frequency (). In practice, set the filter cutoff below Nyquist to allow for the filter’s gradual roll-off:
Setting creates transition bandwidth, but filter order and out-of-band signal levels still determine whether attenuation at and above is adequate.
Why? If high-frequency noise (>f_sample/2) reaches the ADC, it aliases to lower frequencies, corrupting data.
Example: 1 kHz accelerometer sampling without anti-aliasing filter
- Motor emits 1.2 kHz vibration harmonic
- Nyquist frequency: 1000 Hz / 2 = 500 Hz
- 1.2 kHz signal aliases to: |1200 Hz - 1000 Hz| = 200 Hz
- False reading: 200 Hz vibration appears in data (doesn’t exist!)
- Solution: Add RC low-pass filter with f_c = 400 Hz before ADC
28.15 ADC Sampling and Aliasing Demo
This section: ADC Sampling and Aliasing Demo
28.16 Sampling Rate Design Calculator
This section: Sampling Rate Design Calculator
This section:
Checkpoint: Filters and Calculators
You now know:
- At 1 kHz sampling, a 1.2 kHz vibration harmonic can fold into a false 200 Hz reading.
- A 500 Hz vibration monitor can sample at 2500 Hz, use a 600 Hz hardware filter, and apply a 500 Hz digital filter.
- A first-order RC filter rolls off at -20 dB/decade; a 2nd-order Sallen-Key filter gives -40 dB/decade.
28.17 Continue to the Next Part
This section: Continue to the Next Part — Carry this evidence into Sampling Design: Product Scenarios, which begins with For Kids: Meet the Sensor Squad!.
Carry this evidence into Sampling Design: Product Scenarios, which begins with For Kids: Meet the Sensor Squad!.
Find help
3 reviewed answers.
Where should I start in a module?
Open the module page from the sidebar to see its chapters in order. Use the module map to return to a topic you need.
Modules and pathsReviewed
What can I try when a project does not work?
Check the symptom, then work through the diagnostic steps. Keep the error message and the smallest example that reproduces it.
When you are stuckReviewed
How do interactive examples work?
Use the interactive guide to check how examples and simulations work before changing your project.
Interactive examples guideReviewed
