Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Chapter 7 FIR Filter Design Techniques. 2 Design of FIR Filters by Windowing (1)  We have discussed techniques for the design of discrete-time IIR.

Similar presentations


Presentation on theme: "1 Chapter 7 FIR Filter Design Techniques. 2 Design of FIR Filters by Windowing (1)  We have discussed techniques for the design of discrete-time IIR."— Presentation transcript:

1 1 Chapter 7 FIR Filter Design Techniques

2 2 Design of FIR Filters by Windowing (1)  We have discussed techniques for the design of discrete-time IIR filters based on the transformations of continuous-time IIR systems.  In contrast, FIR design filters are almost entirely restricted to discrete-time implementations. The design techniques for filters are based on directly approximating the desired frequency response of the discrete-time system.  Most techniques for approximating the magnitude response of an FIR system assume a linear phase constraint, thereby avoiding the problem of spectrum factorization that complicates the direct design of IIR filters.  The simplest method for FIR design is called the Window method.

3 3 Design of FIR Filters by Windowing (2)  We consider an ideal desired frequency response that can be represented as In turn, the impulse response sequence can be expressed as  Many idealized systems are defined by piecewise-constant or piecewise-functional frequency responses with discontinuities at the boundaries between bands. As a result, these systems have impulse responses that are noncausal and infinitely long.  The most straightforward approach to obtaining a causal FIR approximation to such systems is to truncate the ideal response.

4 4 Design of FIR Filters by Windowing (3)  The simplest way to obtain a causal FIR filter from h d [n] is to define a new system with impulse response h[n] given by  As can be seen in the LPF example (we discussed it in Ch. 2), there is the Gibbs phenomenon.  More generally, we can represent h[n] as the product of the desired impulse response and a finite-duration “window” w[n], where the window for the above example is

5 5 Design of FIR Filters by Windowing (4)

6 6 Design of FIR Filters by Windowing (5)  From the modulation theorem (or windowing theorem) That is, H(e j  ) is the periodic convolution of H d (e j  ) and W(e j  ). Thus, H(e j  ) will be a smeared version of H d (e j  ).

7 7 Design of FIR Filters by Windowing (6)  If W(e j  ) is concentrated in a narrowband of frequencies around  =0, then H(e j  ) will look like H d (e j  ), except where H d (e j  ) changes very abruptly.  The choice of the window is to have w[n] as short as possible in duration, so as to minimize computation in the implementation of the filter, while having W(e j  ) approximate an impulse. Clearly, there are conflicting requirements.  For the rectangular window, the side lobes are large, and as M increases, the peak amplitudes of the main lobe and the side lobes grow in a manner such that the area under lobe is a constant while the width of each lobe decreases with M.

8 8 Design of FIR Filters by Windowing (7)  Frequency response of rectangular window  Next, we will see that, by tapering the window smoothly to zero at each end, the height of the side lobes can be reduced at the expense of a wider main lobes.

9 9 Properties of Commonly Used Windows (1)  Commonly used windows Rectangular Bartlett (triangular) Hanning Hamming Blackman

10 10 Properties of Commonly Used Windows (2)  Commonly used windows (Note that the windows are plotted as functions of a continuous variable. The actual window sequence is defined only at integer value of n.)

11 11 Properties of Commonly Used Windows (3)  Commonly used windows – magnitude response M=50 Rectangular Peak sidelobe level: –13 dB Approx. width of main lobe: 4  /(M+1) Bartlett Peak sidelobe level: –25 dB Approx. width of main lobe: 8  /M

12 12 Properties of Commonly Used Windows (4) Hanning Peak sidelobe level: –31 dB Approx. width of main lobe: 8  /M Hamming Peak sidelobe level: –41 dB Approx. width of main lobe: 8  /M Blackman Peak sidelobe level: –57 dB Approx. width of main lobe: 12  /M

13 13 Incorporation of Generalized Linear Phase  All the windows have the property that i.e., they are symmetric about M/2.  If the desired impulse response is also symmetric about M/2, i.e., if h d [n]= h d [M – n], then the windowed impulse response will also have that symmetry, and the resulting frequency response will have a generalized linear phase; that is where A e (e j  ) is real and is an even function of . Properties of Commonly Used Windows (5)

