0% found this document useful (0 votes)
306 views

Lab Manual

The document describes the syllabus for the Digital Signal Processing Laboratory course offered by the Electronics and Communication Engineering department at Saranathan College of Engineering. The course aims to teach students how to perform basic digital signal processing operations using MATLAB and a DSP processor. The syllabus covers generating discrete-time sequences, filtering, spectral analysis, and implementing filters and signal processing systems on a DSP processor. Students will design and analyze FIR and IIR filters, study DSP processor architecture, and complete projects involving applications like signal processing, communication and networking. The course outcomes are mapped to the program outcomes to evaluate the skills and concepts students will gain from this course.

Uploaded by

Sivagami Mani
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)
306 views

Lab Manual

The document describes the syllabus for the Digital Signal Processing Laboratory course offered by the Electronics and Communication Engineering department at Saranathan College of Engineering. The course aims to teach students how to perform basic digital signal processing operations using MATLAB and a DSP processor. The syllabus covers generating discrete-time sequences, filtering, spectral analysis, and implementing filters and signal processing systems on a DSP processor. Students will design and analyze FIR and IIR filters, study DSP processor architecture, and complete projects involving applications like signal processing, communication and networking. The course outcomes are mapped to the program outcomes to evaluate the skills and concepts students will gain from this course.

Uploaded by

Sivagami Mani
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/ 112

SARANATHAN COLLEGE OF ENGINEERING

Venkateswara Nagar, Panjappur, Tiruchirappalli – 12.


(Approved by AICTE, Accredited by NBA and Affiliated by Anna University, Chennai)

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

THIRD YEAR / V SEMESTER (R 2017)

EC 8562 – DIGITAL SIGNAL PROCESSING LABORATORY


RECORD NOTE BOOK

ACADEMIC YEAR: AUGUST 2020 - OCTOBER 2020

Name: ……………………………………………….

Reg. No: ……………………………………………..


Vision of the Institution

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.

Mission of the Institution

 Create a nurturing, holistic environment of engineering education to facilitate every


student realize their full potential.
 Strive to make the students strong in basic concepts, armed with appropriate skills to
enhance one’s ability to apply the knowledge, to provide solutions to real time issues.
 Maintain an ambience that facilitates the students to strengthen their ethical value
systems.
 Actively promote R & D and institute- industry interaction.

Vision of the Department

To become a leading department of Higher Learning and a Research Centre of


Excellence in Research in Electronics and Communication Engineering.

Mission of the Department

 To enable budding engineers to obtain technical exposure in various areas of


Electronics and Communication Engineering.
 To nurture career improvement.
 To initiate and sustain research activities in the department in state of the art areas
of Electronics and Communication Engineering.
 To develop professional and ethical attitude in the students.

Program Educational Objectives (PEOs)

 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.

Program Outcomes (POs)

1. Engineering knowledge: Apply the knowledge of mathematics, science, engineering


fundamentals, and an engineering specialization to the solution of complex engineering
problems.

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.

3. Design/development of solutions: Design solutions for complex engineering problems


and design system components or processes that meet the specified needs with
appropriate consideration for the public health and safety, and the cultural, societal,
and environmental considerations.

4. Conduct investigations of complex problems: Use research-based knowledge and


research methods including design of experiments, analysis and interpretation of data,
and synthesis of the information to provide valid conclusions.

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.

9. Individual and team work: Function effectively as an individual, and as a member or


leader in diverse teams, and in multidisciplinary settings.

10.Communication: Communicate effectively on complex engineering activities with the


engineering community and with society at large, such as, being able to comprehend
and write effective reports and design documentation, make effective presentations,
and give and receive clear instructions.

11.Project management and finance: Demonstrate knowledge and understanding of the


engineering and management principles and apply these to one’s own work, as a
member and leader in a team, to manage projects and in multidisciplinary
environments.

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.

Program Specific Outcomes (PSOs)

1. Comprehend and demonstrate the principles and concepts of Semiconductor theory,


Signal Processing & Embedded systems in the fields of Consumer Electronics,
Medical Electronics and Defence Electronics.

