[0]128[1]199[2]228[3]199[4]128[5]57[6]28[7]5712864321684210101010101010101LPF1v = codes * 0.012held = np.repeat(v, 16)3X = np.fft.rfft(held) / 644abs(X[[1, 7, 9]]).round(2)128 × 10 mV = 1.28 V128
00.511.52012t (ms)volts (V)OUTPUT VOLTAGElate by Ts/2 = 62.5 µsfilter delay 123 µspulse of sample 204812162000.51frequency (kHz)amplitude (V) · gainSPECTRUM (TONES)filter gainstaircaseafter filter7 kHz image = 1/7fc = 3.5 kHz7 kHz gain 1/167 kHz: 0.139 → 0.0087 Vnumpy: 0.98 · 0.14 · 0.11 V
Coloured parts: what the current step is about; everything else rests in whiteBlocks: memory cells, the DAC with its 8 bit lamps, a low-pass filter chip, a speaker and a Python code cardPlots: the output voltage over time and its spectrum (which tones it holds)The code token and the speaker cone move in slow motion; the pill shows code × 10 mV right now8 codes per period of a 1000 Hz tone at fs = 8000 per second: the DAC holds code × 10 mV for 125 µs, making a staircase with images at k·fs ± 1 kHz, and a 4th-order Butterworth low-pass filter (cutoff 3.5 kHz) smooths it.

Codes to voltages

  1. Memory holds a 1 kHz tone as numbers: 8 samples per wave, one every 125 µs (fs = 8000 per second). A DAC, a digital-to-analog converter, turns numbers like these back into a voltage.

Why the steps matter

Smoothing it out

Check and recap

The working

# step 1/10 · codes

fs = 8000 samples per second
Ts = 1 / fs = 125 µs

one period of a 1000 Hz tone = 8 samples
code[n] = round(128 + 100·sin(2π·n/8))

 n        0   1   2   3   4   5   6   7
 code   128 199 228 199 128  57  28  57

8-bit codes: 0 .. 255, middle = 128
how the codes were made: see "Inside an ADC"

The DAC is an example: 8 bits, steps of 10 mV, fed with 8 codes per period of a 1000 Hz tone at fs = 8000 per second. The filter is an example 4th-order Butterworth low-pass with cutoff 3500 Hz. Every value and curve in the figure is computed from this model. The motion is slowed down a great deal: the real DAC takes a new code every 125 µs. The filter output y(t) is the steady state (the tone has been playing for a while); it is the sum of the staircase's tones, each scaled and delayed by the filter.