Presentation is loading. Please wait.

Presentation is loading. Please wait.

FIR Digital Filter Design

Similar presentations


Presentation on theme: "FIR Digital Filter Design"— Presentation transcript:

1 FIR Digital Filter Design
Chapter 10 FIR Digital Filter Design

2 §10.2.1 Least Integral-Squared Error Design of FIR Filters
Let Hd(e jω) denote the desired frequency response Since Hd(e jω) is a periodic function of ω with a period 2π,it can be expressed as a Fourier series where

3 §10.2.1 Least Integral-Squared Error Design of FIR Filters
In general Hd(e jω) is piecewise constant with sharp transitions between bands In which case {hd[n]} is of infinite length and noncausal Objective – Find a finite-duration {ht[n]} of length 2M+1 whose DTFT Ht(e jω) approximates the desired DTFT Hd(e jω) in some sence

4 §10.2.1 Least Integral-Squared Error Design of FIR Filters
Commonly used approximation criterion – Minimize the integral-squared error where

5 §10.2.1 Least Integral-Squared Error Design of FIR Filters
Using Parseval’s relation we can write It follows from the above that Φis minimum when ht[n]= hd[n] for -M≤n≤M Best finite-length approximation to ideal infinite-length impulse response in the mean-square sense is obtained by truncation

6 §10.2.1 Least Integral-Squared Error Design of FIR Filters
A causal FIR filter with an impulse response h[n] can be derived from ht[n] by delaying: h[n]=ht[n-M] The causal FIR filter h[n] has the same magnitude response as ht[n] and its phase response has a linear phase shift of ωM radians with respect to that of ht[n]

7 §10.2.2 Impulse Responses of Ideal Filters
Ideal lowpass filter – Ideal highpass filter –

8 §10.2.2 Impulse Responses of Ideal Filters
Ideal bandpass filter –

9 §10.2.2 Impulse Responses of Ideal Filters
Ideal bandstop filter –

10 §10.2.2 Impulse Responses of Ideal Filters
Ideal multiband filter –

11 §10.2.2 Impulse Responses of Ideal Filters
Ideal discrete-time Hilbert transformer –

12 §10.2.2 Impulse Responses of Ideal Filters
Ideal discrete-time differentiator –

13 § Gibbs Phenomenon Gibbs phenomenon - Oscillatory behavior in the magnitude responses of causal FIR filters obtained by truncating the impulse response coefficients of ideal filters

14 § Gibbs Phenomenon As can be seen, as the length of the lowpass filter is increased, the number of ripples in both passband and stopband increases, with a corresponding decrease in the ripple widths Height of the largest ripples remain the same independent of length Similar oscillatory behavior observed in the magnitude responses of the truncated versions of other types of ideal filters

15 § Gibbs Phenomenon Gibbs phenomenon can be explained by treating the truncation operation as an windowing operation: In the frequency domain where Ht(ejω) and Ψ(ejω) are the DTFTs of ht[n] and w[n] , respectively

16 § Gibbs Phenomenon Thus Ht(ejω) is obtained by a periodic continuous convolution of Hd(ejω) with Ψ(ejω)

17 § Gibbs Phenomenon If Ψ(ejω) is a very narrow pulse centered at ω=0 (ideally a delta function) compared to variations in Hd(ejω) , then Ht(ejω) will approximate Hd(ejω) very closely Length 2M+1 of w[n] should be very large On the other hand, length 2M+1 of ht[n] should be as small as possible to reduce computational complexity

18 § Gibbs Phenomenon A rectangular window is used to achieve simple truncation: Presence of oscillatory behavior in Ht(ejω) is basically due to: – 1) hd[n] nitely long and not absolutely summable, and hence filter is unstable – 2) Rectangular window has an abrupt transition to zero

19 § Gibbs Phenomenon Oscillatory behavior can be explained by examining the DTFT ΨR(ejω) of hwR[n]: R(ejω) has a main lobe centered at ω=0 Other ripples are called sidelobes

20 § Gibbs Phenomenon Main lobe of ΨR(ejω) characterized by its width 4π/(2M+1) defined by first zero crossings on both sides of ω=0 As M increases, width of main lobe decreases as desired Area under each lobe remains constant while width of each lobe decreases with an increase in M Ripples in Ht(ejω) around the point of discontinuity occur more closely but with no decrease in amplitude as M increases

21 § Gibbs Phenomenon Rectangular window has an abrupt transition to zero outside the range -M≤n≤M, which results in Gibbs phenomenon in Ht(ejω) Gibbs phenomenon can be reduced either: (1) Using a window that tapers smoothly to zero at each end, or (2) Providing a smooth transition from passband to stopband in the magnitude specifications

22 §10.2.4 Fixed Window Functions
Using a tapered window causes the height of the sidelobes to diminish, with a corresponding increase in the main lobe width resulting in a wider transition at the discontinuity Hann: Hamming: Blackman:

