Lab Manual
Lab Manual
Name: ……………………………………………….
Impart an inclusive engineering education that beyond being a facilitator for a career
and rudimentary skills, equips the students to offer ethically & environmentally conscious
solutions to societal issues.
To provide the students with a strong foundation in the required sciences in order
to pursue studies in Electronics and Communication Engineering.
To give a broad exposure to the students in various topics related to Electronics
and Communication Engineering fields, to enable them to excel in their
professional career /higher studies.
To develop innovative skills in the students in order to solve the technical
problems which will arise in their professional skills.
To inculcate in the students a professional and ethical attitude and an ability to
visualize the engineering issues in a broader social context.
2. Problem analysis: Identify, formulate, review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of
mathematics, natural sciences, and engineering sciences.
5. Modern tool usage: Create, select, and apply appropriate techniques, resources, and
modern engineering and IT tools including prediction and modelling to complex
engineering activities with an understanding of the limitations.
6. The engineer and society: Apply reasoning informed by the contextual knowledge to
assess societal, health, safety, legal and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional
engineering solutions in societal and environmental contexts, and demonstrate the
knowledge of, and need for sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities
and norms of the engineering practice.
12.Life-long learning: Recognize the need for, and have the preparation and ability to
engage in independent and life-long learning in the broadest context of technological
change.
2. Analyze and design modules and systems for applications including Signal Processing,
Communication, Networking and RF & Microwave Engineering.
Course Outcomes (COs)
Course PO1 PO2 PO3 PO4 PO5 PO6 PO7 PO8 PO9 PO10 PO11 PO12 PSO1 PSO2
C307.1 3 3 3 3 3 1 - 1 2 3 3 3 3 3
C307.2 3 3 3 3 3 1 - 1 2 3 3 3 3 3
C307.3 3 3 3 3 3 1 - 1 2 3 3 3 3 3
C307.4 3 3 3 3 3 1 - 1 2 3 3 3 3 3
C307.5 3 3 3 3 3 1 - 1 2 3 3 3 3 3
C307.6 3 3 3 3 3 1 - 1 2 3 3 3 3 3
SYLLABUS
LTPC
0 0 4 2
4. Design and demonstration of FIR Filter for Low pass, High pass, Band pass and
Band stop filtering
5. Design and demonstration of Butter worth and Chebyshev IIR Filters for Low pass,
High pass, Band pass and Band stop filtering
PROGRAM:
clc;
clear all;
close all;
n1=input('Enter the initial value: ');
n2=input('Enter the final value: ');
n0=input('Enter the location at which the impulse must arise: ');
[n,x]=impulse_seq(n1,n2,n0);
stem(n,x);
xlabel('Time index');
ylabel('Amplitude');
title('impulse seq');
grid on;
OUTPUT:
impulse seq
1
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
0 0.5 1 1.5 2 2.5 3
Time index
UNIT STEP SEQUENCE
PROGRAM:
clc;
clear all;
close all;
n1=input('Enter the initial value: ');
n2=input('Enter the final value: ');
n0=input('Enter the value: ');
[n,x]=step_seq(n1,n2,n0);
stem(n,x);
xlabel('Time');
ylabel('Amplitude');
OUTPUT:
0.9
0.8
0.7
0.6
Amplitude
0.5
0.4
0.3
0.2
0.1
0
0 0.5 1 1.5 2 2.5 3 3.5 4
Time
UNIT RAMP SEQUENCE
PROGRAM:
clc;
clear all;
close all;
n1=input('Enter the initial value:');
n2=input('Enter the final value:');
[n,r]=ramp_seq(n1,n2);
stem(n,r);
xlabel('Time Index');
ylabel('Amplitude');
OUTPUT:
RAMP SEQUENCE
6
4
Amplitude
0
0 1 2 3 4 5 6
Time Index
COSINUSOIDAL SEQUENCE
PROGRAM:
clc;
clear all;
close all;
n1=input('Enter the initial value: ');
n2=input('Enter the final value: ');
F=input('enter a frequency');
Fs=input('Enter the sampling frequency: ');
A=input('Enter the amplitude: ');
[n,x]=cos_seq(n1,n2,F,Fs,A);
stem(n,x);
xlabel('Time Index');
ylabel('Amplitude');
OUTPUT:
COSINUSOIDAL SEQUENCE
4
1
Amplitude
-1
-2
-3
-4
0 5 10 15 20 25 30
Time Index
SINUSOIDAL SEQUENCE
PROGRAM:
clc;
clear all;
close all;
n1=input('Enter the initial value: ');
n2=input('Enter the final value: ');
F=input('enter a frequency');
Fs=input('Enter the sampling frequency: ');
A=input('Enter the amplitude: ');
[n,x]=sin_seq(n1,n2,F,Fs,A);
stem(n,x);
xlabel('Time Index');
ylabel('Amplitude');
OUTPUT:
SINUSOIDAL SEQUENCE
4
1
Amplitude
-1
-2
-3
-4
0 5 10 15 20 25 30
Time Index
EXPONENTIAL SEQUENCE
PROGRAM:
clc;
clear all;
close all;
n1=input('Enter the initial value: ');
n2=input('Enter the final value: ');
a=input('Enter the amplitude: ');
[n,e]=exponential_seq(n1,n2,a);
stem(e,n);
xlabel('Time index');
ylabel('Amplitude');
grid on;
OUTPUT:
Exponential sequence
5
4.5
3.5
3
Amplitude
2.5
1.5
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
Time index
LINEAR CONVOLUTION
PROGRAM:
clc;
clear all;
close all;
x=input('Enter the input sequence:');
nx=input('Enter the time indices of the input sequence:');
h=input('Enter the impulse response sequence:');
nh=input('Enter the time indices of the impulse sequence:');
[ny,y]=conv_m(x,nx,h,nh);
subplot(3,1,1);
stem(nx,x);
title('Input sequence x(n)');
subplot(3,1,2);
stem(nh,h);
title('Impulse sequence h(n)');
subplot(3,1,3);
stem(ny,y);
title('Output sequence y(n)');
function [ny,y]=conv_m(x,nx,h,nh)
nyb=nx(1)+nh(1);
nye=nx(length(x))+nh(length(h));
ny=nyb:nye;
y=conv(x,h);
OUTPUT:
Input sequence x(n)
4
Amplitude
2
0
0 0.5 1 1.5 2 2.5 3
Time indices
Impulse sequence h(n)
10
Amplitude
0
0 0.5 1 1.5 2 2.5 3
Time indices
Output sequence y(n)
100
Amplitude
50
0
0 1 2 3 4 5 6
Time indices
CIRCULAR CONVOLUTION
PROGRAM:
clc;
clear all;
close all;
x=input('Enter the input sequence:');
h=input('Enter the impulse response sequence:');
N=input('Enter the length of the sequence:');
n=(0:N-1);
Xk=fft(x,N);
Hk=fft(h,N);
Yk=Xk.*Hk;
y=ifft(Yk);
subplot(3,1,1);
stem(n,x);
subplot(3,1,2);
stem(n,h);
subplot(3,1,3);
stem(n,y);
OUTPUT:
Input Sequence x(n)
Amplitude 4
0
0 0.5 1 1.5 2 2.5 3
Time indices
Impulse Sequence h(n)
10
Amplitude
0
0 0.5 1 1.5 2 2.5 3
Time Indices
Output Sequence y(n)
100
Amplitude
50
0
0 0.5 1 1.5 2 2.5 3
Time indices
AUTO CORRELATION
(USING SYNTAX)
PROGRAM:
clc;
clear all;
close all;
x=input('Enter the input sequence:');
N=input('Enter the length of the sequence :');
n=[0:N-1];
rxx=xcorr(x,x)
subplot(3,1,1);
stem(n,x);
xlabel('Time index');
ylabel('Amplitude');
title('Input sequence');
subplot(3,1,2);
stem(rxx);
xlabel('Time index');
ylabel('Amplitude');
title('rxx');
grid on;
OUTPUT:
Input sequence
Amplitude 4
0
0 0.5 1 1.5 2 2.5 3
Time index
rxx
40
Amplitude
20
0
1 2 3 4 5 6 7
Time index
AUTO CORRELATION
(USING FUNCTION)
PROGRAM:
clc;
clear all;
close all;
x=[3,11,7,0,-1,4,2]
pause;
nx=[-3:3]
pause;
[y1,n1]=sigshift(x,nx,2)
pause;
y2=0.2*y1
pause;
n2=n1
pause;
w=randn(1,length(x))
pause;
nw=n1
pause;
[y,n]=sigadd(y2,n1,w,nw)
pause;
[foldedy,n2]=sigfold(y,n)
pause;
[ryy,nryy]=conv_m(y,n,foldedy,n2)
pause;
stem(nryy,ryy);
xlabel('timeindex');
ylabel('Amplitude');
function [y,n]=sigshift(x,m,n0)
y=x;
n=m+n0;
function [y,n]=sigadd(x1,n1,x2,n2)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));
y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1+y2;
function [y,n]=sigfold(x,n)
y=fliplr(x);
n=-fliplr(n);
function [y,n]=conv_m(x1,n1,x2,n2)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));
y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
OUTPUT:
AUTO CORRELATION
18
16
14
12
10
Amplitude
-2
-5 -4 -3 -2 -1 0 1 2 3 4 5
timeindex
CROSS CORRELATION
(USING SYNTAX)
PROGRAM:
clc;
clear all;
close all;
x=input('Enter the input sequence:');
N=input('Enter the length of the sequence :');
y=input('Enter the second sequence:');
n=[0:N-1];
rxy=xcorr(x,y)
subplot(3,1,1);
stem(n,x);
xlabel('Time index');
ylabel('Amplitude');
title('x(n)');
subplot(3,1,2);
stem(n,y);
xlabel('Time index');
ylabel('Amplitude');
title('y(n)');
subplot(3,1,3);
stem(rxy);
xlabel('Time index');
ylabel('Amplitude');
title('rxy');
grid on;
OUTPUT:
x(n)
4
Amplitude
2
0
0 0.5 1 1.5 2 2.5 3
Time index
y(n)
10
Amplitude
0
0 0.5 1 1.5 2 2.5 3
Time index
rxy
100
Amplitude
50
0
1 2 3 4 5 6 7
Time index
CROSS CORRELATION
(USING FUNCTION)
PROGRAM:
clc;
clear all;
close all;
x=[3,11,7,0,-1,4,2]
pause;
nx=[-3:3]
pause;
[y1,n1]=sigshift(x,nx,2)
pause;
y2=0.2*y1
pause;
n2=n1
pause;
w=randn(1,length(x))
pause;
nw=n1
pause;
[y,n]=sigadd(y2,n1,w,nw)
pause;
[foldedx,n2]=sigfold(x,nx)
pause;
[rxy,nrxy]=conv_m(y,n,foldedx,n2)
pause;
stem(nrxy,rxy);
xlabel('timeindex');
ylabel('Amplitude');
function [y,n]=sigshift(x,m,n0)
y=x;
n=m+n0;
function [y,n]=sigadd(x1,n1,x2,n2)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));
y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1+y2;
function [y,n]=sigfold(x,n)
y=fliplr(x);
n=-fliplr(n);
function [y,n]=conv_m(x1,n1,x2,n2)
n=min(min(n1),min(n2)):max(max(n1),max(n2));
y1=zeros(1,length(n));
y2=y1;
y1(find((n>=min(n1))&(n<=max(n1))==1))=x1;
y2(find((n>=min(n2))&(n<=max(n2))==1))=x2;
y=y1.*y2;
OUTPUT:
CROSS CORRELATION
10
4
Amplitude
-2
-4
-6
-8
-3 -2 -1 0 1 2 3 4 5
timeindex
FREQUENCY ANALYSIS USING DFT
(USING FUNCTION)
DFT:
PROGRAM:
clc;
clear all;
close all;
x=input('Enter the sequence:');
N=length(x);
n=[0:N-1];
k=[0:N-1];
[Xk]=dft(x,N);
Xk_real=real(Xk);
subplot(5,1,1);
stem(x,real(Xk));
title('Real part');
xlabel('Time index');
ylabel('Amplitude');
Xk_imag=imag(Xk);
subplot(5,1,2);
stem(x,imag(Xk));
title('Imag part');
xlabel('Time index');
ylabel('Amplitude');
Xk_mag=abs(Xk);
subplot(5,1,3);
stem(x,abs(Xk));
title('Magnitude');
xlabel('Time index');
ylabel('Amplitude');
Xk_ang=angle(Xk);
subplot(5,1,4);
stem(x,angle(Xk));
title('Phase');
xlabel('Time index');
ylabel('Amplitude');
subplot(5,1,5);
stem(k,x);
title('Full sequence');
xlabel('Time index');
ylabel('Amplitude');
grid on;
function[Xk]=dft(x,N)
n=[0:1:N-1];
k=[0:1:N-1];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^(nk);
Xk=x*WNnk;
OUTPUT:
IDFT:
PROGRAM:
clc;
clear all;
close all;
Xk=input('Enter the sequence:');
N=length(Xk);
n=[0:N-1];
k=[0:N-1];
[xn]=idft(Xk,N);
xn_real=real(xn);
subplot(5,1,1);
stem(Xk,real(xn/N));
title('Real part');
xlabel('Time index');
ylabel('Amplitude');
xn_imag=imag(xn);
subplot(5,1,2);
stem(Xk,imag(xn/N));
title('Imag part');
xlabel('Time index');
ylabel('Amplitude');
xn_mag=abs(xn);
subplot(5,1,3);
stem(Xk,abs(xn/N));
title('Magnitude');
xlabel('Time index');
ylabel('Amplitude');
xn_ang=angle(xn/N);
subplot(5,1,4);
stem(Xk,angle(xn/N));
title('Phase');
xlabel('Time index');
ylabel('Amplitude');
subplot(5,1,5);
stem(k,Xk);
title('Full sequence');
xlabel('Time index');
ylabel('Amplitude');
grid on;
function[xn]=idft(Xk,N)
n=0:1:N-1;
k=0:1:N-1;
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN.^(-nk);
xn=Xk*WNnk;
OUTPUT:
FREQUENCY ANALYSIS USING DFT
DFT:
PROGRAM:
clc;
clear all;
close all;
x=input('enter the input sequence');
N=length(x);
n=0:N-1;
k=0:N-1;
nk=n'*k;
wn=exp((-1i*2*pi)/N);
wnnk=wn.^nk;
xk=x*wnnk;
am=abs(xk);
ph=angle(xk);
subplot(2,1,1);
stem(k,am)
xlabel('index')
ylabel('amplitude')
title('DFT')
subplot(2,1,2)
stem(k,ph)
xlabel('index')
ylabel('phase')
title('DFT')
disp(am)
disp(ph)
OUTPUT:
DFT
2
1.5
amplitude
0.5
0
0 0.5 1 1.5 2 2.5 3
index
DFT
1
0
phase
-1
-2
0 0.5 1 1.5 2 2.5 3
index
IDFT:
PROGRAM:
clc;
clear all;
close all;
xk=input('enter the input sequence');
N=length(xk);
n=0:N-1;
k=0:N-1;
nk=n'*k;
wn=exp((-1i*2*pi)/N);
wnnk=wn.^-nk;
xn=(xk*wnnk)/N;
am=abs(xn);
ph=angle(xn);
subplot(2,1,1);
stem(k,am)
xlabel('index')
ylabel('amplitude')
title('IDFT')
subplot(2,1,2);
stem(k,ph)
xlabel('index')
ylabel('phase')
title('IDFT')
disp(am)
disp(ph)
OUTPUT:
IDFT
1
amplitude
0.5
0
0 0.5 1 1.5 2 2.5 3
index
IDFT
3
2
phase
-1
0 0.5 1 1.5 2 2.5 3
index
DESIGN OF FIR FILTER
PROGRAM:
clc;
clear all;
close all;
wp=0.2*pi;
ws=0.3*pi;
tr_width=ws-wp;
N=ceil((6.6*pi)/(tr_width)+1);
n=0:1:N-1;
wc=(ws+wp)/2;
h=ideal_lpf(N,wc);
win=hamming(N)';
hd=h.*win;
[db,mag,pha,w]=freqz_modified(hd,1);
subplot(2,2,1);
stem(n,hd);
title('ideal imp.response');
axis([0 N-1 -0.1 0.5]);
xlabel('n');
ylabel('hd(n)');
subplot(2,2,2);
stem(n,win);
title('hamming window');
axis([0 N-1 0 1.1]);
xlabel('n');
ylabel('w(n)');
subplot(2,2,3);
stem(n,h);
title('actual imp response');
axis([0 N-1 -0.1 0.3]);
xlabel('x(n)');
ylabel('y(n)');
subplot(2,2,4);
plot(w/pi,db);
title('mag response in db');
function [hd] = ideal_lpf(N,wc )
a=(N-1)/2;
n=[0:1:(N-1)];
m=n-a+eps;
hd=sin(wc*m)./(pi*m);
end
OUTPUT:
LOW PASS FILTER USING HANNING WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
wp=0.2*pi;
ws=0.3*pi;
tr_width=ws-wp;
N=ceil(6.6*pi/tr_width)+1;
n=0:1:N-1;
wc=(wp+ws)/2;
h=ideal_lpf(N,wc);
win=(hanning(N))';
hd=h.*win;
[db,mag,pha,w]=freqz_modified(hd,1);
subplot(2,2,1);
stem(n,hd);
title('ideal imp.response');
axis([0 N-1 -0.1 0.3]);
xlabel('n');
ylabel('hd');
subplot(2,2,2);
stem(n,win);
title('hanning window');
axis([0 N-1 0 1.1]);
xlabel('n');
ylabel('win');
subplot(2,2,3);
stem(n,h);
title('actual imp.response');
axis([0 N-1 -0.1 0.3]);
xlabel('x(n)');
ylabel('h(n)');
subplot(2,2,4);
plot(w/pi,db);
title('mag response in db');
grid;
axis([0 -100 10]);
xlabel('freq in pi units');
ylabel('decibles');
function[db,mag,pha,w]=freqz_modified(b,a)
[H,w]=freqz(b,a,1000,'whole');
H=(H(1:1:501))';
w=(w(1:1:501))';
mag=abs(H);
db=20*log((mag+eps)/max(mag));
pha=angle(H);
end
function[h]=ideal_lpf(N,wc)
a=(N-1)/2;
n=[0:1:(N-1)];
m=n-a+eps;
h=sin(wc*m)./(pi*m);
OUTPUT:
LOW PASS FILTER USING RECTANGULAR WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc=input('Enter The Frquency:');
h=[0:N-1];
whr=1
[hd]=lpffir (N,Wc)
h=hd.*whr
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(4,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(4,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(4,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
subplot(4,1,4);
plot(w/pi,g);
xlabel('Frequency');
ylabel('Phase');
title('Group delay');
function [hd]=lpffir (N,Wc)
alpha=(N-1)/2
n=[-alpha:alpha]
m=[n-alpha]+eps;
Nu=sin(m*Wc);
De=pi*m;
hd=Nu./De;
end
OUTPUT:
Enter The Order:5
Enter The Frquency:0.2*pi
whr =
n=
-2 -1 0 1 2
alpha =
hd =
h=
Transfer function:
0.04677 z^4 + 0.1009 z^3 + 0.1514 z^2 + 0.1871 z + 0.2
Sampling time: 1
HIGH PASS FILTER USING HAMMING WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc=input('Enter The Frquency:');
h=[0:N-1];
whm=hamming(N)
[hd]= hpffir (N,Wc)
h=hd.*whm'
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(3,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(3,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(3,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
whm =
0.0800
0.2147
0.5400
0.8653
1.0000
0.8653
0.5400
0.2147
0.0800
hd =
h=
Transfer function:
-0.003027 z^8 + 0.009287 z^7 - 0.01684 z^6 + 6.071e-017 z^5 + 0.04677 z^4 -
0.08731 z^3 + 0.08174 z^2 - 0.04018 z
+ 0.016
Sampling time: 1
HIGH PASS FILTER USING HANNING WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc=input('Enter The Frquency:');
h=[0:N-1];
whn=hann(N)
[hd]=hpffir (N,Wc)
h=hd.*whn'
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(3,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(3,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(3,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
whn =
0.1464
0.5000
0.8536
1.0000
0.8536
0.5000
0.1464
hd =
h=
Transfer function:
0.006333 z^7 - 0.01559 z^6 + 5.989e-017 z^5 + 0.04677 z^4 - 0.08613 z^3 +
0.07568 z^2 - 0.0274 z
Sampling time: 1
HIGH PASS FILTER USING RECTANGULAR WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc=input('Enter The Frquency:');
h=[0:N-1];
wr=1
[hd]=hpffir (N,Wc)
h=hd.*wr'
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(3,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(3,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(3,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
wr =
hd =
h=
Transfer function:
-0.03784 z^8 + 0.04325 z^7 - 0.03118 z^6 + 7.017e-017 z^5 + 0.04677 z^4 -
0.1009 z^3 + 0.1514 z^2 - 0.1871 z + 0.2
Sampling time: 1
BAND PASS FILTER USING HAMMING WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc1=input('Enter The Frquency 1:');
Wc2=input('Enter The Frequency 2:');
h=[0:N-1];
whm=hamming(N)
[hd]=bpffir(N,Wc1,Wc2)
h=hd.*whm'
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(3,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(3,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(3,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
whm =
0.0800
0.1679
0.3979
0.6821
0.9121
1.0000
0.9121
0.6821
0.3979
0.1679
0.0800
hd =
h=
Transfer function:
0.002546 z^10 + 0.002951 z^9 + 3.515e-018 z^8 + 0.0124 z^7 - 0.06098 z^6 -
0.04502 z^5 + 0.1381 z^4 + 0.03122 z^3
Sampling time: 1
BAND PASS FILTER USING HANNING WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc1=input('Enter The Frquency 1:');
Wc2=input('Enter The Frequency 2:');
h=[0:N-1];
whn=hann(N)
[hd]=bpffir (N,Wc1,Wc2)
h=hd.*whn'
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(3,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(3,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(3,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
whn =
0.0955
0.3455
0.6545
0.9045
1.0000
0.9045
0.6545
0.3455
0.0955
hd =
h=
Transfer function:
0.001679 z^9 + 3.052e-018 z^8 + 0.0119 z^7 - 0.06047 z^6 - 0.04502 z^5 +
0.1369 z^4 + 0.02996 z^3 - 0.07681 z^2
- 0.001825 z
Sampling time: 1
BAND PASS FILTER USING RECTANGULAR WINDOWING TECHNIQUE
PROGRAM:
clc;
clear all;
close all;
N=input('Enter The Order:');
Wc1=input('Enter The Frquency 1:');
Wc2=input('Enter The Frequency 2:');
h=[0:N-1];
wr=1
[hd]=bpffir (N,Wc1,Wc2)
h=hd.*wr'
tf(h,1,1)
w=(0:pi/16:pi);
H=freqz(h,1,w);
mag=abs(H);
db=20*log10(mag/max(mag));
ph=angle(H);
g=grpdelay(h,1,w);
subplot(3,1,1);
plot(w/pi,mag);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude');
subplot(3,1,2);
plot(w/pi,db);
xlabel('Frequency');
ylabel('Amplitude');
title('Magnitude Response In Db');
subplot(3,1,3);
plot(w/pi,ph);
xlabel('Frequency');
ylabel('Phase');
title('Phase Response');
wr =
1
hd =
h=
Transfer function:
0.03183 z^10 + 0.01758 z^9 + 8.835e-018 z^8 + 0.01818 z^7 - 0.06685 z^6 -
0.04502 z^5 + 0.1514 z^4 + 0.04577 z^3
Sampling time: 1
DESIGN OF IIR FILTER
BUTTERWORTH LOW PASS FILTER
PROGRAM:
clc;
clear all;
close all;
op=0.2*pi;
os=0.3*pi;
ap=7;
as=16;
[b,a]=afd_buttap(op,os,ap,as)
[dB,mag,phas,o]=freqs_modified(b,a,0.5*pi);
subplot(3,1,1)
plot(o,mag)
xlabel('frequency')
ylabel('Amplitude')
title('Magnitude')
subplot(3,1,2)
plot(o,phas)
xlabel('frequency')
ylabel('phase')
title('Phase')
subplot(3,1,3)
plot(o,dB)
xlabel('frequency')
ylabel('amp in dB')
title('Mag in dB')
function [b,a]=unnorm_buttap(N,oc)
[z,p,k]=buttap(N);
p=p*oc;
k=k*oc^N;
b=real(poly(z));
bo=k;
bo=k*b;
a=real(poly(p));
function [dB,mag,phas,o]=freqs_modified(b,a,omax)
o=[0:1:500]*omax/500;
H=freqs(b,a,o);
mag=abs(H);
phas=angle(H);
dB=20*log10((mag+eps)/max(mag));
OUTPUT:
Magnitude
Amplitude 10
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
frequency
Phase
5
phase
-5
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
frequency
Mag in dB
0
amp in dB
-20
-40
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6
frequency
CHEBYSHEV-I LOW PASS FILTER
PROGRAM:
clc;
clear all;
close all;
Op=0.2*pi;
Os=0.3*pi;
Ap=1;
As=16;
Ripple=10^(-Ap/20);
Attn=10^(-As/20);
[b,a]=afd_chb1(Op,Os,Ap,As)
[db,mag,pha,O]=freqs_modified(b,a,0.5*pi);
subplot(3,1,1);
plot(O,mag);
xlabel('frequency');
ylabel('amplitude');
title('magnitude');
subplot(3,1,2);
plot(O,pha);
xlabel('frequency');
ylabel('phase');
title('phase');
subplot(3,1,3);
plot(O,db);
xlabel('frequency');
ylabel('amp in dB');
title('Mag in dB');
function[b,a]=afd_chb1(Op,Os,Ap,As)
ep=sqrt(10^(Ap/10)-1);
A=10^(As/20);
OmegaC=Op
OmegaR=Os/Op;
g=sqrt(A*A-1)/ep;
N=ceil(log10(g+sqrt(g*g-1))/log10(OmegaR+sqrt(OmegaR*OmegaR-1)))
fprintf('\n***chebyshev.1 filer order=%2 of \n',N)
[b,a]=u_chb1ap(N,Ap,OmegaC);
end
function[b,a]=u_chb1ap(N,Ap,OmegaC)
[z,p,k]=cheb1ap(N,Ap);
a=real(poly(p));
aNn=a(N+1);
p=p*OmegaC;
a=real(poly(p));
aNu=a(N+1);
k=k*aNu/aNn;
b0=k;
B=real(poly(z));
b=k*B;
end
function[dB,mag,pha,O]=freqs_modified(b,a,Omax)
O=[0:1:500]*Omax/500;
H=freqs(b,a,O);
mag=abs(H);
pha=angle(H);
dB=20*log10((mag+eps)/max(mag));
end
OUTPUT:
OmegaC =
0.6283
N=
b=
0.0383
a=
PROGRAM:
clc;
clear all;
close all;
Op=0.2*pi;
Os=0.3*pi;
Ap=1;
As=15;
Ripple=10^(-Ap/20);
Attn=10^(-As/20);
[b,a]=afd_chb2(Op,Os,Ap,As)
[db,mag,pha,O]=freqs_modified(b,a,0.5*pi);
subplot(3,1,1);
plot(O,mag);
xlabel('frequency');
ylabel('amplitude');
title('magnitude');
subplot(3,1,2);
plot(O,pha);
xlabel('frequency');
ylabel('phase');
title('phase');
subplot(3,1,3);
plot(O,db);
xlabel('frequency');
ylabel('amp in dB');
title('Mag in dB');
function [b,a]=afd_chb2(Op,Os,Ap,As)
ep=sqrt(10^(Ap/10)-1);
A=10^(As/10);
OmegaC=Op
OmegaR=Os/Op;
g=sqrt(A*A-1)/ep;
N=ceil(log10(g+sqrt(g*g-1))/log10(OmegaR+sqrt(OmegaR*OmegaR-1)))
[b,a]=u_chb2ap(N,As,Os);
end
function[b,a]=u_chb2ap(N,As,OmegaC)
[z,p,k]=cheb2ap(N,As);
a=real(poly(p));
aNn=a(N+1);
p=p*OmegaC;
a=real(poly(p));
aNu=a(N+1);
b=real(poly(z));
M=length(b);
bNn=b(M);
z=z*OmegaC;
b=real(poly(z));
bNu=b(M);
k=k*(aNu*bNn)/(aNn*bNu);
b0=k;
b=k*b;
end
function[dB,mag,pha,O]=freqs_modified(b,a,Omax)
O=[0:1:500]*Omax/500;
H=freqs(b,a,O);
mag=abs(H);
pha=angle(H);
dB=20*log10((mag+eps)/max(mag));
end
OUTPUT:
N=
b=
a=
Objective:
To study the Architecture of Digital Signal Processor TMSS320c6748
Outcome:
At the end of the experiment, the student will have a clarity on the architectural
overview of DSProcessor TMS320c6748 and develop programs to configure it.
AIM:
EQUIPMENTS REQUIRED:
Objective:
To perform MAC operation using Digital Signal Processor
Outcome:
At the end of the experiment , the student should be able to perform the Multiply and
Accumulate operation using DSProcessor and develop the programs for the operations
involving convolution, correlation and filtering,
AIM:
To perform MAC operation using DSProcessor TMS320c6748.
EQUIPMENTS REQUIRED:
Procedure:
//MAC.c
#include<stdio.h>
void main()
{
int a,b,c,d;
a=5;
b=10;
c=a+b;
d=a*c;
printf("Sum a+b:%d \n",c);
printf("Multiply a*c:%d",d);
}
;MAC1.asm
.global _main
_main:
MVK .S1 5, A2
MVK .S1 10,A4
Result:
EX.NO:
DATE:
Generation of Signals and Random Noise Using DSProcessor
Objective:
To Generate the waveforms using Digital Signal Processor
Outcome:
At the end of the experiment, the student should be able to generate the signals of
different kinds and understand the need for selecting the appropriate samples per sec
to generate the DT versions of the analog signals.
AIM:
To generate signals of different kinds using DSProcessor TMS320c6748.
EQUIPMENTS REQUIRED:
Procedure:
printf("%d\n",y[i]);
}
}
// Program for Random signal Generation
#include<stdio.h>
#include<math.h>
#define PI 3.14
#define PTS 128
float x[PTS];
float y[PTS];
float z[PTS];
float n[PTS];
void main()
{
int i;
for (i = 0 ; i < PTS ; i++)
{
x[i] = sin(2*PI*i*20/128.0);
y[i]=0.0;
n[i]=x[i] + rand() * 10 ; //rand function to generate random signal
}
}
#include <stdio.h>
#define amp 1 // defined amplitude
int amp;
float y;// no. of points to be stored in output variable 'y'
int i=0;
void main()
{
for(i=0;i<255;i++)
{
y=amp;
amp=i+1;
printf("%f\n",y++);
}
for(i=255;i>0;i--)
{
y=amp;
amp=i-1;
printf("%f\n",y--);
}
}
Result:
EX.NO:
DATE:
Down sampling and Up sampling Operations in DSProcessor
Objective:
To Generate the down sampled and the up sampled waveforms using Digital Signal
Processor
Outcome:
At the end of the experiment, the student should be able to generate the signals with
different sampling rates such as increasing the sampling rate using interpolation for
hi-fidelity requirements and reducing the samples per second using Decimation for
reducing the memory requirements .
AIM:
To decimate and interpolate the DT sequences using DSProcessor TMS320c6748.
EQUIPMENTS REQUIRED:
Procedure:
Objective:
To design and demonstrate FIR filters using Digital Signal Processor
Outcome:
At the end of the experiment, the student should be able to design FIR filters using the
specified technique and plot the responses of the filter. Also the student should be
able to write programs in the Code composer studio with the impulse response of the
filter coefficients; supply input from Analog Discovery Kit and obtain the filtered
output from the DSProcessor.
AIM:
To implement the filtering operation using FIR filters of different kinds in the
DSProcessor TMS320c6748.
EQUIPMENTS REQUIRED:
Procedure:
1. In the Matlab Command window, type fdatool command. Invoke the filter design and
analysis window / console.
2. Select the filter parameters as specified in the problem statement and design the filters
of Lowpass/ High Pass/ Bandpass/ or Bandstop filters.
3. From the Menu, click the menu item – Generate the the c target file. Save the filter
coefficients in a file.
4. Open the file in which the filer coefficients were stored and copy the impulse
response coefficients.
5. Procedure specified for the real time experiments are to be followed in the CCS
command window.
6. In the main c program, the filter coefficients are to be replaced by the filter
coefficients designed using FDATOOL.
7. Build, debug and run the program.
8. Connections between the ADK and Host PC are to be established using the USB
connector.
9. In the Waveforms software for ADK, the wavegen console is to be opened and
provided with the appropriate parameters such as the amplitude and the frequency of
the input waveform ( the frequencies are selected such that the frequencies in the pass
band and the stop band).
10. In the Waveforms software for ADK, the scope is to be run for the demonstration of
the filtering operation using DSP.
/ L138_fir_intr.c
#include "L138_LCDK_aic3106_init.h"
#define N 5
float h[N] = {
2.0000E-001,2.0000E-001,2.0000E-001,2.0000E-001,2.0000E-001
};float x[N]; // filter delay line
interrupt void interrupt4(void)
{
short i;
float yn = 0.0;
x[0] = (float)(input_left_sample()); // input from ADC
for (i=0 ; i<N ; i++) // compute filter output
yn += h[i]*x[i];
for (i=(N-1) ; i>0 ; i--) // shift delay line
x[i] = x[i-1];
output_left_sample((uint16_t)(yn)); // output to DAC
return;
}
int main(void)
{
L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_LINE_I
NPUT);
while(1);
}
Result:
EX.NO:
DATE:
Design and demonstration of Butterworth and Chebyshev IIR filters for Lowpass,
HighPass, Band Pass and Bandstop filtering Using DSProcessor
Objective:
To design and demonstrate IIR filters using Digital Signal Processor
Outcome:
At the end of the experiment, the student should be able to design IIR filters using the
specified technique and plot the responses of the filter. Also the student should be
able to write programs in the Code composer studio with the impulse response of the
filter coefficients; supply input from Analog Discovery Kit and obtain the filtered
output from the DSProcessor.
AIM:
To implement the filtering operation using IIR filters of different kinds ( butterworth
and Chebyshev ) in the DSProcessor TMS320c6748.
EQUIPMENTS REQUIRED:
Procedure:
1. In the Matlab Command window, type fdatool command. Invoke the filter design and
analysis window / console.
2. Select the filter parameters as specified in the problem statement and design the filters
of Lowpass/ High Pass/ Bandpass/ or Bandstop filters.
3. From the Menu, click the menu item – Export the filter coefficients. Save the filter
coefficients in a file. (you may have to type the variables in which the filter
coefficients are to be stored and they will be in the workspace of the Matlab itsef).
4. Open the file in which the filer coefficients were stored and copy the impulse
response coefficients.
5. In the Command window of Matlab, type the following command
>> L138_iirsos_coeffs(coeff,gain)
6. Execute the MATLAB function required to write SOS IIR filter
coefficients in format suitable for use in L138 eXperimenter
programs including L138_iirsos_intr.c, L138_iirsosprn_intr.c
and L138_iirsosdelta_intr.c (The coefficients have been
exported from fdatool as two matrices).
7. The matlab execution will expect an input file name and enter
the filename for storing the filter coefficients. ( Preferably
use the file name "elliptic.cof")
8. Procedure specified for the real time experiments are to be followed in the CCS
command window.
9. Build, debug and run the program.
10. Connections between the ADK and Host PC are to be established using the USB
connector.
11. In the Waveforms software for ADK, the wavegen console is to be opened and
provided with the appropriate parameters such as the amplitude and the frequency of
the input waveform ( the frequencies are selected such that the frequencies in the pass
band and the stop band).
12. In the Waveforms software for ADK, the scope is to be run for the demonstration of
the filtering operation using DSP.
// L138_iirsos_intr.c
// IIR filter implemented using second order sections
// floating point coefficients read from file
#include "L138_LCDK_aic3106_init.h"
#include "elliptic.cof"
float w[NUM_SECTIONS][2] = {0};
interrupt void interrupt4(void)// interrupt service routine
{
int section;// index for section number
float input;// input to each section
float wn,yn;// intermediate and output values
input = ((float)input_left_sample());// input from ADC
for (section=0 ; section< NUM_SECTIONS ; section++)
{
wn = input - a[section][1]*w[section][0] - a[section][2]*w[section][1];
yn = b[section][0]*wn + b[section][1]*w[section][0] + b[section][2]*w[section][1];
w[section][1] = w[section][0];
w[section][0] = wn;
input = yn;// output of current section is input to next
}
output_left_sample((int16_t)(yn));// output to L DAC
return;
}
int main(void)
{
L138_initialise_intr(FS_48000_HZ,ADC_GAIN_0DB,DAC_ATTEN_0DB,LCDK_L
INE_INPUT);
while(1);
}
Result:
EX.NO:
DATE:
Computation of Power Spectral Density in DSProcessor TMS320c6748
Objective:
To determine the Power Spectral Density of the given input signal using Digital
Signal Processor.
Outcome:
At the end of the experiment, the student should be able to compute the Fourier
Transform and Power Spectral Density using DSProcessor,
AIM:
To compute the PSD of the input signal using DSProcessor TMS320c6748
EQUIPMENTS REQUIRED: