www.getmyuni.com

Digital

IIR Filter Design www.getmyuni.com 9.1 – IIR Filter

¾ Difference Equation N N y(n) = ∑ ai x(n − i) +∑bj y(n − j) i=0 j=1 N ¾ −i ∑ ai z i=0 H (z) = N − j 1+ ∑bj z j=1 where; N is the filter’s order.

ai,bj are the filter’s coefficients. www.getmyuni.com 9.1 – IIR Filter – contd.

• IIR filter have infinite-duration impulse responses, hence they can be matched to analog filters, all of which generally have infinitely long impulse responses.

• The basic techniques of IIR filter design transform well-known analog filters into digital filters using complex-valued mappings.

• The advantage of these techniques lie in the fact that both analog filter design (AFD) tables and the mappings are available extensively in the literature.

• The basic techniques are called the A/D filter transformation.

• However, thAFDtblthe AFD tables are avail ilblable onl y f or lowpass filters. W e al so want design other frequency-selective filters (highpass, bandpass, bandstop, etc.)

• To do this, we need to apply frequency-band transformations to lowpass filters. These transformations are also complex-valued mappings, and they are also available in the literature. www.getmyuni.com 9.2 – Design Methods

¾ The following A/D filter transformation methods are used in calculatinggffff the coefficients of IIR filter:

1. Impulse Invariant Method. 2. Bilinear Z-transform Method.

Æ to achieve a diggfital filter that has a certain sppfecification eq uivalent to an

Note ¾ We have no control over the phase characteristics of the IIR filter. Hence IIR filter designs will be treated as magnitude-only designs. www.getmyuni.com 9.3 – Impulse Invariant Method

• Here we require that the impulse response of the discrete system () be the discrete version of the impulse response of the analogue system (filter), (Hence t he name: impu lse invariant ).

H(s) Ł-1 h(t) t = nT h(nT) Z X T H(z)

To remove the sampling effect: ¾ Steps: (1/T) δ(t‐nT) 1. Get H(s), continuous time transfer function of an analogue filter that satisfies the prescribed magnitude response. 2. Apply the inverse to get the impulse response h(t). h(n). 3. Obtain a discrete version of h(t) by replacing t by nT Æ h(nT). h(t) 4. Apply the Z-transform to h(nT) to get H(z) and multiply by T. h(nT)

n n ∞ www.getmyuni.com Example - 1

¾ Using the invariant impulse response method, design a digital filter that has the shown pole-zero distribution. jω ω 9 Solution ω x 0 s + a H (s) = σ [s + (a + j )][s + (a − jω )] ‐ a s + a 0 0 H (s) = x - ω0 2 2 [(s + a) + ω0 )] −1 −at (1) L {H(s)} = e cos(ω0t) = h(t) −anT (2) h(nT) = e cos(ω0nT) −aT −1 1− e cos(ω0T )z (3) T × Z{h(nT)} = −aT −1 −2aT −2 ×T 1− 2e cos(ω0T )z + e z −aT −1 T − (e T cos(ω0T ))z H (z) = −aT −1 −2aT −2 1− (2e cos(ω0T ))z + e z www.getmyuni.com Example - 1 – cont.

−aT −1 T − (e T cos(ω0T ))z H (z) = −aT −1 −2aT −2 1− (2e cos(ω0T ))z + e z a x(n) 0 y(n) X

-b1 T a1 X X

- b2 T X

where, a 0 = T − aT a1 = −e T cos( ω 0T ) − aT b1 = −2e cos( ω 0T ) − 2 aT b2 = e www.getmyuni.com 9.4 – Bilinear Z-Transform (BZT) Method

s t z s z s1 Impulse Invariant Method Bilinear Z‐Transform Method • It is the most important method of obtaining IIR filter coefficients. • In the BZT method, the basis operation is to convert an analogue filter H(s) into an equival ent di g ita l fil ter H(z) b y usi ng th e bili near approxi mati on.

