TExcelTAD
Home › Signals, Systems & Digital Filters for Engineers › Modulation Fundamentals: AM, FM, Mixing and I/Q

Modulation Fundamentals: AM, FM, Mixing and I/Q

A 1 kHz1\ \text{kHz} tone cannot travel through an antenna of sensible size, and a dozen sensors cannot share one cable if they all occupy the same band. Modulation moves a message to a carrier frequency where it can be transmitted or separated, and demodulation brings it back. Every radio, every lock-in amplifier, every vibration analyser with an "envelope" mode and every software-defined receiver uses the same few ideas: multiplying signals shifts spectra, the envelope and phase of a signal can carry information, and a pair of quadrature mixers turns any band-pass signal into a complex baseband signal that a computer can process. This lesson covers those ideas with NumPy and SciPy. The full treatment of communication systems (noise, digital modulation, RF hardware) is the subject of the planned course Communications, RF Engineering & Antennas.

Mixing: multiplication shifts spectra

The product of two cosines is a sum of two cosines at the sum and difference frequencies:

cos⁡(2πf1t)cos⁡(2πf2t)=12cos⁡(2π(f1−f2)t)+12cos⁡(2π(f1+f2)t)\cos(2\pi f_1 t)\cos(2\pi f_2 t) = \tfrac{1}{2}\cos\big(2\pi (f_1 - f_2) t\big) + \tfrac{1}{2}\cos\big(2\pi (f_1 + f_2) t\big)

More generally, multiplying a message m(t)m(t) by cos⁡(2πfct)\cos(2\pi f_c t) copies its spectrum to ±fc\pm f_c (the modulation property of the Fourier transform). A mixer is therefore linear but time varying (System Properties): it creates frequencies that were not in its input, which no LTI system can do.

Amplitude modulation

AM (double sideband with carrier): x(t)=Ac[1+mcos⁡(2πfmt)]cos⁡(2πfct)x(t) = A_c[1 + m\cos(2\pi f_m t)]\cos(2\pi f_c t), with modulation index 0<m≤10 < m \le 1. Its spectrum has the carrier at fcf_c and two sidebands at fc±fmf_c \pm f_m, each of amplitude mAc/2mA_c/2; the bandwidth is 2fm2f_m (twice the message bandwidth). The envelope Ac[1+mcos⁡(2πfmt)]A_c[1 + m\cos(2\pi f_m t)] stays positive, so a simple diode-and-RC envelope detector recovers the message. The price is power: the carrier carries no information, and the sidebands get only m2/(2+m2)m^2/(2 + m^2) of the total, at most one third.

DSB-SC (suppressed carrier) drops the carrier: x(t)=m(t)cos⁡(2πfct)x(t) = m(t)\cos(2\pi f_c t). Recovering it needs coherent detection, multiplying again by a carrier of the right frequency and phase and low-pass filtering. SSB keeps only one sideband and halves the bandwidth.

Frequency modulation

FM: x(t)=Accos⁡(2πfct+2πkf∫m dt)x(t) = A_c\cos\big(2\pi f_c t + 2\pi k_f \int m\,dt\big). For a tone the instantaneous frequency swings by the peak deviation Δf\Delta f around fcf_c, and the modulation index is β=Δf/fm\beta = \Delta f/f_m. The spectrum has lines at fc+nfmf_c + n f_m for every integer nn, with amplitudes AcJn(β)A_c J_n(\beta) (Bessel functions of the first kind); the total power stays Ac2/2A_c^2/2 whatever the modulation. Carson's rule estimates the bandwidth holding about 98 %98\,\% of the power: B≈2(Δf+fm)B \approx 2(\Delta f + f_m). FM trades bandwidth for noise immunity, and a constant envelope lets transmitters use efficient saturated amplifiers.

I/Q: complex baseband

x(t) x x oscillator fc 2cos -2sin low-pass B/2 low-pass B/2 I(t) Q(t) I + jQ: envelope = |I + jQ| phase = atan2(Q, I) the products contain f - fc (kept) and f + fc (removed by the low-pass filters)

Any band-pass signal can be written as x(t)=I(t)cos⁡(2πfct)−Q(t)sin⁡(2πfct)=Re⁡{[I(t)+jQ(t)] ej2πfct}x(t) = I(t)\cos(2\pi f_c t) - Q(t)\sin(2\pi f_c t) = \operatorname{Re}\{[I(t) + jQ(t)]\,e^{j2\pi f_c t}\}. Mixing with 2cos⁡2\cos and −2sin⁡-2\sin and low-pass filtering recovers II and QQ. The complex signal I+jQI + jQ holds everything: its magnitude is the envelope (AM), its phase the phase modulation, the derivative of the phase the frequency (FM). This is how software-defined radios, lock-in amplifiers and modern vibration analysers work. In software, scipy.signal.hilbert builds the analytic signal x+jx^x + j\hat{x} directly, whose magnitude is the envelope.

Worked example: AM and FM test signals

Given: a carrier fc=10 kHzf_c = 10\ \text{kHz}, Ac=1 VA_c = 1\ \text{V}, a message tone fm=1 kHzf_m = 1\ \text{kHz}. (a) AM with m=0.5m = 0.5. (b) FM with Δf=2.5 kHz\Delta f = 2.5\ \text{kHz}.

Find: the spectral lines, bandwidth and sideband power of each.

Solve:

  • (a) Carrier 1 V1\ \text{V} at 10 kHz10\ \text{kHz}; sidebands 0.25 V0.25\ \text{V} at 9 and 11 kHz11\ \text{kHz}, i.e. 20log⁡10(0.25)=−12.0 dBc20\log_{10}(0.25) = -12.0\ \text{dBc}. Bandwidth 2 kHz2\ \text{kHz}. Power into 1 Ω1\ \Omega: carrier 0.5 W0.5\ \text{W}, sidebands 2×0.252/2=0.0625 W2 \times 0.25^2/2 = 0.0625\ \text{W}, efficiency 0.25/2.25=11.1 %0.25/2.25 = 11.1\,\%.
  • (b) β=2.5\beta = 2.5. Line amplitudes J0(2.5)=−0.048J_0(2.5) = -0.048 (the carrier almost vanishes), J1=0.497J_1 = 0.497, J2=0.446J_2 = 0.446, J3=0.217J_3 = 0.217, J4=0.074 VJ_4 = 0.074\ \text{V}. Carson: 2(2.5+1)=7 kHz2(2.5 + 1) = 7\ \text{kHz}, from 6.5 to 13.5 kHz13.5\ \text{kHz}, holding the lines n=−3…3n = -3 \ldots 3: J02+2(J12+J22+J32)=98.8 %J_0^2 + 2(J_1^2 + J_2^2 + J_3^2) = 98.8\,\% of the power.

Check: with FFTs of the sampled signals below.

python · try it yourself
import numpy as np
from scipy.signal import hilbert
from scipy.special import jv

fs, T = 100e3, 0.01                             # 10 ms = whole periods of 1 kHz and 10 kHz
t = np.arange(int(fs * T)) / fs
fc, fm = 10e3, 1e3

def lines(x, freqs):                            # amplitude of each line (window not needed: whole periods)
    X = np.fft.rfft(x) / len(x) * 2
    return [abs(X[int(round(f * T))]) for f in freqs]

am = (1 + 0.5 * np.cos(2 * np.pi * fm * t)) * np.cos(2 * np.pi * fc * t)
a9, a10, a11 = lines(am, [9e3, 10e3, 11e3])
print(f"AM lines: 9 kHz {a9:.3f} V, 10 kHz {a10:.3f} V, 11 kHz {a11:.3f} V -> sidebands {20 * np.log10(a9 / a10):.1f} dBc")
env = np.abs(hilbert(am))
print(f"envelope from the analytic signal: max {env.max():.3f}, min {env.min():.3f} -> m = {(env.max() - env.min()) / (env.max() + env.min()):.3f}")

beta = 2.5
fmod = np.cos(2 * np.pi * fc * t + beta * np.sin(2 * np.pi * fm * t))
amps = lines(fmod, [fc + n * fm for n in range(5)])
print("FM lines n = 0..4 (V):", np.round(amps, 4))
print("|J_n(2.5)|           :", np.round(np.abs(jv(np.arange(5), beta)), 4))
inside = sum(a**2 / 2 for a in lines(fmod, [fc + n * fm for n in range(-3, 4)]))
print(f"power within Carson's band: {100 * inside / 0.5:.1f} %")
AM lines: 9 kHz 0.250 V, 10 kHz 1.000 V, 11 kHz 0.250 V -> sidebands -12.0 dBc
envelope from the analytic signal: max 1.500, min 0.500 -> m = 0.500
FM lines n = 0..4 (V): [0.0484 0.4971 0.4461 0.2166 0.0738]
|J_n(2.5)|           : [0.0484 0.4971 0.4461 0.2166 0.0738]
power within Carson's band: 98.8 %

Recovering FM with an I/Q receiver

The receiver mixes down with a local oscillator, filters, and differentiates the phase of I+jQI + jQ:

python · try it yourself
import numpy as np
from scipy.signal import butter, sosfiltfilt

fs = 100e3
t = np.arange(int(0.02 * fs)) / fs
fc, fm, dev = 10e3, 1e3, 2.5e3
msg = np.cos(2 * np.pi * fm * t)
x = np.cos(2 * np.pi * fc * t + (dev / fm) * np.sin(2 * np.pi * fm * t))