2. Analyze and design modules and systems for applications including Signal Processing,
Communication, Networking and RF & Microwave Engineering.
Course Outcomes (COs)

COs Course Outcomes


C307.1 Analyze and carryout basic signal processing operations using MATLAB
C307.2 Performing spectral analysis using DFT / FFT Algorithms.
C307.3 Design and Implement the FIR and IIR Filters using MATLAB
C307.4 Analyze the architecture of a DSP Processor
C307.5 Design and Implement the FIR and IIR Filters in DSP Processor for performing filtering
operation over real-time signals
C307.6 Design a DSP system for various applications of DSP.

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

EC 8562 - DIGITAL SIGNAL PROCESSING LABORATORY (R 2017)

LTPC
0 0 4 2

LIST OF EXPERIMENTS: MATLAB / EQUIVALENT SOFTWARE PACKAGE

1. Generation of elementary Discrete-Time sequences

2. Linear and Circular convolution

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

DSP PROCESSOR BASED IMPLEMENTATION

1. Study of architecture of Digital Signal Processor

2. Perform MAC operation using various addressing modes

3. Generation of various signals and random noise

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

6. Implement an Up-sampling and Down-sampling operation in DSP Processor


UNIT IMPULSE SEQUENCE

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;

function [n,x] = impulse_seq(n1,n2,n0)


n=n1:n2;
x=[(n-n0)==0];

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');

function [ n,x ] = step_seq( n1,n2,n0 )


n=[n1:n2];
x=[(n-n0)>=0];

OUTPUT:

UNIT STEP SEQUENCE


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 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');

function [ n,r ] = ramp_seq(n1,n2)


n=[n1:n2];
r=[n]

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');

function [ n,x ] = cos_seq( n1,n2,F,Fs,A )


n=n1:n2;
x=A*cos(2*pi*(F/Fs)*n);

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');

function [ n,x ] = sin_seq( n1,n2,F,Fs,A )


n=n1:n2;
x=A*sin(2*pi*(F/Fs)*n);

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;

function [n,e] = exponential_seq(n1,n2,a)


n=[n1:1:n2];
e=a.^n;

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