Ha(s) HD(z) sT sT e 2 1 + + ... z = e sT = = 2 1st order bilinear Q − sT approximation 2 1 − sT + ... e 2 1 + sT ∴ z ≅ 2 1 − sT 2 www.getmyuni.com 9.4 – BZT Method – cont.

sT 1 + sT sT z ≅ 2 z − z = 1 + 1 − sT 2 2 2 T z - 1 = (z + 1) s 2

2 z −1 ∴s ≅ T z +1 1

H (z) = H (s) 2 z−1 D a s= T z+1 www.getmyuni.com 9.4 – BZT Method – cont.

− jΩT 2 z −1 2 e jΩT −1 e 2 s = = × Q jΩT − jΩT T z +1 T e +1 e 2 j ΩT − j ΩT ΩT 2 e 2 − e 2 2 2 j sin ( ) = = 2 j ΩT − j ΩT T 2 2 T 2 cos ΩT e + e ( 2 ) 2 jω = j tan (ΩT ) a T 2 2 ω = tan (ΩT ) Pre-Warppgffing effect a T 2 2 −1 ⎛ω T ⎞ Ω = tan ⎜ a Warppgffing effect T ⎝ 2 ⎠ Digital frequency www.getmyuni.com 9.5 – Frequency Warping Effect (BZT)

Analogue frequency • The effect of the bilinear Z-transform is called ωa frequency warping: every feature appears in the of th e conti nuous-time filt er appears as it is in the frequency response of the discrete-time filter but at different frequency. ω jω when − π∞ ≤ a ≤ ∞ S domain tan(θ) π Ω − ≤ Ω ≤ σ Digital frequency T T ‐π/2 jΩ θ Ω s Ω s Ωs/2 π/2 − ≤ Ω ≤ S domain 2 2 1

- Ωs/2 • To compensate for this, every frequency specification the designer has a control

over (ωc,ωs,…) has to be ‘prewarped’ by setting it with; 2 ω = tan (ΩT ) 2 T 2 www.getmyuni.com 9.6 - IIR Filter Design Procedure Using BZT

1 Given specification in digital domain 2 Convert it into analog filter specification(prewarping) 3 Design analog filter (Butterworth , Chebyshov , elliptic):H(s) 4 Apply bilinear transform to get H(z) out of H(s) ω ω

ωs 3 2 2 ω = tan (ΩT ) a T 2 ωp | H(jω)| Ω 1 1 1 | H(ejΩ)| 2 1 1+ε A 1 1 + ε 2 4 1 1 H (z) = H (s) 2 1− z −1 A s= ⋅ Ω −1 Ω π T 1+ z p Ωs www.getmyuni.com 9.7 – IIR Filter Design Steps Using BZT

1. Prewarp any critical frequency in the digital filter specifications(ωc,ωp,ωs,…) using; 1 ω = tan Ω T ;T = ( 2 ) Fs 2. Use the diggfital filter sp pfecifications to f ind a suitable normalized p rototyp e analogue LPF, H(s), e.g., for butterworth; 1 • 1st order: H (s) = s +1 1 • 2nd order: H (s) = s2 + 2s +1 For butterworth prototype filter 1 • 3rd order: H (s) = (s +1)(s2 + s +1) Where ⎛ 10 0.1 As − 1 ⎞ log ⎜ ⎟ 10 ⎜ 0.1 A p A the passband ripple in dB ⎝ 10 − 1 ⎠ p N ≥ A the stopband attenuation in dB ⎛ω ⎞ s 2.log ⎜ s ⎟ 10 ⎜ ⎟ ⎝ ω p ⎠ www.getmyuni.com 9.7 – Design Steps – cont.

2. Denormalization according to filter type; (LPF, HPF, BPF, BSF).

• LPF s s ω c

• HPF s ω s c ω 2 2 2 = ω ω • BPF s (s + ω 0 ) sω ;where, ω0 = ω1ω2 0 1 2 ω ω 2 2 • BSF = 2 −ω1 s s (s + ω 0 )