23 §10.2.4 Fixed Window Functions
Plots of magnitudes of the DTFTs of these windows for M=25 are shown below: 0.2 0.4 0.6 0.8 1 -100 -80 -60 -40 -20 w / p Gain, dB Rectangular window 0.2 0.4 0.6 0.8 1 -100 -80 -60 -40 -20 w / p Gain, dB Hanning window 0.2 0.4 0.6 0.8 1 -100 -80 -60 -40 -20 w / p Gain, dB Hamming window 0.2 0.4 0.6 0.8 1 -100 -80 -60 -40 -20 w / p Gain, dB Blackman window

24 §10.2.4 Fixed Window Functions
Magnitude spectrum of each window characterized by a main lobe centered at ω= 0 followed by a series of sidelobes with decreasing amplitudes Parameters predicting the performance of a window in filter design are: Main lobe width Relative sidelobe level

25 §10.2.4 Fixed Window Functions
Main lobe width ML - given by the distance between zero crossings on both sides of main lobe Relative sidelobe level Asl - given by the difference in dB between amplitudes of largest sidelobe and main lobe

26 §10.2.4 Fixed Window Functions
Observe Thus, Passband and stopband ripples are the same

27 §10.2.4 Fixed Window Functions
Distance between the locations of the maximum passband deviation and minimum stopband value  ML Width of transition band   = s - p < ML

28 §10.2.4 Fixed Window Functions
To ensure a fast transition from passband to stopband, window should have a very small main lobe width To reduce the passband and stopband ripple δ, the area under the sidelobes should be very small Unfortunately, these two requirements are contradictory

29 §10.2.4 Fixed Window Functions
In the case of rectangular, Hann, Hamming, and Blackman windows, the value of ripple does not depend on filter length or cutoff frequency c , and is essentially constant In addition,    c / M where c is a constant for most practical purposes

30 §10.2.4 Fixed Window Functions
Rectangular window - ML=4/(2M+1) Asl=13.3 dB, s=20.9 dB, =0.92/M Hann window - ML=8/(2M+1) Asl=31.5 dB, s=43.9 dB, =3.11/M Hamming window - ML=8/(2M+1) Asl=42.7 dB, s=54.5 dB, =3.32/M, Blackman window - ML=12/(2M+1) Asl=58.1 dB, s=75.3 dB, =5.56/M

31 §10.2.4 Fixed Window Functions
Filter Design Steps - (1) Set c =(p + s )/2 (2) Choose window based on specified s (3) Estimate M using  c / M

32 §10.2.4 Fixed Window Functions
FIR Filter Design Example Lowpass filter of length 51 and c=/2 0.2 0.4 0.6 0.8 1 -100 -50 w / p Gain, dB Lowpass Filter Designed Using Hann window 0.2 0.4 0.6 0.8 1 -100 -50 w / p Gain, dB Lowpass Filter Designed Using Hamming window 0.2 0.4 0.6 0.8 1 -100 -50 w / p Gain, dB Lowpass Filter Designed Using Blackman window

33 §10.2.4 Fixed Window Functions
FIR Filter Design Example An increase in the main lobe width is associated with an increase in the width of the transition band A decrease in the sidelobe amplitude results in an increase in the stopband attenuation

34 §10.2.5 Adjustable Window Functions
Dolph-Chebyshev Window – where and

35 §10.2.5 Adjustable Window Functions
Dolph-Chebyshev window can be designed with any specified relative sidelobe level while the main lobe width adjusted by choosing length appropriately Filter order is estimated using where   is the normalized transition bandwidth, e.g, for a lowpss filter   = s - p

36 §10.2.5 Adjustable Window Functions
Gain response of a Dolph-Chebyshev window of length 51 and relative sidelobe level of 50 dB is shown below

37 §10.2.5 Adjustable Window Functions
Properties of Dolph-Chebyshev window: All sidelobes are of equal height Stopband approximation error of filters designed have essentially equiripple behavior For a given window length, it has the smallest main lobe width compared to other windows resulting in filters with the smallest transition band

38 §10.2.5 Adjustable Window Functions
Kaiser Window – where βis an adjustable parameter and I0(u) is the modified zeroth-order Bessel function of the first kind: Note I0(u)>0 for u>0 In practice

39 §10.2.5 Adjustable Window Functions
βcontrols the minimum stopband attenuation of the windowed filter response βis estimated using Filter order is estimated using where   is the normalized transition bandwidth

40 §10.2.5 Adjustable Window Functions
FIR Filter Design Example Specifications: p=  , s=  , c=40 dB Thus Choose N=24 implying M=1

41 §10.2.5 Adjustable Window Functions
FIR Filter Design Example Hence ht[n]=sin(0.4n)/ n, -12n12 where w[n] is the n-th coefficient of a length-25 Kaiser window with =3.3953 0.2 0.4 0.6 0.8 1 -80 -60 -40 -20 w / p Gain, dB Kaiser Window 0.2 0.4 0.6 0.8 1 -80 -60 -40 -20 w / p Gain, dB Lowpass filter designed with Kaiser window

