Lecture 06: Design of Recursive Digital Filters
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 06: Design of Recursive Digital Filters John Chiverton School of Information Technology Mae Fah Luang University 1st Semester 2009/ 2552 Lecture Contents Introduction IIR Filter Design Pole-Zero Placement Method IIR Filter Design from Analogue Filters Summary Outline Introduction IIR Filter Design Pole-Zero Placement Method IIR Filter Design from Analogue Filters Summary What is a Digital Filter? Often used to remove some frequencies from a signal X(Ω) and to allow other frequencies to pass through to the output Y (Ω). | ) Ω ( H | Ω Low Pass Low Frequencies π Ω Output, Y( ) | ) Ω ( H | Band Pass Middle Frequencies π Ω Ω H( ), Linear Time Invariant System | ) Ω ( H | Ω High Pass π Ω Input, X( ) High Frequencies Recursive digital filters Linear Time Input, x[n] Output, y[n] Invariant System What is a Recursive digital filter? I \Recursive" comes from the word \to recur" Meaning: to repeat A recursive filter uses past output values (y[n − i]) for the calculation of the current output y[n]: I Recursive Filter Example y[n] = 0:5y[n − 1] + 0:5x[n]: A non-recursive filter only uses input values x[n − i]: I Non-recursive Filter Example y[n] = 0:5x[n − 1] + 0:5x[n]: Generalised Difference Equation Recall the generalised difference equation for causal LTI systems (see Lecture 02): N M X X a[k]y[n − k] = b[k]x[n − k] k=0 k=0 If a[0] = 1, this can then be changed to: M N X X y[n] = b[k]x[n − k] − a[k]y[n − k]: k=0 k=1 The Frequency Response (see Lecture 03) of such a system can be described by: M M P b[k] exp(−jkΩ) P b[k] exp(−jkΩ) H(Ω) = k=0 = k=0 : N N exp(0) + P a[k] exp(−jkΩ) 1 + P a[k] exp(−jkΩ) k=1 k=1 z-transform Representation Fourier based frequency representation: M P b[k] exp(−jkΩ) H(Ω) = k=0 : N 1 + P a[k] exp(−jkΩ) k=1 Can also be represented in the z-domain (z-transform): M P b[k]z−k H(z) = k=0 : N 1 + P a[k]z−k k=1 Both describe a type of frequency response of the system. Comparison of IIR and FIR System Structures The system structure of an IIR filter demonstrates the feedback of the output into the input again. FIR Filter IIR Filter x[n]x[n−1] x[n−2] x[n−3] x[n]x[n−1] x[n−2] x[n−3] TTT TTT x1/4 x1/4 x1/4 x1/4 x1/4 x1/4 x1/4 x1/4 + x(−1/10) + y[n] y[n] y[n−1] T y[n] = y[n] = 1 (x[n] + x[n − 1] + x[n − 2] + x[n − 3]) (x[n] + x[n − 1] + x[n − 2] + x[n − 3]) 4 1 − y[n − 1] 10 Unit Delay in the z-plane A single z−1 is the same as a unit delay, \T" in a system diagram. x[n]x[n−1] x[n−2] x[n−3] TTT x1/4 x1/4 x1/4 x1/4 x(−1/10) + y[n] y[n−1] T Unit Delay in the z-plane A single z−1 is the same as a unit delay, \T" in a system diagram. x[n]x[n−1] x[n−2] x[n−3] z−1 z−1 z−1 x1/4 x1/4 x1/4 x1/4 x(−1/10) + −1 y[n] y[n−1] z Recursive Digital Filters Recursive digital filters are often known as I Infinite Impulse Response (IIR) Filters as the impulse response of an IIR filter often has an infinite number of coefficients. IIR Filters I Require fewer calculations than FIR filters. I ) Faster response to the input signal, I and ) shorter frequency response transition width. However! I IIR filters can become unstable. I ) Need to think carefully about stability when designing IIR Filters. Outline Introduction IIR Filter Design Pole-Zero Placement Method IIR Filter Design from Analogue Filters Summary IIR Filter Design Overview 1. Filter specification 2. Coefficient calculations 3. Convert transfer function to suitable filter structure 4. Error analysis 5. Implementation Filter Specification Frequency domain parameters - for filter description. 1+δ p passband ripple 1 1−δ p I Stop band - high attenuation I Pass band - low attenuation (gain≈1) δ s Stop Band Pass Band Stop Band Transition Width TransitionWidth Ω Ω s1 p1 Ωp2 Ωs2 Filter Specification Frequency domain parameters - for filter description. 1+δ p passband ripple 1 δ 1− p I δp passband ripple I δs stopband ripple I Ωs1 lower stop band edge frequency I Ωp1 lower pass band edge frequency I Ωp2 upper pass band δ s edge frequency I Ωs2 upper stop band Stop Band Pass Band Stop Band edge frequency Transition Width TransitionWidth Ω Ω s1 p1 Ωp2 Ωs2 Outline Introduction IIR Filter Design Pole-Zero Placement Method IIR Filter Design from Analogue Filters Summary Pole-Zero Placement Method A filter can be described in the z-plane with Poles and Zeros (Lecture 04): Y (z) K(z − z )(z − z )(z − z )::: zeros H(z) = = 1 2 3 = X(z) (z − p1)(z − p2)(z − p3)::: poles I Poles located at: z1, z2, z3, ... I Zeros located at: p1, p2, p3, ... Pole-Zero Placement Method A filter can be described in the z-plane with Poles and Zeros (Lecture 04): Y (z) K(z − z )(z − z )(z − z )::: zeros H(z) = = 1 2 3 = X(z) (z − p1)(z − p2)(z − p3)::: poles I Poles (X) close to unit circle I make large peaks I Zeros (O) close to unit circle I make troughs or minima Pole-Zero Placement Method Angle of poles and zeros on z-plane correspond to frequencies that can be used for filter specification. I A bandpass filter, with centre frequency Ω0 radians can have two poles at 1 ±Ω0 radians in the z-plane . I Complete attenuation at two frequencies, Ωr1 = 0 radians and Ωr2 = π radians can have two zeros at0 and π radians. I The radius of the poles can be | ) calculated with: Ω ( H | r =∼ 1 − Ωcf or Band Pass Ω r =∼ 1 − bw 2 Ω Ω0−Ωcf Ω0+Ωcf π where Ωbw = 2Ωcf is the -3dB 0 Ω0 bandwidth of the filter. (DC) 1 Complex conjugate pair to make real filter coefficients, when Ω0 6=0 or Ω0 6=π radians (on the real line). Pole-Zero Placement Method: Example Q. Design a bandpass filter using the Pole-zero placement method with: I centre frequency at Ω0 = π=2; I a bandwidth of Ωbw = π=8; I complete attenuation at Ωr1 = 0 and Ωr2 = π; I and peak unity pass band gain. A. Bandpass filter has x2 poles at ±Ω0 = ±π=2 radians. zeros H(z) = K ) (z − r exp(jπ=2))(z − r exp(−jπ=2)) The radii of the poles are given by: Ωbw π=8 r =∼ 1 − = 1 − = 0:80365; 2 2 and the zeros are at Ωr1 = 0 and Ωr2 = π, so that (z − exp(jΩ ))(z − exp(jΩ )) H(z) = K r1 r2 : (z − 0:80365 exp(jπ=2))(z − 0:80365 exp(−jπ=2)) Pole-Zero Placement Method: Example cont'd. As I exp(Ωr1) = exp(j0) = cos(0) + j sin(0) = 1 − j0 = 1 I exp(Ωr2) = exp(jπ) = cos(π) + j sin(π) = −1 + j0 = −1, then the transfer function becomes: (z − 1)(z + 1) H(z) = K : (z − 0:80365 exp(jπ=2))(z − 0:80365 exp(−jπ=2)) Using Euler's identity, I exp(jπ=2) = cos(π=2) + j sin(π=2) = +j I and exp(jπ=2) = cos(π=2) − j sin(π=2) = −j; so that (z − 1)(z + 1) H(z) = K : (z − 0:80365j)(z + 0:80365j) the pole zero diagram can then be plotted. Pole-Zero Placement Method: Example cont'd. Y (z) Recall that H(z) = X(z) , Y (z) (z − 1)(z + 1) z2 − 1 H(z) = = K = K : X(z) (z − 0:80365j)(z + 0:80365j) z2 + 0:64585 Then Y (z)(z2 + 0:64585) = X(z)K(z2 − 1): Remembering that each z−1 is a unit delay, so that each z is a unit advance, then the difference equation is: y[n + 2] + 0:64585y[n] = K(x[n + 2] − x[n]) which can be made causal by making n = n − 2 so that y[n] + 0:64585y[n − 2] = K(x[n] − x[n − 2]): K is not known, but can be used to make the peak pass band gain to be unity. Pole-Zero Placement Method: Example cont'd. The frequency response of the filter can be determined from the difference equation: y[n] + 0:64585y[n − 2] = K(x[n] − x[n − 2]); in combination with: M P b[k] exp(−jkΩ) Magnitude Frequency Response H(Ω) = k=0 : N 1 + P a[k] exp(−jkΩ) k=1 So that (using Euler's identity): K(1 − cos(2Ω) + j sin(2Ω)) H(Ω) = 1 + 0:64585(cos(2Ω) − j sin(2Ω)) which has magnitude frequency response: where K = 0:17708. K((1 − cos(2Ω))2 + sin2(2Ω)) Mag(H(Ω))2 = : (1 + 0:64585 cos(2Ω))2 + sin2(2Ω) Pole-Zero Placement Method: Example cont'd. Relating the digital frequencies for previous example to actual frequencies... If the sampling frequency is fs = 500Hz, the sampling frequency corresponds to Ω = 2π, therefore the filter parameters become: I centre frequency at Ω0 = π=2, so actual centre frequency π=2 f0 = 2π fs = 125Hz; I a bandwidth of Ωbw = π=8, so actual bandwidth fbw = 31:25Hz; I complete attenuation at Ωr1 = 0 and Ωr2 = π, with actual π frequencies fr1 = 0Hz and fr2 = 2π 500 = 250Hz.