14 14 Incorporation of Generalized Linear Phase (cont.)  If the desired impulse response is anti-symmetric about M/2, i.e., if h d [n]= –h d [M – n], then the windowed impulse response will also be anti-symmetry about M/2, and the resulting frequency response will have a generalized linear phase; that is where A o (e j  ) is real and is an odd function of . Properties of Commonly Used Windows (6)

15 15  The trade-off between the main lobe width and side-lobe area can be quantified by seeking the window function that is maximally concentrated around  =0 in the frequency domain. This was considered and the solution shows that the filter design involves prolate spheroidal wave functions and thus is difficult.  However, Kaiser found that a near-optimal window could be formed using the zeroth-order modified Bessel function of the first kind [I 0 (·)], a function that is much easier to compute.  The Kaiser window is defined as where  =M/2. The Kaiser Window Filter Design Method (1)

16 16  The Kaiser window has two parameters: the window length (M+1) and a shape parameter . By adjusting (M+1) and , the side-lobe amplitude and main-lobe width can be properly designed.   =0 becomes the rectangular window. Increasing  will reduce the side-lobe level, but the main-lobe becomes wider.  Increasing M while holding  constant causes the main lobe to reduce in width, but does not affect the amplitude of the side lobes.  Through extensive numerical experiments, Kaiser obtained a pair of formulas to predict the values of  and  needed to meet a given filter specification. The Kaiser Window Filter Design Method (2)

17 17 The Kaiser Window Filter Design Method (3)

18 18 Relationship of the Kaiser Window to Other Windows

19 19 Window Related Matlab Functions (Signal Processing Toolbox) WINDOW - Window function gateway WINDOW(@WNAME,N) returns an N-point window of type specified by the function handle @WNAME in a column vector. @WNAME can be any valid window function name, for example: @bartlett - Bartlett window. @blackman - Blackman window. @hamming - Hamming window. @hann - Hann window. @kaiser - Kaiser window. @rectwin - Rectangular window. @triang - Triangular window.

20 20 W = BARTLETT(N) returns the N-point Bartlett window. W=BLACKMAN(N) returns the N-point symmetric Blackman window in a column vector. W=HAMMING(N) returns the N-point symmetric Hamming window in a column vector. W=HANN(N) returns the N-point symmetric Hann window in a column vector. W = RECTWIN(N) returns the N-point rectangular window. W = TRIANG(N) returns the N-point triangular window. W = KAISER(N,beta) returns the BETA-valued N-point Kaiser window. Window Related Matlab Functions (Signal Processing Toolbox)

21 21 fir1 - Window based FIR filter design - low, high, band, stop, multi. kaiserord - Kaiser window design based filter order estimation. Also, the following two functions are available at the standard “Specialized math functions”. BESSELI Modified Bessel function of the first kind. I = BESSELI(NU,Z) is the modified Bessel function of the first kind, I_nu(Z). For more functions related to window and filter design, use “help signal”. For detailed information for each function, use “help func_name”. FIR Design Related Matlab Functions (Signal Processing Toolbox)

22 22 The Kaiser Window Filter Design Method (4) Note that, in the Kaiser window design, the passband and the stopband have the same error bound .

23 23  Defining A = – 20log 10  Kaiser determined empirically that the value of  is given by  When the transition bandwidth is  =  s –  p, M must satisfy This equation predicts M to within  2 over a wide range of values of  and  The Kaiser Window Filter Design Method (5)