42 §10.2.6 Impulse Responses of FIR Filters with a Smooth Transition
First-order spline passband-to-stopband transition

43 §10.2.6 Impulse Responses of FIR Filters with a Smooth Transition
Pth-order spline passband-to-stopband transition

44 §10.2.6 Impulse Responses of FIR Filters with a Smooth Transition
Lowpass FIR Filter Design Example

45 §10.3 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
The FIR filter design techniques discussed so far can be easily implemented on a computer In addition, there are a number of FIR filter design algorithms that rely on some type of optimization techniques that are used to minimize the error between the desired frequency response and that of the computer-generated filter

46 §10.3 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
Basic idea behind the computer-based iterative technique Let H(ejω) denote the frequency response of the digital filter H(z) to be designed approximating the desired frequency response D(ejω), given as a piecewise linear function of ω, in some sense

47 §10.3 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
Objective - Determine iteratively the coefficients of H(z) so that the difference between H(ejω) and D(ejω) over closed subintervals of 0≤ω≤π is minimized This difference usually specified as a weighted error function ε(ω)=W(ejω)[H(ejω)-D(ejω)] where W(ejω) is some user-specified weighting function

48 §10.3 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
Chebyshev or minimax criterion - Minimizes the peak absolute value of the weighted error: where R is the set of disjoint frequency bands in the range 0≤ω≤π, on which D(ejω) is defined

49 §10.3 Computer-Aided Design of Equiripple Linear-Phase FIR Filters
The linear-phase FIR filter obtained by minimizing the peak absolute value of is usually called the equiripple FIR filter After ε is minimized, the weighted error function ε(ω) exhibits an equiripple behavior in the ferquency range R

50 §10.3.1 the Parks-McClellan Algorithm
The general form of frequency response of a causal linear-phase FIR filter of length 2M+1: where the amplitude response is a real function of ω Weighted error function is given by where D(ω) is the desired amplitude response and W(ω) is a positive weighting function

51 §10.3.1 the Parks-McClellan Algorithm
The Parks-McClellan Algorithm is based on iteratively adjusting the coefficients of until the peak absolute value of ε(ω) is minimized If peak absolute value of ε(ω) in a band ωa≤ω≤ωb is ε0, then the absolute error satisfies

52 §10.3.1 the Parks-McClellan Algorithm
For filter design, is required to satisfy the above desired response with a ripple of ±δp in the passband and a ripple of δs in the stopband

53 §10.3.1 the Parks-McClellan Algorithm
Thus, weighting function can be chosen either as or

54 §10.3.1 the Parks-McClellan Algorithm
Type 1 FIR Filter – where Type 2 FIR Filter – where

55 §10.3.1 the Parks-McClellan Algorithm
Type 3 FIR Filter – where Type 4 FIR Filter – where

56 §10.3.1 the Parks-McClellan Algorithm
Amplitude response for all 4 types of linear- phase FIR filters can be expressed as where

57 §10.3.1 the Parks-McClellan Algorithm
and where

58 §10.3.1 the Parks-McClellan Algorithm
with are elated to b[k], c[k], and d[k], respectively

59 §10.3.1 the Parks-McClellan Algorithm
Modified form of weighted error function Modified form of weighted error function

60 §10.3.1 the Parks-McClellan Algorithm
Optimization Problem – Determine which minimize the peak absolute value εof over the specified frequency bands ω∈R After has been determined, corresponding coefficients of the original A(ω) are computed from which h[n] are determined

61 § Alternation Theorem The aplitude function A(ω) is the best unique approximation of obtained by minimizing peak absolute value ω of if and only if there exist at least L+2 extremal frequencies, {ωi}, 0≤i≤L+1 in a closed subset R of the frequency range 0≤ω≤π such that ω0<ω1<···ωL<ωL+1 and ε(ωi)=-ε(ωi+1), |ε(ωi)|=ε for all i

62 §10.3.1 Design of Equiripple Linear-Phase FIR Filters
Consider a Type 1 FIR filter with an amplitude response A(ω) whose approximation error ε(ω) satisfies the Alternation Theorem Peaks of E(ω) are at ω=ωi, 0≤i≤L+1 where d E(ω)/dω=0 Since in the passband and stopband, and are piecewise constant,

63 §10.3.1 Design of Equiripple Linear-Phase FIR Filters
Using cos(ωk)=Tk(cosω), where Tk(x) is the k-th order Chebyshev polynomial A(ω) can be expressed as which is an Lth-order polynomial in cosω Hence, A(ω) can have at most L-1 local minima and maxima inside specified passband and stopband

64 §10.3.1 Design of Equiripple Linear-Phase FIR Filters
At bandedges, ω=ωp, and ω=ωs , |ε(ω)| is a maximum, and hence A(ω) has extrem at these points A(ω) can have extrema at ω=0, and ω=π Therefore, there are at most L+3 extremal frequencies of ε(ω) For linear-phase FIR filters with K specified bandedges, there can be at most L+K+1 extremal frequencies

