Lesson plan

Digital signal processing lesson plan

Signals into numbers and back, on the Uno and the ESP32: sampling and aliasing, moving averages and FIR filters, IIR filters, the FFT, windows and leakage, pitch and beat detection, and a guitar tuner on a microphone and a TFT.

4 chapters, 7 lessons, about 7 hours, on the Arduino Uno R3. Every lesson runs in the browser, with nothing to install.

The unit

Objectives and materials

By the end, students can

  • What a fixed sample rate can see, and what it gets wrong.
  • Moving average, FIR and IIR, measured on real hum and steps.
  • The FFT, windows, and finding pitch and beat.
  • A guitar tuner from microphone to needle.

Materials for the whole unit

  • Arduino Uno R3
  • ESP32 DevKit V1
  • Function generator x 2
  • I2S microphone, INMP441
  • Oscilloscope
  • Resistor x 2
  • TFT display, 240x320

Every part is already on the simulator’s bench, so there is nothing to buy or hand out. The counts are the most any one lesson uses, if you build it on real breadboards too.

Chapter 1. About 1 h 5 min

Sampling

What a fixed sample rate can see, and what it gets wrong.

LessonTimeWhat students do
Sampling and NyquistAn Uno samples a signal generator at exactly 1000 Hz and finds the frequency in its samples: right up to 500 Hz, and a false, lower one above it. Aliasing, seen and measured.65 min
  1. How fast can an Uno sample?
  2. Samples on a clock
  3. Close to the limit
  4. An alias
  5. Folded all the way down
  6. Sample faster
  7. The anti-aliasing filter

Materials

  • Arduino Uno R3
  • Function generator
  • Oscilloscope

Check for understanding

Each student finishes "Sampling and Nyquist" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "The anti-aliasing filter".

Chapter 2. About 1 h 50 min

Filters

Moving average, FIR and IIR, measured on real hum and steps.

LessonTimeWhat students do
Moving average and FIRA slow sensor with mains hum on top, at 500 samples a second: a 10-point moving average that cancels 50 Hz exactly, a 15-tap FIR low-pass, and what happens at 60 Hz.55 min
  1. A sensor with hum
  2. The moving average
  3. An FIR low-pass
  4. American hum
  5. Designing an FIR
  6. Fit the hum
IIR filtersThe exponential moving average: one line, one variable, and a memory that never quite forgets. Its time constant measured on a square wave, and the trade between smoothing and lag.55 min
  1. A filter with a memory of one
  2. The time constant
  3. Up and down alike
  4. Infinite, but fading
  5. Smoother and slower
  6. Which filter when

Materials

  • Arduino Uno R3
  • Function generator x 2
  • Oscilloscope
  • Resistor x 2

Check for understanding

Each student finishes "IIR filters" on their own, without opening the hints. The simulator checks 6 of its 6 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Which filter when".

Chapter 3. About 3 h 5 min

The spectrum

The FFT, windows, and finding pitch and beat.

LessonTimeWhat students do
The FFT128 samples at 4000 Hz through arduinoFFT on an Uno: bins 31.25 Hz apart, the biggest one is the pitch, a square wave shows its odd harmonics, and a tone above Nyquist folds into the spectrum.65 min
  1. From time to frequency
  2. The biggest bin
  3. The harmonics of a square wave
  4. High in the spectrum
  5. Folded into the spectrum
  6. Finer bins
  7. What the FFT is for
WindowingA tone between two bins smears across the whole spectrum. The same capture through the FFT with no window and with a Hamming window, and the leakage eight bins away measured both ways.55 min
  1. One capture, two spectra
  2. Leakage
  3. A window
  4. A tone on a bin
  5. A family of windows
  6. Try Blackman
Pitch and beat detectionAutocorrelation finds the pitch of a note on A0 whatever its wave shape, and an onset detector on A1 finds a drum’s beat and its tempo, measuring pitch in the quiet between beats.65 min
  1. A note and a drum
  2. Autocorrelation
  3. Any shape
  4. Onsets
  5. Tempo
  6. Speed up the drum
  7. Octave errors

Materials

  • Arduino Uno R3
  • Function generator x 2
  • Oscilloscope

Check for understanding

Each student finishes "Pitch and beat detection" on their own, without opening the hints. The simulator checks 7 of its 7 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Octave errors".

Chapter 4. About 1 h 10 min

Boss project

A guitar tuner from microphone to needle.

LessonTimeWhat students do
Boss: a guitar tunerAn ESP32 listens through an INMP441, decimates, autocorrelates, names the nearest guitar string and shows the cents on an ILI9341 with a needle that turns green in tune.70 min
  1. Tuner on
  2. The screen
  3. The A string
  4. The low E
  5. Sharp
  6. Flat
  7. Tune to 432
  8. Make it yours

Materials

  • ESP32 DevKit V1
  • I2S microphone, INMP441
  • TFT display, 240x320

Check for understanding

Each student finishes "Boss: a guitar tuner" on their own, without opening the hints. The simulator checks 8 of its 8 steps as they go.

Then ask each one to explain, in a sentence or two, the last thing it asked of them: "Make it yours".

Your class

Teach this unit as a class

Start a class from this course and its 7 lessons are assigned in one go, in order. Students join with a six-character code or printed login cards, and each one’s work comes back to you.

The class tools are free for 30 days for one class of up to 20 students, with no card. The lessons themselves are free either way.