Design of IIR Elliptical Band Pass Filter: Expt. No.: 3A

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 12

Expt. No.

: 3A
Name: Kshitij Shallesh Tater Date: 11/06/23
Slot: L39+L40
Register Number: 21BEE0094

Design of IIR Elliptical


Band Pass Filter

AIM:

Design an IIR Elliptic band pass filter to filter out noise from the sinusoidal signal using
MATLAB. Assume appropriate specifications. Plot the spectra. Comment on the results.

APPARATUS REQUIRED:

System with MATLAB R2022b.

THEORY

IIR ELLIPTICAL BAND PASS FILTER:

An elliptical bandpass filter, also known as an elliptic filter or Cauer filter, is a type of infinite
impulse response (IIR) filter commonly used in signal processing and telecommunications. It is
designed to allow a specific range of frequencies to pass through while attenuating frequencies
outside the passband.

The elliptical filter has a unique frequency response characteristic that exhibits ripples in both
the passband and stopband. This allows for a sharper transition between the passband and
stopband compared to other types of filters, such as Butterworth or Chebyshev filters. The
elliptical filter can achieve a steeper roll-off and a more compact filter design.

To design an elliptical bandpass filter, you need to specify certain parameters:

Passband frequencies: These define the range of frequencies that should pass through the filter
without significant attenuation.

Stopband frequencies: These define the range of frequencies that should be attenuated to a
certain level.

Passband ripple: It specifies the allowable variation in gain within the passband. This ripple is
typically specified in decibels (dB).
Stopband attenuation: It specifies how much the filter should attenuate frequencies in the
stopband. This attenuation is also specified in decibels (dB).

ALGORITHM:

1. Get the number of samples.

2. Generate the output sequence of the given two input signals.

3. Plot the graph.

MATLAB PROGRAM:

IIR ELLIPTICAL BAND

PASS FILTER

%Design of IIR Band Pass Elliptical filter


%Specifications: Order N=4;Passband ripple: alpha p = 0.1dB
%Stop band attenuation: alpha s=40dB;cutoff freq : fcl=15Hz
%Sampling frequency fs = 150Hz
% Kshitij Shallesh Tater 21BEE0094

clc;
clear all;
close all;
t=0:200;
fs=150; % sampling frequency
s1=sin(2*pi*10*t/fs); %10Hz signal
subplot(4,1,1);
plot(s1);
title('s1-10Hz signal');

s2=sin(2*pi*20*t/fs); %20Hz signal


subplot(4,1,2);
plot(s2);
title("s2-20Hz signal");

s3=sin(2*pi*40*t/fs); %40Hz signal


subplot(4,1,3);
plot(s3);
title("s3-40Hz signal");

s4=sin(2*pi*50*t/fs); %50Hz signal


subplot(4,1,4);
plot(s4);
title("s4-50Hz signal");
s=s1+s2+s3+s4; %sum of the signals
figure(2);
plot(s);

%Y = FILTER(B,A,X) One dimensional digital filter


%[B,A] = ELLIP(N,Rp,Rs,Wp,'low') % IIR Elliptical low pass filter
%Wp = [W1 W2]:[B,A] = ELLIP(N,Rp,Rs,Wp,'stop') % IIR Elliptical high pass filter

[b,a]=ellip(4,0.1,40,[15 45]*2/fs); % IIR Elliptical band pass filter


[h,w]=freqz(b,a,512);

figure(3);
plot(w*fs/(2*pi), abs(h));
title("Response of the filter");
xlabel('Frequency(Hz)');
ylabel('Gain(dB)');

sf = filter(b,a,s);
figure(4);
subplot(2,1,1);
plot(sf);
title("Filtered output");
xlabel("Time");
ylabel("Amplitude");