65 §10.3.1 Design of Equiripple Linear-Phase FIR Filters
The set of equations is written in a matrix form

66 §10.3.1 Design of Equiripple Linear-Phase FIR Filters
The matrix equation can be solved for the unknowns andεif the locations of the L+2 extremal frequencies are known a priori The Remez exchange algorithm is used to determine the locations of the extremal frequencies

67 §10.3.2 Remez Exchange Algorithm
Step 1: A set of initial values of extremal frequencies are either chosen or are available from completion of previous stage Step 2: Value ofεis computed using where

68 §10.3.2 Remez Exchange Algorithm
Step 3: Values of A(ω) at ω=ωi are then computed using Step 4: The polynomial A(ω) is determined by interpolating the above values at the L+2 extremal frequencies using the Lagrange interpolation formula

69 §10.3.2 Remez Exchange Algorithm
Step 4: The new error function is computed at a dense set S(S≥L) of frequencies. In practice S=16L is adequate. Determine the L+2 new extremal frequencies from the values of ε(ω) evaluated at the dense set of frequencies. Step 5: If the peak values εof ε(ω) are equal in magnitude, algorithm has converged. Otherwise, go back to Step 2.

70 §10.3.2 Remez Exchange Algorithm
Illustration of algorithm Iteration process is stopped if the difference between the values of the peak absolute errors between two consecutive stages is less than a preset value, e.g., 10-6

71 §10.3.2 Remez Exchange Algorithm
Example – Approximate the desired y a linear function D(x)=1.1x2-0.1 defined for the range 0≤x≤2 by a linear function a1x+a0 by minimizing the peak value of the absolute error Stage 1: Choose arbitrarily the initial extremal points

72 §10.3.2 Remez Exchange Algorithm
Solve the three linear equations i.e., for the given extremal points yielding

73 §10.3.2 Remez Exchange Algorithm
Plot of ε1(x)=1.1x2-1.65x along with values of error at chosen extremal points shown below Note: Errors are equal in magnitude and alternate in sign

74 §10.3.2 Remez Exchange Algorithm
Stage 2: Choose extremal points where ε1(x) assumes its maximum absolute values These are x1=0, x2=0.75, x3=2 New values of unknowns are obtained by solving yielding a0= , a1=2.2, ε=0.5156

75 §10.3.2 Remez Exchange Algorithm
Plot of ε2(x)=1.1x2-2.2x along with values of error at chosen extremal points shown below

76 §10.3.2 Remez Exchange Algorithm
Stage 3: Choose extremal points where ε2(x) assumes its maximum absolute values These are x1=0, x2=1, x3=2 New values of unknowns are obtained by solving yielding a0=-0.65, a1=2.2, ε=0.55

77 §10.3.2 Remez Exchange Algorithm
Plot of ε3(x)=1.1x2-2.2x+0.55 along with values of error at chosen extremal points shown below Algorithm has converged as εis also the maximum value of the absolute error

78 §10.4 Design of Minimum-Phase FIR Filters
Linear-phase FIR filters with narrow transition bands are of very high order, and as a result have a very long group delay that is about half the filter order By relaxing the linear-phase requirement, it is possible to design an FIR filter of lower order thus reducing the overall group delay and the computational cost

79 §10.4 Design of Minimum-Phase FIR Filters
A very simple method of minimum-phase FIR filter is described next Consider an arbitrary FIR transfer function of degree N:

80 §10.4 Design of Minimum-Phase FIR Filters
The mirror-image polynomial to H(z) is given by The zeros of are thus at z=1/ξk, i.e., are reciprocal to the zeros of H(z) at z=ξk

81 §10.4 Design of Minimum-Phase FIR Filters
As a result has zeros exhibiting mirror-image symmetry in the z-plane and is thus a Type 1 linear- phase transfer function of order 2N Moreover, if H(z) has a zero on the unit circle, will also have a zero on the unit circle at the conjugate reciprocal position

82 §10.4 Design of Minimum-Phase FIR Filters
Thus, unit circle zeros of G(z) occur in pairs On the unit circle we have Moreover, the amplitude response has double zeros in the frequency range [0,π]

83 §10.4 Design of Minimum-Phase FIR Filters
Design Procedure – Step 1: Design a Type 1 linear-phase transfer function F(z) of degree 2N satisfying the specifications: Note that F(z) has single unit circle zeros

84 §10.4 Design of Minimum-Phase FIR Filters
Step 2: Determine the linear-phase transfer function Its amplitude response satisfies

85 §10.4 Design of Minimum-Phase FIR Filters
Note that G(z) has double zeros on the unit circle and all other zeros are situated with a mirror-image symmetry Hence, it can be expressed in the form G(z)=z-n Hm(z)Hm(z-1) where Hm(z) is a minimum-phase transfer function containing all zeros of G(z) that are inside the unit circle and one each of the unit circle double zeros

