0% found this document useful (0 votes)
8 views35 pages

DSP Lab Manual 2022 batch

The document outlines a laboratory course on Digital Signal Processing, detailing experiments including the generation of discrete-time sequences, convolution, correlation, frequency analysis using DFT, and the design of FIR and IIR filters. Each experiment includes the aim, required software, procedures, and sample codes using Scilab. The results indicate successful execution of the experiments and the generation of various signal types and filter responses.
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)
8 views35 pages

DSP Lab Manual 2022 batch

The document outlines a laboratory course on Digital Signal Processing, detailing experiments including the generation of discrete-time sequences, convolution, correlation, frequency analysis using DFT, and the design of FIR and IIR filters. Each experiment includes the aim, required software, procedures, and sample codes using Scilab. The results indicate successful execution of the experiments and the generation of various signal types and filter responses.
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/ 35

20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

INDEX
S.N DATE EXPERIMENT NAME SUBMISSIO MARK SIGN
O N S
DATE
1. GENERATION OF ELEMENTARY
DISCRETE-TIME SEQUENCES

2. LINEAR AND CIRCULAR


CONVOLUTIONS

3. AUTO CORRELATION AND CROSS


CORRELATION

4. FREQUENCY ANALYSIS USING DFT.

5. DESIGN OF FIR FILTERS


(LPF/HPF/BPF/BSF) AND
DEMONSTRATES THE FILTERING
OPERATION.

6. DESIGN OF BUTTERWORTH AND


CHEBYSHEV IIR FILTERS
(LPF/HPF/BPF/BSF) AND
DEMONSTRATE THE
FILTERING OPERATIONS.

7.

8.

9.

10.

1
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

Ex no: GENERATION OF ELEMENTARY DISCRETE-TIME


Date: SEQUENCES

AIM:

● To generate elementary Discrete Time Signals.

SOFTWARE REQUIRED:

● Scilab 6.1.1

PROCEDURE:

● Open The Scilab Software


● Create A New File.
● Generate the Discrete Time Signals for Cosine, Sine, Unit Step, Ramp,
Rectangular, Signum, Sinc, Exponential.
● Execute and Obtain the Wave Signal.
● Save The File.

COSINE WAVES:

f=0.2;
t=0:0.1:10;
x=cos(2*%pi*t*f);
plot2d3(t,x)
title(' cosine wave ');
xlabel(' t ');
ylabel(' x ');

2
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

SINE WAVES:

f=0.2;
t=0:0.1:10;
x=sin(2*%pi*t*f);
plot2d3(t,x)
title(' sine wave ');
xlabel(' t ');
ylabel(' x ');

UNIT STEP:
3
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

t=0:4;
y=ones(1,5);
subplot(2,1,1);
plot2d3(t,y);
xlabel('time');
ylabel('amplitude');
title('Unit Step Discrete Signal');

SINC SIGNAL:

t=-10:0.2:10
x=sinc(t);
plot2d3(t,x)
title(' sinc wave ');
xlabel(' t ');
ylabel('x ');

4
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

RECTANGULAR WAVE:

clf;
t=linspace(0,10,50);
vm=5*squarewave(t);
plot2d3(t,vm)

EXPONENTIAL WAVE:

t=-2:0.1:2;
x=exp(t);
plot2d3(t,x)

5
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

title(' exponential wave ');


xlabel(' t ');
ylabel(' x ');

RESULT:

The demonstration of discrete time signal was conducted successfully.

6
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

Ex no: LINEAR AND CIRCULAR CONVOLUTION


Date:

AIM:

● To Perform Linear and Circular convolution of two sequences.

SOFTWARE USED:

● Scilab 6.1.1

PROCEDURE:

● Open The Scilab Software


● Create A New File.
● Perform Linear and Circular convolution of two sequences.
● Execute and Obtain The Wave Signal.
● Save The File.

CODE:

// program for linear convolution


clc;
clf;
clear all;
x =input('enter the first sequence:');
y =input('enter the second sequence:');
n =convol(x,y);
subplot(2,2,1);
plot2d3(x);

7
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