LOW PASS FILTER USING HAMMING 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=(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

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*log10((mag+eps)/(max(mag)));
pha=angle(H);
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 =

0.0468 0.1009 0.1514 0.1871 0.2000

h=

0.0468 0.1009 0.1514 0.1871 0.2000

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');

function [hd]=hpffir (N,Wc)


alpha=(N-1)/2;
n=[-alpha:alpha];
m=[n-alpha]+eps;
Nu=sin(m*pi)-sin(m*Wc);
De=pi*m;
hd=Nu./De;
end
OUTPUT:

Enter The Order:9

Enter The Frquency:0.8*pi

whm =

0.0800

0.2147

0.5400

0.8653

1.0000

0.8653

0.5400

0.2147

0.0800

hd =

-0.0378 0.0432 -0.0312 0.0000 0.0468 -0.1009 0.1514 -0.1871


0.2000

h=

-0.0030 0.0093 -0.0168 0.0000 0.0468 -0.0873 0.0817 -0.0402


0.0160

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');

function [hd]=hpffir (N,Wc)


alpha=(N-1)/2;
n=[-alpha:alpha];
m=[n-alpha]+eps;
Nu=sin(m*pi)-sin(m*Wc);
De=pi*m;
hd=Nu./De;
end
OUTPUT:

Enter The Order:9

Enter The Frquency:0.8*pi

whn =

0.1464

0.5000

0.8536

1.0000

0.8536

0.5000

0.1464

hd =

-0.0378 0.0432 -0.0312 0.0000 0.0468 -0.1009 0.1514 -0.1871


0.2000

h=

0 0.0063 -0.0156 0.0000 0.0468 -0.0861 0.0757 -0.0274


0

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');

function [hd]=hpffir (N,Wc)


alpha=(N-1)/2;
n=[-alpha:alpha];
m=[n-alpha]+eps;
Nu=sin(m*pi)-sin(m*Wc);
De=pi*m;
hd=Nu./De;
end
OUTPUT:

Enter The Order:9


Enter The Frquency:0.8*pi

wr =

hd =

-0.0378 0.0432 -0.0312 0.0000 0.0468 -0.1009 0.1514 -0.1871


0.2000

h=

-0.0378 0.0432 -0.0312 0.0000 0.0468 -0.1009 0.1514 -0.1871


0.2000

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');

function [hd]=bpffir (N,Wc1,Wc2)


alpha=(N-1)/2;
n=[-alpha:alpha];
m=[n-alpha]+eps;
Nu=sin(m*Wc2)-sin(m*Wc1);
De=pi*m;
hd=Nu./De;
end
OUTPUT:

Enter The Order:11


Enter TheFrquency 1:0.4*pi
Enter The Frequency 2:0.65*pi

whm =

0.0800
0.1679
0.3979
0.6821
0.9121
1.0000
0.9121
0.6821
0.3979
0.1679
0.0800

hd =

0.0318 0.0176 0.0000 0.0182 -0.0668 -0.0450 0.1514 0.0458


-0.2223 -0.0191 0.2500

h=

0.0025 0.0030 0.0000 0.0124 -0.0610 -0.0450 0.1381 0.0312


-0.0884 -0.0032 0.0200

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

- 0.08845 z^2 - 0.003208


z + 0.02

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');

function [hd]=bpffir (N,Wc1,Wc2)


alpha=(N-1)/2;
n=[-alpha:alpha];
m=[n-alpha]+eps;
Nu=sin(m*Wc2)-sin(m*Wc1);
De=pi*m;
hd=Nu./De;
end
OUTPUT:
Enter The Order:11

Enter TheFrquency 1:.4*pi

Enter The Frequency 2:.65*pi

whn =

0.0955

0.3455

0.6545

0.9045

1.0000

0.9045

0.6545

0.3455

0.0955

hd =

0.0318 0.0176 0.0000 0.0182 -0.0668 -0.0450 0.1514 0.0458


-0.2223 -0.0191 0.2500

h=

0 0.0017 0.0000 0.0119 -0.0605 -0.0450 0.1369 0.0300 -


0.0768 -0.0018 0

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');

function [hd]=bpffir (N,Wc1,Wc2)


alpha=(N-1)/2;
n=[-alpha:alpha];
m=[n-alpha]+eps;
Nu=sin(m*Wc2)-sin(m*Wc1);
De=pi*m;
hd=Nu./De;
end
OUTPUT:

Enter The Order:11


Enter TheFrquency 1:0.4*pi
Enter The Frequency 2:0.65*pi

wr =
1

hd =

0.0318 0.0176 0.0000 0.0182 -0.0668 -0.0450 0.1514 0.0458


-0.2223 -0.0191 0.2500

h=

0.0318 0.0176 0.0000 0.0182 -0.0668 -0.0450 0.1514 0.0458


-0.2223 -0.0191 0.2500

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

- 0.2223 z^2 - 0.01911 z


+ 0.25

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]= afd_buttap(op,os,ap,as)


N=ceil(log10(sqrt((10^(0.1*as)-1)/(10^(0.1*ap)-1)))/log10((os/op)))
oc=op/(((10^(0.1*ap)-1))^(1/(2*N)))
[b,a]=unnorm_buttap(N,oc);

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=

1.0000 0.5987 0.5740 0.1842 0.0430


CHEBYSHEV-II LOW PASS FILTER

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=

0.1778 0 2.8432 0 6.7348 0 3.9882

a=

1.0000 4.1690 9.1960 11.8715 12.4492 6.7513 3.9882


EX.NO:
DATE:
Study of Architecture of Digital Signal Processor (TMS320c6748)

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:

To have an overview of the salient features and the architectural significance of


DSProcessor TMS320c6748.

EQUIPMENTS REQUIRED:

S.No Equipments/ Components/ software required Specification Quantity


Result:
EX.NO:
DATE:
MAC operations using Addressing modes in DSProcessor TMS320c6748

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:

S.No Equipments/ Components required Specification Quantity

Procedure:

1. Launch CCS from Desktop icon by double clicking the icon.