sos = butter(6, 8e3, fs=fs, output="sos")       # keeps |f - fc| < 8 kHz, removes the 2 fc products
I = sosfiltfilt(sos, 2 * x * np.cos(2 * np.pi * fc * t))
Q = sosfiltfilt(sos, -2 * x * np.sin(2 * np.pi * fc * t))
phase = np.unwrap(np.angle(I + 1j * Q))
f_inst = np.gradient(phase, t) / (2 * np.pi)    # instantaneous frequency offset, Hz
k = slice(200, -200)                            # skip the filter edges
err = f_inst[k] - dev * msg[k]
print(f"recovered peak deviation {f_inst[k].max():.0f} Hz (true {dev:.0f} Hz)")
print(f"rms error of the demodulated message: {np.sqrt(np.mean(err**2)):.1f} Hz ({100 * np.sqrt(np.mean(err**2)) / dev:.2f} % of the deviation)")
print(f"envelope |I + jQ|: {np.abs(I + 1j * Q)[k].min():.3f} to {np.abs(I + 1j * Q)[k].max():.3f} (constant for FM)")
recovered peak deviation 2497 Hz (true 2500 Hz)
rms error of the demodulated message: 1.5 Hz (0.06 % of the deviation)
envelope |I + jQ|: 1.000 to 1.000 (constant for FM)

The low-pass must pass the whole FM signal, not just the message: with its corner at 5 kHz5\ \text{kHz} instead of 8 kHz8\ \text{kHz} it trims the sidebands beyond ±4 kHz\pm 4\ \text{kHz}, the envelope ripples by a few percent and the recovered deviation falls by about 3 %3\,\% (try it).

Guided lab: AM and FM on a scope's FFT

Hand calculation. As in the worked example: AM sidebands at ±1 kHz\pm 1\ \text{kHz} and −12.0 dBc-12.0\ \text{dBc} for m=0.5m = 0.5; FM with Δf=2.5 kHz\Delta f = 2.5\ \text{kHz} shows a nearly absent carrier and strong first and second sidebands.

Simulation. Change beta to 2.4052.405 (the first zero of J0J_0): the carrier line disappears. This is the classic way to calibrate an FM deviation meter.

What you would measure. Set a function generator to a 10 kHz10\ \text{kHz}, 1 V1\ \text{V} sine with internal AM (1 kHz1\ \text{kHz}, 50 %50\,\%) and view it on a scope's FFT with a flat-top window (Scope FFT). Expect sidebands 12.0±0.5 dB12.0 \pm 0.5\ \text{dB} below the carrier (the generator's modulation depth accuracy and the FFT's amplitude flatness). Switch to FM with 2.5 kHz2.5\ \text{kHz} deviation: the carrier should drop to about −26 dBc-26\ \text{dBc} relative to an unmodulated carrier (20log⁡100.04820\log_{10}0.048), easily disturbed by a small deviation error, and the first two sidebands should sit near −6-6 to −7 dB-7\ \text{dB}.

Hazards and safe setup. Cable-connected low-level signals only. Do not connect an antenna or radiate: transmitting on radio frequencies needs a licence or a permitted band and power, and is outside this lab.

Pitfalls

  • Treating a mixer as LTI and expecting no new frequencies.
  • Over-modulating AM (m>1m > 1): the envelope crosses zero and an envelope detector distorts.
  • Taking FM bandwidth as 2fm2f_m, the AM rule: for β>1\beta > 1 it is set by the deviation.
  • Forgetting the image: a single real mixer cannot tell fc+Δf_c + \Delta from fc−Δf_c - \Delta; I/Q mixing can.

Practice

  1. AM with m=0.8m = 0.8, Ac=2 VA_c = 2\ \text{V}: sideband amplitude and the fraction of power in the sidebands?
  2. FM broadcast uses Δf=75 kHz\Delta f = 75\ \text{kHz} and audio up to 15 kHz15\ \text{kHz}. What bandwidth does Carson's rule give?
  3. Mixing a 10.7 MHz10.7\ \text{MHz} signal with a 10.0 MHz10.0\ \text{MHz} oscillator gives which frequencies?
Answer
  1. mAc/2=0.8 VmA_c/2 = 0.8\ \text{V} each; m2/(2+m2)=0.64/2.64=24.2 %m^2/(2 + m^2) = 0.64/2.64 = 24.2\,\%.
  2. 2(75+15)=180 kHz2(75 + 15) = 180\ \text{kHz}.
  3. 0.7 MHz0.7\ \text{MHz} and 20.7 MHz20.7\ \text{MHz}.

Test yourself

Multiplying a 1 kHz tone by a 10 kHz carrier produces

  1. only 10 kHz
  2. 9 kHz and 11 kHz
  3. 1 kHz and 10 kHz
  4. 11 kHz only

With AM at m=1m = 1, the fraction of the transmitted power in the sidebands is

  1. 100 %
  2. 50 %
  3. 33 %
  4. 11 %

Carson's rule for FM with deviation Δf\Delta f and message bandwidth fmf_m is

  1. 2fm2f_m
  2. 2Δf2\Delta f
  3. 2(Δf+fm)2(\Delta f + f_m)
  4. Δf fm\Delta f\,f_m

In complex baseband I+jQI + jQ, the envelope of the signal is

  1. II
  2. QQ
  3. I2+Q2\sqrt{I^2 + Q^2}
  4. atan2⁡(Q,I)\operatorname{atan2}(Q, I)