You are on page 1of 6

EXPERIMENT NO.

8
DATE:12-08-15

LOWPASS FIR FILTER USING HAMMING WINDOW


AIM:
To design a Low Pass FIR filter using Hamming window and to plot its frequency response.

THEORY:
Window design - The basic idea behind the window design is to choose a proper ideal frequencyselective filter(which always has a non-causal, infinite duration impulse response and then
truncate (or window) its impulse response to obtain a linear phase and causal FIR filter.An ideal
LPF of bandwidth wc< is given by
(

| |

| |
Where wc is also called the cutoff frequency and is called the sample delay .The impulse
response of this filter is of infinite duration and is given by
(
(

( )
To obtain an FIR filter from

)
)

( ), one has to truncate

( ) on both sides. To obtain a causal

and linear phase FIR filter ( ) of length M, we must have


( )

( )

Where
This operation is called windowing. In general, ( ) can be thought of as being formed by the
product of

( ) and a window function


( )

( ) as follows:
( ) ( )

Where
( )

Depending on how we define

( ) above, we obtain different window designs.

45

Hamming window
This is a raised cosine window with a small amount of discontinuity and is given by
( )
The approximate transition width

is

and the exact value is

The minimum stop band attenuation is 53 dB

ALGORITHM:
Step 1: Start
Step 2:Input the pass band ripple rp in dB, stop band ripple rs in dB, pass band frequency in Hz
fp, sampling frequency in Hz f, stop band frequency fs in Hz
Step 3: Compute the normalized frequencies
Step 4: Find the length of the window using the equation
N= ceil((-20*log10(sqrt(dp*ds))-13)/( 14.6*(ws-wp)/2))
and if N is even, increment N
Step 5: Find normalized cut off frequency by the formula wn= (wp + ws)/2
Step 6: Find the N point symmetric hamming window using hamming function.
Step 7: Design the low pass FIR filter using hamming window with order N produce an N-1
length vector to window the impulse response using fir1 command.
Step 8: Plot the magnitude and phase response using freqz
Step 9: Stop

46

PROGRAM:

(a)

FIR Filter Design using Hamming Window

clc;
clear all;
close all;
fsmp=2000;

% sampling frequency

fp=200;
fs=400;

% pass band frequency


% stop band frequency

wp=fp/(fsmp/2);
ws=fs/(fsmp/2);
rp=.1;
rs=35;

% pass band ripple


% stop band ripple

dp=(10^(rp/20)-1)/(10^(rp/20)+1);
ds=1/(10^(rs/20));
N=((-20*log(sqrt(dp*ds)))-13)/(14.6*(ws-wp)/2);
N=ceil(N);
% rounding to next largest number
if rem(N,2) == 0
N=N+1;
end;
wn=(wp+ws)/2;
y=hamming(N);
b=fir1(N-1,wn,y);
figure(1);
stem(y);
title('Hamming window');
figure(2);
freqz(b,1,256,fsmp);
title('Response of the filter');

47

(b)

Illustration of filter

f1=100;
f2=500;

48

T=1/f1;
t=0:1/fsmp:3*T;
s1=sin(2*pi*f1*t);
s2=sin(2*pi*f2*t);
s=s1+s2;

% signal 1 of frequency f1
% signal 2 of frequency f2

y=filter(b,1,s);
figure(3);
subplot(2,2,1);
plot(t,s1);
title('Signal 1 ( f = 100 Hz)');
xlabel('time');
ylabel('Amplitude');
subplot(2,2,2);
plot(t,s2);
title('Signal 2 ( f = 500 Hz)');
xlabel('time');
ylabel('Amplitude');
subplot(2,2,3);
plot(t,s);
title('Composite signal');
xlabel('time');
ylabel('Amplitude');
subplot(2,2,4);
plot(t,y);
title('Filtered Output');
xlabel('time');
ylabel('Amplitude');

49

RESULT:
Designed a Low Pass FIR filter using Hamming window and plotted its frequency response.

50

You might also like