86 §10.4 Design of Minimum-Phase FIR Filters
Step 3: Determine Hm(z) from G(z) by applying a spectral factorization The passband ripple and the stopband ripple of F(z) must be chosen to ensure that the specified passband ripple δp and the stopband rippleδp of Hm(z) are satisfied

87 §10.4 Design of Minimum-Phase FIR Filters
It can be shown An estimate of the order N of Hm(z) can be found by first estimating the order of F(z) and then dividing it by 2 If the estimated order of F(z) is an odd integer, it should be increased by 1

88 §10.5 FIR Digital Filter Design Using MATLAB
Order Estimation – Kaiser’s Formula: Note: Filter order N is inversely proportional to transition band width (ωp-ωs ) and does not depend on actual location of transition band

89 §10.5 FIR Digital Filter Design Using MATLAB
Hermann-Rabiner-Chan’s Formula: where with

90 §10.5 FIR Digital Filter Design Using MATLAB
Formula valid for δp≥δs For δp<δs , Formula to be used is obtained by interchanging δp and δs Both formulas provide only an estimate of the required filter order N Frequency response of FIR filter designed using this estimated order may or may not meet the given specifications If specifications are not met, increase filter order until they are met

91 §10.5 FIR Digital Filter Design Using MATLAB
MATLAB code fragments for estimating filter order using Kaiser’s formula num = - 20*log10(sqrt(dp*ds))-13; den = 14.6*(Fs - Fp)/FT N = ceil(num/den); M-file remezord implements Hermann-Rabiner-Chan’s order estimation formula

92 §10.5 FIR Digital Filter Design Using MATLAB
For FIR filter design using the Kaiser window, window order is estimated using the M-file kaiserord The M-file kaiserord can in some cases generate a value of N which is either greater or smaller than the required minimum order If filter designed using the estimated order N does not meet the specifications, N should either be gradually increased or decreased until the specifications are met

93 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
The M-file remez can be used to design an equiripple FIR filter using the Parks- McClellan algorithm Example – Design an equiripple FIR filter with the specifications: Fp=0.8kHz, Fs=1kHz, FT=4kHz, αp=0.5dB, αs=40dB Here δp= and δs=0.01

94 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
MATLAB code fragments used are [N, fpts, mag, wt]= remezord(fedge, mval, dev, FT); b = remez(N, fpts, mag, wt); where fedge = [ ], mval = [1 0], dev = [ ],and FT=400

95 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
The computed gain response with the filter order obtained (N=28) does not the specifications (αp=0.6dB, αs=38.7dB) Specifications are met with N=30

96 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Example – Design a linear-phase FIR bandpass filter of order 26 with a passband from 0.3 to 0.5, and stopbands from 0 to 0.25 and from 0.55 to 1 The pertinent input data here are N = 26 fpts = [ ] mag = [ ] wt = [ ]

97 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Computed gain response shown below where αp=1dB, αs=18.7dB

98 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
We redesign the filter with order increased to 110 Computed gain response shown below where αp=0.024dB, αs=51.2dB Note: Increase in order improves gain response at the expense of increased computational complexity

99 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
αs can be increased at the expenses of a larger αp by decreasing the relative weight ratio W(ω)=αp/αs Gain response of bandpass filter of order 110 obtained with a weight vector [ ] Now αp=0.076dB, αs=60.86dB

100 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Plots of absolute error for 1st design Absolute error has same peak value all bands As L=13, and there are 4 band edges, there can be at most L-1+6=18 extrema Error plot exhibits 17 extrema

101 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Absolute error has same peak value in all bands for the 2nd design Absolute error in passband of 3rd design is 10 times the error in the stopbands

102 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Example – Design a linear-phase FIR bandpass filter of order 60 with a passband from 0.3 to 0.5, and stopbands from 0 to 0.25 and from 0.6 to 1 with unequal weights The pertinent input data here are N = 60 fpts = [ ] mag = [ ] wt = [ ]

103 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Plots of gain response and absolute error shown below

104 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Response in the second transition band shows a peak with a value higher than that in passband Result does not contradict alternation theorem As N = 60, M = 30, and hence, there must be at least M + 2 = 32 extremal frequencies Plot of absolute error shows the presence of 32 extremal frequencies

105 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
If gain response of filter designed exhibits a nonmonotonic behavior, it is recommended that either the filter order or the bandedges or the weighting function be adjusted until a satisfactory gain response has been obtained Gain plot obtained by moving the second stopband edge to 0.55

106 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
FIR Differentiator Design Examples A lowpass differentiator has a bandlimited frequency response where 0≤|ω|≤ωp represents the passband and ωs≤|ω|≤π represents the stopband For the design phase we choose W(ω)=1/ω, D(ω)=1, 0≤|ω|≤ωp

107 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
The M-file remezord cannot be used to estimate the order of an FIR differentiator Example - Design a full-band (ωp=π) differentiator of order 11 Code fragment to use b = remez(N, fpts, mag, ‘differentiator’); where N = 11 fpts = [0 1] mag = [0 pi]