title('first sequence');
xlabel('n−−−−−−>');
ylabel('amp−−−−>');
subplot(2,2,2);
plot2d3(y);
title ('second sequence') ;
xlabel ( ' n−−−−−−> ' ) ;
ylabel ( 'amp−−−−> ' ) ;
subplot (2,2,3) ;
plot2d3(n);
title ( 'convolved sequence') ;
xlabel( ' n−−−−−−> ' ) ;
ylabel ( 'amp−−−−> ' ) ;
disp( 'The Convolved Sequences' ) ;
disp(n);

OUTPUT:
Enter the first sequence : [ 4 2 6 2 ]
Enter the second Sequence : [ 6 5 2 3 ]
The convolved sequences
24 32 54 58 28 22 6

8
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

// program for circular convolution


clc ;
clf ;
clear all;
g = input ( ’ Enter the first sequence : ’ ) ;
h = input ( ’ Enter the second sequence : ’ ) ;
N1 = length ( g ) ;
N2 = length ( h ) ;
N = max (N1 , N2 ) ;
N3 = N1 - N2 ;
if( N3 >=0) then
h =[ h , zeros (1 , N3 ) ];
else
g =[ g , zeros (1 , - N3 ) ];
end

9
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

for n =1: N
y ( n ) =0;
for i =1: N
j =n - i +1;
if(j <=0)
j=N+j;
end
y ( n ) = y( n ) + g ( i ) * h( j ) ;
end
end
disp ( ’ The resultant signal is : ’ ) ;
disp ( y );
subplot (3 ,1 ,1) ;
plot2d3 ( g );
title ( ’ f i r s t i n p u t s e q u e n c e ’ ) ;
subplot (3 ,1 ,2) ;
plot2d3 ( h );
title ( ’ s e c o n d i n p u t s e q u e n c e ’ ) ;
subplot (3 ,1 ,3) ;
plot2d3 ( y );
title ( ’ convolved sequence ’ ) ;

10
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

OUTPUT:
// Enter the first sequence : [ 5 3 6 4 ]
// Enter the second sequence : [ 2 6 5 3 ]
// The resultant signal is :
// 7 3 7 4 6 7 7 4

RESULT:

The Linear and Circular convolution of two sequences was performed.

11
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

Ex no: AUTOCORRELATION AND CROSS CORRELATION


Date:

AIM:

● To perform autocorrelation and cross correlation

SOFTWARE REQUIRED:

● Scilab 6.1.1

PROCEDURE:

● Open The Scilab Software


● Create A New File.
● Perform autocorrelation and cross correlation
● Execute and Obtain The Wave Signal.
● Save The File.

AUTOCORRELATION CODE:

t = linspace(0, 100, 2000);


y = 0.8 * sin(t) + 0.8 * sin(2 * t);
[c, ind] = xcorr(y, &quot;biased&quot;);
plot(ind, c)
CROSS CORRELATION CODE:

t = linspace(0, 100, 2000);


x = 0.5 * cos(t) + 0.9 * tan(2 * t);
y = 0.8 * sin(t) + 0.8 * sin(2 * t);
[c, ind] = xcorr(x,y, &quot;biased&quot;);
plot(ind, c)

12
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

OUTPUT:

OUTPUT:

RESULT:
The autocorrelation and cross correlation of signals was performed.

13
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

Ex no: FREQUENCY ANALYSIS USING DFT


Date:

AIM:

● To perform frequency analysis using DFT technique.

SOFTWARE REQUIRED:

● Scilab 6.1.1

PROCEDURE:

● Open The Scilab Software


● Create A New File.
● Perform frequency analysis using DFT
● Execute and Obtain The Wave Signal.
● Save The File.

CODE:

BasebandFrequency = 10e3;
SamplingFrequency = 1e6;
BufferLength = 200;
n = 0:(BufferLength - 1);
BasebandSignal = sin(2*%pi*n / (SamplingFrequency/BasebandFrequency));
plot(n, BasebandSignal)
BasebandDFT = fft(BasebandSignal);
BasebandDFT_magnitude = abs(BasebandDFT);
plot(BasebandDFT_magnitude);

14
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

OUTPUT:

RESULT:

The frequency analysis of baseband signal using DFT was performed.


15
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

Ex no: DESIGN OF FIR FILTERS (LPF/HPF/BPF/BSF) AND


Date: DEMONSTRATES THE FILTERING OPERATION

AIM:

● To design FIR filters like LPF, HPF, BPF, BSF.

SOFTWARE REQUIRED:

● Scilab 6.1.1

PROCEDURE:

● Open The Scilab Software


● Create A New File.
● Design various FIR filters like LPF, HPF, BPF and BSF.
● Execute and Obtain the output.
● Save The File.

LPF CODE:

// code for low pass filter


clc ;
clear ;
xdel ( winsid () ) ;
fc = input("Enter Analog Cutoff Frequency In Hz :") //250
fs = input("Enter Analog sampling Frequency in Hz:")//2000
M = input("Enter order of filter:")//4
w = (2* %pi ) *( fc / fs ) ;
disp(w,'Digital cutoff frequency in radians.cycles/samples');
wc = w/ %pi ;

16
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

disp ( wc ,'Normalized digital cutoff frequency in cycles/samples');


[wft,wfm,fr]=wfir('lp',M+1,[wc/2,0],'re',[0,0]);
disp ( wft ,'Impulse response of LPF FIR filter:h[n]=');
// P l o t t i n g t h e Magnitude R e s po n s e of LPF FIR Filter
subplot (2 ,1 ,1)
plot (2* fr , wfm )
xlabel("Normalized digital frequency w---->");
ylabel("Magnitude |H(w)|=");
title("MAgnitude response of FIR filter");
xgrid(1)
subplot (2 ,1 ,2)
plot(fr*fs,wfm)
xlabel("Analog frequency in Hz f---->");
ylabel("Magnitude |H(w)|=");
title("Magnitude response of FIR LPF");2
xgrid (1)
OUTPUT:

17
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

HPF CODE:

// code for high pass filter


clc ;
clear ;
xdel ( winsid () ) ;

18
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

fc=input("Enter Analog cutoff cutoff frequency in HZ:")// 250


fs=input("Enter Analog sampling cutoff frequency in Hz:")//2000
M=input ("Enter order of filter") // 4
w=(2*%pi)*(fc/fs);
disp(w,'Digital cutoff frequency in radians.cycles/samples') ;
wc=w/%pi ;
disp (wc,'Normalized digital cutoff frequency in cycles/samples') ;
[wft,wfm,fr]=wfir('hp',M+1,[wc/2,0],'re',[0,0]) ;
disp (wft,'Impulse Response of HPF FIR Filter:h[n]=');
20 // P l o t t i n g t h e Magnitude R e s po n s e of HPF FIR Filter
subplot(2 ,1 ,1)
plot(2*fr,wfm)
xlabel("Normalized Digital Frequency w−−−>");
ylabel("Magnitude |H(w)|=");
title("Magnitude Response of FIR HPF");
xgrid(1)
subplot (2 ,1 ,2)
plot(fr*fs,wfm);
xlabel("Analog Frequency in Hz f −−−>");
ylabel("Magnitude |H(w)|=");
title("Magnitude Response of FIR HPF");
xgrid(1)

OUTPUT:
19
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

BPF CODE:

// code for band pass filter


clc ;
clear ;
xdel ( winsid () ) ;
20
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

fc1=input("Enter Analog lower cutoff frequency in Hz:") // 250


fc2=input("Enter Analog higher cutoff frequency in Hz:") // 600
fs=input("Enter Analog sampling frequency in Hz:") //2000
M=input("Enter order of filter:") // 4
w1=(2*%pi)*(fc1/fs);
w2=(2*%pi)*(fc2/fs);
disp(w1,'Digital lower cutoff frequency in radians.cycles/samples') ;
disp(w2,'Digital higher cutoff frequency in radians.cycles/samples') ;
wc1=w1/%pi;
wc2=w2/%pi;
disp(wc1,'Normalized digital lower cutoff frequency in cycles/samples');
disp(wc2,'Normalized digital higher cutoff frequency in cycles/samples');
[wft,wfm,fr]= wfir('bp',M +1,[wc1/2,wc2/2],'re',[0,0]);
disp(wft,'Impulse response of BPF FIR Filter:h[n]=');
// P l o t t i n g t h e Magnitude R e s po n s e of HPF FIR Filter
subplot(2,1,1)
plot(2*fr,wfm);
xlabel('Normalized Digital Frequency w−−−>');
ylabel('Magnitude |H(w)|=');
title('Magnitude Response of FIR BPF');
xgrid(1)
subplot(2,1,2)
plot(fr*fs,wfm);
xlabel('Analog Frequency in Hz f −−−>');
21
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

