---
title: The spectrum
heading: The same signal, seen as a list of frequencies
eyebrow: A10 · Lesson 7 · The spectrum
xp: 40
---

::: hook
A scope shows a signal as voltage against time. A spectrum analyzer shows the same signal as amplitude against frequency: one vertical line per sinusoid it contains. Some questions are hard in one view and obvious in the other. Is this amplifier adding distortion? Will this clock signal interfere with the radio next to it? How much bandwidth does this pulse need? Engineers switch views constantly.

::: play
- The signal is a pulse train at 1 kHz: high for a fraction $D$ of each period. The top panel is time and the bottom is frequency.
- Make the pulses narrower. What happens to the spacing between the lines? To the shape of their tops?
- Where is the first frequency with no line at all? Compare it with $1/(\text{pulse width})$.
:::
:::

```sim plot
view: spectrum
x: t = 0..10m s
y: v = -0.5..1.5 V
samples: 1024
freq: f = 0..20k Hz
slider: D = 0.05..0.5 step 0.05 = 0.25
plot: step(cos(2*pi*1000*t) - cos(pi*D)) | label: pulse train
marker: f = 1000/D | label: 1/width
readout: pulse width = D ms
```

::: predict
## A 1 kHz pulse train has pulses 0.2 ms wide. Where is the first null in its spectrum, the first frequency with nothing in it?

- [ ] 1 kHz
- [ ] 2 kHz
- [x] 5 kHz
- [ ] 200 Hz

::: reveal
5 kHz, which is one over the pulse width. The lines are always 1 kHz apart, set by the period, but their heights follow an envelope shaped like $\sin(\pi f\tau)/(\pi f\tau)$, which first reaches zero at $f = 1/\tau$. Narrower pulses push that null higher: short pulses need wide bandwidth. That's the time-bandwidth tradeoff of lesson 13, seen early.
:::
:::

::: nameit
## Reading a spectrum

**Line spectra.** A periodic signal with period $T$ contains only the frequencies $0, f_0, 2f_0, 3f_0, \ldots$ with $f_0 = 1/T$, so its spectrum is a row of lines spaced $f_0$ apart. The **amplitude spectrum** plots $A_n$ at each $nf_0$; the **phase spectrum** plots $\varphi_n$. Most of the time engineers look only at the amplitudes.

**One-sided and two-sided.** The complex form puts $c_n = A_n/2$ at $+nf_0$ and its conjugate at $-nf_0$. A two-sided spectrum is symmetric, with half-height lines on both sides of zero. Instruments show the one-sided version, with only positive frequencies.

**The envelope of a pulse train.** For pulses of height $A$ and width $\tau$ repeating every $T$, the line heights follow

$$A_n = \frac{2A\tau}{T}\left|\frac{\sin(\pi nf_0\tau)}{\pi nf_0\tau}\right|$$

The function $\sin(\pi x)/(\pi x)$ is called $\text{sinc}(x)$. It's 1 at zero and first reaches zero at $x = 1$, so the first null is at $f = 1/\tau$. The period sets the line spacing; the pulse width sets the envelope.

**Decibels on spectra.** Harmonics are often tiny compared with the fundamental, so spectra are drawn in dB. A harmonic's level relative to the fundamental is quoted in **dBc** (dB relative to the carrier): $20\log_{10}(A_n/A_1)$. A square wave's 3rd harmonic is at $20\log_{10}(1/3) = -9.5$ dBc.

**Distortion.** A perfect amplifier fed a pure sine puts out a pure sine. A real one adds harmonics. **Total harmonic distortion** compares them with the fundamental:

$$\text{THD} = \frac{\sqrt{A_2^2 + A_3^2 + A_4^2 + \cdots}}{A_1}$$

Good audio amplifiers manage well under 0.1%.
:::

::: example
## Pulses of 5 V, 0.1 ms wide, repeat every 1 ms. Describe the spectrum.

