Professional Documents
Culture Documents
9-Design IIR Filters Updated
9-Design IIR Filters Updated
∞ N M
y( n ) = ∑ h ( k ) x ( n − k ) = ∑ b k x ( n − k ) − ∑ a k y( n − k )
k =0 k =0 k =0
Y (z) ∑b k z −k
H (z) = = k =0
M
X (z)
1 + ∑ a k z −k
k =0
Direct 1 form Direct 2 form
b0 y(n) b0 y(n)
X(n) X(n)
. . .
. . . .
z-1 . .
. z-1 .
z-1 .
bN -aM -aM bN
1
1
Design Steps
1. Filter Specification
2. Coefficient Calculations
3. Realisation
4. Implementation
2
Pole-Zero Placement
Basic Concept:
Zero in the z- plane H(f)=0
Fs/4
H(f)
x
Fs/4
Fs/2 0
0 f
Fs/4 Fs/2 3Fs/4
x
3Fs/4
3
3
Pole-Zero Placement
Example: Design Bandpass Digital Filter to meet the following Specifications:
Solution: H(f)
r=1-(Bw/Ft)*π=0.937
x
250Hz
r
0
0 f
x 0 125Hz 250Hz
125Hz
4
Pole-Zero Placement
(z − 1)(z + 1)
H(z) = jπ / 2 − jπ / 2
=
(z − re )(z − re )
1 − z −2 -2
H(z) =Y(z)/X(z) = Y(z)(1+0.8z
-2
1 + 0.877969 z − 2 =x(z)(1-z
Reccurence equation
y(n) = - 0.877969 y(n-2)+x(n)- x(n-2)
1
y(n)
x(n) -1
z-1 z-1
z-1
z-1
- 0.877969
5
5
Impulse invariant Method
Basic Concept:
LT Sampling ZT
H(s) h(t) h(nt) H(z)
Ilustration:
C
H(s) = ; h ( t ) = L−1 [H(s)] = Ce pt
s−p
∞ ∞
H(z) = ∑ h (nT)z −n
=∑ Ce pnT z − n
n =0 n =0
C
H(z) =
1 − e pT z − 1
6
6
Impulse invariant Method
Example:Design a IIF filter with Butterworth characteristic to meet
the followingSpecifications:
0
FN=1000/2; % Nyquist frequency
fc=300; % cut offf frequency
-5
N=5; % filter order
[z, p, k]=buttap(N);% create an analog filter
Magnitude (dB)
-10
w=linspace(0, FN/fc, 1000); % plot the response of filter
h=freqs(k*poly(z), poly(p), w);
-15
f=fc*w;
plot(f, 20*log10(abs(h))), grid;
-20
ylabel('Magnitude (dB)')
xlabel('Frequency (Hz)')
-25
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hz)
7
Impulse invariant Method
2
Fs=1000; % sampling frequency
0
fc=300; % cutoff frequency
-2
WC=2*pi*fc; % cutoff frequency in radian
-4
N=5; % filter order
Magnitude (dB)
-6
[b,a]=butter(N,WC,'s'); % create an analog filter
-8
[z, p, k]=butter(N, WC, 's');
-10
[bz, az]=impinvar(b,a,Fs);% determine coeff. of filter
-12
[h, f]=freqz(bz, az, 512,Fs);
-14
plot(f, 20*log10(abs(h))), grid
-16
xlabel('Frequency (Hz)')
-18
ylabel('Magnitude (dB)') 0 50 100 150 200 250 300 350 400 450 500
Frequency (Hz)
8
IIF design using Impulse invariant Method
Design IIF with following specifications:
10 Rs /10 − 1)
Passband edge frequency: wp=0.25*pi; log( Rp /10
Stopband edge frequency: ws=0.55*pi;
Sampling frequency: T=1 N= 10 −1
Passband ripple: Rp=-0.5; 2 log(ws / wp)
Stopband ripple: Rs=-15;
Matlab Program:
wp=0.25*pi; ws=0.55*piRp=0.5; Rs=15; s=0.1*Rs; e2=(10^s)-1;
v=0.1*Rp; e3=10^v-1; k=ws/wp; N=log10(e2/e3)/(2*log10(k)); N=ceil(N)
[z p k]=buttap(N) % Buttap - Butterworth analog lowpass filter
[num,den]=zp2tf(z,p,k); %[num,den]- numerator and denominator coefficients of analog filter
[bz,az]=impinvar(num,den) % [bz,az] numerator BZ and AZ denominator coefficients of digital filter
[h omega]=freqz(bz,az,512);%[h omega]-frequency response of digital filter
g=20*log10(abs(h));
plot(omega/pi,g);'grid'
xlabel('Normalized frequeny')
ylabel('Gain,dB')
[bz,az]=impinvar(num,den)
9
bz =
-0.0000 0.0828 0.1657 0.0226 0
az =
1.0000 -1.5587 1.2283 -0.4722 0.0733
Transfer function:
0 . 08 z − 1 + 0 . 16 z − 2 + 0 . 02 z − 3
H (z) =
1 − 1 . 5 z −1 + 1 . 2 z − 2 − 0 .4 z − 3 + 0 . 07 z − 4
5
-5
-10
-15
Gain,dB
-20
-25
-30
-35
-40
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Normalized frequeny
10
10
Bilinear Z-Transform (BZT)
x x x
x
x x
x x x
x x x
Re Re
x x x
S-plane
z-plane
11
11
Warping Effect
z −1 2
s=k ; k = 1 or z = e j ωT ; s = jω'
z +1 T
e jω T − 1 ωT ω’- analog frequency
j ω = k jω T ;
'
ω' = k tan ω- digital frequency
e +1 2 T-sampling period
ω’ (analog) ωT
Relationship between ω and ω’ is nonlinear ω ' = k tan
2
(tangensoidal) leading to a distortyion or warping of
digital frequency.Passband for the analog filter are with
regular intervals, whereas the passband for the digital
filterare somewhat squashed up. This effect is
Coımpensated for by prewarping the analog filter
before applying the BZT.
' ωp T ω(digital)
ωp = k tan
2
ωp- specified cutoff frequency
ω’p- prewarped frequency
12
12
Summary of the BZT
1. Use the DF specifications to find a suitable analog LPF, H(s)
2. Determine and prewrap bandedge frequencies
ω pT For LPF and HPF
ω 'P = ktan
2
ω p1 T ω p2 T
ω 'P1 = ktan ; ω 'P2 = ktan ; For Band pass and stopband filters
2 2
4. Apply BZT z −1
s=k
z +1
13
13
Matlab-files using BZT
50
Magnitude (dB)
N=5; % filter order
-100
[z, p, k]=butter(N, fc/FN);
BZT
[h, f]=freqz(k*poly(z), poly(p), 512, Fs); -150
plot(f, 20*log10(abs(h))), grid
ylabel('Magnitude (dB)') -200
xlabel('Frequency (Hz)')
-250
0 50 100 150 200 250 300 350 400 450 500
Frequency (Hz)
2
Fs=1000; % sampling frequency
0
-2
fc=300; % cutoff frequency
-4
WC=2*pi*fc; % cutoff frequency in radian
N=5; % filter order
Magnitude (dB)
-6
-12
[bz, az]=impinvar(b,a,Fs);% determine coeffs of IIR filter
-14
[h, f]=freqz(bz, az, 512,Fs);
-16
plot(f, 20*log10(abs(h))), grid
-18
xlabel('Frequency (Hz)')
0 50 100 150 200 250 300
Frequency (Hz)
350 400 450 500
ylabel('Magnitude (dB)') 14
14
Matlab-files using BZT
Problem: Design Bandpass filter with Butterworth characteristics rhat meets the following specifications:
Passband 200-300 Hz
Sampling frequency 2000 Hz
1
Filter order 8
Magnitude Response
0.8
Fs=2000; % Sampling frequency 0.6
FN=Fs/2; fc1=200/FN; 0.4
fc2=300/FN; 0.2
[b,a]=butter(4,[fc1, fc2]); % Create and digit. analogue filter. 0
0 100 200 300 400 500 600 700 800 900 1000
[z,p,k]=butter(4, [fc1, fc2]); Frequency (Hz)
subplot(2,1,1) % Plot magnitude freq. response
1
[H, f]=freqz(b, a, 512, Fs);
Imaginary Part
0.5
plot(f, abs(H))
4 4
0
xlabel('Frequency (Hz)')
ylabel('Magnitude Response ') -0.5
15
15
Matlab-files using BZT
Problem: Design Bandpass filter with Butterworth characteristics rhat meets the following specifications:
Magnitude Response
Uppere stopband edge frequency 450 Hz 0.8
Passband ripple 3 dB 0.6
Stopband attenuation 20 dB
0.4
Sampling frequency 1 kHz
0.2
Determine
0
• the order N of filter; 0 50 100 150 200 250 300 350 400 450 500
• b) poles, zeros, gain, coefficients and transfer functİon of DF Frequency (Hz)
1
Fs=1000; % Sampling frequency
Imaginary Part
Ap=3; 0.5
As=20; 2 2
0
Wp=[200/500, 300/500]; % Band edge frequencies
Ws=[50/500, 450/500]; -0.5
[N, Wc]=buttord(Wp, Ws, Ap, As); % Determine filter order -1
[zz, pz, kz]=butter(N,Wp); % Digitise filter -3 -2 -1 0 1 2 3
[b, a]=butter(N, Wp); Real Part
subplot(2,1,1) % Plot magnitude freq. response
[H, f]=freqz(b, a, 512, Fs);
plot(f, abs(H))
xlabel('Frequency (Hz)')
ylabel('Magnitude Response ')
subplot(2,1,2) % Plot pole-zero diagram
zplane(b, a) 16
16
N=2
pz= [-0.1884 ± 0.7791j ; 0.1884 ± 0.7791j]
zz= [1 1 -1 -1]
0.0675 − 0.1349z −2 + 0.0675z −4
kz=0.0675
H(z) =
b= [0.0675 0 -0.1349 0 0.0675] 1 + 1.1430z − 2 + 0.4128z − 4
a= [1.0000 -0.0000 1.1430 -0.0000 0.4128]
0.0675 y(n)
x(n)
z-1 z-1 z-1 z-1
z-1
-0.1349 - 1.1430 z-1
z-1
- 0.4128
z-1
17
17
Realization of IIR
N M
y( n ) = ∑ b k x ( n − k ) − ∑ a k y( n − k ) M ≥ N
k =0 k =1
b 0 + b1z −1 + b 2 z −2
H(z) =
1 + a 1z −1 + a 2 z − 2
Direct 1 Direct 2
2nd order 2nd order
2
2 2 w (n ) = x (n ) − ∑ a k w (n − k )
y( n ) = ∑ b k x ( n − k ) − ∑ a k y( n − k ) k =1
k =0 k =1 2
X(n) b0 y(n) y( n ) = ∑ b k w ( n − k )
k =0
X(n) w(n) b0
y(n)
z-1 z-1
b1 -a1
z-1
z-1 z-1 -a1 b1
b2 -a2
z-1
-a2 b2
18
18
Cascade Realization of IIR
N/2 b + b z + b2z
−1 −2 N/2 N k (z) = b 0 + b1z −1 + b 2 z − 2
N k (z)
H (z) = ∏ 0 1 −1 = ∏
k =1 1 + a 1z + a 2 z
−2
k =1 D k (z)
D k (z) = 1 + a1z −1 + a 2 z − 2
b01 b0n
X(n) y(n)
H(z) =
N1 ( z ) N 2 ( z ) N (z) N 2 (z)
; H(z) = 1 z-1 z-1
D1 (z) D 2 (z) D 2 (z) D1 (z) -a11 b11 -a1n b1n
N 2 ( z ) N1 ( z ) N (z) N1 (z)
H(z) = ; H(z) = 2
D1 (z) D 2 (z) D 2 (z) D1 (z)
z-1 z-1
-a21 b21 -a2n b2n
b01 b0n
X(n) y(n)
z-1 z-1
-a11 b11 -a1n b1n
19
19
Parallel Realization of IIR
N/2 C
H(z) = C + ∑ H k (z) b01
k =1
z-1
-a11 b11
b b 0 k + b1k z −1 X(n)
C= N , H(z) =
aN 1 + a 1k z −1 + a 1k z −1 y(n)
z-1
-a21
.
.
b0n
.
n
b 0 k + b1k z −1
H(z) = C + ∑ −1 −1
k =1 1 + a 1k z + a 1k z z-1
-a1n b1n
z-1
-a2n
20
20
Develop Cascade and Parallel Realization
0.1432(1 + 3z −1 + 3z −2 + z −3 )
H(z) =
1 − 0.1801z −1 + 0.3419z − 2 − 0.0165z −3 )
1. For casacade realization H(z) is expressed in factored form:
1 + 2z −1 + z −2 1 + z −1
H(z) = 0.1432
1 − 0.1307 z −1 + 0.3355z − 2 1 − 0.0490z −1
0.1432 1 1 y(n)
x(n)
z-1
-8.7107
0.1307
2 z-1
0.0490 1 1.2916
-0.33557
z-1
1 z-1
0.1310 -0.0841
1. For parallel realization H(z) is expressed using
partial fraction expansion as the sum second- and X(n) y(n)
first order sections:
-0.3355
z-1
10.1764
−1
1.2916 − 0.08407z 10.1764
H(z) = + − 8.7107
1 − 0.131z −1 + 0.3355z − 2 1 − 0.049z −1 z-1
0.0490
21
21
Finite Wordlength Effects
Application of IIR
1. Telecommunication- in Transmitter as antialiasing filter and in Receiver anti imaging filter
2. Digital Telephony-digital dual tone multifrequency touch-tone receiver
3. Clock recover in Data communications etc
22
22