3. MfMap from s-didomain to z-didomain; 1− z −1 s = 1+ z −1 4. Realize the IIR filter . www.getmyuni.com Example – 2

st ¾ Design a 1 order Butterworth HPF with Ωc = 1 rad/sec, Fs = 1Hz. 9 Solution 1 H (s) = s ω s s +1 c 1 s H (s) = = ωc s +1 s +ωc

⎛ Ω cT ⎞ ⎛ 1 ⎞ ω c = tan ⎜ = tan ⎜ ⎝ 2 ⎠ ⎝ 2 ⎠ (1− z −1) (1+ z −1) 1− z −1 H (z) = = (1− z −1) 1− z −1 +ω +ω z −1 +ω c c (1+ z −1) c www.getmyuni.com Example - 2 – cont.

1 1− z −1 H (z) = 1 ω −1 k = 1+ωc c −1 1+ z 1+ωc ωc +1 k a x(n) 0 y(n) X X

- b1 T a1 X X

where, a 0 = 1

a1 = −1

ω c − 1 b1 = ω c + 1 www.getmyuni.com Example - 3

¾ Design a 3rd order Butterworth LPF to have a cutoff frequency at 4 kHz using the BZT method & assuming a sampling frequency of 10 kHz.

9 Solution 1 −4 fc = 4 kHz & T = =10 sec Fs 3 −4 ΩcT = 2π × 4×10 ×10 = 2.513 rad Ω T prewarping : ω = tan( c ) = 3.0762 rad c 2 sec 1 H (s) = ω (s +1)(s2 + s +1) 1 H(z) = ω 2 2 ⎛ 1 ⎛1− z −1 ⎞ ⎞⎛⎛ 1 ⎞ ⎛1− z−1 ⎞ 1 ⎛1− z−1 ⎞ ⎞ ⎜ ⎜ +1 ⎜⎜ ⎜ + ⎜ +1 ⎜ ⎜1+ z −1 ⎜⎜ ⎜1+ z−1 ω ⎜1+ z−1 ⎟ ⎝ c ⎝ ⎠ ⎠⎝⎝ c ⎠ ⎝ ⎠ c ⎝ ⎠ ⎠ www.getmyuni.com Example - 3 – cont.

(1+z−1) (1+z−1)2 H(z)= (1.3249 + 0.6751 z−1)(0.105 (1−z−1)2 + 0.3249 (1−z−2)+(1+z−1)2)

(1 + z −1 ) (1 + 2 z −1 + z −2 ) = 1 . 3249 (1 + 0.5095 z −1 ) ()1.4305 + 1.789 z −1 + 0.7806 z − 2

(1 + z −1 ) (1 + 2 z −1 + z −2 ) = × 1.3249 (1 + 0.5095 z −1 ) 1.4305 ()1 + 1.2506 z −1 + 0.5457 z − 2

(1 + z −1 ) (1 + 2 z −1 + z −2 ) = 0.52763 × × (1 + 0.5095 z −1 ) (1 + 1.2506 z −1 + 0.5457 z − 2 ) www.getmyuni.com Example - 3 – cont.

Filter Realization (Cascaded Realization)

0. 52763 x(n) X y(n) - 0.5095 2 T - 1.2506 T X X X - 0.5457 T X www.getmyuni.com Example - 4

¾ Using BZT method, design a digital filter meeting the specifications given by the following tolerance structure, |H(f)|

¾ assume a Butterworth characteristic for this 1 filter. 0.707

9 Solution 0.1 f (1) From the specifications, the prewarped frequencies are: 0.5 2 4 kHz

⎛ 2π ×500 ⎞ ω p = tan⎜ = 0.198912 ⎝ 2×8000 ⎠ ⎛ 2π × 2000 ⎞ ωs = tan⎜ =1 ⎝ 2×8000 ⎠ www.getmyuni.com Example - 4 – contd.