ylabel('Magnitude |H(w)|=');
title('Magnitude R e s po n s e of FIR BPF');
xgrid(1)

OUTPUT:

22
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

BSF CODE:

// code for band stop filter


clc;
clear;
xdel(winsid());
fc1=input("Enter analog lower cutoff frequency in Hz:")//250
fc2=input("Enter analog higher cutoff frequency in Hz")//600
fs=input("Enter analog sampling frequency in Hz:")//2000
M=input("Enter order of filter:")//4
w1=(2*%pi)*(fc1/fs);
w2=(2*%pi)*(fc2/fs);
disp(w1,'Digital lower cutoff frequency in radians. cycles/samples');
disp(w2,'Digital higher cutoff frequency in radians.cycles/samples');
wc1=w1/%pi;

23
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

wc2=w2/%pi;
disp(wc1,'Normalized digital lower cutoff frequency in cycles/samples');
disp(wc2,'Normalized digital higher cutoff frequency in cycles/samples');
[wft,wfm,fr]=wfir('sb',M+1,[wc1/2,wc2/2],'re',[0,0]);
disp(wft,'Impulse response of BSF FIR Filter:h[n]:');
subplot(2,1,1)
plot(2*fr,wfm)
xlabel("Normalized digital frequency w---->");
ylabel("Magnitude |H(w)|:");
title("Magnitude response of FIR BSF");
xgrid(1)
subplot(2,1,2)
plot(fr*fs,wfm)
xlabel("Analog Frequency in Hz f---->");
ylabel("Magnitude |H(w)|:");
title("Magnitude response of FIR BSF");
xgrid(1)

OUTPUT:

24
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

25
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

RESULT:

The FIR filters like LPF, HPF, BPF, BSF were designed and output waveforms
were obtained.

Ex no: DESIGN OF BUTTERWORTH AND CHEBYSHEV IIR


Date: FILTERS (LPF/HPF/BPF/BSF) AND DEMONSTRATE
THE FILTERING OPERATIONS.

AIM:

● To design butterworth and chebyshev IIR filters for LPF, HPF, BPF, BSF.

SOFTWARE REQUIRED:

● Scilab 6.1.1

PROCEDURE:

● Open The Scilab Software


● Create A New File.
● Design butterworth and chebyshev IIR filters for LPF, HPF, BPF, BSF .

26
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

● Execute and Obtain the output.


● Save The File.

BUTTERWORTH LPF CODE:

// Caption : To design a digital IIR First Order Butterworth LPF Filter