s = fft(s,512);
sf = fft(sf,512);
% p=(0:255)/256*(fs/2);
p=(0:511)/(512*(fs));
% p1=(0:255)/256*(fs/2);
subplot(2,1,2);
plot(p,abs([s(1:512)' sf(1:512)']));
%plot(p,abs([s(1:256)']));
%plot(p,abs([s(1:512)']));
title("Frequency spectrum of the filtered signal");
xlabel("Frequency (Hz)");
ylabel("PSD-Power Spectral Density");

RESULT:

Design an IIR Elliptic band pass filter to filter out noise from the sinusoidal signal are
successfully generated using Matlab code.
INFERENCE:

Filter selection: Based on the experiment's requirements, the researcher can choose the elliptical
bandpass filter as the filter of choice. This decision would be influenced by the desired
characteristics of the filter, such as the sharpness of the transition region, passband ripple, and
stopband attenuation.

Filter design: The parameters of the elliptical bandpass filter need to be determined to achieve
the desired filtering characteristics. The passband frequencies, stopband frequencies, passband
ripple, and stopband attenuation should be carefully defined based on the experiment's
requirements.

Implementation: Once the filter design parameters are determined, they can be used to calculate
the filter coefficients or pole-zero placements required for implementing the elliptical bandpass
filter. This implementation can be done using digital signal processing techniques or analog
circuitry, depending on the specific experiment setup.

Signal processing: The designed and implemented elliptical bandpass filter can be applied to the
experimental data to selectively pass the desired frequency range while attenuating unwanted
frequencies. This filtering process helps to isolate and analyze specific components of the signal
relevant to the experiment.

Data analysis: The filtered data can then be further analyzed and processed to draw inferences
and conclusions based on the experiment's objectives. The filtered signal may reveal patterns,
features, or specific frequency components that are of interest for the experiment.

REFERENCES:

Matlab help.

OUTPUT:
Register Number: 21BEE0094 Expt. No.:3B
Name: Kshitij Shallesh Tater
Date:11/06/23
Slot:L39+L40

DESIGN OF FIR FILTER

AIM:

Design a FIR LPF, HPF, BPF and BSF using Hamming window. Estimate the filter
coefficients using MATLAB. Assume appropriate specifications. Plot the spectra and
comment on the results.

APPARATUS REQUIRED:

System with MATLAB R2022b.

THEORY:

The design of a Finite Impulse Response (FIR) filter involves determining the filter coefficients
that define its frequency response. FIR filters are widely used in digital signal processing due to
their linear phase characteristics and ease of implementation.

Here are the basic steps involved in designing an FIR filter:

Filter Specifications: Define the specifications of the FIR filter based on your requirements.
These specifications typically include the desired frequency response characteristics, such as
passband ripple, stopband attenuation, and transition bandwidth. You may also specify the filter
order, which determines the number of coefficients in the filter.
Select a Window Function: Choose a window function that will shape the impulse response of
the FIR filter. Commonly used window functions include Hamming, Hann (or Hanning),
Blackman, and Kaiser. The choice of window function depends on the desired trade-off between
the main lobe width and the level of sidelobe attenuation.
Determine Filter Length: Determine the length of the FIR filter, which is equal to the number
of coefficients. The filter length is usually determined based on the desired frequency resolution
and the characteristics of the window function. A longer filter length generally provides better
frequency resolution but increases computational complexity.
Compute Ideal Frequency Response: Calculate the desired ideal frequency response for the
FIR filter based on the specified filter specifications. This can be done using mathematical
formulas or filter design tools.
Apply Windowing: Multiply the ideal frequency response by the chosen window function to
obtain the windowed frequency response. This process narrows the main lobe and reduces the
sidelobe levels.
Inverse Fourier Transform: Apply an inverse Fourier transform to the windowed frequency
response to obtain the time-domain impulse response of the filter.
Normalize and Quantize: Normalize the filter coefficients to ensure the maximum amplitude
does not exceed 1. If required, quantize the coefficients to the desired number of bits for
implementation.
Filter Implementation: Implement the designed FIR filter using the computed filter
coefficients. The implementation can be in software, hardware (e.g., FPGA or ASIC), or
dedicated DSP processors.

ALGORITHM:

1. Get the number of samples.

2. Generate the output sequence of the given two input signals.

3. Plot the graph.

MATLAB PROGRAM:

%program for FIR filter design using hamming window LPF,HPF,BPF,BSF


%Kshitij Shallesh Tater 21BEE0094

clc;
clear all;
close all;

rp=0.02;
rs=0.01;
fpb=1200;
fsb=1700;
fs=9000;
wp=2*fpb/fs;
ws=2*fsb/fs;
num=-20*log10(sqrt(rp*rs))-13;
den=14.6*(fsb-fpb)/fs;
n=ceil(num/den);
n1=n+1;
if (rem(n,2)~=0)
n1=n;
n=n-1;
end
y=hamming(n1);
%LOW PASS EILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10 (abs (h) );
subplot (2,2,1);
plot (o/pi,m);
ylabel ('Gain(dB)');
xlabel (' (a)Normalized frequency --- >');
title ('Magnitude response of FIR lo₩ pass filter');
%HIGH PASS FILTER
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10 (abs(h) );
subplot (2,2,2);
plot (o/pi,m, 'g');
ylabel ('Gain (dB)');
xlabel (' (b)Normalized frequency --- >');
% BAND PASS FILTER
wn=[wp,ws];
b=fir1(n, wn,y);
[h,o]=freqz (b,1,256);
m=20*log10 (abs (h));
subplot (2,2,3);
plot (o/pi,m,'r');
ylabel ('Gain (dB)');
xlabel (' (c)Normalized frequency --- >');
title('Magnitude response of FIR band pass filter');
%BAND STOP FILTER
b=-fir1(n,wn,'stop',y);
[h,o]=freqz(b, 1,256);
m=20*log10 (abs (h));
subplot (2,2,4);
plot (o/pi,m);
ylabel ('Gain (dB)');
%BAND STOP FILTER
b=fir1 (n,wn, 'stop',y);
[h, o]=freqz(b, 1,256);
m=20*log10 (abs (h));
subplot (2,2,4);
plot (o/pi,m);
ylabel ('Gain(dB)');
xlabel (' (d)Normalized frequency --- >');
title('Magnitude response of FIR band stop filter');
%Examрle
%Enter the pass band ripple-0.02 (bcozpap-rs]
%Enter the stop band ripple=0.01
% Enter the pass band frequency=1200
% Enter the stop band frequency-1700
% Enter the sampling frequency-9000

RESULT:

Design a FIR LPF, HPF, BPF and BSF using Hamming window are successfully generated using
Matlab code.

INFERENCE:

Experimental requirements: Determine the specific requirements of the experiment in terms of


signal processing. This includes identifying the desired frequency response characteristics, such
as the desired passband, stopband, and transition bandwidth, as well as any constraints on
passband ripple and stopband attenuation.

Filter design: Based on the experimental requirements, design an FIR filter that can meet these
specifications. The filter design process involves selecting an appropriate window function and
determining the filter length (number of coefficients) to achieve the desired trade-off between
frequency resolution and computational complexity.

Frequency response shaping: By designing the FIR filter, you can shape its frequency response
to emphasize or attenuate specific frequency components in the input signal. This can be useful
for isolating or enhancing certain features of the signal that are relevant to the experiment.

Windowing: Applying a window function to the desired frequency response narrows the main
lobe and reduces the levels of sidelobes. This step helps to minimize unwanted effects, such as
spectral leakage or distortion, that can impact the accuracy and reliability of the experimental
results.

Implementation: Once the filter coefficients are obtained, the FIR filter can be implemented in
software or hardware based on the specific experiment setup. The implementation involves
applying the filter coefficients to the input signal to perform the desired signal processing
operation, such as filtering out noise or extracting specific frequency components.

REFERENCES:

Matlab help.

OUTPUT:

You might also like