(2) De term ine the or der o f the pro to type ana logue Bu tterworth LPF us ing the foll owi ng relation, ⎛ 1 ⎞ ⎜ 2 −1 ⎟ ⎜ δ s As log ⎛ 10 ⎞ ⎜ 1 ⎟ ⎜ 10 −1 ⎟ log A ⎜ 2 −1⎟ ⎜ p ⎟ ⎜ 10 ⎟ (1− δ p ) 10 −1 N ≥ ⎝ ⎠ = ⎝ ⎠ ⎛ ω ⎞ ⎛ ω ⎞ 2× log⎜ s ⎟ 2× log⎜ s ⎟ ⎜ ⎟ ⎜ ⎟ ⎝ ω p ⎠ ⎝ ω p ⎠ 1 1 1 ⎛ 99 ⎞ 2 −1 = −1 = 99 , 2 −1 = 2 −1 =1 ⇒ log⎜ ⎟ =1.995635 δ s 0.01 (1−δ p ) ⎝ 1 ⎠ ⎛ ω ⎞ ⎛ 1 ⎞ 2×log⎜ s ⎟ = 2×log =1.402678 ⎜ ⎟ ⎜ ⎟ ⎝ ω p ⎠ ⎝ 0.198912 ⎠ 1.995635 N ≥ =1.423. Let N = 2 1.402678 www.getmyuni.com Example - 4 – contd.

(3) A 2 nd order B utt erworth anal ogue LPF h as th e s-plltfftiH()ibane transfer function, H(s), given by, 1 H (s) = s 2 + 2s +1 (4) For a denormalized LPF transfer function, substitute s s ω p 2 1 ω H (s) = = p 2 2 2 ⎛ ωs ⎞ s s + 2 sω p + ω p ⎜ ⎟ + 2 +1 ⎜ ⎟ ⎝ p ⎠ ω p (5) Applying the BZT, 2 ω p H (z) = H (s) ⎛ 1−z −1 ⎞ = s=⎜ ⎟ 2 ⎜ −1 ⎟ −1 −1 ⎝ 1+z ⎠ ⎛1− z ⎞ ⎛1− z ⎞ ⎜ + 2 ω ⎜ +ω 2 ⎜ −1 ⎟ p ⎜ −1 ⎟ p ⎝1+ z ⎠ ⎝1+ z ⎠ ω 2 ω 2 (1+ z−1) = p −1 2 −1 −1 2 −1 2 ()1− z + 2 p ()()()1− z 1+ z +ωp 1+ z www.getmyuni.com Example - 4 – contd.

ω 2 (1+ 2z−1 + z−2 ) H(z) = p −1 −2 −2 2 −1 −2 (1−2z + z )+ 2 ωp (1− z )+ωp (1+ 2z + z ) ω 2 (1+ 2z−1 + z −2 ) H(z) = p (1+ 2 ω +ω 2 ) + 2 (ω 2 −1)z−1 + (1− 2 ω +ω 2 )z−2 ω p p p p p ω Substituting the values of the parameters, 2 2 1+ 2 p + p =1.32087 , ω p −1= −0.96043 2 2 1− 2 ω p +ω p = 0.7582858 , ω p = 0.0395659 0.0395659 (1 + 2z −1 + z −2 ) H (z) = 1.32087 − 1.92086 z −1 + 0.7582858 z −2 www.getmyuni.com Example - 4 – contd.

2 Dividing top & buttom by (1+ 2 ω p + ω p ) = 1.32087 0.0029952995 (1 + 2z −1 + z −2 ) H (z) = 1 − 1.4542 z −1 + 0.57408 z −2 k a (6) Realization, x(n) 0 y(n) X X

-b1 T a1 X X

-b2 T a2 X X

where, k = 0.02995

a 0 = 1 , a1 = 2 , a 2 = 1

b1 = − 1.4542 , b2 = 0.57408