::: solution
1. **The line spacing.** The pulses repeat every 1 ms, so there are lines every $f_0 = 1$ kHz.
2. **The DC level.**
   $$\begin{aligned} \frac{A\tau}{T} &= 5\ \text{V} \times \frac{0.1}{1} \\ &= 0.5\ \text{V} \end{aligned}$$
3. **The fundamental.**
   $$\begin{aligned} A_1 &= \frac{2A\tau}{T}\,\text{sinc}(0.1) \\ &= 1 \times 0.984 \\ &= 0.984\ \text{V} \end{aligned}$$
4. **The missing harmonics.** The envelope's first null is at $1/\tau = 10$ kHz, so the 10th harmonic is missing, as are the 20th and 30th.

**Answer:** lines every 1 kHz, with 0.5 V of DC, a 0.984 V fundamental, and no 10th, 20th or 30th harmonic.
:::
:::

::: example
## An amplifier puts out a 10 V fundamental with a 0.2 V 2nd harmonic and a 0.1 V 3rd. What is its THD, and the 2nd harmonic's level in dBc?

::: solution
1. **The THD.**
   $$\begin{aligned} \text{THD} &= \frac{\sqrt{0.2^2 + 0.1^2}}{10} \\ &= 2.24\% \end{aligned}$$
2. **The 2nd harmonic in dBc.**
   $$20\log_{10}\frac{0.2}{10} = -34.0\ \text{dBc}$$

**Answer:** the THD is 2.24%, and the 2nd harmonic is at $-34.0$ dBc.
:::
:::

::: example
## A pulse train has 25% duty. Which harmonics are missing?

::: solution
1. **The envelope.** The harmonic amplitudes follow $\left|\frac{\sin(\pi nd)}{\pi n}\right|$ with $d = 0.25$.
2. **Find its zeros.** That's zero whenever $nd$ is a whole number: $n = 4, 8, 12, \ldots$ Every fourth harmonic vanishes.
3. **In general.** A duty cycle of $1/m$ removes every $m$th harmonic. A 50% square wave, with $m = 2$, loses all the even ones.

**Answer:** every fourth harmonic is missing: the 4th, 8th, 12th and so on.
:::
:::

::: check
given: T = 1 | 2 | 4 | 5 | 10
answer: 1000/T
unit: Hz
tolerance: 0.5%

## A periodic signal repeats every {T} ms. How far apart are the lines in its spectrum?

::: right
Right. The lines sit at multiples of $f_0 = 1/T$ = {answer}.
:::

::: misses
- [T] The spacing is one over the period.
- [1/T] Convert milliseconds to seconds.
- [any] Not yet. Line spacing $= f_0 = 1/T$.
:::
:::

::: check
given: A1 = 1 | 2 | 5; r2 = 0.01 | 0.02 | 0.05; r3 = 0.005 | 0.03; let A2 = A1*r2; let A3 = A1*r3
answer: 100*sqrt(A2^2 + A3^2)/A1
unit: %
tolerance: 1%

## An amplifier's output has a {A1} V fundamental, a {A2} V 2nd harmonic and a {A3} V 3rd harmonic. What is its THD?

::: right
Right. $\sqrt{A_2^2 + A_3^2}/A_1$ = {answer}.
:::

::: misses
- [100*(A2 + A3)/A1] Add the harmonics' powers, then take the square root.
- [100*(A2^2 + A3^2)/A1^2] That's the power ratio. THD is quoted as an amplitude ratio: take the square root.
- [any] Not yet. $\text{THD} = \sqrt{A_2^2 + A_3^2}/A_1$.
:::
:::

::: check
given: w = 0.1 | 0.2 | 0.5 | 2 | 5
answer: 1/w
unit: MHz
tolerance: 0.5%

## A pulse train has pulses {w} µs wide. Where is the first null in its spectrum envelope?

::: right
Right. The first null is at $1/\tau$ = {answer}.
:::

::: misses
- [w] It's one over the width.
- [1/(2*w)] The sinc envelope first reaches zero at $f = 1/\tau$.
- [any] Not yet. The first null is at $f = 1/\tau$.
:::
:::

