Lab Guide DSP PDF
Lab Guide DSP PDF
Digital Filters
Problem 4.1
We want to design a Discrete Time Low Pass Filter for a voice signal. The specifications are:
Passband Fp 4kHz, with 0.8dB ripple;
Stopband FS 4.5kHz, with 50dB attenuation;
Sampling Frequency Fs 22kHz.
values of H in the Passband and the Stopband, where H is the filter frequency response.
Determine a) the discrete time Passband and Stopband frequencies, b) the maximum and minimum
Solution
a) Recall the mapping from analog to digital frequency 2F Fs , with Fs the sampling fre-
quency. Then the passband and stopband frequencies become p 2 4 22 rad 0.36 rad,
s 2 4.5 22 rad 0.41 rad;
b) A 0.8dB ripple means that the frequency response in the passband is within the interval 1
frequency response within the passband is within the interval 0.9035 H 1.096.
where is such that 20 log10 1 0.8 This yields 100.04 1 0.096. Therefore the
Problem 4.2
Also let the sampling frequency be Fs 8kHz. Determine the Passband and Stopband frequencies in
kHz, the Passband ripple and the Stopband attenuation in dB.
Solution
20log10 0.005 46dB. The analog passband frequency is 0.3 Fs 2 1.2kHz and the
The passband ripple is given by 20 log10 1.05 0.42dB, and the attenuation in the stopband
Problem 4.3
Determine the passband and stopband frequencies in Hz, assuming a passband ripple of 1dB and
attenuation of 40dB in the stopband. Also determine the half power frequency Fc .
Solution.
HF
2F
2
1
then we determine the passband from the equation
1
1000
2F
2
1
1 0.12 0.88
1
1000
HF 104020 0.01 which yields F 15, 914 Hz Notice that this filter has a very long
which yields F 85.9Hz. Similarly for the stopband, we need to determine the frequency where
dB
FHz
5000 10000 15000 20000
-10
-20
-30
-40
Problem 4.4
Solution
G
40
30
20
10
0.5 1 1.5 2 2.5 3
Problem 4.5
Solution
Therefore the zeros must be such that z4 1, with the exclusion of z 1. That is to say z4 ejk2
for k 1, 2, 3, and therefore the zeros are z jk with k 1, 2, 3, ie z j, 1, j.This is
shown in the z-plane below.
Solutions_Chapter4[1].nb 5
Im
Re
the zeros are of the form z ejk N , k 1, ..., N 1 and the poles are all at z 0.
2
c) Since yn
1 xn 1 ... xn N and
N
yn 1
1
N xn 2 ... xn N 1 by comparing yn and yn 1 we see
that
yn yn 1
N xn 1
1
N xn N 1
1
as we saw before. This is an example of a recursive filter with finite impulse response (FIR).
Problem 4.6
We want to design a Low Pass FIR Filter with the following characteristics:
6 Solutions_Chapter4[1].nb
Passband 10kHz,
Stopband 11kHz, with attenuation of 50dB,
Sampling frequency 44kHz
Determine the causal impulse response hn, and an expression for the phase within the passband.
Use one of the standard windows listed in section 4.3.
Solution
2 p S
Therefore we choose the passband of the ideal filter as C 44 0.477. We
1 21
which yields N 12 22 264. Therefore we choose N 265 and a shift L 132. Finally the
impulse response is
hn hd n 132 wBlackmann
n132 wBlackmann
sin0.4545 n132
Within the passband the phase is linear and it is given by the expression
H L 132
Problem 4.7
Repeat Problem 2.1 with an equiripple filter using the "remez" function in Matlab. Plot the two
frequency responses and compare the two filters in terms of performance and complexity.
Solution
With Matlab we need first to determine the order of the filter. Use the function "remezord" as follows:
Notice that the order of the equiripple filter N 114 is considerably smaller than the order of the
filter designed with the Blackman window in Problem 4.6.
Problem 4.8
Solution
Wi the Kaiser window we have to determine the parameters N and b from the specifications. In particu-
lar we want an attenuation A 50dB which yields a factor from the expression
0.5842A 210.4 .07886A 21 4.53
Also the filter length is determine from the expression
N
2.285
22 128.717
A8 42
2.285
So we can choose N 129 and L 64. The frequency response of the filter therefore becomes
sin0.4545 n64
wKaisern
n64
Problem 4.9
e0.1F if F 10 Hz
We want to approximate a filter with frequency response
HF
0 if F 11Hz
Let the sampling frequency be Fs 50Hz, and the attenuation in the stopband be 40dB. Determine
the impulse response of a FIR filter which approximates this frequency response. Plot the frequency
response in terms of magnitude and phase to verify that the approximation holds.
Solution
In the digital domain, let 2F Fs and therefore F Fs 2. Therefore the filter's desired
e52 if 2 5 rad
frequency response becomes
H
0 if F 2.2 5 rad
The ideal filter therefore is going to have a frequency response Hd given by
2.1 5
Hd
e52 if
0 otherwise
and the impulse response
10 Solutions_Chapter4[1].nb
hd n
2.15
2
1 e52 ejnd
2.274050.795775 Cos1.31947 n1. n Sin1.31947 n
5.685128.97758 n2
2.15
tion region of width 8 N. The desired width is 2 50 and therefore N is determined from
Since we want 40dB attenuation in the stopband we can use a hamming window, which has a transi-
the equation
50
2 8
N
and N 50 4 200. Choose N 201 and L 100. This yields the impulse response
hn hd n 100whammingn
Problem 4.10
A bandpass filter needs to be designed, to pass a signal within frequencies 4kHz and 8kHz, with
two transition regions not exceeding F 0.5kHz . Also we want the attenuation in the stopband
not exceeding 50dB, and the same error within the passband. Finally let the sampling frequency be
Fs 44kHz.
a) Determine the impulse response of the ideal filter;
b) Design the filter using the Kaiser window;
c) Design the filter using the equiripple method.
Compare the two frequency responses.
Solution
attenuation A 50dB and the width of the stopband 2 0.5 44 44 rad. Recall the
b) From the formulas of the Kaiser window we determine the parameters and N as follows from the
formulas:
Solutions_Chapter4[1].nb 11
which yields a window of length N 259 and a time delay L 129. Finally thr impulse response
becomes
hn hd n 129wkaisern
Problem 4.11
You want to design a low pass filter with passband Fp 2kHz and stopband FS 2.5kHz, with
attenuation of at least 40dB. Let the sampling frequency be Fs 10kHz. Using the techniques you
know, determine the design with the least number of coefficients.
Solution
Problem 4.12
In the section on equiripple filters we have taken a few things for granted. In this problem try to prove
the following simple facts:
a) when the order of the filter N increases, the maximum error decreases;
b) the solution is unique, in the sense that, for any given order N, there is only one impulse response
h0, ..., hNwhich minimizes the maximum error.
Solution
a) Call hN hN 0, ..., hN N the optimal solution (in the minmax sense) of order N. Then
the vector
hN1 hN 0, ..., hN n, 0 hN1
The leftmost inequality is due to the fact that hN1 is not the optimal solution of order N 1, and the
rightmost equality is due to the fact
HN1 HN for all
Solutions_Chapter4[1].nb 13
where HN1 and HN are the frequency responses of hN1 and hN .
b) If there were two different solutions hN and
gN of the same order N having the sign alternation
property, the difference HN GN would have N 1 roots against the assumption of being
polynomials (in cos) of order N.
Problem 4.13
Solution
| H ( ) |
1
H ( )
2
2
14 Solutions_Chapter4[1].nb
hd n
2 jsigne
2
n 2
2 Sin
jn d
n if n 0
1
and hd 0 0.
c) The plots of
HL hd nejn
L
nL
are shown below (magnitude only) for L 20, 40, 60 corresponding to the orders
N 40, 60, 120 respectively. The transition region is defined around the frequency 0.
N40
1.2
1
0.8
0.6
0.4
0.2
3 2 1 1 2 3
N60
1.2
1
0.8
0.6
0.4
0.2
3 2 1 1 2 3
Solutions_Chapter4[1].nb 15
N120
1.2
1
0.8
0.6
0.4
0.2
3 2 1 1 2 3
Problem 4.14
Using the Bilinear Transformation, determine the order N and the cut off frequency c of the analog
prototype filter for the following discrete time design:
a) passband 8kHz;
b) stopband 9kHz;
c) passband ripple 0.5dB;
d) stopband attenuation 40dB;
e) sampling frequency Fs 44kHz.
Solution
p 100.520 0.944
p 1 0.349
1 2
which yields N 38. Finally we determine the cut off frequency of the filter as
c p 1N 58141.4 rad sec
and therefore its frequency response becomes
p
H
1
2N
1
2N
p 1N
1
2 1
The following plot shows the poles of the filter in the s-plane:
Solutions_Chapter4[1].nb 17
-5 -4 -3 -2 -1
-2
-4
-6
-50
-75
-100
-125
-150
-175
18 Solutions_Chapter4[1].nb
Problem 4.15
A 4-th order Butterworth filter has cut off frequency c 200 rad sec.
a) Determine the zeros and poles of the transfer function;
b) What would be its passband and stopband frequencies if we want 1dB ripple in the passband and
40dB attenuation in the stopband?
c) If we apply a Bilinear Transformation with sampling frequency Fs 1kHz, determine the zeros
and poles in the z-plane.
Solution
c 200 rad sec spaced by an angle of 360 2N 360 8 45 degrees. The poles are
a) Recall that an N th order Butterworth Filter has poles on a circle with radius
s plane
and they are given by p1,4 200ej58 and p2,3 200ej78 . All zeros are at s .
c) Applying the formula for the Bilinear Transformation each pole is mapped as
s
2
z
2
T
s
s
Ts
Solutions_Chapter4[1].nb 19
This yields poles in the z-plane at 0.673045 j 0.433479 and 0.53675 j0.143193 and
four zeros at z 1.
Problem 4.16
Repeat Problem 4.14 using a Chebyshev filter. Which one would you choose if complexity is an issue?
Solution
The specifications of the prototype filter are the same, since they depend on the original specifications
of the filter and on the bilinear transformation. Recall them here for convenience:
2 Fp
p
Fs 1.1424 rad
2 FS
S
Fs 1.2852 rad
p 1 0.349
1 2
Then use the formulas for the Chebyshev Filter, from section 4.4, to obtain N 12 (the complexity of
the filter) and the frequency response as shown below.
log
S 2
S
N
log
p
S
p 1
which yields N 12. Then the poles of the filter in the s-plane are computed as
20 Solutions_Chapter4[1].nb
2 1 1
;
1N
p 1 2
r1 ;
p 2 1
2
r2 ;
2 k 1 2 k 1
2
p r2 cos j r1 sin , k 0, ..., N 1
2N 2 2N 2
The poles in the s-plane are shown below. Notice the two different scales for the Real and Imaginary
axis
40000
20000
-20000
-40000
The plot of the frequency response is shown below. If you compare it with the Butterworth filter in
Problem 4.14, notice that you obtain the same attenuation with a lower complexity (N 12 for Cheby-
shev and N 38 for Butterworth).
-40
-60
-80
-100
Solutions_Chapter4[1].nb 21
Problem 4.17
by a discrete time approximation, using the Bilinear Transformation. Let Fs 10Hz be the sampling
frequency.
a) Determine zeros and poles of both the analog filter Hs and the discrete time implementation
Hz;
b) Determine the Linear Difference Equation of the discrete time implementation;
c) Plot the frequency responses of the digital filter H and the analog filter H. Verify that you
can obtain one from the other by the appropriate frequency transformation.
Solution
a) The zeros of the analog system are s 1 2, and s (yes this is a zero too!). The poles are
the solution of s2 s 1 0 which yields s ej23
Ts
b) Since we know the zeros and the poles we can write the transfer function to be
z1z0.9512
z0.947743j 0.0822827z0.947743j
Hz K
0.0822827
z 0.0488z0.9512
2
Hz 0.0973361
z2 1.8955z
0.9050
and the difference equation
Problem 4.18
a) Determine a discrete time implementation using Euler's approximation, with sampling frequency
Fs 10Hz. Sketch the frequency response, and verify that it approximates the integrator for low
frequencies;
b) Same as a), using the Bilinear Transformation.
Solution
we obtain
Hz 0.1
z
z1
For small, we can approximate ej 1 and sin 2 2, and therefore we see that, for
2j ej2 sin2
small the discrete time system behaves like an integrator with frequency response
H j2F FFs 2
j Fs
1 1
The following plot compares the frequency response H with the ideal integrator. We can see
that in this case the Euler approximation gives a good approximation.
Solutions_Chapter4[1].nb 23
60
40
20
-20
The following plot compares the frequency response H with the ideal integrator. Even here
2 j sin 2
we can see that in this case the Euler approximation gives a good approximation. Notice that at
z 1 (ie ), the frequency response is zero, and in the dB plot it goes to .
100
50
-100
-150
Problem 4.19
You want to design an analog Band Pass Filter which passes the frequencies in the interval
5kHz F 6kHz
24 Solutions_Chapter4[1].nb
with 1dB ripple in the passband. Let the the filter be Butterworth with order N 4.
a) Determine the frequency transformation Low Pass to Band Pass you would use;
b) Determine the frequency response of the corresponding Low Pass Filter, together with its zeros and
poles;
c) Determine the zeros and poles of the Band Pass Filter and its transfer function.
Solution
C s2 L U
In order to apply the proper transformation (Low Pass to Band Pass)
s U L
qs
-16
610
-16
510
-16
410
-16
310
-16
210
-16
110
Problem 4.20
Recall that, when we apply a digital filter to a continuous time signal, we need two analog filters:
Anti-Aliasing and Reconstruction. Due to hardware constraints and cost, these two filters cannot have
a very large order, and they represent a constraint in our design. Suppose we want to design a digital
filter for a signal having bandwidth of 8kHz, and we have to use a 5 pole Butterworth filter
(commercially available for low cost) for both antialiasing and reconstruction filters. Also we want
1dB passband ripple and 50dB attenuation in the stopband.
a) What do you think would be the minimum sampling frequency we can have, with these two analog
filters. (Hint: recall what is the passband and what is the stopband of the analog antialising and recon-
struction filters in terms of signal bandwidth and sampling frequency);
b) The 5 pole Butterworth filter you buy, often is based on switched capacitor technology. This allows
to select the cut off frequency c fairly easily, by adjusting the frequency of an oscillator. Given the
sampling frequency you determined in question Q1, determine a suitable value for the cut off fre-
quency c of the filter.
26 Solutions_Chapter4[1].nb
Solution
a) From the specifications of the problem, we have to pass all frequencies up to 8kHz. This yields
p 2 8000 rad/sec
We want 1dB ripple in the passband. This gives a value of as
0.509
Therefore the frequency response becomes
H
10
1
12 p
with e and p as given. Now we have to find the stopband frequency, from the requirement of 50dB
attenuation. This leads to the equation
H
p
1 5020
10 10
1
2
H
1 1
10
1 2 2
p
which yields C 57537.7 rad sec. The figure below illustrates the problem.
Solutions_Chapter4[1].nb 27
FPASS
FSTOP
8. 0 Fs 8.0 Fs F (kHz )
Sampling freq.
Problem 4.21
In your CD the data is sampled at 44.1kHz (CD quality), and we want to have a good sound quality up
to 21kHz. If you had a to use an analog Butterworth filter as a reconstruction filter, what would be the
order of your filter? Do you think you can reasonably build a filter with that complexity? (I do not
think so either!) The chapter on Multi Rate DSP is going to show you how the CD technology solves
this problem.
Solution
Since we want the filter to pass the signal and reject all frequencies above Fs 2, we can see that
passband and stopband frequencies become
p 2 21000 rad sec
S 244100 2 2 22050rad sec
Assuming a 1dB passband ripple and 40dB attenuation in the stopband, this would yield a frequency
response of the form
H
2
12
1
N
p
with e=0.509 and P as given. For an attenuation of 40dB we obtain N 108 after solving
HS
2
12
1
S
N 0.01
p