Sei sulla pagina 1di 8

# FIR FILTERS

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.

## 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
function:

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
windows
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
a cosine at twice the frequency.

## 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
page[Fig.3]
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
process
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
samples,
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
specifications.

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
shape.

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

## MATLAB PROGRAM FOR FIR FILTER DESIGN

clc; clear all; close all;
tau=input('enter slope for linear phase response:');
tau=ceil(tau);
N=2*tau+1;
t=input('enter type of filter(1.LPF, 2.HPF, 3.BPF, 4.BRF):');
n=0:N-1;
switch t
case 1
hiir=wc/pi*sinc(wc/pi*(n-tau));%LPF
case 2
hiir=sinc(n-tau)-wc/pi*sinc(wc/pi*(n-tau));%HPF
case 3
wc1=input('enter cutoff frequency wc1 in rad/sample:');
wc2=input('enter cutoff frequency wc2 in rad/sample:');
hiir=wc2/pi*sinc(wc2/pi*(n-tau))-wc1/pi*sinc(wc1/pi*(n-tau));%BPF
case 4
wc1=input('enter cutoff frequency wc1 in rad/sample:');
wc2=input('enter cutoff frequency wc2 in rad/sample:');
hiir=sinc(n-tau)-(wc2/pi*sinc(wc2/pi*(n-tau))-
wc1/pi*sinc(wc1/pi*(n-tau)));%BSF
end
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
w(4,i+1)=0.42-0.5*cos(2*pi*i/(N-1))+0.08*cos(4*pi*i/(N-1));%blackmann
window
%Bartlett window
if(i<=(N-1)/2)
w(5,i+1)=2*i/(N-1);
else
w(5,i+1)=2-2*i/(N-1);
end
end
for j=1:5
hfir(j,:)=hiir.*w(j,:);
end
for j=1:5
figure;
freqz(hfir(j,:));
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');
end
end
OUTPUT:
enter slope for linear phase response:3
enter type of filter(1.LPF, 2.HPF, 3.BPF, 4.BRF):1