EE-410L Communication Systems Lab · Lab 3 · read before the labAll labsGo to the lab →

Every signal is a sum of sines. A filter decides which ones stay.

Ten minutes of reading. Move the sliders, then the code of the lab will read like plain sentences.

01

The Fourier transform

TransformX(f) = ∫ x(t) e−j2πft dttime domain to frequency domain
Inversex(t) = ∫ X(f) ej2πft dfback to time
Pulse of width TX(f) = T sinc(T f)sinc(u) = sin(πu)/(πu)

A pulse of height 1 from −T/2 to T/2 has a sinc shaped spectrum. Its value at f = 0 is the area of the pulse, T, and its zeros fall at every multiple of 1/T. Time and frequency trade against each other: a shorter pulse has a wider spectrum. That is why fast data needs a wide channel.

Why the phase jumps. The pulse is centred on t = 0, so X(f) is real. Where X is negative its angle is π, where it is positive 0. The phase plot of the lab is a set of steps, not a smooth curve.
02

Output of a linear system

Frequency domainY(f) = H(f) · X(f)one multiplication per frequency
RC low pass filterH(f) = 1 / (1 + j2πfRC)a resistor then a capacitor
Cut offfc = 1 / (2πRC)|H| = 0.707 there

A linear time invariant system obeys superposition, so it treats every frequency on its own: it scales it by |H(f)| and shifts its phase by the angle of H(f). Multiplying the spectra gives Y(f); the inverse transform gives the output y(t). In the lab the inverse transform is done numerically by trapz, one value of t at a time. The same result in time is the convolution y(t) = x(t) * h(t).

03

Butterworth filters

Magnitude|H(f)|² = 1 / [1 + (f/fc)2n]n is the order
At the cut off|H(fc)| = 0.7071−3 dB for every order
Beyond the cut off−20n dB per decadea higher order falls faster

The Butterworth response is maximally flat: no ripple in the passband, a smooth fall after it. butter(n, Wn, 's')designs the analog filter and returns the coefficients b and a of H(s) = B(s)/A(s); Wn is the cut off in rad/s, so 300 Hz is 2*pi*300. freqs(b, a, w) gives H at the frequencies w (rad/s). Add 'high' for a high pass filter.

Analog or digital. Without 's' butter designs a digital filter, and Wn is a number between 0 and 1, where 1 is half the sampling rate. Sections 3.5 and 3.6 of the manual use digital filters; 3.4 and the lab tasks use analog ones.
04

Filtering in time

tf(b, a) turns the coefficients into a transfer function, and lsim(H, x, t) runs the input x through it. With 100 Hz plus 500 Hz at the input and a cut off of 300 Hz, the output is the 100 Hz tone alone, once the start is over.

The first few milliseconds are the transient: the filter starts from rest and needs time to settle. After that comes the steady state, a sine at the input frequency, scaled by |H| and delayed by the filter.

Fast enough samples. lsim works on samples, so t must be fine compared with the highest frequency: 0.2 ms is 10 samples per period of 500 Hz. Too few samples and the output is wrong, not only rough.
05

Group delay and phase delay

Phase delayτp = −θ(ω) / ωdelay of one sine
Group delayτg = −dθ / dωdelay of the envelope
No distortionτg constantevery frequency arrives together

θ(ω) is the phase of H. A sine is delayed by the phase delay. A group of nearby frequencies, such as the envelope of a modulated signal, is delayed by the group delay. When the group delay is not constant, frequencies arrive at different times and a pulse spreads out. A Butterworth filter of order 2 or more has a delay peak a little below its cut off, and a higher order makes it taller (order 1 has no peak: its delay only falls). In MATLAB grpdelay plots the group delay of a digital filter in samples, and fvtool can overlay the phase delay.

06

Filters in Simulink

Lab task 2 builds the same low pass filter in Simulink. The Analog Filter Design block (DSP System Toolbox) asks for the design method (Butterworth), the type (Lowpass), the order and the passband edge frequency in rad/s: 1 kHz is 2*pi*1000.

The Filter Designer app (fdatool or filterDesigner) can design a filter and export it to a Simulink block as well. Two Sine Wave blocks and an Add block make the test signal; a Scope with two inputs shows the input and the output on one screen.

Stop time. A 500 Hz wave has a period of 2 ms, so a stop time of 0.01 s shows five cycles. With the default of 10 s the Scope is a solid band.
07

In the virtual lab

Scripts (.m)
Open the file→Move the sliders→Run→Read the figure→Add to report
the sliders are the boxed numbers in the code; Copy code gives the code with your values for real MATLAB
Model (.slx)
Open the model→Click the filter block→Type the parameters→OK→Run→Read the Scope
parameters are typed as in Simulink (2*pi*1000); the Scope shows the last run until you press Run again

In guided mode each step ticks itself when it is really done: the right file open, the right values set, the script or the simulation run, the value read and typed. Free mode leaves you alone with every file. The report keeps each figure with the values that made it.

08

What you should see

FileSettingsResult
ft_pulseT = 4sinc with peak 4 at f = 0, zeros every 0.25 Hz
rc_spectrum, rc_outputR = 1.5 MΩ, C = 1 µFcut off 0.106 Hz; the output pulse is heavily rounded
rc_outputR = 150 kΩcut off ten times higher; the output is close to the pulse
butter_freqsn = 5, 10, 20, fc = 300 Hzall three pass 0.7071 at 300 Hz; order 20 falls almost straight down
butter_lsimn = 20, 100 Hz + 500 Hza transient, then the 100 Hz tone alone
grpdelay_butter, fvtool_delaydigital Butterworth, n = 6 and 10both delays equal at low frequency; group delay peaks near the cut off
task2_lpf.slx500 Hz + 3 kHz, edge 2*pi*1000the output is the 500 Hz sine
09

Check yourself

Q1What is a linear communication system?

A system that obeys superposition: the response to a sum of inputs is the sum of the responses, and scaling the input scales the output. If it is also time invariant (LTI) it is fully described by its impulse response h(t) or its frequency response H(f).

Q2How is the output of a linear communication system analyzed?

In the frequency domain the output spectrum is Y(f) = H(f)X(f), and the inverse Fourier transform of Y(f) gives y(t). In the time domain the same output is the convolution y(t) = x(t) * h(t).

Q3Write down the command for simulating a low pass Butterworth filter.

Analog: [b,a] = butter(n, 2*pi*fc, 's'); then H = freqs(b,a,w) for the response and y = lsim(tf(b,a), x, t) for the output. Digital: [b,a] = butter(n, Wn) with Wn between 0 and 1, then filter(b,a,x).

Q4Write down the command for simulating a high pass Butterworth filter.

Analog: [b,a] = butter(n, 2*pi*fc, 'high', 's'). Digital: [b,a] = butter(n, Wn, 'high'). The response and output are found with freqs and lsim (or freqz and filter) as for the low pass filter.

Q5Explain the magnitude response of a low pass Butterworth filter.

|H(f)| = 1/√(1 + (f/fc)^(2n)). It is 1 at f = 0, maximally flat in the passband with no ripple, 0.7071 (−3 dB) at the cut off for every order, and falls at 20n dB per decade beyond it. A higher order gives a sharper edge.

Q6Explain the frequency response of a low pass Butterworth filter.

The frequency response H(f) has a magnitude and a phase. The magnitude is as above. The phase falls from 0 towards −nπ/2 rad as f grows and is −nπ/4 at the cut off; it is nearly linear well inside the passband, so the group delay is flat there and peaks near the cut off.

Q7Define group delay.

τg(ω) = −dθ(ω)/dω, the negative slope of the phase response. It is the delay of the envelope of a narrow band of frequencies around ω. A constant group delay means no phase distortion.

Q8Define phase delay.

τp(ω) = −θ(ω)/ω, the delay of a single sine of frequency ω passing through the filter. For a linear phase filter the phase delay and the group delay are equal.

I am ready, go to the lab →