Вы находитесь на странице: 1из 28

Design of FIR Filters

• Finite impulse response (FIR) filters show the property of linear phase.
• There are three design techniques for FIR filters, namely
• the window design,
• the frequency sampling design, and
• the optimal equiripple design techniques
• If h(n), 0 ≤ n ≤ M −1 is the impulse response of length M.
• Then the system function is

• which has (M −1) poles at the origin z = 0 (trivial poles) and (M −1)
zeros located anywhere in the z-plane.
• The frequency response function is
IMPULSE RESPONSE h(n)
For linear-phase H(ejω) = −αω, −π<ω≤ π where α is a constant phase
delay.
• h(n) must be symmetric, that is, h(n) = h(M −1 − n), 0 ≤ n ≤ (M −1)
with α = (M −1)/ 2. Hence h(n) is symmetric about α, which is the
index of symmetry.
• The two possible types of symmetry are:
• M odd: In this case α = (M−1)/2 is an integer.
• M even: In this case α = (M −1)/2 is not an integer.
• Iif we require that the phase response H(ejω) satisfy the condition
H(ejω) = β –α ω which is a straight line but not through the origin.
• In this case α is not a constant phase delay, but d H(ejω) / dω = − α is
constant, which is the group delay. Therefore α is called a constant
group delay.
• In this case, as a group, frequencies are delayed at a constant rate.
But some frequencies may get delayed more and others delayed less.
• For this type of linear phase h(n)=−h(M−1−n), 0 ≤ n ≤(M−1); α = (M
−1)/ 2 ,β = ±π/ 2. This means that the impulse response h(n) is anti-
symmetric. The index of symmetry is α = (M −1)/2.
• M odd: In this case α = ( M − 1)/2 is an integer and the impulse
response is as shown. The sample h(α) at α = (M−1)/2 must
necessarily be equal to zero, i.e., h((M −1)/2) = 0.
• M even: In this case α = (M −1)/2 is not an integer
FREQUENCY RESPONSE
• Combining the cases of symmetry and anti-symmetry we get four
types of linear-phase FIR filters.
• Frequency response functions for each of these types have some
peculiar expressions and shapes.
• To study these responses, we write H(ejω) as

• where Hr(ω) is an amplitude response function and not a magnitude


response function.
• The amplitude response may be both positive and negative.
WINDOW DESIGN TECHNIQUES

The basic idea:


• Choose a proper ideal frequency-selective filter which has a non-
causal, infinite-duration impulse response.
• Truncate (or window) its impulse response to obtain a linear-phase
and causal FIR filter.
• Emphasis in this method:
Selecting an appropriate windowing function and an appropriate ideal
filter.
• Denote an ideal frequency-selective filter by Hd(ejω), with a unity
magnitude gain and linear-phase
characteristics over its passband, and zero response over its
stopband.
• An ideal LPF of bandwidth ωc < π is given by

• where ωc is the cutoff frequency, and α is the sample delay.


• The impulse response of this filter is of infinite duration and is given
by
•• To obtain an FIR filter from hd(n), truncate hd(n) on both sides.
• To obtain a causal and linear-phase FIR filter h(n) of length M, we must have

• This operation is called “windowing.”


• In general, h(n) can be thought of as being formed by the product of hd(n) and a
window function w(n) as follows:
• h(n) = hd(n)w(n)

• where w(n) =
Basic Windows
• Rectangular window • Bartlett window
• Hann window • Hamming window
• Blackman window
Commonly used window function characteristics

Window Transition width Min. Stopband


Name Approximate Exact Value Attenuation

Rectangular 21dB

Bartlett 25dB

Hann 44dB

Hamming 53dB

Blackman 74dB
Frequency Sampling method
• In this design approach the system function H (z) can be obtained
from the samples H(k) of the frequency response H(ejω).
• h(n)be the impulse response of an M-point FIR filter, H(k) be its M-
point DFT, and H(z) be its system function.
• Then, H(z) = …….(1)
• And
• ………(2)
• With H(k) = ……..(3)
• For linear phase filters, h(n) = ± h(M – 1 – N)
+ for type 1 and type 2 linear phase filters and
– for type 3 and type 4 linear phase filters.
• We have h(n)=IDFT[H(k)] …….(4)
Basic idea
• Given the ideal lowpass filter Hd(ejω), choose the filter length M and
then sample Hd(ejω) at M equispaced frequencies between 0 and 2π.
• The actual response H(ejω) is the interpolation of the samples H(k).
• Similar steps apply to other frequency-selective filters.
• From Figure, we observe the following:
1. The approximation error—that is, the difference between the ideal
and the actual response—is zero at the sampled frequencies.
2. The approximation error at all other frequencies depends on the
shape of the ideal response; that is, the sharper the ideal response, the
larger the approximation error.
3. The error is larger near the band edges and smaller within the band.
Design Approches
• There are two design approaches.
• The naive design method: We use the basic idea literally and provide
no constraints on the approximation error; that is, we accept
whatever error we get from the design.
• The optimum design method: We try to minimize error in the
stopband by varying values of the transition band samples.
• Consider the lowpass filter specifications
• ωp = 0.2π,
• ωs = 0.3π,
• Ap = 0.25 dB
• As = 50 dB
• Design an FIR filter using the frequency sampling approach
• Let us choose M = 20 so that we have a frequency sample at
ωp, that is, at k = 2.
• ωp = 0.2π = 2(2π/20)
and the next sample at ωs, that is, at k = 3:
• ωs = 0.3π =3(2π/20)
• Thus we have 3 samples in the passband [0 ≤ ω ≤ ωp] and 7
samples in the stopband [ωs ≤ ω ≤ π]. From (7.36) we have
• Hr (k) = [1, 1, 1, 0,0, ...., 0(15 zeros), 1, 1]
• Since M = 20, α = (20−1)/2 = 9.5.
• Type-2 linear-phase filter,
• M = 20; alpha = (M-1)/2; l = 0:M-1; wl = (2*pi/M)*l;
• Hrs = [1,1,1,zeros(1,15),1,1]; %Ideal Amp Res sampled
• Hdr = [1,1,0,0]; wdl = [0,0.25,0.25,1]; %Ideal Amp Res for plotting
• k1 = 0:floor((M-1)/2); k2 = floor((M-1)/2)+1:M-1;
• angH = [-alpha*(2*pi)/M*k1, alpha*(2*pi)/M*(M-k2)];
• H = Hrs.*exp(j*angH); h = real(ifft(H,M));
• [db,mag,pha,grd,w] = freqz_m(h,1); [Hr,ww,a,L] = Hr_Type2(h);
• The minimum stopband attenuation is about 16 dB, (unacceptable.)
• If we increase M, then there will be samples in the transition band, for
which we do not precisely know the frequency response.
• Therefore the naïve design method is seldom used in practice.
Optimum Design method
• Choose M = 40.
• We get one sample in the transition band 0.2π < ω < 0.3π.
• Since ω1 = 2π/40, the transition band samples are at k = 5 and at
k = 40 − 5 = 35.
• Denote the value of the samples in the transition band by T1,(0 < T1 < 1 )
• The sampled amplitude response is
Hr (k) = [1, 1, 1, 1, 1, T1, 0, ... 0(29 zeros), , T1, 1, 1, 1, 1]
• α = (40−1)/2 = 19.5,
• The samples of the phase response are

• We can vary T1 to get the best minimum stopband attenuation. This


will result in the widening of the transition width.
• We need to select optimum value for T1 such that the required
stopband attenuation is obtained.
• For T1 = 0.5, the stopband attenuation is 30 dB
• For T1 = 0.39, the stopband attenuation is 43 dB
• Choosing M = 60 and two sample values T1 and T2in the transition
band and

we get better result (stopband attenuation = 63 dBs

Вам также может понравиться