ENع
←Reading a spectrum
Lesson 24 · Fourier series and the Fourier transform

Reading a spectrum

14 min9 steps5 questionsIntermediate
About this lesson

A spectrum says which sine waves a signal is made of, how big each one is and where each one starts. Follow one voltage, x(t) = 0.5 + cos(2π·100·t) + 0.6·sin(2π·250·t): a filter bank pulls its three parts apart, level meters read their amplitudes, and the row of meters becomes the amplitude spectrum. Then read the phase spectrum and the two-sided spectrum with its negative frequencies, and compute the same lines in Python with numpy's FFT. Builds on the Circuits lessons "Sinusoids: amplitude, frequency, phase and RMS" and "Phasors and complex numbers".

You'll learn to

Tick what you feel confident about. These self-checks do not affect your lesson score.

Fig 24 · Interactive
01 / 09

A lumpy signal

This voltage x(t) repeats every 20 ms, but its shape is lumpy. Looking at it over time, it is hard to say what it is made of. A spectrum answers that: it lists the sine waves inside a signal.

x(t): a voltage, drawn against time t in ms

it repeats every T = 20 ms
(so its basic frequency is 1/T = 50 Hz)

time view:      value at each instant
frequency view: which sines, how big

the spectrum is the frequency view
Loading figure…
or ← →
Read the lesson step by step
  1. A lumpy signal

    This voltage x(t) repeats every 20 ms, but its shape is lumpy. Looking at it over time, it is hard to say what it is made of. A spectrum answers that: it lists the sine waves inside a signal.

    x(t): a voltage, drawn against time t in ms
    
    it repeats every T = 20 ms
    (so its basic frequency is 1/T = 50 Hz)
    
    time view:      value at each instant
    frequency view: which sines, how big
    
    the spectrum is the frequency view
  2. Three simple parts added

    x(t) is a constant 0.50 V, plus a 100 Hz cosine of 1.0 V, plus a 250 Hz sine of 0.6 V. At t = 1 ms, 0.50 + 0.81 + 0.60 = 1.91 V. Fourier showed periodic signals split this way.

    x(t) = 0.5 + 1.0·cos(2π·100·t) + 0.6·sin(2π·250·t)
    
    at t = 1 ms = 0.001 s:
      constant          0.50 V
      100 Hz cosine    0.81 V   cos(0.628 rad)
      250 Hz sine      0.60 V   sin(1.571 rad)
      sum x(1 ms)     1.91 V
    
    Fourier series: a periodic signal is a sum
    of sines at multiples of 1/T (here 50 Hz):
      100 Hz = 2 × 50,  250 Hz = 5 × 50
  3. Filters pull the sines apart

    Send x(t) to four filters at once. Each is tuned: it passes only its own frequency (0, 100, 250 or 400 Hz) and blocks the rest. A row of tuned filters, a filter bank, is one way to build a spectrum analyser.

    filter bank = an array of filters
                  that splits a signal into parts
    
      0 Hz filter    a lowpass: keeps the constant (average)
      100 Hz filter  passes the 100 Hz cosine
      250 Hz filter  passes the 250 Hz sine
      400 Hz filter  passes ... nothing is there
    
    ideal filters assumed (real ones have
    a width and let a little through)
  4. Each meter reads one amplitude

    Each column rises to the amplitude its filter lets through: 0.50 V at 0 Hz, 1.00 V at 100 Hz, 0.60 V at 250 Hz. Lined up by frequency, the columns are the amplitude spectrum, drawn flat in the plot.

    amplitude = the peak of each sine
    
      f (Hz)   amplitude (V)
         0     0.50
       100     1.00
       250     0.60
       400     0.00
    
    plot: one vertical line per sine
    height = amplitude, place = frequency
  5. Reading the axes

    Across: frequency in hertz. Up: amplitude in volts. Each line is one sine. No line at 400 Hz means no 400 Hz in x(t). The line at 0 Hz is the constant part, the signal's average.

    reading an amplitude spectrum
      where a line stands  ->  its frequency
      how tall it is      ->  its amplitude
      empty space         ->  nothing there
      line at 0 Hz        ->  the average (DC)
    
    the tallest line here: 100 Hz, 1.00 V
    lines at multiples of 50 Hz: x is periodic
  6. Phase: where each sine starts

    Amplitude is half the story. The 100 Hz cosine starts at its peak (phase 0°); the 250 Hz sine starts a quarter turn later (−90°). Shift only that phase and the shape changes (dashed), but the amplitude spectrum does not.

    x(t) = Σ A·cos(2π·f·t + φ)
    
      f (Hz)   A (V)   φ
         0     0.50    0°
       100     1.00    0°
       250     0.60   −90°   (sin θ = cos(θ − 90°))
    
    dashed: the 250 Hz part with φ = 0° instead
      same amplitudes, different shape
    
    amplitude + phase spectrum = the whole signal
  7. Negative frequencies

    Maths books draw two-sided spectra. A cosine is two phasors spinning opposite ways: cos θ = (e^jθ + e^−jθ)/2. So each line splits into two half-height lines at +f and −f: 0.50 V at ±100 Hz, 0.30 V at ±250 Hz.

    cos θ = (e^jθ + e^−jθ) / 2    (Euler)
    
    one-sided     two-sided
      0 Hz  0.50     0 Hz     0.50   (not split)
    100 Hz  1.00   ±100 Hz   0.50 each
    250 Hz  0.60   ±250 Hz   0.30 each
    
    the two halves are mirror images:
    X(−f) = conj X(f) for a real signal
    phasors: see Circuits, "Phasors and complex numbers"
  8. A spectrum in Python

    numpy's FFT computes the spectrum from samples. 200 samples at 1000 per second give lines every 5 Hz. Divide by 200, then double every line except 0 Hz (and the last one): line 20 sits at 100 Hz, and 2·|X[20]| = 1.00 V.

    import numpy as np
    t = np.arange(200) / 1000
    x = 0.5 + np.cos(2*np.pi*100*t)
    x += 0.6*np.sin(2*np.pi*250*t)
    X = np.fft.rfft(x) / 200
    f = np.fft.rfftfreq(200, 1/1000)
    
    >>> len(X)
    101
    >>> f[[0, 20, 50]]
    array([  0., 100., 250.])
    >>> amp = 2*np.abs(X); amp[0] /= 2
    >>> amp[[0, 20, 50]].round(2)
    array([0.5, 1. , 0.6])
    >>> np.degrees(np.angle(X[[0, 20, 50]])).round(1)
    array([  0.,   0., -90.])
    
    (Python 3 with numpy)
  9. Spectra you have seen

    Music apps, some guitar tuners and SDR radio apps show spectra. Tall line: a strong sine. Lines at whole multiples of one frequency: a repeating sound, like a note. Next lesson: what sampling does to a spectrum.

    read any spectrum the same way:
      across  frequency (Hz)
      up      amplitude (V, or dB)
    
    guitar note: lines at f0, 2f0, 3f0 ...
    mains hum:   a line at 50 or 60 Hz
    radio:       one hump per station
    
    time view and frequency view hold
    the same information

Quiz Unlocks after the last step.