Worked Solutions to Exercises 7.2#
Solution to Exercise 7.2.1#
See: Exercise 7.2.1
We first write down the difference equations by tracing through the signals in the block diagram of Fig. 15.
We take Z-transforms of equations (66) and (67):
Gather terms in (68) and (69):
From (71) we obtain
We then use (72) to eliminate
and the transfer function follows:
Solution to Exercise 7.2.2#
See: u72:ex:2
The same procedure used for Solution to Exercise 7.2.1 is used.
Solution to Exercise 7.2.3#
Design a 2nd-order Butterworth filter with
kHz. Use the Bilinear transformation to convert the analogue filter to a digital filter with sampling frequency of 44.1 kHz. Use pre-warping to ensure that the cutoff frequency is correct at the equivalent digital frequency.
See: Exercise 7.2.3
The magnitude squared function of a
We need to design a filter that has
We follow the procedure outlined in the notes (see Butterworth Analogue Low-Pass Filter Design).
which on subsitution of
The poles of this equation are given by
Thus $
We take the left-half plane poles
The gain
We now convert this to the filter we need by substitution
from which
and
We will complete the problem by switching to MATLAB. We first need to determine the pre-warping correction
fs = 44.1e2; % sampling frequency
Ts = 1/fs;
wc = 2*pi*20e3
wc =
1.2566e+05
wa = (2/Ts)*tan(wc*Ts/2)
wa =
-7.9553e+04
Re calculate Butterworth filter with pre-warped frequency
Hs = tf(wa^2,[1 sqrt(2)*wa wa^2])
Hs =
6.329e09
---------------------------
s^2 - 1.125e05 s + 6.329e09
Continuous-time transfer function.
Now find
You should try this algebraicly, but we will cheat
Hz = c2d(Hs,Ts,'tustin')
Hz =
1.169 z^2 + 2.338 z + 1.169
---------------------------
z^2 + 2.309 z + 1.367
Sample time: 0.00022676 seconds
Discrete-time transfer function.
From which
To implement this, we simply convert to negative powers of
Solution to Exercise 7.2.4#
A digital filter with cutoff frequency of 100 Hz for a signal sampled at 1 kHz has transfer function
The frequency response for this filter (plotted against
) is shown in Fig. 26. a) What type of filter is this?
b) Estimate the band-pass ripple, and stop-band ripple of the filter.
c) Implement the filter as Direct Form Type II digital filter and sketch its block diagram.
d) Use the example of Convert to code to give a code implementation of the filter.
e) If the input to this filter is a step function
, calculate the first 5 outputs of the filter.
See: Exercise 7.2.4
This is a 2nd-order filter designed to have a cut-off frequency of
a) The gain at high frequency is 0 dB so the filter is high-pass. There is ripple in the stop-band so it is Chebyshev Type II.
b) The stop-band ripple is 10 dB, there is no ripple in the pass-band. Note that it is not clear that the cut-off frequency is 100 Hz! Any value near the -3dB cut-off frequency will be taken as correct.
c) For the sketch, refer to Fig. 18 and note that the coefficients will be:
d) To write the code, we need to express the transfer function as a difference equation.
So
Taking inverse Z-transform:
Using the example in Convert to code with
/* Initialize */
Ts = 0.001; /* more probably some fraction of clock speed */
ynm1 = 0; ynm2 = 0; unm1 = 0; unm2 = 0;
while (true) {
un = read_adc();
yn = 0.6401*un + −1.1518*unm1 + 0.6401*unm2 + 1.0130*ynm1 - 0.4190*ynm2;
write_dac(yn);
/* store past values */
ynm2 = ynm1; ynm1 = yn;
unm2 = unm1; unm1 = un;
wait(Ts);
}
e) The easiest way to complete the problem is to tabulate the data
from which
I find the use of Excel to be a useful tool for confirming such results and the sheet for this one can be downloaded sol_ex_7_2_3.xlsx.
You can also use MATLAB of course. Here we set up the transfer function:
fs = 1000;
Ts = 1/fs
Hz = tf([0.6401,-1.1518,0.6401],[1,-1.0130,0.4190],Ts)
Ts =
1.0000e-03
Hz =
0.6401 z^2 - 1.152 z + 0.6401
-----------------------------
z^2 - 1.013 z + 0.419
Sample time: 0.001 seconds
Discrete-time transfer function.
Then compute the step response
[yn,nTs] = step(Hz);
stem(nTs*1000,yn),grid,title('Step response of filter in Exercise 7.2.3'),xlabel('Time [ms]')
ylabel('y[n]')

Confirm the tabulated results
yn(1:5)
ans =
0.6401
0.1367
-0.0013
0.0698
0.1996