::: check
given: n = 3 | 5 | 7 | 9
answer: 20*log10(1/n)
unit: dB
tolerance: 0.5%

## How far below the fundamental is a square wave's {n}th harmonic, in dBc?

::: right
Right. Its amplitude is $1/n$ of the fundamental's: $20\log_{10}(1/\given{n})$ = {answer}.
:::

::: misses
- [10*log10(1/n)] Amplitude ratios use $20\log_{10}$.
- [20*log10(1/n^2)] A square wave's harmonics fall as $1/n$, not $1/n^2$.
- [any] Not yet. $20\log_{10}(A_n/A_1)$, with $A_n/A_1 = 1/n$.
:::
:::

::: check
kind: choice

## On a two-sided spectrum, a cosine of amplitude 4 V at 1 kHz appears as what?

- [ ] One line of height 4 at 1 kHz
- [x] Lines of height 2 at +1 kHz and −1 kHz
- [ ] Lines of height 4 at +1 kHz and −1 kHz
- [ ] One line of height 2 at 1 kHz

::: right
Right. $4\cos\omega t = 2e^{j\omega t} + 2e^{-j\omega t}$: two counter-rotating phasors of half the amplitude.
:::

::: misses
- [1] That's the one-sided picture.
- [3] Each side gets half the amplitude.
- [4] There's a matching line at the negative frequency.
:::
:::

::: check
kind: parts
given: m = 3 | 4 | 5; f = 1 | 10

## A pulse train at {f} kHz has duty $1/\given{m}$.

::: part
answer: m*f
unit: kHz
tolerance: 0.5%

### What is the lowest missing harmonic's frequency?

::: misses
- [f*m/2] Every $m$th harmonic is missing, starting at the $m$th.
- [any] Nulls fall where $nd$ is a whole number.
:::
:::
:::

::: check
kind: derivation
vars: V1 = 1..10, V2 = 0.01..1, V3 = 0.01..1

## An amplifier's output has harmonics of $V_1$, $V_2$ and $V_3$.

::: step
answer: sqrt(V2^2 + V3^2)/V1

### What is its THD?
:::

::: step
answer: 20*log(V2/V1)

### How far below the fundamental is the 2nd harmonic, in dB?
:::

::: right
Right. THD adds the harmonics in power; each one's level is its own ratio in dB.
:::
:::

::: explain
## Why does a periodic signal's spectrum contain only lines at multiples of $1/T$, and nothing in between?

::: model
A signal that repeats every T can only be built from sinusoids that also repeat every T, otherwise the sum wouldn't come back to the same shape after one period. A sinusoid repeats every T only if a whole number of its cycles fits into T, which means its frequency is a whole-number multiple of $1/T$. So those are the only frequencies that can appear.
:::
:::

::: practice

::: check
given: f0 = 50 | 60 | 400 | 1000
answer: f0
unit: Hz
tolerance: 0.5%

## A {f0} Hz periodic signal's spectrum lines are how far apart?

::: misses
- [2*f0] Every multiple of the fundamental can appear: the spacing is $f_0$.
- [any] The spacing is $f_0$.
:::
:::

::: check
given: r = 0.001 | 0.01 | 0.1
answer: 20*log10(r)
unit: dB
tolerance: 0.5%

## A harmonic is {r} times the fundamental's amplitude. What is its level in dBc?

::: misses
- [10*log10(r)] Amplitudes use $20\log_{10}$.
- [any] $20\log_{10}(A_n/A_1)$.
:::
:::

::: check
given: T = 1 | 2 | 5; D = 0.1 | 0.2 | 0.25
answer: 1/(D*T)
unit: kHz
tolerance: 0.5%

## A pulse train has period {T} ms and duty cycle {D}. Where is the first null of its envelope?

::: misses
- [1/T] That's the line spacing. The null depends on the pulse width.
- [D/T] The width is $D\cdot T$; the null is at one over it.
- [any] First null at $1/\tau$, with $\tau = DT$.
:::
:::
:::
