Loading documents preview...
Digital Signal Processing
Digital Filter Design
Copyright © 2005, S. K. Mitra
Digital Filter Design • Objective - Determination of a realizable transfer function G(z) approximating a given frequency response specification is an important step in the development of a digital filter • If an IIR filter is desired, G(z) should be a stable real rational function • Digital filter design is the process of deriving the transfer function G(z) 2
Copyright © 2005, S. K. Mitra
Digital Filter Specifications • Usually, either the magnitude and/or the phase (delay) response is specified for the design of digital filter for most applications • In some situations, the unit sample response or the step response may be specified • In most practical applications, the problem of interest is the development of a realizable approximation to a given magnitude response specification 3
Copyright © 2005, S. K. Mitra
Digital Filter Specifications • We discuss in this course only the magnitude approximation problem • There are four basic types of ideal filters with magnitude responses as shown below
4
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
5
• As the impulse response corresponding to each of these ideal filters is noncausal and of infinite length, these filters are not realizable • In practice, the magnitude response specifications of a digital filter in the passband and in the stopband are given with some acceptable tolerances • In addition, a transition band is specified between the passband and stopband Copyright © 2005, S. K. Mitra
Digital Filter Specifications j
• For example, the magnitude response G (e ) of a digital lowpass filter may be given as indicated below
6
Copyright © 2005, S. K. Mitra
Digital Filter Specifications • As indicated in the figure, in the passband, defined by 0 p , we require that j G (e ) 1 with an error p, i.e., j
1 p G (e ) 1 p ,
p
• In the stopband, defined by s , we j require that G (e ) 0 with an error s , i.e., j G (e ) s , s 7
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
8
• p - passband edge frequency • s - stopband edge frequency • p - peak ripple value in the passband • s - peak ripple value in the stopband • Since G (e j ) is a periodic function of , j G ( e ) of a real-coefficient digital and filter is an even function of • As a result, filter specifications are given only for the frequency range 0 Copyright © 2005, S. K. Mitra
Digital Filter Specifications • Specifications are often given in terms of j loss function A () 20 log10 G (e ) in dB • Peak passband ripple p 20 log10 (1 p ) dB • Minimum stopband attenuation s 20 log10 ( s ) dB 9
Copyright © 2005, S. K. Mitra
Digital Filter Specifications • Magnitude specifications may alternately be given in a normalized form as indicated below
10
Copyright © 2005, S. K. Mitra
Digital Filter Specifications • Here, the maximum value of the magnitude in the passband is assumed to be unity • 1 / 1 2 - Maximum passband deviation, given by the minimum value of the magnitude in the passband
• 1 - Maximum stopband magnitude A 11
Copyright © 2005, S. K. Mitra
Digital Filter Specifications • For the normalized specification, maximum value of the gain function or the minimum value of the loss function is 0 dB • Maximum passband attenuation 2 max 20 log10 1 dB • For p 1, it can be shown that max 20 log10 (1 2 p ) dB
12
Copyright © 2005, S. K. Mitra
Digital Filter Specifications
13
• In practice, passband edge frequency Fp and stopband edge frequency Fs are specified in Hz • For digital filter design, normalized bandedge frequencies need to be computed from specifications in Hz using p 2 Fp p 2 FpT FT FT s 2 Fs s 2 Fs T FT FT Copyright © 2005, S. K. Mitra
Digital Filter Specifications • Example - Let Fp 7 kHz, Fs 3 kHz, and FT 25 kHz • Then 2(7 103 ) p 0.56 3 25 10 2(3 103 ) s 0.24 3 25 10 14
Copyright © 2005, S. K. Mitra
Selection of Filter Type • The transfer function H(z) meeting the frequency response specifications should be a causal transfer function • For IIR digital filter design, the IIR transfer 1 function is a real rational function of z : 1
2
M
p0 p1z p2 z pM z H ( z) , M N 1 2 N d0 d1z d 2 z d N z
• H(z) must be a stable transfer function and must be of lowest order N for reduced 15 computational complexity
Copyright © 2005, S. K. Mitra
FIR filters • For FIR digital filter design, the FIR transfer function is a polynomial in z 1 with real coefficients: N
H ( z ) h[n] z n n 0
• For reduced computational complexity, degree N of H(z) must be as small as possible • If a linear phase is desired, the filter coefficients must satisfy the constraint: h[n] h[ N n] 16
Copyright © 2005, S. K. Mitra
Digital Filter Design: Basic Approaches • FIR filter design is based on a direct approximation of the specified magnitude response, with the often added requirement that the phase be linear • The design of an FIR filter of order N may be accomplished by finding either the length-(N+1) impulse response samples h[n] or the (N+1) samples of its frequency j response H (e ) 17
Copyright © 2005, S. K. Mitra
Digital Filter Design: Basic Approaches • Three commonly used approaches to FIR filter design (1) Windowed Fourier series approach (2) Frequency sampling approach (3) Computer-based optimization methods
18
Copyright © 2005, S. K. Mitra
Selection of Filter Type
19
• Advantages in using an FIR filter (1) Can be designed with exact linear phase, (2) Filter structure always stable with quantized coefficients • Disadvantages in using an FIR filter - Order of an FIR filter, in most cases, is considerably higher than the order of an equivalent IIR filter meeting the same specifications, and FIR filter has thus higher computational complexity Copyright © 2005, S. K. Mitra
Digital Filter Design: Basic Approaches • Most common approach to IIR filter design (1) Convert the digital filter specifications into an analog prototype lowpass filter specifications • (2) Determine the analog lowpass filter transfer function H a (s) • (3) Transform H a (s) into the desired digital transfer function G (z ) 20
Copyright © 2005, S. K. Mitra
Digital Filter Design: Basic Approaches
21
• This approach has been widely used for the following reasons: (1) Analog approximation techniques are highly advanced (2) They usually yield closed-form solutions (3) Extensive tables are available for analog filter design (4) Many applications require digital simulation of analog systems Copyright © 2005, S. K. Mitra
Digital Filter Design: Basic Approaches • An analog transfer function to be denoted as Pa ( s ) H a ( s) Da ( s )
22
where the subscript “a” specifically indicates the analog domain • A digital transfer function derived from H a (s) shall be denoted as P( z ) G( z) D( z ) Copyright © 2005, S. K. Mitra
Digital Filter Design: Basic Approaches • Basic idea behind the conversion of H a (s) into G (z ) is to apply a mapping from the s-domain to the z-domain so that essential properties of the analog frequency response are preserved • Thus mapping function should be such that – Imaginary ( j ) axis in the s-plane be
23
mapped onto the unit circle of the z-plane – A stable analog transfer function be mapped into a stable digital transfer function Copyright © 2005, S. K. Mitra
IIR Digital Filter Design: Bilinear Transformation Method • Bilinear transformation 1 1 z s 2 1 T 1 z • Above transformation maps a single point in the s-plane to a unique point in the z-plane and vice-versa • Relation between G(z) and Ha (s) is then given by G ( z ) Ha ( s ) 2 1 z 1 24
s
T 1 z 1
Copyright © 2005, S. K. Mitra
Bilinear Transformation • Digital filter design consists of 3 steps: (1) Develop the specifications of Ha (s) by applying the inverse bilinear transformation to specifications of G(z) (2) Design Ha (s) (3) Determine G(z) by applying bilinear transformation to Ha (s) • As a result, the parameter T has no effect on G(z) and T = 2 is chosen for convenience 25
Copyright © 2005, S. K. Mitra
Bilinear Transformation • Inverse bilinear transformation for T = 2 is 1 s z 1 s • For s o jo 2 2 (1 o ) jo 2 (1 o ) o z z 2 2 (1 o ) jo (1 o ) o • Thus,
26
o 0 z 1 o 0 z 1 o 0 z 1
Copyright © 2005, S. K. Mitra
Bilinear Transformation • Mapping of s-plane into the z-plane
27
Copyright © 2005, S. K. Mitra
Mapping of the bilinear transformation between s-plane and z-plane (after D. Ellis)
1 z 1 s 1 1 z
1 s z 1 s
Copyright © 2005, S. K. Mitra
Bilinear Transformation • For z e j with T = 2 we have j e j / 2 ( e j / 2 e j / 2 ) j 1 e j j / 2 j / 2 j / 2 1 e e (e e ) j 2 sin( / 2) j tan( / 2) 2 cos( / 2 ) or tan( / 2)
29
Copyright © 2005, S. K. Mitra
Bilinear Transformation • Mapping is highly nonlinear • Complete negative imaginary axis in the splane from to 0 is mapped into the lower half of the unit circle in the z-plane from z 1 to z 1 • Complete positive imaginary axis in the splane from 0 to is mapped into the upper half of the unit circle in the z-plane from z 1 to z 1 30
Copyright © 2005, S. K. Mitra
Bilinear Transformation • Nonlinear mapping introduces a distortion in the frequency axis called frequency warping • Effect of warping shown below
31
tan/2
Copyright © 2005, S. K. Mitra
Effect of bilinear transformation on a Lowpass filter
tan( / 2)
s
p
2 tan 1
H ( ) H a ()
p
s
Copyright © 2005, S. K. Mitra
Bilinear Transformation
33
• Steps in the design of a digital filter (1) Prewarp ( p , s ) to find their analog equivalents ( p , s ) (2) Design the analog filter H a (s) (3) Design the digital filter G(z) by applying bilinear transformation to H a (s) • Transformation can be used only to design digital filters with prescribed magnitude response with piecewise constant values • Transformation does not preserve phase response of analog filter Copyright © 2005, S. K. Mitra
Design of IIR Highpass, Bandpass, and Bandstop Digital Filters (1) Prewarp digital frequency specifications of desired digital filter GD (z ) to arrive at frequency specifications of analog filter H D (s) of same type (2) Convert frequency specifications of H D (s) into that of prototype analog lowpass filter H LP (s) 34
(3) Design analog lowpass filter H LP (s) Copyright © 2005, S. K. Mitra
Design of IIR Highpass, Bandpass, and Bandstop Digital Filters (4) Convert H LP (s) into H D (s) using inverse frequency transformation used in Step 2 (5) Design desired digital filter GD (z ) by applying bilinear transformation to H D (s)
35
Copyright © 2005, S. K. Mitra
IIR Highpass Digital Filter Design • Design of a Type 1 Chebyshev IIR digital highpass filter • Specifications: Fp 700 Hz, Fs 500 Hz, p 1 dB, s 32 dB, FT 2 kHz • Normalized angular bandedge frequencies
2 Fp
36
2 700 p 0.7 FT 2000 2 Fs 2 500 s 0.5 FT 2000 Copyright © 2005, S. K. Mitra
IIR Highpass Digital Filter Design • Prewarping these frequencies we get ˆ p tan( p / 2) 1.9626105 ˆ s tan( s / 2) 1.0 • For the prototype analog lowpass filter choose p 1 ˆp p • Using we get s 1.962105 ˆ • Analog lowpass filter specifications: p 1 , s 1.926105 , p 1dB, s 32 dB 37
Copyright © 2005, S. K. Mitra
IIR Highpass Digital Filter Design • MATLAB code fragments used for the design [N , Wn] = cheb1ord (1, 1.9626105, 1, 32, ’s’) [B, A] = cheby1(N , 1, Wn, ’s’); [BT, AT] = lp 2hp (B, A, 1.9626105); [nu m , d en] = bilinear(BT, AT, 0.5); 0
Gain, dB
-10 -20 -30 -40 -50
38
0
0.2
0.4
0.6 /
0.8
1 Copyright © 2005, S. K. Mitra
IIR Bandpass Digital Filter Design • Design of a Butterworth IIR digital bandpass filter • Specifications: p1 0.45 , p 2 0.65 , s1 0.3, s 2 0.75, p 1 dB, s 40 dB • Prewarping we get ˆ p1 tan( p1 / 2) 0.8540807 ˆ p 2 tan( p 2 / 2) 1.6318517
39
ˆ s1 tan( s1 / 2) 0.5095254 ˆ s 2 tan( s 2 / 2) 2.41421356 Copyright © 2005, S. K. Mitra
IIR Bandpass Digital Filter Design ˆ p2 ˆ p1 0.777771 • Width of passband Bw 2 ˆ ˆ p1 ˆ p 2 1.393733 o ˆ s1 ˆ s 2 1.23010325 ˆ o2 ˆ s1and ˆ s1 so that • We therefore modify ˆ s 2 exhibit geometric symmetry with 2 ˆ respect to o ˆ s1 0.5773031 • We set • For the prototype analog lowpass filter we choose p 1 40
Copyright © 2005, S. K. Mitra
IIR Bandpass Digital Filter Design ˆ o2 ˆ2 • Using p we get ˆ Bw
1.393733 0.3332788 s 2.3617627 0.5773031 0.777771
• Specifications of prototype analog Butterworth lowpass filter: p 1 , s 2.3617627 , p 1 dB, s 40 dB 41
Copyright © 2005, S. K. Mitra
IIR Bandpass Digital Filter Design • MATLAB code fragments used for the design [N , Wn] = bu ttord (1, 2.3617627, 1, 40, ’s’) [B, A] = bu tter(N , Wn, ’s’); [BT, AT] = lp 2bp (B, A, 1.1805647, 0.777771); [nu m , d en] = bilinear(BT, AT, 0.5); 0
Gain, dB
-10 -20 -30 -40 -50
42
0
0.2
0.4
0.6 /
0.8
1 Copyright © 2005, S. K. Mitra
IIR Bandstop Digital Filter Design • Design of an elliptic IIR digital bandstop filter • Specifications: s1 0.45 , s 2 0.65 , p1 0.3, p 2 0.75, p 1 dB, s 40 dB • Prewarping we get ˆ s 2 1.6318517, ˆ s1 0.8540806, ˆ p 2 2.4142136 ˆ p1 0.5095254, ˆ s2 ˆ s1 0.777771 • Width of stopband Bw
43
ˆ o2 ˆ s 2 ˆ s1 1.393733 ˆ p 2 ˆ p1 1.230103 ˆ o2 Copyright © 2005, S. K. Mitra
IIR Bandstop Digital Filter Design ˆ p1and ˆ p2 ˆ p1so that • We therefore modify exhibit geometric symmetry with respect to 2 ˆ o ˆ p1 0.577303 • We set
• For the prototype analog lowpass filter we choose s 1 ˆ Bw • Using s 2 we get 2 ˆ o ˆ 0.5095254 0.777771 p 0.4234126 1 . 393733 0 . 3332787 44
Copyright © 2005, S. K. Mitra
IIR Bandstop Digital Filter Design • MATLAB code fragments used for the design [N , Wn] = ellip ord (0.4234126, 1, 1, 40, ’s’); [B, A] = ellip(N , 1, 40, Wn, ’s’); [BT, AT] = lp 2bs(B, A, 1.1805647, 0.777771); [nu m , d en] = bilinear(BT, AT, 0.5); 0
Gain, dB
-10 -20 -30 -40 -50
45
0
0.2
0.4
0.6 /
0.8
1 Copyright © 2005, S. K. Mitra