Skip to content
Tactiverge

School/△ Builder/Week 22

Sampling: how often is often enough?

In films, a fast car's wheels sometimes seem to spin backwards. What has that got to do with a temperature sensor?

About 30 min · 3 goals · Checked by automated tests

1.Why should I care?

A digital system only knows the world at the moments it takes samples. Sample too slowly and it does not just miss detail: it sees things that are not there. Choosing a sample rate is one of the first decisions in any sensing project.

  • ◇ Convert between sample rate and sample period, and count samples in a recording.
  • ◇ Calculate samples per cycle and explain why fewer than two per cycle cannot represent a wave.
  • ◇ Describe aliasing with an everyday example and say how engineers avoid it.

2.Watch

→ Notice that the camera takes separate pictures (samples). Ask: how far does the wheel turn between two frames?

The wagon-wheel effect: a camera samples too slowly for a fast wheel, so the frames show a slow, false motion. Aliasing you have already seen.

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 signal goes up and down 9 times a second. You sample it 10 times a second. What wave do your samples seem to show?

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

4.Discover

Set the signal to 9 Hz and the sample rate to 10 Hz. Untick the real signal: what do the dots show? Now raise the sample rate until the readout stops warning you. How many samples per cycle did that take?

Loading the interactive…

Can't use the interactive? Read a description instead

In the signal lab, a 9 Hz wave sampled 10 times a second gives dots that trace a slow 1 Hz wave: the readout warns that there are fewer than 2 samples per cycle. Raising the sample rate above 18 Hz removes the warning, and around 40–60 Hz the dots clearly follow the real wave's shape.

5.Checkpoint: guided practice

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

Practice 1 · a fresh version every time

You sample a 1 Hz signal at 10 Hz. How many samples land in each cycle of the signal?

samples

6.Understand

Rate and period

The sample rate fs is samples per second (Hz); the sample period is the time between samples, 1 ÷ fs. A greenhouse logger sampling at 0.1 Hz takes one reading every 10 s; an audio recorder at 44,100 Hz takes one every 22.7 µs. Samples recorded = rate × duration: 50 Hz for 60 s gives 3,000 samples.

Samples per cycle

Divide the sample rate by the signal frequency to get samples per cycle. Ten or more show the wave's shape clearly. Between two and about five catch the frequency but the shape looks rough. Fewer than two per cycle cannot represent the wave at all. So a signal with frequency f needs a sample rate of more than 2f: half the sample rate is the highest frequency you can capture.

Aliasing and how to avoid it

When a signal is too fast for the sample rate, its samples line up into a slower, false wave: an alias. A 9 Hz wiggle sampled at 10 Hz pretends to be 1 Hz, and no maths afterwards can tell the difference. Engineers prevent it by sampling fast enough for every frequency present and by filtering out faster wiggles (like mains hum) before the ADC.

Explain it another way

Imagine photographing a spinning fan with a flash once a second. If it spins almost exactly once between flashes, each photo shows it nearly still, creeping slowly: your photos tell a lie about its speed.

Worked example 1

You want to measure 50 Hz mains hum on a sensor line. What is the slowest sample rate that could possibly capture it, and what would you actually choose?

More than 2 × 50 = 100 Hz is the bare minimum. To see the shape you might choose 1,000 Hz: 20 samples per cycle.

Worked example 2

A logger samples at 250 Hz for 30 s. How many samples?

250 × 30 = 7,500 samples.

Common mix-ups

  • Sampling too slowly just makes the wave a bit rough.
    ✓ Below two samples per cycle the samples show a different, false frequency. That is worse than roughness: it is wrong information.
  • You can fix aliasing later with clever software.
    ✓ Once aliased, the false wave looks exactly like a real slow one. Prevent it with a fast enough rate and a filter before sampling.

7.Practice on your own

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

Practice 2 · a fresh version every time

A data logger samples at 1000 Hz for 2 s. How many samples does it record?

samples

Practice 3

A sensor is sampled at 200 Hz. How long is the gap between samples, in milliseconds?

ms

Practice 4

A 48 Hz vibration is sampled at 50 Hz. What frequency do the samples seem to show, in Hz?

Hz

Practice 5

A heart-rate signal contains rhythms up to 3 Hz. Which sample rate is the smallest that could work?

8.Apply it

Pick sample rates for three sensors in the greenhouse: air temperature (changes over minutes), a fan's speed sensor (pulses up to 40 times a second) and a microphone listening for a failing pump bearing (sounds up to 5 kHz). Justify each with the 'more than twice' rule and a margin.

9.Reflect

Concepts: Signals: amplitude, frequency and period · Sampling rate and aliasing