0% found this document useful (0 votes)
36 views13 pages

Exp6 Edsp Rohit

Uploaded by

rohit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
36 views13 pages

Exp6 Edsp Rohit

Uploaded by

rohit Singh
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

EXP6. DATE.

- 16/10/23

FIR DIGITAL FILTER DESIGN USING WINDOWS


1 Objectives
1. To plot the window functions.
2. To design FIR,lowpass, digital filters using rectangu lar,Hamming, Hanning, Bartlett,
Blackman and Kaiser windows.

2 Theory Overview
The time domain classification of a digital filter based on the length of its
impulse response sequence leads to the finite impulse response(FIR) filter
There are four types of ideal filters(LPF,HPF,BPF,BSF) are usually defined
based on the magnitude function |H(e jω)|.
These ideal filters have doubly infinite impulse responses and are unrealizable as
they are not causal. In practice, realizable approximations to the ideal filters can
be made.
The design of FIR filter is therefore based on a direct approximation of the
specified magnitude response .
A variety approaches has been proposed for the design of FIR filters.A direct and
straightforward method is based on truncating the Fourier series representation of
the prescribed frequency response using windows.

2.1 Filter Design Specifications


The desired magnitude |G(e jω )| of a lowpass filter is shown in Fig.1. As
indicated in the figure, the passband defined by 0 ≤ ω ≤ ωp and require that the
magnitude approximates unity with an error of ±δp: that is
1 − δp ≤ |G(e jω)| ≤ 1 + δp, for |ω| ≤ ωp (1)
In the stopband, defined by ωs ω π, the magnitude approximates zero with an
error bound of δs; that is |G(e jω)| ≤ δs, for ωs ≤ |ω| ≤ π (2) The frequencies ωp
and ωs are respectively, called the passband edge frequency and the stopband
edge frequency.The limits of the tolerances in the passband and stopband, δp and
δp, are usually called the peak ripple values. Hence the digital filter
specifications are ωp, ωs, δp and δs.
2.2 Estimation of Order of The Filter
From the digital filter specifications the minimum value of the filter order N can
be directly estimated using the formula
2.4 Algorithm

1. Get the passband and stopband ripples.


2. Get the passband and stopband edge frequencies,
3. Get the sampling frequency.
4. Calculate the order of the filter using Eq.3.
5. Find the filter coefficients.
6. Draw the magnitude responses

3 Matlab Programs
%CB.EN.U4ELC21048

clc

clear all

close all

tap = input("Enter the type of tap filter: ");

fcut = input("Enter the cutoff frequency: ");

fsa = input("Enter the sampling rate: ");

stat = input("Enter the stopband attenuation: ");

fcn = fcut / fsa;

if mod(tap, 2) == 0

m = (tap) / 2;

else

m = (tap - 1) / 2;

end

n = -m:m;

arr = 1:2*m+1;

if stat <= 33

disp("rectangular")

h = zeros(size(arr));

arr = 1;

for i = -m:m

if i == 0
h(arr) = 2 * fcn

else

h(arr) = 2 * fcn * sin(2 * pi * fcn * abs(i) ) / (2 * pi * fcn* abs(i) )

end

w(arr)=1;

ans(arr) = w(arr) * h(arr);

arr = arr + 1;

end

stem(n,ans);

title('Magnitude Response of Low Pass FIR Filter- rectangular');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

elseif stat > 33 && stat < 48

disp("Hanning")

arr = 1;

h = zeros(size(arr));

w = zeros(size(arr));

ans = zeros(size(arr));

for i = -m:m

if i == 0

h(arr) = 2 * fcn;

else

h(arr) = 2 * fcn * (sin(2 * pi * fcn * abs(i) )) / (2 * pi * fcn* abs(i) );

end

w(arr) = 0.5 + 0.5 * cos(abs(i) * pi / m);

ans(arr) = w(arr) * h(arr)

arr =arr + 1;

end

stem(n,ans);

title('Magnitude Response of Low Pass FIR Filter- Hanning');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

elseif stat >=48 & stat < 64

disp("Hamming")

arr = 1;

h = zeros(size(arr));

w = zeros(size(arr));

ans = zeros(size(arr));
for i = -m:m

if i == 0

h(arr) = 2 * fcn;

else

h(arr) = 2 * fcn * (sin(2 * pi * fcn * abs(i) )) / (2 * pi * fcn* abs(i) );

end

w(arr) = 0.54 + 0.46 * cos(abs(i) * pi / m);

ans(arr) = w(arr) * h(arr)

arr =arr + 1

end

stem(n,ans);

title('Magnitude Response of Low Pass FIR Filter- Hamming');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

elseif stat >= 64

disp("Blackman")

arr = 1;

h = zeros(size(arr));

w = zeros(size(arr));

ans = zeros(size(arr));

for i = -m:m

if i == 0

h(arr) = 2 * fcn;

else

h(arr) = 2 * fcn * (sin(2 * pi * fcn * abs(i) )) / (2 * pi * fcn* abs(i) );

end

w(arr) = 0.542 + 0.5 * cos(abs(i) * pi / m) + 0.08*cos(2*abs(i)*3.14/m);

ans(arr) = w(arr) * h(arr)

arr =arr + 1;

end

stem(n,ans);

title('Magnitude Response of Low Pass FIR Filter-Black man');

xlabel('Frequency (Hz)');

ylabel('Magnitude');

end

Output
Rectangular Window-
Plot:

Case 2 -Hanning Window


Plot:

Case –3 Hamming Window


Plot:

Case – 4 Blackman Window


Plot:

3.1 Matlab Syntax and Description


b = fir1(n,Wn,ftype,window) designs a lowpass, highpass, bandpass, bandstop,
filter, depending on the value of ftype, the number of elements of Wn and type of
window.
[h,w] = freqz(b,a,n) returns the n-point frequency response vector h and the
corresponding angular frequency vector w for the digital filter with transfer
function coefficients stored in b and a.

References

[1] https://in.mathworks.com/support.html.
[2] Dimitris G.Monolakis John G.Prokais. Digital Signal Processing,Principles,
Algorithms and Applications. The Prentice Hall International Ins, 1996.
[3] Sanjit K Mitra. Digital Signal Processing, A Computer-Based Approach. The
Mcgrawhill Publishing Companies, 2008.

4. Results and Inference

The Fir digital filter is desinged in this experiment using the windowing method
The different types of windowing method like rectangular, triangular , hanning
,hamming and black man window is introduced.
The windowing method is powerful tool for designing a fir filter.
The Choice Of the window function can have an impact on the filter’s frequency
Response and characteristics.
For example, Hanning and Hamming windows are often used for smoother
frequency responses, while the Blackmann window provides better attenuation
Properties.

Name: ROHIT KUMAR SINGH. Reg. No. - CB.EN.U4ELC21048

Date of Experiment : ……………


Date of Report Submission : ……………
Submission Delay: …........ ASSESSMENT
Student Task Max. Marks Graded Marks
Conduction 5
Results & Conclusion 5
Total 10

Signature

You might also like