108 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Plots of magnitude response and absolute error Absolute error increases with ω as the algorithm result in an equiripple error of the function [A(ω)/ ω-1]

109 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Example – Design a lowpass differentiator of order 50 with ωp=0.4π, and ωs=0.45π Code fragment to use b = remez(N, fpts, mag, ‘differentiator’); where N = 50 fpts = [ ] mag = [ *pi ]

110 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Plot of the magnitude response of the lowpass differentiator

111 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
FIR Hilbert Transformer Design Examples Desired amplitude response of a bandpass Hilbert transformer is D(ω)=1, ωL≤|ω|≤ωH with weighting function W(ω)=1, ωL≤|ω|≤ωH Impulse response of an ideal Hilbert transformer satisfies the condition hHT[n]=0, for n even which can be met by a Type 3 FIR filter

112 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Example - Design a linear-phase bandpass FIR Hilbert transformer of order 20 with ωL=0.1π, ωH =0.9π Code fragment to use b = remez(N, fpts, mag, ‘Hilbert’); where N = 20 fpts = [ ]

113 §10.5.2 Equiripple FIR Digital Filter Design Using MATLAB
Plots of magnitude response and absolute error

114 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
The minimum-phase FIR filter design method outlined earlier involves the spectral factorization of a Type 1 linear-phase FIR transfer function G(z) with a non-negative amplitude response in the form G(z)=z-NHm(z)Hm(z-1) where Hm(z) contains all zeros of G(z) that are inside the unit circle and one each of the unit circle double zeros

115 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
Spectral Factorization We next outline the basic idea behind a simple spectral factorization method Without any loss of generality we consider the spectral factorization of a 6-th order linear-linear phase FIR transfer function G(z) with a non-negative amplitude response: G(z)=g3+g2z-1+g1z-2+g0z-3+g1z-4+g2z-5+g3z-6

116 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
Our objective is to express the above G(z) in the form G(z)=z-3Hm(z)Hm(z-1) where Hm(z)=a0+a1z-1+a2z-2+a3z-3 is the minimum-phase factor of G(z)

117 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
Expressing G(z) in terms of the coefficients of Hm(z) we get G(z)=(a0+a1z-1+a2z-2+a3z-3) × (a3+a2z-1+a1z-2+a0z-3) Forming the product of the two polynomials given above and comparing the coefficients of like powers of z-1 the product with that of G(z) given on the previous slide we arrive at 4 equations given in the next slide

118 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
The above set of equations is then solved iteratively using the Newton-Raphson method

119 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
First, the initial values of ai are chosen to ensure that Hm(z) has all zeros strictly inside the unit circle Then, the coefficients ai are changed by adding the corrections ei so that the modified values ai +ei satisfy better the set of 4 equalities given in the previous slide The process is repeated until the iteration converges

120 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
Substituting ai +ei in the 4 equations given earlier and expanding the products, a set of linear equations are obtained by eliminating all quadratic terms in ei from the expansion In matrix form, these equations can be written as Ae=b where

121 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
and The matrix A can be expressed

122 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
The iteration convergence is checked at each step by evaluating the error term The error term first decreases monotonically and the iteration is stopped when the error starts increasing The M-file minphase.m implements the above spectral factorization method

123 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB
Example – Design a minimum-phase lowpass FIR filter with the following specifications: ωp=0.45π, ωs=0.6π, Rp=2 dB and Rs=26 dB Using Program 10_3.m we arrive at the desired filter Plots of zeros of G(z), zeros of Hm(z), and the gain response of Hm(z) are shown in the next slide

124 §10.5.3 Minimum-Phase FIR Filter Design Using MATLAB

125 §10.5.3 Maximum-Phase FIR Filter Design Using MATLAB
A maximum-phase spectral factor of a linear-phase FIR filter with an impulse response b of even order with a non- negative zero-phase frequency response can be designed by first computing its minimum-phase spectral factor h and the using the statement G = fliplr(h)

126 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Window Generation – Code fragments to use w = blackman(L); w = hamming(L); w = hanning(L); w = chebwin(L, Rs); w = kaiser(L, beta); where window length L is odd

127 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Example – Kaiser window design for use in a lowpass FIR filter design Specifications of lowpass filter: ωp=0.4π, ωs=0.45π, αs=50 dB, → δs= Code fragments to use [N, Wn, beta, ftype] = kaiserord(fpts, mag,dev); w = kaiser(N+1, beta); where fpts = [ ] mag = [1 0] dev = [ ]

128 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Plot of the gain response of the Kaiser window

129 §10.5.4 Window-Based FIR Filter Design Using MATLAB
M-files available are fir1 and fir2 fir1 is used to design conventional lowpass, highpass, bandpass, bandstop and multiband FIR filters fir2 is used to design FIR filters with arbitrarily shaped magnitude response In fir1, Hamming window is used as a default if no window is specified