24 24 LPF Design Example [  1 =0.01,  2 =0.001,  p  s   ]  Step 1: because the Kaiser window assume the same error bound for the passband and stopband, we let  = min[  1  2 ]=0.001.  Step 2: The cutoff frequency of the underlying ideal LPF is  c  = (  p   s   Step 3: Determine A and . A = – 20log 10  dB,  =  p  –  p  Then we can obtain  = 5.653, M =37.  Step 4: The impulse response of the filter is obtained as (  =M/2) The Kaiser Window Filter Design Method (6) Ideal LPF window

25 25 LPF Design Example [  1 =0.01,  2 =0.001,  p  s   ] (cont.)  Since M is an odd integer, the resulting linear-phase system would be of type II ( H(e j  ) is zero at  ).  The approximation error function is defined as (note that the error is not defined in the transition region)  In this design example, the peak approximation error is slightly greater than  =0.001. Increasing M to 38 results in a type I filter for which  =0.0008.  It is not necessary to plot the phase and group delay, because the phase is precisely linear and the delay is M/2 samples. The Kaiser Window Filter Design Method (7)

26 26 LPF Design Example [  1 =0.01,  2 =0.001,  p  s   ] (cont.) The Kaiser Window Filter Design Method (8)

27 27 HPF Design Example [  1 =  2 =0.021,  s  p   ]  The frequency response of an ideal HPF is and the corresponding impulse response is  The HPF impulse response after applying the Kaiser window is The Kaiser Window Filter Design Method (9)

28 28 HPF Design Example [  1 =  2 =0.021,  s  p   ]  Using the Kaiser’s formula, we obtain that  =2.6, M=24. The cutoff frequency of the ideal HPF is  c  = (  p   p   The actual approximation error of this type I filter is  =0.0213.  If we increase M to 25 and keep  unchanged (as we did in the LPF design), the frequency response becomes highly unsatisfactory because the type II filter has a zero at . Type II FIR linear-phase systems are generally not appropriate approximation for the either highpass or bandstop filters.  Increasing M to 26 will result in type I filter with narrower transition region, and will satisfy the design requirement. The Kaiser Window Filter Design Method (10)

29 29 HPF Design Example [  1 =  2 =0.021,  s  p   ] (cont.) M=24 The Kaiser Window Filter Design Method (11)

30 30 HPF Design Example [  1 =  2 =0.021,  s  p   ] (cont.) M=25 The Kaiser Window Filter Design Method (12)

31 31 The Kaiser Window Filter Design Method (13) Multiband filter (cont.)  If such a magnitude function is multiplied by a linear phase factor e –j  M/2, the corresponding ideal impulse response is where N mb is the number of bands and.  If h mb [n] is multiplied by a Kaiser window, the type of approximations we have observed at the single discontinuity of the lowpass and highpass systems will occur at each of the discontinuities. The approximation error will be scaled by the size of the jump.

32 32 Discrete-Time Differentiators  As we discussed before, the discrete-time differentiator system has a frequency response ( j  /T ) for – .  For an ideal discrete-time differentiator with a linear phase, the appropriate frequency response is (the factor of 1/T is omitted)  The corresponding ideal impulse response is  If h diff [n] is multiplied by a symmetric window of length (M+1), then it is easy to show that h[n]= –h[M–n]. The resulting system is either type III or type IV general linear-phase system. The Kaiser Window Filter Design Method (14)

33 33 Discrete-Time Differentiators – Design Example using type III  Suppose M=10,  =2.4. Type III does not provide good magnitude linearity because of the zero at . The Kaiser Window Filter Design Method (15)

34 34 The Kaiser Window Filter Design Method (16) Discrete-Time Differentiators – Design Example using type IV  Suppose M=5,  =2.4. Type IV achieves much better approximations to the amplitude function.  This type of system generates a non-integer time delay.

35 35 Optimum Approximation Criterion (1)  We have discussed design of FIR filters by windowing, which is straightforward and is quite general.  However, we often wish to design a filter that is the BEST that can be achieved for a given value of M.  What is the criterion? It is meaningless to discuss the best solution without an approximation criterion.  For example, if the criterion is to minimize the mean square error then, the following rectangular window is the best approximation.

36 36 Optimum Approximation Criterion (2)  However, the window methods generally have two problems:  Adverse behavior at discontinuities of H(e j  ); the error usually becomes smaller for frequencies away from the discontinuity (over-specified at those frequencies).  It does not permit individual control over approximation error in different bands (over-specified over some bands).  For many applications, better filters result from a minimax strategy (minimization of the maximum errors) or a frequency-weighted criterion.  Approximation error is spread out uniformly in frequency  Individual control of approximation error over different bands Such criterion avoids the abovementioned over-specifications.

37 37 Optimum Approximation Criterion (3)  We consider a particularly effective and widely used algorithmic procedure for the design of FIR filters with a generalized linear phase.  We consider only type I filters in detail, and examples for type II filters are also shown. We can understand how the method can be extended to other types of filters.  We first consider a zero-phase filter (this filter can be made causal by inserting a proper delay), h e [n]= h e [–n] and the corresponding frequency response is ( L = M/2 is an integer)

38 38 Optimum Approximation Criterion (4)  The frequency response can be rewritten as Therefore, it is a real, even, and periodic function of .  A causal system can be obtained from h e [n] by delaying it by L = M/2 samples; i.e, h[n]= h e [n – M/2] = h[M–n] and the corresponding frequency response is

39 39 Optimum Approximation Criterion (5)  A tolerance scheme for an approximation to a LPF with a real function A e (e j  ).  Some of the parameters L,  1,  2,  p, and  s are fixed and an iterative procedure is used to obtain optimum adjustment of the remaining parameters.

40 40 Optimum Approximation Criterion (6)  There are several methods for FIR filter design. The Parks- McClellan algorithm (Remez algorithm) has become the dominant method for optimum design of FIR filters. This is because it is the most flexible and the most computationally efficient. We will discuss only that algorithm.  The Parks-McClellan algorithm is based on reformulating the filter design problem as a problem in polynomial approximation.  We note that the term cos(  n) in A e (e j  ) can be expressed as a sum of powers of  in the form cos(  n) =T n (cos  ) where T n (x) = cos(ncos -1 x) is the nth-order Chebyshev polynomial.

41 41 Chebyshev Polynomial  Chebyshev polynomial V n (x) is an nth polynomial of x.

42 42 Optimum Approximation Criterion (7)  Therefore, A e (e j  ) can be expressed as an Lth-order polynomial in cos  namely where

43 43 Optimum Approximation Criterion (8)  Define an approximation error function W(  ) : weighting function H d (e j  ) : desired frequency response A e (e j  ) : approximation function These functions are defined only over closed subintervals (e.g., passband and stopband) of 0 ≤  ≤ .  For example, the weighting function and desired frequency response of an LPF are (K=  1 /  2 )

44 44 Optimum Approximation Criterion (9)  Note that, with weighting, the maximum weighted absolute approximation error is  =  2 in both bands. Typical frequency response. Weighted error.

45 45 Optimum Approximation Criterion (10) The Minimax Criterion  The particular criterion used in this design procedure is the so- called minimax or Chebyshev criterion, where, with the frequency intervals of interest (the passband and stopband for an LPF), we seek a frequency response A e (e j  ) that minimizes the maximum weighted approximation error; i.e., where F is the closed subset of 0 ≤  ≤  e.g., passband and stopband for an LPF).

46 46 Optimum Approximation Criterion (11) Alternation Theorem  Let F P denote the closed subset consisting of the disjoint union of closed subset of the real axis x. Then is an rth-order polynomial. Also, D P (x) denotes a given desired function of x that is continuous on F P. W P (x) is a positive function, continuous on F P, and E P (x) = W P (x)[D P (x) – P(x) ] is the weighted error. The maximum error is defined as A necessary and sufficient condition that P(x) be the unique rth- order polynomial that minimizes ||E|| is that E P (x) exhibit at least (r+2) alternations.

47 47 Optimum Approximation Criterion (11)  (r +2) alternations means… there must exist at least (r + 2) values x i in F P such that x 1 < x 2 < …< x r+2 and such that E P (x i )= – E P (x i+1 )=  ||E|| for i=1, 2,…, r +1.  Example … which one satisfies the alternation theorem (r =5)?

48 48 Optimal Type I Lowpass Filters (1)  For type I filters, the polynomial P(x) is the cosine polynomial A e (e j  ) with the transformation of variable x=cos  and r = L: D P (x) and W P (x) become and respectively, and the weighted approximation error is

49 49 Optimal Type I Lowpass Filters (2)  Equivalent polynomial approximation function as a function of x=cos .

50 50 Optimal Type I Lowpass Filters (3) Properties  The maximum possible number of alternations of the error is L+3. An Lth-degree polynomial can have at most (L–1) points with zero slope in an open interval, the maximum possible number of locations for alternations are those plus 4 band edges. Even P(x) may not have zero-slope at x = 1 and x = –1, P(cos  ) always have zero slope at  =0 and .  Alternations will always occur at  p and  s.  All points with zero slope inside the passband and all points with zero slope inside the stopband will correspond to alternations. That is, the filter will be equiripple, except possibly at  =0 and .

51 51 Optimal Type I Lowpass Filters (4)  Possible optimum LPF approximations for L=7. L+3 alternations (extraripple case) L+2 alternations (extrenum at  ) L+2 alternations (extrenum at  =0) L+2 alternations (extrenum at  =0 and  )

52 52 Optimal Type I Lowpass Filters (5)  Illustrations supporting the second and third properties

53 53 Optimal Type II Lowpass Filters (1)  For type II filters, the filter length (M+1) is even, with the symmetric property h[n]= h[M – n] Therefore, the frequency response H(e j  ) can be expressed in the form  Let b[n]=2h[(M+1)/2 –n], n=1, 2, …, (M+1)/2, then

54 54 Optimal Type II Lowpass Filters (2)  Derivation memo (see Problem 7.52) Using the trigonometric identity cos  cos  = ½ cos(  +  ) + ½ cos(  –  ) we get

55 55 Optimal Type II Lowpass Filters (3)  Derivation memo (cont.) This will be equal if we let

56 56 Optimal Type II Lowpass Filters (4) Therefore, Consequently, type II filter design is a different polynomial approximation problem than type I filter design. Type III and type IV filters can be considered similarly.

57 57 The Parks-McClellan Algorithm (1)  The alternation theorem gives necessary and sufficient conditions on the error for optimality in the Chebyshev or minimax sense. Although the theorem does not state explicitly how to find the optimum filter, the conditions that are presented serve as the basis for an efficient algorithm for finding it. We consider type I LPF design herein.  From the alternation theorem, the optimum filter A e (e j  ) will satisfy the set of equations We can write these equations as

58 58 The Parks-McClellan Algorithm (2)  In matrix form, it becomes (x i =cos  i )  This set of equations serves as the basis for an iterative algorithm for finding the optimum A e (e j  ). The procedure begins by guessing a set of alternation frequencies  i, i=1, 2, …, (L+2).  Note that  p and  s are fixed and are necessary members of the set of alternation frequencies. Specifically, if  l =  p, then  l+1 =  s.

59 59 The Parks-McClellan Algorithm (3)  The above set of equations could be solved for the set of coefficients a k and .  A more efficient alternative is to use polynomial interpolation. In particular, Parks and McClellan found that, for the given set of the extremal frequencies (x i =cos  i ), That is, A e (e j  ) has values 1  K  if 0 ≤  i ≤  p and  if  s ≤  ≤ .

60 60 The Parks-McClellan Algorithm (4)  Now, since A e (e j  ) is known to be an Lth-order trigonometric polynomial, we can interpolate a trigonometric polynomial through (L+1) of the (L+2) known values E(  i ) [or, equivalently, A e (e j  )].

61 61 The Parks-McClellan Algorithm (5)  Parks and McClellan used the Lagrange interpolation formula to obtain (x=cos , x i =cos  i ), with  If |E(  )| ≤  for all  in the passband and stopband, then the optimum approximation has been found. Otherwise we must find a new set of extremal frequencies.

62 62 The Parks-McClellan Algorithm (6)  For the LPF shown at the previous figure,  was too small. The extremal frequencies are exchanged for a completely new set defined by the (L+2) largest peaks of the error curve (marked with x in the figure).  As before,  p and  s must be selected as extremal frequencies. Also recall that there are at most (L – 1) local minima and maxima in the open interval 0 <  <  p and  s <  < . The remaining extrema can be either  =0 and . If there is a maximum of the error function at both 0 and , then the frequency at which the greatest error occurs is taken as the new estimate of the frequency of the remaining extremum.  The circle – computing the value of , fitting a polynomial to the assumed error peaks, and then locating the actual error peaks – is repeating until  does not change from its previous value by more than a prescribed small amount.

63 63 The Parks-McClellan Algorithm (7)

64 64 Characteristics of Optimum FIR filters (1)  For different types of filters (e.g., M=9 and M=10), it is possible that a shorter filter is better. For the same type of filters (e.g., M=8 and M=10), a longer filter always provides better or identical performance (in this case, the two filters are identical).  Illustration of the dependence of passband and stopband error on cutoff frequency for optimal approximation of a LPF (K=1,  s –  p =0.2  ).

65 65 Characteristics of Optimum FIR filters (2)  The estimate of M for equiripple lowpass approximation is where  =  s –  p. Compared with the design formula for the Kaiser window method for the comparable case (  1 =  2 =  ), the optimal approximations provide about 5 dB better approximation error for a given value of M. Another important advantage of equiripple filters is that  1 and  2 need not be equal, as must be the case for the window method.

66 66 kaiser Kaiser window kaiserord FIR order estimator of Kaiser window method remez Parks-McClellan optimal equiripple FIR filter design remezord FIR order estimator of Parks-McClellan optimal approximation method MatLab Functions

67 67 Design Examples - LPF (1) LPF Design Example [  1 =0.01,  2 =0.001, (K=10),  p  s   ] estimate of M=25.34  M=26, result: maximum error in the stopband = 0.00116: unsatisfied.

68 68 Design Examples - LPF (2) LPF Design Example (cont.) [  1 =0.01,  2 =0.001, (K=10),  p  s   ] increase M to M=27 [compare: M=38 required at Kaiser window] result: maximum error in the stopband = 0.00092: satisfactory.

69 69 Design Examples - BPF (1)  For an LPF filter, there are only two approximation bands. However, bandpass and bandstop filters require three approximation bands.  The alternation theorem does not assume any limit on the number of disjoint approximation intervals. Therefore, the minimum number of alternations is still (L+2). However, multiband filters can have more than (L+3) alternations, because there are more band edges.  Some of the statements so far are not true in the multiband case. For example, it is not necessary for all the local minima or maxima of A e (e j  ) to lie inside the approximation intervals. Local extrema can occur in the transition regions, and the approximation need not be equiripple in the approximation regions.

70 70 Design Examples - BPF (2) BPF Design Example M = 74 L = M/2 = 37 The alternation theorem requires at least L+2 = 39 alternations.

71 71 Design Examples - BPF (3)

72 72 Design Examples - BPF (4)  The approximations we obtained are optimal in the sense of the alternation theorem, but they would probably be unacceptable in a filtering application. In general, there is no guarantee that the transition region of a multiband filter will be monotonic, because the Parks-McClellan algorithm leaves these regions completely unconstrained.  When this kind of response results for a particularly choice of the filter parameters, acceptable transition regions can usually be obtained by systematically changing one or more of the band edge frequencies, the impulse-response length, or the error- weighting function and redesigning the filter.

73 73 Comments on IIR and FIR Filters  We have discussed design methods for linear time-invariant discrete-time systems.  What type of system is the best, IIR or FIR?  Why give so many different design methods?  Which method yields the best results? It is generally not possible to give a precise answer.  IIR: + closed-form design formulas - noniterative IIR filter design. + efficient – usually less order is required. – only the magnitude response can be specified.  FIR: + precise generalized linear phase. – no closed-form design formula - some iterations may be necessary to meet a given specification.

74 74 Homework 7.6 7.7 7.16 7.34 (a)


Download ppt "1 Chapter 7 FIR Filter Design Techniques. 2 Design of FIR Filters by Windowing (1)  We have discussed techniques for the design of discrete-time IIR."

Similar presentations


Ads by Google