// Using Bilinear Transformation
clear all;
clc ;
close ;
s=poly(0,'s');
Omegac=0.2*%pi; // Cut off f r e q u e n c y
H=Omegac/(s+Omegac); // Analog first order Butterworth filter transfer function
T =1; // Sampling p e r i o d T = 1 Second
z =poly(0,'z');
Hz =horner(H,(2/T)*((z-1)/(z+1))) // Bilinear r a n sf o rm a ti o n
HW = frmag(Hz(2),Hz(3),512); // Frequency response of o r 512 p o i n t s
W =0:%pi/511:%pi;
a = gca();
a.thickness=1;
plot(W/%pi,HW,'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of Single pole LPF filter cutoff frequency =
0.2*pi','Normalized digital frequency -----> ',' Magnitude');

27
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

OUTPUT :

BUTTERWORTH HPF CODE:

clear all;
clc;
close ;
s = poly(0,'s');
Omegac = 0.2*%pi;
H = Omegac/(s+Omegac);
T=1;
z=poly(0,'z');
Hz_LPF = horner(H,(2/T)*((z-1)/(z+1)));
alpha = -(cos((Omegac+Omegac)/2))/(cos((Omegac-Omegac)/2));

28
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

HZ_HPF = horner(Hz_LPF, -(z+alpha)/(1+alpha*z))


HW = frmag(HZ_HPF(2),HZ_HPF(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,HW,'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of Single pole HPF Filter Cutoff frequency =
0.2*pi','Normalized digital frequency W/pi ---->','Magnitude');

OUTPUT :

29
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

BUTTERWORTH BPF CODE:

clear all;
clc;
close;
omegaP = 0.2*%pi;
omegaL = (1/5)*%pi;
omegaU = (3/5)*%pi;
z=poly(0,'z');
H_LPF=(0.245)*(1+(z^-1))/(1-0.509*(z^-1));
alpha = (cos((omegaU+omegaL)/2)/cos((omegaU-omegaL)/2));
k=(cos((omegaU-omegaL)/2)/sin((omegaU-omegaL)/2))*tan(omegaP/2);
NUM = -((z^2)-((2*alpha*k/(k+1))*z)+((k-1)/(k+1)));
DEN = (1-((2*alpha*k/(k+1))*z)+(((k-1)/(k+1))*(z^2)));

30
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

HZ_BPF=horner(H_LPF,NUM/DEN);
disp(HZ_BPF,'Digital BPF IIR Filter H(Z)= ');
HW = frmag(HZ_BPF(2),HZ_BPF(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,HW,'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of BPF Filter cutoff frequency [0.2,0.6]','Normalized
digital frequency --->','MAgnitude');

OUTPUT :

BUTTERWORTH BSF CODE:

31
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

clear all;
clc;
close;
omegaP = 0.2*%pi;
omegaL = (1/5)*%pi;
omegaU = (3/5)*%pi;
z=poly(0,'z');
H_LPF=(0.245)*(1+(z^-1))/(1-0.509*(z^-1));
alpha = (cos((omegaU+omegaL)/2)/cos((omegaU-omegaL)/2));
k=tan((omegaU-omegaL)/2)*tan(omegaP/2);
NUM = -((z^2)-((2*alpha/(1+k))*z)+((1-k)/(1+k)));
DEN = (1-((2*alpha/(1+k))*z)+(((1-k)/(1+k))*(z^2)));
HZ_BPF=horner(H_LPF,NUM/DEN);
HW = frmag(HZ_BPF(2),HZ_BPF(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,HW,'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of BSF Filter cutoff frequency [0.2,0.6]','Normalized
digital frequency --->','MAgnitude');

OUTPUT :

32
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

CHEBYSHEV LPF CODE:

clear all;
clc;
close;
Wp= input('Enter the digital pass band edge frequency');
Ws= input('Enter the digital stop band edge frequency');
T=input('sampling interval')
OmegaP = (2/T)*tan(Wp/2)
OmegaS = (2/T)*tan(Ws/2)
Delta1 = input('Enter the pass band ripple');
Delta2 = input('Enter the stop band ripple');
Delta = sqrt(((1/Delta2)^2)-1)
Epsilon = sqrt(((1/Delta1)^2)-1)
N = (acosh(Delta/Epsilon))/(acosh(OmegaS/OmegaP))

33
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

N=ceil(N)
OmegaC = OmegaP/((((1/Delta1)^2)-1)^(1/(2*N)))
[pols,gn]=zpch1(N,Epsilon,OmegaP)
Hs=poly(gn,'s','coeff')/real(poly(pols,'s'))
z=poly(0,'z');
Hz=horner(Hs,((2/T)*((z-1)/(z+1))))
HW = frmag(Hz(2),Hz(3),512);
W=0:%pi/511:%pi;
a=gca();
a.thickness=1;
plot(W/%pi,abs(HW),'r')
a.foreground=1;
a.font_style=9;
xgrid(1)
xtitle('Magnitude Response of Chebyshev LPF Filter','Normalized digital
frequency --->','MAgnitude in dB');

OUTPUT :

34
20EC611- DIGITAL SIGNAL PROCESSING LABORATORY

35

You might also like