130 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Example – Design using a Kaiser window a lowpass FIR filter with the specifications: ωp=0.3π, ωs=0.4π, δs= Code fragments to use [N, Wn, beta, ftype] = kaiserord(fpts, mag, dev); b = fir1(N, Wn, kaiser(N+1, beta)); where fpts = [ ] mag = [1 0] dev = [ ]

131 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Plot of gain response

132 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Example – Design using a Kaiser window a highpass FIR filter with the specifications: ωp=0.55π, ωs=0.4π, δs=0.02 Code fragments to use [N, Wn, beta, ftype] = kaiserord(fpts, mag, dev); b = fir1(N, Wn, ‘ftype’, kaiser(N+1, beta)); where fpts = [ ] mag = [0 1] dev = [ ]

133 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Plot of gain response

134 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Example – Design using a Hamming window an FIR filter of order 100 with three different constant magnitude levels: 0.3 in the frequency range [0, 0.28], 1.0 in the frequency range [0.3, 0.5], and 0.7 in the frequency range [0.52, 1.0]

135 §10.5.4 Window-Based FIR Filter Design Using MATLAB
Code fragment to use b = fir2(100, fpts, mval); where fpts = [ ]; mval = [ ];

136 §10.6 Design of Computationally Efficient FIR Digital Filters
As indicated earlier, the order N of a linear- phase FIR filter is inversely proportional to the width ∆ω of the transition band Hence, in the case of an FIR filter with a very sharp transition, the order of the filter is very high This is particularly critical in designing very narrow-band or very wide-band FIR filters

137 §10.6 Design of Computationally Efficient FIR Digital Filters
The computational complexity of a digital filter is basically determined by the total number of multipliers and adders needed to implement the filter The direct form implementation of a linear- phase FIR filter of order N requires, in general, multipliers and N two-input adders

138 §10.6 Design of Computationally Efficient FIR Digital Filters
We now outline two methods of realizing computationally efficient linear-phase FIR filters The basic building block in both methods is an FIR subfilter structure with a periodic impulse response

139 §10.6.1 The Periodic Filter Section
Consider a Type 1 linear-phase FIR filter F(z) of even degree N: Its delay-complementary filter E(z) is given by

140 §10.6.1 The Periodic Filter Section
The transfer function H(z) obtained by replacing z-1 in F(z) with z-L, with L being a positive integer, is given by The order of H(z) is thus NL A direct realization of H(z) is obtained by simply replacing each unit delay in the realization of F(z) with L unit delays

141 §10.6.1 The Periodic Filter Section
Note: The number of multiplers and delays in the realization of H(z) is the same as those in the realization of F(z) The transfer function H(z) has a sparse impulse response of length NL+1, with L-1 zero-valued samples inserted between every consecutive pair of impulse response samples of F(z)

142 §10.6.1 The Periodic Filter Section
The parameter L is called the sparsity factor The relation between the amplitude responses of these two filters is given by It follows from the above that the amplitude response is a period function of ω with a period 2π/L

143 §10.6.1 The Periodic Filter Section
One period of is obtained by compressing the amplitude response in the interval [0, 2π] to the interval [0, 2π/L] A transfer function H(z) with a frequency response that is a periodic function of ω with a period 2π/L is called a periodic filter

144 §10.6.1 The Periodic Filter Section
If F(z) is a lowpass filter with a single pasband and a single stopband, H(z) will be a multiband filter with pasbands and stopbands as shown in the next slide for L=4

145 §10.6.1 The Periodic Filter Section

146 §10.6.1 The Periodic Filter Section
Let F(z) be a lowpass filter with passband edge at and stopband edge at , where Then, the passband and stopband edges of the first band of H(z) are at and respectively The passband and stopband edges of the second band of H(z) are at and , respectively, and so on as shown on the previous slide

147 §10.6.1 The Periodic Filter Section
The width of the transition bands of H(z) are , which is 1/L-th of that of F(z) Likewise, the transfer function G(z) by replacing z-1 in E(z) with z-L, is given by The amplitude response of G(z) is given by

148 §10.6.2 Interpolated FIR Filter
The overall filter HIFIR(z) is designed as a cascade of a linear-phase FIR filter F(zL) and another filter I(z) that suppreses the undesired passbands of the periodic filter section as shown below F(zL) I(z) periodic filter interpolator The widths of the transition band and the passband of the cascade are 1/L-th of those of F(z)

149 §10.6.2 Interpolated FIR Filter
The cascaded structure is called the interpolated finite impulse response (IFIR) filter, as the missing impulse response samples of the periodic filter section are being interpolated by the filter section I(z), called the interpolator As the filter F(z) determines approximately the shape of the amplitude response of the IFIR filter, it is called a shaping filter

150 §10.6.2 Interpolated FIR Filter
Design Steps – IFIR specifications: passband edge ωp, stopband edge ωs, passband rippleδp, stopband ripple δs Shaping filter specifications: passband edge stopband edge passband ripple stopband ripple

