Sei sulla pagina 1di 8


In this report we will study the approximation schemes for digital filters with FIR and we will
present the methods for determining the multiplier coefficients and the filter order, in such a
way that the resulting frequency response satisfies a set of prescribed specifications.
In some cases, FIR filters are considered inefficient, in the sense that they require a high-order
transfer function to satisfy the system requirements when compared with the order required by
IIR digital filters. However, FIR digital filters do possess a few implementation advantages,
such as a possible exact linear-phase characteristic and intrinsically stable implementations,
when using nonrecursive realizations. In addition, the computational
complexity of FIR digital filters can be reduced if they are implemented using fast numerical
algorithms such as the FFT.

An FIR filter is one that is described by the difference equation,

and by the transfer function:

We address the problem of designing an FIR filter that meets specifications of limited deviation
from the ideal response in specified frequency bands.
The window design method does not produce filters that are optimal (in the sense of meeting
the design specifications in the most computationally-efficient fashion), but the method is
easy to understand and does produce filters that are reasonably good. Of all the hand-design
methods, the window method is the most popular and effective.
In brief, in the window method we develop a causal linear-phase FIR filter by multipying an
ideal filter that has an infinite-duration impulse response (IIR) by a finite-duration window

where is the practical FIR filter, is the ideal IIR prototype filter, and is the finite-duration
window function. An important consequence of this operation is that the DTFTs of hd[n] and

w[n] and undergo circular convolution in frequency

Ideal filters
Ideal filters have a response that is constant in the passbands and zero in the stopbands,along
with linear phase. As a reference, the transfer functions and corresponding impulse responses
ideal filters are as follows:
A. Lowpass filters

B. Highpass filters

C. Bandpass filters

In the filters above, the delay parameter must be an integer multiple of 1/2 for the filter to be
linear phase (and must be an integer multiple of 1 in the case of the highpass filter in order
for the delta function to be meaningful).

Commonly used windows in FIR filter design

Rectangular window
The rectangular window is what you would obtain if you were to simply segment a finite portion
of the impulse response without any shaping in the time domain:

And we know its DTFT to be,

Figure 1.DTFT and magnitude response curve of the sinc window function.

Bartlett (or triangular) window

The Bartlett window is triangularly shaped:

Because the Bartlett window can be thought of as having been obtained by convolving two
rectangular windows of half the width, its transform is easily squaring the transform of the
rectangular windows:

Hanning window
The Hanning window(or the von Hann window) is a raised cosine:

The Hanning window has the same mainlobe width as the Bartlett window, but its sidelobes
are attenuated further.
Hamming window
Richard W. Hamming observed that the sidelobes of the rectangular and Hanning
are phase reversed relative to each other, so a linear combination of the two would tend to
cause them to cancel each other. He searched for the linear combination that minimized the
maximum sidelobe amplitude and came up with the following formulation, which representsa
raised cosine on a rectangular pedestal:

Blackmann window
The Hanning and Hamming have a constant and a cosine term; the Blackmann
window adds
a cosine at twice the frequency.

Figure 2.Time domain window functions

DTFT and the FIR filters

The frequency response of the filter we obtain is the circular convolution of the
Fourier transform of the window with the frequency response of the desired ideal filter. The
magnitude of the Fourier transform of the five classic windows is shown in the next
Figure 3.Frequency response of the five typical window shapes

The curves in Fig. 3 are valuable because they provide insight into how the windowing
impacts on the performance of the resulting non-ideal filter. The width of the transition band
depends on the width of the mainlobe of the window function used to produce the FIR filter.
While this width depends on the length of the window, it also depends on the window shape.
It can be seen that in Fig. 3 (where all windows are of length 51), the rectangular window has
the narrowest mainlobe, the Blackman window has the widest mainlobe, and the other three
windows have the same (intermediate) width. The size of the ripple in the sidelobes of the
window determines the relative deviation of the resulting filter gain from its ideal value. This
effect is particular evident in the amount of attenutation in the stopbands of the resulting
filter (i.e. those frequencies for which the ideal transfer function has zero magnitude).
The curves in Fig. 4 show the magnitude of the response of actual (nonideal) filters designed
using the five windows, and an ideal lowpass prototype unit sample response with a cutoff
frequency of wc = 0.4.
It can be seen that as we go from the rectangular to the Blackman windows, the stopband
attenuation becomes progressively greater. It also can be seen that the transition bandwidths
behave as expected as stated in the previous page.
Figure 4.Lowpass filters obtained by multiplying windows by unit impulse

Effect of window duration

Fig. 5 below compares the frequency response of lowpass filters of 51, 101, and 201
all obtained using cutoff frequencies of 0.4radians and Hamming windows. It can be seen
that increasing the filter length decreases the transition bandwidth, but has has no effect on
the stopband attenuation (provided that the window shape remains the same).
The window shape affects the width of the transition band and the stopband attenuation,
while the window duration affects the transition bandwidth only. This suggests a
straightforward procedure that can be used to obtain an approximate design based on

On the basis of the information above, the steps for designing a filter are:
1. Choose the window shape to meet the stopband attenuation specifications.

2. Choose the window size to meet the transition bandwidth spec, given the window

3. Obtain the filter sample response by multiplying the window by the ideal sample
response. We should use an ideal filter with the cut-off frequency halfway between the
passband and stopband edges. Also we have to delay the ideal sample response by samples so
that the resulting filter will have linear phase.
Figure 5.Comparison of the effect of window length on the frequency response of lowpass
filters.[Hamming window -0.4 radians]


clc; clear all; close all;
tau=input('enter slope for linear phase response:');
t=input('enter type of filter(1.LPF, 2.HPF, 3.BPF, 4.BRF):');
switch t
case 1
wc=input('enter cutoff frequency in rad/sample:');
case 2
wc=input('enter cutoff frequency in rad/sample:');
case 3
wc1=input('enter cutoff frequency wc1 in rad/sample:');
wc2=input('enter cutoff frequency wc2 in rad/sample:');
case 4
wc1=input('enter cutoff frequency wc1 in rad/sample:');
wc2=input('enter cutoff frequency wc2 in rad/sample:');
for i=0:N-1
w(1,i+1)=1;%rectangular window
w(2,i+1)=0.5*(1-cos(2*pi*i/(N-1)));%hanning window
w(3,i+1)=0.54-0.46*cos(2*pi*i/(N-1));%Hamming window
%Bartlett window
for j=1:5
for j=1:5
switch j
case 1
title('FIR filter using rectangular window');
case 2
title('FIR filter using Hanning window');
case 3
title('FIR filter using Hamming window');
case 4
title('FIR filter using Blackmann window');
case 5
title('FIR filter using Bartlett window');
enter slope for linear phase response:3
enter type of filter(1.LPF, 2.HPF, 3.BPF, 4.BRF):1
enter cutoff frequency in rad/sample:0.5*pi