Finite Impulse Response (FIR)
Filter Design
FIR Design Methods
• Several design methods such as:
– Fourier transform method
– Window method
– Frequency sampling method
– Optimal design method
Finite Impulse Response Filter Format
• An FIR filter is completely specified by the following input-output
relationship:
y[n] bi x[n - i]
= b0 x[n] + b1 x[n - 1] + b2 x[n - 2] + ….. + bK x[n - K]
where bi represents FIR filter coefficients and K + 1 denotes the FIR filter
length. Applying the z-transform on both sides leads to:
Factoring out X(z) on the right-hand side and then dividing X(z) on both sides,
we have the transfer function, which depicts the FIR filter, as:
The transfer function has a constant term, all the other terms each have a negative
power of z, and all the poles are at the origin on the z-plane. Hence, the stability
of filter is guaranteed.
Fourier Transform Design
• We begin with an ideal lowpass filter with a normalized cutoff frequency
Ωc, whose magnitude frequency response in terms of the normalized digital
frequency Ω is characterized by:
• Since the frequency response is periodic with a period of Ω = 2π radians, so
we can extend the frequency response of the ideal filter H(e jΩ), as shown
The periodic frequency response
can be approximated using a
complex Fourier series expansion in
terms of the normalized digital
frequency Ω, that is,
Fourier Transform Design, lowpass filter
• The Fourier coefficients are given by
The fundamental frequency is easily found to be
Substituting ω0 = 1 and introducing h[n] = cn, called the desired impulse
response of the ideal filter, we obtain the Fourier transform design as
h[n]
The desired impulse response approximation of the ideal lowpass filter is
solved as:
h[n]
For n =0
Fourier Transform Design, lowpass filter cont.
h[n]
h[n]
Fourier Transform Design, lowpass filter cont.
• If we substitute e jΩ = z and ω0 = 1 back into the equation of H(e jΩ), we yield a z-
transfer function in the following format:
h[n] z-n
= … + h[-2]z2 + h[-1]z1 + h[0] + h[1]z-1 + h[2]z-2 + …
The FIR filter design must first be completed by truncating the infinite-length sequence
h[n] to achieve the 2M + 1 dominant coefficients using the coefficient symmetry, that is,
H(z) = h[M]zM + … + h[1]z1 + h[0] + h[1]z-1 + … + h[M]z-M
The obtained filter is a noncausal z-transfer function
of the FIR filter. To avoid this noncausality, we delay
the truncated impulse response h[n] by M samples to
yield the following causal FIR filter:
where the delay operation is given by
bn = h[n - M] for n = 0, 1, . . ., 2M:
Summary of ideal impulse responses for standard FIR filters
h[n]
h[n]
h[n]
h[n]
h[n]
Causal FIR filter coefficients: shifting h[n] to the right by M samples.
Transfer function:
bn = h[n - M] for n = 0, 1, . . ., 2M:
Example1: FIR lowpass filter design
the table
h[0]
h[n]
Example1 solution, cont.
h[0]
h[1]
h[-1] h[1]
h[0 - 1] h[-1]
h[1 - 1] h[0]
h[2 - 1] h[1]
Example1 solution, cont.
y[n] = 0.1871x[n] + 0.2x[n – 1] + 0.1871x[n – 2].
Example1 solution, cont.
before
In general, the FIR filter with symmetrical coefficients has a linear phase
response (linear function of V) as follows:
Example1 solution, cont.
Magnitude and frequency response in Example1 Magnitude and phase frequency responses of
the lowpass FIR filters with 3 coefficients (dash-
dotted line) and 17 coefficients (solid line).
Example2: FIR bandpass filter design
h[n]
Example2, solution cont.
Example2, solution cont.
the figure
Window Method
• Gibbs oscillations originate from the abrupt truncation of the infinite-length
coefficient sequence. Then it is natural to seek a window function, which is
symmetrical and can gradually weight the designed FIR coefficients down to zeros
at both ends for the range of -M ≤ n ≤ M.
• Applying the window sequence to the filter coefficients gives:
hw[n] = h[n] • w[n]
where w[n] designates the window function. Common window functions used in the FIR
filter design are as follows:
Example3
• Given the calculated filter coefficients
h[0] = 0.25, h[-1] = h[1] = 0.22508, h[-2] = h[2] = 0.15915, h[-3]=h[3]=0.07503
– a. Apply the Hamming window function to obtain windowed coefficients hw[n].
– b. Plot the impulse response h[n] and windowed impulse response hw[n].
the Hamming eq.
Example3, cont.
b. Noncausal impulse responses h[n] and hw[n] are plotted in the figure below
Plots of FIR non-causal
coefficients and windowed
FIR coefficients
Designing of windowed FIR procedure steps
• The design procedure of the FIR filter via windowing is summarized as
follows:
h[n]
hw[n] = h[n]w[n], n = -M, . . . 0, 1, . . . , M,
where w[n] is chosen to be one of the window functions listed in
hw[n]
bn = hw[n – M], for n = 0, 1, . . ., 2M:
Example3
the table
h[0] = 0.2 and h[-1] = h[1] = 0.1871
Example3, solution cont.
Applying the Hamming window function
Example3, solution cont.
y[n] = 0.01497x[n] + 0.2x[n - 1] + 0.01497x[n – 2]
Example3, solution cont.
before
Example3, solution cont.
Example4
h[n]
h[0]
h[1]
h[2]
Example4, solution cont.
h[-1] h[1]
h[-2] h[2]
MATLAB function for FIR filter design using the window methods.
Example5, matlab application
Example5, matlab application cont.
MATLAB program for Example5
Example5, matlab application cont.
FIR filter coefficients in Example5
(rectangular and Hamming windows).
Frequency responses using the rectangular
and Hamming windows.
Example5, matlab application cont.
The Blackman window
offers the lowest side lobe,
but with an increased width
of the main lobe. The
Hamming window and
Hanning window have a
similar narrow width of the
main lobe, but the Hamming
window accommodates a
lower side lobe than the
Hanning window.
Frequency Sampling Design Method
• The key feature of frequency sampling is that the filter coefficients can be
calculated based on the specified magnitudes of the desired filter frequency
response uniformly in frequency domain.
• According to the definition of the inverse DFT (IDFT), the impulse
response (FIR filter coefficients), h[n]:
h[n]
We assume that the FIR filter has linear phase and the number of taps N = 2M+1, therefore:
h[n]
Frequency Sampling Design Method, cont.
• The design procedure is therefore simply summarized as follows:
h[n]
h[n] h[2M - n]
Example6
Sampled values of the frequency response in Example5
Example6, solution cont.
h[n]
h[0]
h[1]
h[2]
h[3]
h[4] = h[2] = 0.32100
h[5] = h[1] = 0.07928
h[6] = h[0] = 0.11456
Frequency Sampling Design Method using matlab
Example7, FIR low pass filter design using matlab
Example7, lowpass FIR filter design using matlab, cont.
Example7, lowpass FIR filter design using matlab, cont.
b. The magnitude frequency response plotted using the dash-dotted line is displayed in the
Figure below, where it is observed that oscillations (shown as the dash-dotted line) occur in
the passband and stopband of the designed FIR filter. This is due to the abrupt change of
the specification in the transition band (between the passband and the stopband). To reduce
this ripple effect, the modified specification with a smooth transition band,
Hk, k = 0, 1, . . . , 13, is used: Hk = [1 1 1 1 1 1 1 0:5 0 0 0 0 0].
Therefore the improved magnitude frequency response is shown in the Figure below via
the solid line.
Frequency responses
using the frequency
sampling method in
Example7
Example7, lowpass FIR filter design using matlab, cont.
the table below
FIR filter coefficients in Example7 (frequency sampling method).
Example8, bandpass FIR filter design using matlab
Example8, bandpass FIR filter design using matlab, cont.
Example8, bandpass FIR filter design using matlab, cont.
Frequency responses using
the frequency sampling
method in Example8
c. Observations can be made from examining Examples8. First, the oscillations (Gibbs behavior) in the
passband and stopband can be reduced at the expense of increasing the width of the main lobe. Second,
we can modify the specification of the magnitude frequency response with a smooth transition band to
reduce the oscillations and hence improve the performance of the FIR filter. Third, the magnitude
values Hk, k = 0, 1, . . . , M, in general can be arbitrarily specified. This indicates that the frequency
sampling method is more flexible and can be used to design the FIR filter with an arbitrary
specification of the magnitude frequency response.
Example8, bandpass FIR filter design using matlab, cont.
b. FIR filter coefficients in Example8 (frequency sampling method).
Optimal Design Method
• It uses the Parks-McClellan algorithm is developed based on the idea of minimizing
the maximum approximation error in a Chebyshev polynomial approximation to the
desired filter magnitude frequency response.
the equation of E(ω)
we can obtain the best FIR filter whose magnitude response has an equiripple
approximation to the ideal magnitude response. The achieved filters are optimal in the
sense that the algorithms minimize the maximum error between the desired frequency
response and the actual frequency response. These are often called minimax filters.
Parks-McClellan algorithm: the goal of the algorithm is to minimize the error in the pass and stop bands of the FIR filters by utilizing the Chebyshev approximation.
Chebyshev approximation: One can obtain polynomials very close to the optimal one by expanding the given function in terms of Chebyshev polynomials and then
cutting off the expansion at the desired degree. This is similar to the Fourier analysis of the function, using the Chebyshev polynomials instead of the usual
trigonometric functions.
Remez exchange algorithm: iterative algorithm used to find simple approximations to functions.
Optimal Design Method
• δp is used to specify the magnitude
ripple in the passband, while δs
specifies the stopband magnitude
attenuation. In terms of dB value
specification, we have:
• To make the error magnitudes
balanced, a weight function can be
introduced. The idea is to weight the
band with the bigger magnitude error
with a small weight factor and to
weight the band with the smaller
magnitude error with a big weight
factor. We use a weight factor Wp for
weighting the passband error and Ws
for weighting the stopband error.
Optimal FIR Filter Design Procedure for Parks-McClellan Algorithm
Example9: Optimal FIR Filter Design
Example9: Optimal FIR Filter Design, cont.
Hence, we have
Ws = 12 and Wp = 1:
Applying remez() routine provided by MATLAB,
MATLAB program for Example9
Example9: Optimal FIR Filter Design, cont.
FIR filter coefficients in Example
Example9: Optimal FIR Filter Design, cont.
The ripples in the passband are
between -1 and 1 dB. Hence,
all the specifications are met.
Note that if a specification is
not satisfied, we will increase
the order until the stopband
attenuation and passband
ripple are met.
Zoom in at the passband ripple region
Frequency and phase responses for Example9
Example10: Optimal FIR bandpass filter
Example10: Optimal FIR bandpass filter solution cont.
Then we get
Matlab program
Example10: Optimal FIR bandpass filter solution cont.
Frequency and phase responses for Example10