2. Choose the location for the workspace where the project will be saved.
3. Create a new project. Project New Project by using the usual steps. (Target:138,
LCDKOMAPL138, TI XDS100v3 USB Debug Profile, under c67xx- <new project
name> Compiler version : TIv.7.4.12, Executable, Legacy COFF, Little Endianness,
and Including linker_dsp.cmd)
4. Select the project template  Empty Project template
5. Click Finish
6. To add source file, right click on project and go to new and select source file. Give a
name to source file with an .asm extension and click finish.
7. Type the Assembly program.
8. Save, build and debug it.
9. Once debugging is completed, the CCS window will switch over to Debug
perspective and we can view the register contents.
10. You can either step wise execution / line by line by clicking step info from the menu.
MAC.ASM Program:
;MAC.asm
.global _main
_main:
MVK .S1 5, A2
MVK .S2 10,B2
ADD .L1X A2,B2,A5
MPY .M1 A2,A5,A6
NOP 5

//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

ADDAB .D1 A4,A2,A4


MPY .M1 A4,A2,A6
NOP 5

SNO Registers Contents Before Execution Contents After Execution

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:

S.No Equipments/ Components required Specification Quantity

Procedure:

1. Launch CCS from Desktop icon by double clicking the icon.


2. Choose the location for the workspace where the project will be saved.
3. Create a new project. Project New Project by using the usual steps. (Target:138,
LCDKOMAPL138, TI XDS100v3 USB Debug Profile, under c67xx- <new project
name> Compiler version : TIv.7.4.12, Executable, Legacy COFF, Little Endianness,
and Including linker_dsp.cmd)
4. Click Finish
5. Type the program for waveform generation.
6. Save, build and debug it.
7. Once debugging is completed, in the CCS window the program could be executed.
8. To view the values in Graph Go to Tools  Graphchoosethe option Single time
and also set the Grraph properties such as Buffer size: 128 ( no. of samples) – DSP
data type: 32- bit floating point ; Start Address: m ; Display data Size: 128; Finally,
click O.K
// Program for Sine wave Generation
#include<stdio.h>
#include<math.h>
#define PI 3.14
#define PTS 128
float x[PTS];
float y[PTS];
void main()
{
int i;
for (i = 0 ; i < PTS ; i++)
{
x[i] = sin(2*PI*i*20/128.0);
printf("%f\n",x[i]);
}
}

// Program for Square wave Generation


#include <stdio.h>
#define amp 1 // defined amplitude
int y[50]; // no. of points to be stored in output variable 'y'
int i;
void main()
{
for(i=0;i<25;i++)
{
y[i]=amp;
printf("%d\n",y[i]);
}
for(i=25;i<50;i++)
{
y[i]=-amp;

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:

S.No Equipments/ Components required Specification Quantity

Procedure:

1. Launch CCS from Desktop icon by double clicking the icon.


2. Choose the location for the workspace where the project will be saved.
3. Create a new project. Project New Project by using the usual steps. (Target:138,
LCDKOMAPL138, TI XDS100v3 USB Debug Profile, under c67xx- <new project
name> Compiler version : TIv.7.4.12, Executable, Legacy COFF, Little Endianness,
and Including linker_dsp.cmd)
4. Click Finish
5. Type the program for downsampling and upsampling.
6. Save, build and debug it.
7. Once debugging is completed, in the CCS window the program could be executed.
8. To view the values in Graph Go to Tools  Graphchoosethe option Single time
and also set the Grraph properties such as Buffer size: 128 ( no. of samples) – DSP
data type: 32- bit floating point ; Start Address: m ; Display data Size: 128; Finally,
click O.K
Result:
EX.NO:
DATE:
Design and demonstration of FIR filters for Lowpass, HighPass, Band Pass and
Bandstop filtering Using DSProcessor

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:

S.No Equipments/ Components required Specification Quantity

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.

Program the demonstration of FIR filters

/ 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:

S.No Equipments/ Components required Specification Quantity

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.

Program the demonstration of FIR filters

// 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:

S.No Equipments/ Components required Specification Quantity


Result:

You might also like