Filtering in Continuous and Discrete Time

Filtering in
Continuous and
Discrete Time
•
•
•
•
M.H. Perrott © 2007
Lowpass, highpass, bandpass filtering
Filter response to cosine wave inputs
Discrete-Time Fourier Transform
Filtering based on difference equations
Copyright © 2007 by M.H. Perrott
All rights reserved.
Filtering in Continuous and Discrete Time, Slide 1
Motivation for Filtering
RF
Transmission
RF
Reception
Voice
Voice
RF
Transmitter
Interferer
Y(f)
X(f)
0
Voiceband
frequencies
RF
Receiver
f
RF transmission
frequencies
f
0
Voiceband
frequencies
RF reception
frequencies
• Filtering is used to remove undesired signals
outside of the frequency band of interest
– Enables selection of a specific radio, TV, WLAN, cell
phone, cable TV channel …
– Undesired channels are often called interferers
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 2
Lowpass Filter
z(t)
Lowpass
Filter
w(t)
r(t)
H(f)
y(t) = 2cos(2πfot)
H(f)
W(f)
2A
-2fo
1
A
A
-fo
0
fo
2fo
f
-2fo
-fo
0
fo
2fo
fo
2fo
f
R(f)
• Only low frequency
(i.e. baseband)
portion remains
M.H. Perrott © 2007
2A
-2fo
-fo
0
f
Filtering in Continuous and Discrete Time, Slide 3
Highpass Filter
z(t)
Highpass
Filter
w(t)
r(t)
H(f)
y(t) = 2cos(2πfot)
H(f)
W(f)
2A
-2fo
1
A
A
-fo
0
fo
2fo
f
-2fo
-fo
1
0
fo
2fo
f
R(f)
• Only high frequency
(i.e. RF) portion
remains
M.H. Perrott © 2007
A
A
-2fo
-fo
0
fo
2fo
f
Filtering in Continuous and Discrete Time, Slide 4
Bandpass Filter
z(t)
Bandpass
Filter
w(t)
r(t)
H(f)
y(t) = 2cos(2πfot)
H(f)
W(f)
2A
-2fo
1
A
A
-fo
0
fo
2fo
f
-2fo
1
-fo
0
fo
2fo
f
R(f)
• Only high frequency
(i.e. RF) portion
remains
M.H. Perrott © 2007
A
A
-2fo
-fo
0
fo
2fo
f
Filtering in Continuous and Discrete Time, Slide 5
Why is Bandpass Filtering Useful?
• Allows removal of interfering signals
– Highpass filtering would be of limited use here
• Typically higher complexity implementation than with
lowpass or highpass filters
– Many RF systems such as cell phones use specialized
components called SAW filters to achieve bandpass filtering
W(f)
2A
1
A
A
-2fo
H(f)
Interferer
-fo
0
fo
2fo
f
-2fo
1
-fo
0
fo
2fo
f
R(f)
• Only desired RF
portion remains
– Interferer eliminated
M.H. Perrott © 2007
A
A
-2fo
-fo
0
fo
2fo
f
Filtering in Continuous and Discrete Time, Slide 6
A More Formal Treatment of Filters
Ideal Lowpass
Practical Lowpass
H(f)
H(f)
K
K
-fc
0
fc
f
1
K
2
-fc
H(f)
-fc
fc
0
fc
f
H(f)
f
fc
-fc
f
• An ideal filter would have a “brickwall” magnitude
response and zero phase response
– Practical filters have a more gradual magnitude rolloff
and a non-zero phase response
• Design of the filter usually focuses on getting a
reasonable magnitude rolloff with a specified
cutoff frequency fc (i.e., filter bandwidth)
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 7
Response of Filter to Input Cosine
Lowpass Filter: H(f)
X(f)
Y(f)
H(f)
K
1
-fo
H(-fo) e
1
0
fo
f
-fo
0
fo
-fo
H(-fo)
H(fo) e
j
H(fo)
f
-fo
H(f)
fo
j
0
fo
f
f
• Fourier transform analysis:
• Key properties of practical filters
– Magnitude response is even:
– Phase response is odd:
– We’ll explain why this is true in 6.003 …
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 8
Compute Fourier Transform
Lowpass Filter: H(f)
X(f)
Y(f)
H(f)
K
1
-fo
H(-fo) e
1
0
fo
f
-fo
0
fo
-fo
H(-fo)
H(fo) e
j
H(fo)
f
-fo
H(f)
fo
j
f
0
fo
f
Define:
• Fourier transform of output:
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 9
Compute Time-Domain Response
Lowpass Filter: H(f)
X(f)
Y(f)
H(f)
K
1
-fo
H(-fo) e
1
0
fo
f
-fo
0
fo
-fo
H(-fo)
H(fo) e
j
H(fo)
f
-fo
H(f)
fo
j
0
fo
f
f
• Transform back to time domain:
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 10
Key Observations of Filter Response
Lowpass Filter: H(f)
X(f)
Y(f)
H(f)
K
1
-fo
H(-fo) e
1
0
fo
f
-fo
0
fo
-fo
H(-fo)
H(fo) e
j
H(fo)
f
-fo
H(f)
fo
j
0
fo
f
f
• Input cosine wave is scaled in amplitude and
phase-shifted in time
– Scale factor set by magnitude of H(f) at f=fo
– Phase shift set by phase of H(f) at f=fo
• We typically focus only on the magnitude of the
frequency response, H(f), of the filter
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 11
Designing and Using Filters Within Matlab
Real World
Matlab
x[n]
x(t)
t
n
1
• Our lab exercises will have you design and use
filters in Matlab
– Matlab will interface to the USRP board in order to
receive “real world” signals from the antenna
• Matlab framework is based on discrete-time
sequences (which are indexed on integer values)
– Correspond to samples of corresponding real world signals
(which are continuous-time in nature)
We need another Fourier analysis tool
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 12
The Discrete-Time Fourier Transform
• Allows us to deal with non-periodic, discrete-time
signals
• Frequency domain signal is periodic in this case
x[n]
• Where:
n
1
X(ej2πλ)
-1
0
1
λ
Note: fft function in Matlab used to compute DTFT
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 13
Relating to Samples of `Real World’ Signals
Matlab Sequence
Samples of Real World Signal
x(t)
x[n]
t
n
T
1
X(ej2πλ)
-1
0
X(f)
1
λ
-1/T
0
1/T
f
• Samples of a continuous-time signal with sample
period T leads to frequency domain signal with
period 1/T
– We simply scale frequency axis of fft in Matlab
• We will say much more about sampling later …
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 14
Filters Within Matlab
Discrete-Time
Filter
x[n]
x[n]
H(ej2πλ)
y[n]
y[n]
n
n
1
1
• Implemented as difference equations
– Current output, y[n], depends on weighted values of
previous output samples and current and previous input
samples, x[n]
• Group a and b coefficients as vectors:
• Execute filter using the filter command:
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 15
Impact of Delay on DTFT
• Consider a signal that is a delayed version of
another signal:
• Compute DTFT of y[n]
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 16
Compute Filter Response using DTFT
• Make use of the time shift property:
• Filter response is simply ratio of output over input:
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 17
FIR Filters
• Finite Impulse Response (FIR) filters use only b
coefficients in their implementation
• Example:
x[n]
H(e
j2πλ
y[n]
Note:
)
ak
1
M.H. Perrott © 2007
bk
1
M
k
0
N
k
Filtering in Continuous and Discrete Time, Slide 18
Filter Order for FIR Filters
x[n]
H(e
j2πλ
y[n]
)
ak
1
bk
1
M
k
0
N
k
• Consider two different values for N
N=3
N=7
H(ej2πλ)
H(ej2πλ)
8
4
-1
0
1
λ
-1
0
1
λ
• Higher N leads to steeper filter response
– We refer to N as the order of the filter
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 19
FIR Filter Design in Matlab
x[n]
H(e
j2πλ
y[n]
)
ak
1
bk
K
M
k
0
N
k
• Lowpass, highpass, and bandpass filters can be
realized by appropriately scaling the relative value
of the b coefficients
– Higher order (i.e., higher N) leads to steeper responses
• Perform FIR filter design using fir1 command
• Frequency response observed with freqz command
See Prelab portion of Lab 3 for details …
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 20
Summary
• Filters can generally be classified according to
– Lowpass, highpass, bandpass operation
– Bandwidth and order of filter
• Given a cosine input to a filter, output is:
– Scaled in amplitude by magnitude of filter frequency response
– Shifted in phase by phase of filter frequency response
• Matlab operates on discrete-time signals
– Use DTFT for analytical analysis
– Use commands such as fir1, freqz, and filter for design and
implementation of FIR filters
• Next lecture: introduce I/Q modulation and further
discuss continuous-time filtering
M.H. Perrott © 2007
Filtering in Continuous and Discrete Time, Slide 21