151 §10.6.2 Interpolated FIR Filter
The interpolator I(z) has to be designed to preserve the passband of F(zL) in the frequency range [0, ωp] and mask the amplitude response of F(zL) in the frequency range [ωs ,π] , where the periodic subfilter has unwanted passbands and transition bands This latter region is defined by

152 §10.6.2 Interpolated FIR Filter
The transition band of the interpolator is the frequency range [ωp , 2π/L-ωs] Figure below shows the responses of HIFIR(z) and I(z)

153 §10.6.2 Interpolated FIR Filter
Summarinzing, the design specifications for F(z) and I(z) are as follows: The two linear-phase FIR filters F(z) and I(z) can be designed using the Parks- McClellan method

154 §10.6.2 Interpolated FIR Filter
Example – Filter specifications are as follows: ωp=0.15π, ωs=0.2π, δp=0.002, δs=0.001 It follows from the figure in Slide 101 that to ensure no overlaps between adjacent passbands of F(zL), we should choose L to satisfy the condition

155 §10.6.2 Interpolated FIR Filter
For our example, this reduces to 0.2π< 2π/L- 0.2π Hence, the largest value of L that can be used is L=4, yielding an IFIR structure requiring the least number of multipliers As a result, the specifications for F(z) and I(z) are as given in the next slide

156 §10.6.2 Interpolated FIR Filter
F(z): I(z): The filter orders of F(z) and I(z) obtained using remezord are: Order of F(z)=32 Order of I(z)=43

157 §10.6.2 Interpolated FIR Filter
It can be shown that the filters F(z) and I(z) designed using remez with the above orders do not lead to an IFIR design meeting the minimum stopband attenuation of 60 dB To meet the stopband specifications, the orders of F(z) and I(z) need to be increased to 33 and 46, respectively

158 §10.6.2 Interpolated FIR Filter
The pertinent gain responses of the redesigned IFIR filter are shown below: The number of multipliers needed to implement F(z) and hence, F(z4) is

159 §10.6.2 Interpolated FIR Filter
The number of multipliers needed to implement I(z) is: As a result, the total number of multipliers needed to implement HIFIR(z) is The number of multipliers needed to implement the direct single-stage implementation of the FIR filter is

160 §10.6.3 Frequency-Response Masking Approach
This approach makes use of the relation between a periodic filter H(z)=F(zL) generated from a Type 1 linear-phase FIR filter of even degree N and its delay- complementary filter G(z) given by The amplitude responses of F(z), its delay- complentary filter E(z), the periodic filter H(z) and its delay-complentary filter G(z) are shown in the next slide

161 §10.6.3 Frequency-Response Masking Approach

162 §10.6.3 Frequency-Response Masking Approach
By selectively masking out the unwanted pasbands of both H(z) and G(z) by cascading each with appropriate masking filters I1(z) and I2(z), respectively, and connecting the resulting cascades in prallel, we can design a large class of FIR filters with sharper transition bands The overall structure is then realized as indicated in the next slide

163 §10.6.3 Frequency-Response Masking Approach
F(zL) I1(z) z-LN/2 I2 (z) Note: The delay block z-NL/2 can be realized by tapping the FIR structure implementing F(zL) Also, I1(z) and I2(z) can share the same delay-chain if they are realized using the transposed direct form structure

164 §10.6.3 Frequency-Response Masking Approach
The transfer function of the overall structure is given by The corresponding amplitude response is

165 §10.6.3 Frequency-Response Masking Approach
The overall computational complexity is given by the complexities of F(z), I1(z) and I2(z) All these three filters have wide transition bands and, in general, require considerably fewer multipliers and adders than that required in a direct design of the

166 §10.6.3 Frequency-Response Masking Approach
Design Objective – Given the specifications of HFM(z) , determine the specifications of F(z), I1(z) and I2(z) design these 3 filters Design method – Illustrated for lowpass filter design Two different situations may arise depending on how the transition band of HFM(z) is created

167 §10.6.3 Frequency-Response Masking Approach
Case A – Transition band of HFM(z) is from one of the transition bands of H(z)

168 §10.6.3 Frequency-Response Masking Approach
Bandedges of HFM(z) are related to the bandedges of F(z) as follows:

169 §10.6.3 Frequency-Response Masking Approach
Case B – Transition band of HFM(z) is from one of the transition bands of G(z)

170 §10.6.3 Frequency-Response Masking Approach
Bandedges of HFM(z) are related to the bandedges of F(z) as follows: Example – Specifications for a lowpass filter:ωp=0.4π, ωs=0.402π, δp=0.01 and δs=0.0001

171 §10.6.3 Frequency-Response Masking Approach
For designing HFM(z) the optimum value of L is in the range By calculating the total number of multipliers needed to realize F(z), I1(z) and I2(z) for all possible values of L, we arrive at the realization requiring the least number of multipliers obtained for L =16 is 229 which is about 15% of that required in a direct single-stage realization

172 §10.6.3 Frequency-Response Masking Approach
The gain response of the designed filter is shown below:


Download ppt "FIR Digital Filter Design"

Similar presentations


Ads by Google