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

Digital Signal Processing Lab Record R20 (III ECE)

The document is a laboratory record book for a Digital Signal Processing laboratory course. It includes the vision, mission, and outcomes of the Electronics and Communication Engineering department. It also lists the experiments to be performed, including generating different discrete-time signals in MATLAB, computing the DFT and IDFT, designing filters, and implementing signal processing applications using a DSP kit. The book contains pages for students to record the details of experiments conducted, along with pre-lab and post-lab questions. Textbooks and reference materials used in the course are also listed.

Uploaded by

goud
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)
671 views

Digital Signal Processing Lab Record R20 (III ECE)

The document is a laboratory record book for a Digital Signal Processing laboratory course. It includes the vision, mission, and outcomes of the Electronics and Communication Engineering department. It also lists the experiments to be performed, including generating different discrete-time signals in MATLAB, computing the DFT and IDFT, designing filters, and implementing signal processing applications using a DSP kit. The book contains pages for students to record the details of experiments conducted, along with pre-lab and post-lab questions. Textbooks and reference materials used in the course are also listed.

Uploaded by

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

LABORATORY RECORD BOOK

DIGITAL SIGNAL PROCESSING LABORATORY


B.TECH VI SEMESTER
(ECE)

Name of the Student


Roll Number
Branch & Section

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY


(AUTONOMOUS)
Accredited by NAAC with ‘A’ Grade of UGC, and NBA Accredited (EEE, CSE, & ECE) Approved by AICTE,
New Delhi & Permanently Affiliated to JNTUA, Ananthapuramu (Recognized
by UGC under 2(f) &12(B) & ISO 9001:2008 Certified Institution)
Nandikotkur Road, Kurnool-518452
DIGITAL SIGNAL PROCESSING LABORATORY

Vision of the Department

To produce engineers with sound knowledge in electronics and communication related


domains with entrepreneurial skills to serve societal needs.

Mission of the Department

The department imparts quality technical education with professional competence, leadership
abilities and ethical values through effective teaching learning process.

Course Outcomes
After successful competition of the course, the student will be able to
1 A30435.1 Evaluate the DFT and IDFT of given signals using MATLAB.
2 A30435.2 Analyze various DFT algorithms and their applications.
3 A30435.3 Design IIR and FIR digital filters for the given specifications using MATLAB.
4 A30435.4 Apply the concepts of multirate signal processing using MATLAB.
5 A30435.5 Demonstrate real-time signal Processing applications with DSK kit
(TMS320C6713) and Code Composer Studio.

Department of Electronics and Communication Engineering


G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY
(AUTONOMOUS)
Department of Electronics and Communication Engineering
INDEX
Mr./Ms………………………………………………….. Roll Number…………………………………
S.No Date Name of the Experiment Text Page Marks Signatur
Book No. e of the
staff
Generate different discrete-time
1 T1 ,R1
signals.
Compute DFT and IDFT of given
2 T1 ,R1
discrete-time signal.
Perform linear and circular
3 T1 ,R1
convolution of sequences.
4 Generate FFT of a given sequence. T1 ,R1
Design different FIR filters for a
5 T1 ,R1
given sequence.
Design different IIR filters for a given
6 T1 ,R1
sequence.
Implement decimation and
7 T1 ,R1
interpolation process.
Generation of Sine wave with T1 ,
8
TMS320C6713 DSP Kit. T2, R2
Implementation of Linear T1 ,
9
convolution & Circular Convolution. T2, R2
Computation of N- Point DFT of a T1 ,
10
Given Sequence. T2, R2
IIR and FIR Filter Implementation T1 ,
11
using DSP Kits. T2, R2

12 Implementation of audio loopback. T1 ,


T2, R2
Books and Materials
Text Book(s)
1. John G. Proakis, Dimitris G. Manolakis, Digital Signal Processing Principles,
Algorithms and applications, Pearson Education/ PHI, 4th edition.
2. Vinay K. Ingle, Digital Signal Processing Using MATLAB, S.Chand Company Ltd,
2001.
Reference Book(s)
1 Sanjit.K. Mitra, Digital Signal Processing - A Computer based approach, 3nd
Edition, McGraw- Hill, 2008.
2 Texas instruments, Code Composer Studio User’s Guide, Texas Instruments,
2000.
DIGITAL SIGNAL PROCESSING LABORATORY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

G.PULLAIAH COLLEGE OF ENGINEERING AND TECHNOLOGY


(AUTONOMOUS)
Accredited by NAAC with ‘A’ Grade of UGC, Approved by AICTE, New Delhi
Permanently Affiliated to JNTUA, Ananthapuramu
(Recognized by UGC under 2(f) &12(B) & ISO 9001:2008 Certified Institution)
Nandikotkur Road, Kurnool-518452
DIGITAL SIGNAL PROCESSING LABORATORY

Generate different signals in discrete time


1 domain

Roll No:_______________ Date:_______________

Objectives:

To generate various sequences such as Unit impulse, Unit step, Square, Saw
tooth, Triangular, Sinusoidal, Ramp, Sinc Function.

Apparatus:

Computer loaded with Windows 7


MATLAB
Program:

%Program for Generate different signals in discrete time domain

Clc;
Clear all; close all;
t=-20: 1:20
%--------------------Unit Impulse---------------------%
x=[zeros(1,20), 1,zeros(1,20)] %generate Unit Impulse Signal
figure(1), stem(t,x); % plot the generated Unit Impulse Signal
xlabel('t'); ylabel('x(t)'); title('Unit impulse Signal');
%------------------ Unit Step signal------------------%
y=[zeros(1,20), 1,ones(1,20)]
%y=[zeros(1,20),ones(20,1)] %generate Unit Step Signal
figure(2); stem(t,y); %Plot the generated unit step signal
xlabel('t'); ylabel('x(t)'); title('Unit Step Signal');

Department of Electronics and Communication Engineering 1


DIGITAL SIGNAL PROCESSING LABORATORY

%---------------------- Ramp Signal------------------%


x1 = t;
x2 = 0;
x = x1.*(t>=0)+x2.*(t<0); %generate unit ramp signal
figure(3);stem(t,x); % plot the generated ramp signal
xlabel('t'); ylabel('x(t)'); title(' Ramp Signal');
%----------------------rectangular pulse------------%
t1=-10:0.1:10
a7=rectpuls(t1/10)
figure(4),stem(t1,a7), grid on,axis([-10 10 -2 2])
xlabel('time')
ylabel('magnitude')
title('rectangular pulse')
%-------------------- triangular pulse---------------%
t2=-10:0.1:10
a8=tripuls(t2)
figure(5),stem(t2,a8), grid on
title('triangular pulse')
xlabel('time')
ylabel('magnitude')
%--------------- Sinc Signal----------------------%
x = linspace(-5,5);
y = sinc(x);
figure(6);stem(x,y)
xlabel('time');
ylabel('amplitude');
title('sincfunction');
%-----------------Sinusoidal Signal----------------%
T = 20; %declare time period
F = 1/T; %compute frequency
x = sin(2*pi*F*t); %generate sinusoidal signal
figure(7);stem(t,x); % plot the generated sinusoidal signal
xlabel('t'); ylabel('x(t)'); title('sinusoidal Signal');
%---------------- Sawtooth signal-----------------%
Department of Electronics and Communication Engineering 2
DIGITAL SIGNAL PROCESSING LABORATORY

fs = 1000;
t = 0:1/fs:1.5;
x = sawtooth(2*pi*50*t); %generate sawtooth signal
figure(8);stem(t,x); axis([0 0.2 -1 1]); %plot the generated sawtooth signal
xlabel('t'); ylabel('x(t)'); title('sawtooth Signal');
%----------------- square signal---------------------%
t=(0:0.01:10);
sq_wave=square(4*pi*t); %generate square signal
figure(9); stem(t,sq_wave); axis([0 5 -2 2]) %plot the generated square signal
xlabel('t'); ylabel('x(t)'); title('square signal');
%---------------------periodic triangle------------%
T=20;
x=linspace(0,5*T,1000);
y1=min(0.5,mod(x,T)/T);
y2=min(0.5,1-mod(x,T)/T);
figure(10),stem(x,y1+y2),grid on
xlabel('time')
ylabel('magnitude')
title('periodic triangle wave')

Expected Graphs:

Department of Electronics and Communication Engineering 3


DIGITAL SIGNAL PROCESSING LABORATORY

Post Lab Questions:

1. What is the difference between ‘stem’ and ‘plot’ commands?

----------------------------------------------------------------------------------------------------------------

2. Write a MATLAB code for to generate a random sequence.

----------------------------------------------------------------------------------------------------------------

3. Which MATLAB command divides the graphic space into six parts and select 5th part?

Department of Electronics and Communication Engineering 4


DIGITAL SIGNAL PROCESSING LABORATORY

----------------------------------------------------------------------------------------------------------------

Outcomes:

Upon completion of the experiment, the student will be able to


1. Understand the ways of creating a MATLAB m-file, using the MATLAB Editor, run it
and view the results.
2. Understand the usefulness of different types of sequences.
3. Write MATLAB code to generate any type of sequence.

Department of Electronics and Communication Engineering 5


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

Compute DFT and IDFT of given discrete-time


2 signal

Roll No:_______________ Date:_______________

Objectives:

Write a matlab program to perform and Compute DFT and IDFT of given discrete-time signal.

Apparatus:

Computer loaded with Windows 7


MATLAB

Program:

%Program for Compute DFT and IDFT of given discrete-time signal

clc;
close all;
clear all;
xn=input('Enter the sequence x(n)'); %Get the sequence from user
ln=length(xn); %find the length of the sequence
xk=zeros(1,ln); %initialize an array of same size as that of input sequence
ixk=zeros(1,ln); %initilise an array of same size as that of input sequence
%code block to find the DFT of the sequence %----------------------------------------------
-------------
for k=0:ln-1
for n=0:ln-1
xk(k+1)=xk(k+1)+(xn(n+1)*exp((-i)*2*pi*k*n/ln));
end
end

Department of Electronics and Communication Engineering 6


DIGITAL SIGNAL PROCESSING LABORATORY

%------------------------------------------------------------ %code block to plot the input


sequence %------------------------------------------------------------
t=0:ln-1;
subplot(411);
stem(t,xn);
ylabel ('Amplitude');
xlabel ('Time Index');
title('Input Sequence'); %---------------------------------------------------------------
magnitude=abs(xk); % Find the magnitudes of individual DFT points
%code block to plot the magnitude response %-----------------------------------------------
-------------
t=0:ln-1;
subplot(412);
stem(t,xk);
ylabel ('Amplitude');
xlabel ('TIme Index');
title('DFT Sequaence'); %------------------------------------------------------------
subplot(413);
stem(t,magnitude);
ylabel ('Amplitude');
xlabel ('K');
title('Magnitude Response'); %------------------------------------------------------------
% Code block to find the IDFT of the sequence %-------------------------------------------
-----------------
for n=0:ln-1
for k=0:ln-1
ixk(n+1)=ixk(n+1)+(xk(k+1)*exp(i*2*pi*k*n/ln));
end
end
ixk=ixk/ln;
%%code block to plot the input sequence
t=0:ln-1;
subplot(414);
stem(t,ixk);
Department of Electronics and Communication Engineering 7
DIGITAL SIGNAL PROCESSING LABORATORY

ylabel ('Amplitude');
xlabel ('Time Index');
title('IDFT sequence');

Expected Graphs:

Enter the sequence x(n) [1 1 2 1]


DFT
xk =

5.0000 + 0.0000i -1.0000 - 0.0000i 1.0000 + 0.0000i -1.0000 - 0.0000i


IDFT
ixk =
1.0000 - 0.0000i 1.0000 - 0.0000i 2.0000 + 0.0000i 1.0000 + 0.0000i

Department of Electronics and Communication Engineering 8


DIGITAL SIGNAL PROCESSING LABORATORY

Pre Lab Questions:

1. Define Fourier Transform ?

2. Define and write the expression for DFT.

3. Write the Expression for IDFT.

----------------------------------------------------------------------------------------------------------------
4. What is the condition to apply DFT on a signals

----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------
5. Write the applications of DFT

----------------------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------------------

Department of Electronics and Communication Engineering 9


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No:

Perform linear and circular convolution of


3 sequences.

Roll No:_____________ Date:______________

Objectives:

(A) To perform linear convolution of sequences.

(B) To perform circular convolution of sequences.

Apparatus:

Computer loaded with windows7 and MATLAB software

Program (A):

%Program for Linear Convolution


clc;
clear all;
close all;
%x=input('Enter x: ')
% x=sin(2*pi*0.1.*(1:1:11));
% x=[1 2 3 4 5 3 1 -1];
%h=input('Enter h: ')
% h=[1 2 3 4 5 3 1 -1];
x=input('Enter x: ');
h=input('Enter h: ');
% convolution
m=length(x);
n=length(h);

Department of Electronics and Communication Engineering 10


DIGITAL SIGNAL PROCESSING LABORATORY

X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
% plot results
disp('Linear convolution of given sequences is….');
disp(Y);
figure;
subplot(3,1,1);
stem(x, '-b^');
xlabel('Time---n');
ylabel('Amplitude---x[n]');
title('Input Sequence x(n)');
grid on;
subplot(3,1,2);
stem(h, '-ms');
xlabel('Time---n');
ylabel('Amplitude---h[n]');
title('Impulse Sequence h(n)');
grid on;
subplot(3,1,3);
stem(Y, '-ro');
ylabel('Amplitude---Y[n]');
xlabel('Time--->n');
grid on;
title('Convolution of Two Signals without conv function');

Department of Electronics and Communication Engineering 11


DIGITAL SIGNAL PROCESSING LABORATORY

%% Linear Convolution of Two Signals with conv function


Y(i)=conv(x,h);

Expected Graphs

Enter x: [1 2 3 4 5 6]
Enter h: [2 4 3 2 1 5]
Linear convolution of given sequences is….
2 8 17 28 40 57 60 47 37 31 30

Program (B):

%Program for Circular Convolution

clc;
clear all;
close all;
x=input ('Enter the input sequence :');
h=input ('Enter the impulse response :');
n1=length(x);

Department of Electronics and Communication Engineering 12


DIGITAL SIGNAL PROCESSING LABORATORY

n2=length(h);
n3=max(n1,n2);
n4=n1-n2;
%========================================================
%Appending zeros if lengths of the sequences are not equal
if(n4>0)
h=[h,zeros(1,n4)];
else
x=[x,zeros(1,-n4)];
end
%========================================================

%========================================================
%Loop for circular convolution
for(n=1:n3)
y(n)=0;
for(i=1:n3)
j=n-i+1;
if(j<=0)
j=j+n3;
end
y(n)=y(n)+x(i)*h(j);
end
end
%=======================================================
disp('circ convolution of given sequences is….');
disp(y);
subplot(3, 1,1);
stem(x);
title('input sequence');
xlabel('time----->');
ylabel('amplitude------>');
subplot(3, 1,2);
stem(h);
Department of Electronics and Communication Engineering 13
DIGITAL SIGNAL PROCESSING LABORATORY

title('impulse response');
xlabel('time----->');
ylabel('amplitude------>');
subplot(3, 1,3);
stem(y);
xlabel('n----->');
ylabel('amplitude------>');
title('output sequence(circular convolution)');

Expected Graphs

Enter the input sequence :[1 2 3 4 5 6]


Enter the impulse response :[3 2 4 5 7]
circ convolution of given sequences is….
76 85 82 73 52 73

Department of Electronics and Communication Engineering 14


DIGITAL SIGNAL PROCESSING LABORATORY

Post Lab Questions


1.

1. What is mean by Convolution

_____________________________________________________________

_______________________________________________________________

2. Explain the need for convolution

_______________________________________________________________

3. Define linear convolution

______________________________________________________________

4. Define circular convolution and its advantages?

______________________________________________________________

Outcomes:

Upon completion of the experiment, the student will be able to

1. Compute and plot the linear convolution.


2. Compute and plot the circular convolution.

Department of Electronics and Communication Engineering 15


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

Generate FFT of a given sequence.


4
Roll No: _______________ Date: _______________

Objectives:

(A) Write a matlab program for Generate FFT of a given sequence.


(B) Write a matlab program for Generate DIT-FFT of a given sequence

Apparatus:

Computer loaded with Windows 7


MATLAB

Pre Lab Questions:

1. What is FFT?

2. Define principle of FFT.

3. What is zero padding.

----------------------------------------------------------------------------------------------------------------

Department of Electronics and Communication Engineering 16


DIGITAL SIGNAL PROCESSING LABORATORY

----------------------------------------------------------------------------------------------------------------

(A) Program:

%Program for generation of FFT for a given sequence.


clc;
clear all;
close all;
tic;
x=input ('Enter the sequence :');
n=input ('Enter the length of FFT :');
%compute fft
disp('fourier transformed signal');
X=fft(x,n);
subplot(2, 1,1);
stem(x);
title('Input Sequence');
xlabel('Time--->n');
ylabel('Amplitude----> x(n)');
grid on
subplot(2, 1,2);
stem(X);
title('FFT of a Input x(n) is:');
xlabel('real axis----->');
ylabel('imaginary axis------>');
grid on;

Expected Graphs

Enter the sequence :[1 2 3 4 5 6 7 8]


Enter the length of FFT :8
fourier transformed signal

Department of Electronics and Communication Engineering 17


DIGITAL SIGNAL PROCESSING LABORATORY

X=

Columns 1 through 6

36.0000 + 0.0000i -4.0000 + 9.6569i -4.0000 + 4.0000i -4.0000 + 1.6569i -4.0000


+ 0.0000i -4.0000 - 1.6569i

Columns 7 through 8

-4.0000 - 4.0000i -4.0000 - 9.6569i

Department of Electronics and Communication Engineering 18


DIGITAL SIGNAL PROCESSING LABORATORY

Program (B):

%Program for generation of DIT-FFT for a given sequence


clc;
clear all;
close all;
x=input('enter x[n]:');
N=length(x);
levels=nextpow2(N);
xn=[x,zeros(1,(2^levels)-N)];
x=bitrevorder(xn);
N=length(xn);
tw=cos(2*pi*(1/N)*(0:N/2-1))-j*sin(2*pi*(1/N)*(0:N/2-1));
for level=1:levels
L=2^level;
twlvl=tw(1:N/L:N/2);
for k=0:L:N-L
for n=0:L/2-1
A=x(n+k+1);
B=x(n+k+(L/2)+1)*twlvl(n+1);
x(n+k+1)=A+B;
x(n+k+(L/2)+1)=A-B;
end
end
x;
end
XK=x;
n=0:N-1;
subplot(2,2,1);
stem(n,xn);
title('x(n)');
xlabel('n');
ylabel('Amplitude');

Department of Electronics and Communication Engineering 19


DIGITAL SIGNAL PROCESSING LABORATORY

subplot(2,2,2);
stem(n,real(XK));
title('Real part of X(K)');
xlabel('n');
ylabel('Amplitude');
subplot(2,2,3);
stem(n,imag(XK));
title('Imag part of X(K)');
xlabel('n');
ylabel('Amplitude');

Expected Graphs

enter x[n]:[1 2 3 4 4 3 2 1]

Department of Electronics and Communication Engineering 20


DIGITAL SIGNAL PROCESSING LABORATORY

Post Lab Questions:

1. What is decimation - in - time algorithm?

2. Give the advantages of FFT over DFT?.

3. Write the expression for twiddle factor.


----------------------------------------------------------------------------------------------------------------

4. What are the differences and similarities between DIF and DIT algorithms?
----------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------

Outcomes:

Upon completion of the experiment, the student will be able to

1. Clearly define FFT of a given sequence.


2. Write a MATLAB code for FFT anf DIT-FFT .

Department of Electronics and Communication Engineering 21


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

Design different FIR filters for a given sequence


5
Roll No:_______________ Date:_______________

Objectives:

To Write a Matlab program of FIR Low pass and high pass filter using rectangular, Hanning
Hamming, Blackman and Kaiser window.

Apparatus:

Computer loaded with Windows 7


MATLAB

Pre Lab Questions:

1. Define FIR Filters?

2. Write the expression for FIR filters..

3. What is casual system?

----------------------------------------------------------------------------------------------------------------

Department of Electronics and Communication Engineering 22


DIGITAL SIGNAL PROCESSING LABORATORY

(A )Program:

%MATLAB program of FIR Low pass filter using Rectangular, Hanning, Hamming, Blackman
and Kaiser window
clc;
clear all;
close all;
wc=.5*pi;
N=25;
w=0:0.1:pi;
%% BLACKMAN WINDOW
b=fir1(N,wc/pi,blackman(N+1));
h=freqz(b,1,w);
subplot(3,2,1)
plot(w/pi,abs(h))
grid;xlabel('normalised frequency');
ylabel('magnitude in dB');
title('FIR LPF USING BLACKMAN WINDOW');
%% HAMMING WINDOW
b=fir1(N,wc/pi,hamming(N+1));
h=freqz(b,1,w);
subplot(3,2,2)
plot(w/pi,abs(h));
grid;
xlabel('normalised frequency');
ylabel('magnitude in dB');
title('FIR LPF USING HAMMING WINDOW');
%% HANNING WINDOW
b=fir1(N,wc/pi,hanning(N+1));
h=freqz(b,1,w); subplot(3,2,3)
plot(w/pi,abs(h));
grid;
xlabel('normalised frequency');

Department of Electronics and Communication Engineering 23


DIGITAL SIGNAL PROCESSING LABORATORY

ylabel('magnitude in dB');
title('FIR LPF USING HANNING WINDOW');
%% KAISER WINDOW
b=fir1(N,wc/pi,kaiser(N+1,3.5));
h=freqz(b,1,w); subplot(3,2,4)
plot(w/pi,abs(h));
grid;
xlabel('normalised frequency');
ylabel('magnitude in dB');
title('FIR LPF USING KAISER WINDOW');
%% RECTANGULAR WINDOW
b=fir1(N,wc/pi,boxcar(N+1));
h=freqz(b,1,w);
subplot (3,2,5);
plot(w/pi,abs(h));
grid;xlabel('normalised frequency');
ylabel('magnitude in dB');
title('FIR LPF USING RECTANGULAR WINDOW');

Expected Graphs

Department of Electronics and Communication Engineering 24


DIGITAL SIGNAL PROCESSING LABORATORY

Program (B)

%FIR Filter design window techniques


clc;
clear all;
close all;
rp=input('enter passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter passband freq');
fs=input('enter stopband freq');
f=input('enter sampling freq ');
beta=input('enter beta value');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;

Department of Electronics and Communication Engineering 25


DIGITAL SIGNAL PROCESSING LABORATORY

if(rem(n,2)~=0)
n1=n;
n=n-1;
end
c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n
');
if(c==1)
y=rectwin(n1);
disp('Rectangular window filter response');
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1,beta);
disp('kaiser window filter response');
end
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');

Expected Graphs

enter passband ripple0.02


enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
Department of Electronics and Communication Engineering 26
DIGITAL SIGNAL PROCESSING LABORATORY

enter beta value5


enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
1
Rectangular window filter response

enter passband ripple0.02


enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter beta value5
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
2 Traingular window filter response

Department of Electronics and Communication Engineering 27


DIGITAL SIGNAL PROCESSING LABORATORY

enter passband ripple0.02


enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500
enter sampling freq 10000
enter beta value5
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
3 Kaiser window filter response

Department of Electronics and Communication Engineering 28


DIGITAL SIGNAL PROCESSING LABORATORY

Post Lab Questions:

1. Mention any two advantages of FIR filter.

2. What is the principle of designing FIR filter using windows?.

3. Define Non-Recursive filters.


----------------------------------------------------------------------------------------------------------------

4. What do you understand by linear phase response?

Department of Electronics and Communication Engineering 29


DIGITAL SIGNAL PROCESSING LABORATORY

Outcomes:

Upon completion of the experiment, the student will be able to


1. Clearly define window techniques for FIR filter.
2. Write a MATLAB code for design FIR filters using different window techniques.

Department of Electronics and Communication Engineering 30


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

Design different IIR filters for a given sequence


6
Roll No:_____________ Date:______________

Objectives:

(A) To Design a Butterworth High pass filter for the given specifications using Matlab

(B) To Design a Chebyshev-I High pass filter for the given specifications using Matlab

Apparatus:

Computer loaded with windows7 and MATLAB software

1 Pre-Lab Questions:

1. Define impulse response.

_________________________________________________________________

2. What do you mean by IIR?

__________________________________________________________________

3. Mention the properties of bilinear transformation______

__________________________________________________________________

Department of Electronics and Communication Engineering 31


DIGITAL SIGNAL PROCESSING LABORATORY

Program (A):

% Program for design a Butterworth Highpass filter for the given specifications
clc;
clear all;
close all;
alphap=input('enter pass attenuation in db='); %passband attenuation in db
alphas=input('enter stopband attenuation in db='); % stopband attenuation in db
fp=input('enter passband frequency in hz='); % passband frequency in hz
fs=input('enter stopband frequency in hz='); % stopband frequency in hz
F=input('enter sampling frequency in hz='); % sampling frequency in hz
omp=2*fp/F; %frequency in radians
oms=2*fs/F; %to find cutoff frequency and order of the filter
[n,wn]=buttord(omp,oms,alphap,alphas); %system function of the filter
[b,a]=butter(n,wn,'high');
w=0:0.01:pi;
[h,om]=freqz(b,a,w,'whole');
m=20*log10(abs(h));
an=angle(h);
subplot(1,2,1);
plot(om/pi,m);
grid;
xlabel('normalised frequency');
ylabel('gain in db');
title('magnitude response');
subplot(1,2,2);
plot(om/pi,an);
grid;
xlabel('normalised frequency');
ylabel('phase in radians');
title('phase response');
disp(b);
disp(a);

Department of Electronics and Communication Engineering 32


DIGITAL SIGNAL PROCESSING LABORATORY

Expected Graphs

enter pass attenuation in db=0.5


enter stopband attenuation in db=25
enter passband frequency in hz=1000
enter stopband frequency in hz=400
enter sampling frequency in hz=8000
b= 0.4056 -2.0282 4.0564 -4.0564 2.0282 -0.4056

a= 1.0000 -3.2296 4.3877 -3.0846 1.1140 -0.1645

Department of Electronics and Communication Engineering 33


DIGITAL SIGNAL PROCESSING LABORATORY

Program (B)

% Program for design a chebyshev-1 Hihpass filter for the given specifications
clc;
clear all;
close all;
alphap=input('passband attenuation in db='); %passband attenuation in db
alphas=input('stopband attenuation in db=');% stopband attenuation in db
wp=.3*pi;% passband frequency in rad
ws=.2*pi;% stopband frequency in rad %order and cutoff frequency of the filter
[n,wn]=cheb1ord(wp/pi,ws/pi,alphap,alphas); %system function of the filter
[b,a]=cheby1(n,alphap,wn,'high');
w=0:0.01:pi;
[h,ph]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
subplot(1,2,1);
plot(ph/pi,m);
grid;
xlabel('normalised frequency');
ylabel('gain in db');
title('magnitude response');
subplot(1,2,2);
plot(ph/pi,an);
grid;
xlabel('normalised frequency');
ylabel('phase in rad');
title('phase response');
disp(b);
disp(a);

Department of Electronics and Communication Engineering 34


DIGITAL SIGNAL PROCESSING LABORATORY

Expected Graphs:

passband attenuation in db=1


stopband attenuation in db=20
b= 0.2005 -0.8022 1.2033 -0.8022 0.2005
a= 1.0000 -1.0920 1.0639 -0.2680 0.1764

Post Lab Questions

1. Write the expression for Butterworth low pass filter.

_______________________________________________________________

2. Define type-I and type-II Chebyshev filters.

______________________________________________________________

3. Define Cutt-off frequecny_______________________________

4. Distinguish between Butterworth and Chebyshev (Type-I) filter.

Department of Electronics and Communication Engineering 35


DIGITAL SIGNAL PROCESSING LABORATORY

Outcomes:

Upon completion of the experiment, the student will be able to

1. Plot the frequency response of Butterworth high pass filter.


2. Plot the frequency response of Chebheshev high pass filter.

Department of Electronics and Communication Engineering 36


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

Implementation decimation and interpolation


7 process

Regd No:_______________ Date:_______________

Objectives:

Program to verify the decimation & Interpolation of given sequence

Apparatus:

Computer loaded with windows 7 and MATLAB software

1 Pre-Lab Questions:

1. Define sampling.

_________________________________________________________________

2. Define multirate signal processing.

__________________________________________________________________

3. Define Brightness.

__________________________________________________________________

Program (A)

Program to verify the decimation of given sequence

clc;
clear all;
close all;

Department of Electronics and Communication Engineering 37


DIGITAL SIGNAL PROCESSING LABORATORY

D=input('Enter the down sampling factor');


L=input('Enter the length of the input signal');
f1=input('Enter the frequency of first sinusoidal');
f2=input('Enter the frequency of second sinusoidal');
n=0:L-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=decimate(x,D,'fir');
subplot(2,1,1);
stem(n,x(1:L));
title('input sequence');
xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:(L/D)-1;
stem(m,y(1:L/D));
title('Decimated sequence');
xlabel('time(n)');
ylabel('amplitude');

Expected Graphs

Enter the down sampling factor 5


Enter the length of the input signal 200
Enter the frequency of first sinusoidal 0.01
Enter the frequency of second sinusoidal 0.04

Department of Electronics and Communication Engineering 38


DIGITAL SIGNAL PROCESSING LABORATORY

Program (B)

Program to verify the Interpolation of given sequence

clc;
clear all;
close all;
L=input('Enter the upsampling factor');
N=input('Enter the length of the input signal'); % Length should be greater than 8
f1=input('Enter the frequency of first sinusodal');
f2=input('Enter the frequency of second sinusodal');
n=0:N-1;
x=sin(2*pi*f1*n)+sin(2*pi*f2*n);
y=interp(x,L);
subplot(2,1,1)
stem(n,x(1:N))
title('input sequence');
Department of Electronics and Communication Engineering 39
DIGITAL SIGNAL PROCESSING LABORATORY

xlabel('time(n)');
ylabel('amplitude');
subplot(2,1,2)
m=0:N*L-1;
stem(m,y(1:N*L))
title('Interpolation sequence ');
xlabel('time(n)');
ylabel('amplitude');

Expected Graphs

Enter the upsampling factor 5


Enter the length of the input signal 10
Enter the frequency of first sinusodal 0.1
Enter the frequency of second sinusodal 0.5

Department of Electronics and Communication Engineering 40


DIGITAL SIGNAL PROCESSING LABORATORY

Post Lab Questions

1 Explain about multi rate digital signal processing .

______________________________________________________________

______________________________________________________________

2 Define decimation?

____________________________________________________________

3 Write the applications of decimation?

______________________________________________________________

4 Write the input output relationship for a decimator?

_______________________________________________________________

5 Write the input output relationship for an interpolator.

____________________________________________________________

6 What is meant by up sampling?

______________________________________________________________

Outcomes:

Upon completion of the experiment, the student will be able to

1 Performed Decimation & Interpolation for the given sequence using matlab.
2 Able to understand demiation process in multirate signal processing

Department of Electronics and Communication Engineering 41


DIGITAL SIGNAL PROCESSING LABORATORY

PART-B
EXPERIMENTS
ON DSP
PROCESSOR

Department of Electronics and Communication Engineering 42


DIGITAL SIGNAL PROCESSING LABORATORY

INTRODUCTION TO DSP PROCESSORS

A signal can be defined as a function that conveys information, generally about the
state or behavior of a physical system. There are two basic types of signals viz Analog
(continuous time signals which are defined along a continuum of times) and Digital
(discrete-time).
Remarkably, under reasonable constraints, a continuous time signal can be adequately
represented by samples, obtaining discrete time signals. Thus digital signal processing
is an ideal choice for anyone who needs the performance advantage of digital
manipulation along with today’s analog reality. Hence a processor which is designed
to perform the special operations (digital manipulations) on the digital signal within
very less time can be called as a Digital signal processor. The difference between a
DSP processor, conventional microprocessor and a microcontroller are listed below.

MICROPROCESSOR: or General Purpose Processor such as Intel xx86 or Motorola


680xx family contains - only CPU -No RAM; No ROM; No I/O ports and No Timer

MICROCONTROLLER: Such as 8051 family Contains – CPU; RAM; ROM; I/O


ports; Timer & Interrupt circuitry
Some Micro Controllers also contain A/D, D/A and Flash Memory.

DSP PROCESSORS: Such as Texas instruments and Analog Devices Contains CPU;
RAM; ROM; I/O ports and Timer.

Optimized for
o fast arithmetic
o Extended precision
o Dual operand fetch
o Zero overhead loop
o Circular buffering
A digital signal processor (DSP) is an integrated circuit designed for high-speed data
manipulations, and is used in audio, communications, image manipulation, and other
data-acquisition and data-control applications. The microprocessors used in personal
computers are optimized for tasks involving data movement and inequality testing.
The typical applications requiring such capabilities are word processing, database
management, spread sheets, etc. When it comes to mathematical computations the
traditional microprocessor are deficient particularly where real-time performance is

Department of Electronics and Communication Engineering 43


DIGITAL SIGNAL PROCESSING LABORATORY

required. Digital signal processors are microprocessors optimized for basic


mathematical calculations such as additions and multiplications.

The basic features of a DSP Processor are

Feature Use
Fast-Multiply accumulate Most DSP algorithms, including filtering,
transforms, etc. are multiplication-
intensive
Multiple – access memory architecture Many data-intensive DSP operations
require reading a program instruction and
multiple data items during each
instruction cycle for best performance
Specialized addressing modes Efficient handling of data arrays and first-
in, first-out buffers in memory
Specialized program control Efficient control of loops for many
iterative DSP algorithms. Fast interrupt
handling for frequent I/O operations.
On-chip peripherals and I/O interfaces On-chip peripherals like A/D converters
allow for small low cost system designs.
Similarly I/O interfaces tailored for
common peripherals allow clean
interfaces to off-chip I/O devices.

INTRODUCTION TO TMS 320 C6713 DSK

The high–performance board features the TMS320C6713 floating-point DSP.


Capable of performing 1350 million floating point operations per second, the C6713
DSK the most powerful DSK development board. The DSK is USB port interfaced
platform that allows to efficiently develop and test applications for the C6713. With
extensive host PC and target DSP software support, the DSK provides easeof- use and
capabilities that are attractive to DSP engineers. The 6713 DSP Starter Kit (DSK) is a
low-cost platform which lets customers evaluate and develop applications for the
Texas Instruments C67X DSP family.

Department of Electronics and Communication Engineering 44


DIGITAL SIGNAL PROCESSING LABORATORY

The primary features of the DSK are:


1 225 MHz TMS320C6713 Floating Point DSP
2 AIC23 Stereo Codec
3 Four Position User DIP Switch and Four User LEDs
4 On-board Flash and SDRAM

TMS320C6713 DSK OVERVIEW BLOCK DIAGRAM

TI‟s Code Composer Studio development tools are bundled with the 6713DSK
providing the user with an industrial-strength integrated development environment for
C and assembly programming. Code Composer Studio communicates with the DSP
using an on-board JTAG emulator through a USB interface. The TMS320C6713 DSP
is the heart of the system. It is a core member of Texas Instruments‟ C64X line of
fixed point DSPs whose distinguishing features are an extremely high performance
225MHz VLIW DSP core and 256Kbytes of internal memory. On-chip peripherals
include a 32-bit external memory interface (EMIF) with integrated SDRAM
controller, 2 multi-channel buffered serial ports (McBSPs), two on-board timers and
an enhanced DMA controller (EDMA). The 6713 represents the high end of TI‟s
C6700 floating point DSP line both in terms of computational performance and on-
chip resources.
The DSK has 4 light emitting diodes (LEDs) and 4 DIP switches that allow
users to interact with programs through simple LED displays and user input on the
switches. Many of the included examples make use of these user interfaces Options.
The DSK implements the logic necessary to tie board components together in
a programmable logic device called a CPLD. In addition to random glue logic, the
CPLD implements a set of 4 software programmable registers that can be used to
access the on-board LEDs and DIP switches as well as control the daughter card
interface.

Department of Electronics and Communication Engineering 45


DIGITAL SIGNAL PROCESSING LABORATORY

Department of Electronics and Communication Engineering 46


DIGITAL SIGNAL PROCESSING LABORATORY

AIC23 Codec:
The DSK uses a Texas Instruments AIC23 (part #TLV320AIC23) stereo codec for
input and output of audio signals. The codec samples analog signals on the
microphone or line inputs and converts them into digital data so it can be processed
by the DSP. When the DSP is finished with the data it uses the codec to convert the
samples back into analog signals on the line and headphone outputs so the user can
hear the output.

DSK hardware installation


 Shut down and power off the PC
 Connect the supplied USB port cable to the board
 Connect the other end of the cable to the USB port of PC
 Plug the other end of the power cable into a power outlet
 Plug the power cable into the board
 The user LEDs should flash several times to indicate board is operational

 When you connect your DSK through USB for the first time on a Windows

Loaded PC the new hardware found wizard will come up. So, Install the drivers (The
CCS CD contains the require drivers for C6713 DSK).

Department of Electronics and Communication Engineering 47


DIGITAL SIGNAL PROCESSING LABORATORY

TROUBLESHOOTING DSK CONNECTIVITY


If Code Composer Studio IDE fails to configure your port correctly, perform the
following steps:
 Test the USB port by running DSK Port test from the start menu
 Use Start->Programs->Texas Instruments->Code Composer Studio-> Code
Composer Studio C6713 DSK Tools -> C6713 DSK Diagnostic Utilities
 The below Screen will appear
 Select 6713 DSK Diagnostic Utility Icon from Desktop, The Screen Look like
as below
 Select Start Option Utility Program will test the board
 After testing Diagnostic Status you will get PASS

INTRODUCTION TO CODE COMPOSER STUDIO


Code Composer is the DSP industry's first fully integrated development environment
(IDE) with DSP-specific functionality. With a familiar environment liked MS-based
C+, Code Composer lets you edit, build, debug, profile and manage projects from a
single unified environment. Other unique features include graphical signal analysis,
injection/extraction of data signals via file I/O, multi-processor debugging, automated
testing and customization via a C-interpretive scripting language and much more.
CODE COMPOSER FEATURES INCLUDE:
 IDE
 Debug IDE

Department of Electronics and Communication Engineering 48


DIGITAL SIGNAL PROCESSING LABORATORY

 Advanced watch windows


 Integrated editor
 File I/O, Probe Points, and graphical algorithm scope probes
 Advanced graphical signal analysis
 Interactive profiling
 Automated testing and customization via scripting
 Visual project management system
 Compile in the background while editing and debugging
 Multi-processor debugging
 Help on the target DSP

TO CREATE A SYSTEM CONFIGURATION USING A STANDARD


CONFIGURATION FILES:

STEP 1: Start CCS Setup by double clicking on the Setup CCS desktop icon.
STEP 2: Select Family ->c67xx Platform->simulator Endean’s->little
STEP 3: Click the Import button (File-> import) to import our selection
(c67xx_sim.ccs) to the System configuration currently being created in the
CCS Setup window.
STEP 4: Click the Save and Quit button to save the configuration in the System
Registry.
STEP 5: Click the Yes button to start the CCS IDE when we exit CCS Setup. The
CCS Setup Closes and the CCS IDE automatically opens using the
Configuration we just created.

PROCEDURE TO WORK ON CODE COMPOSER STUDIO


STEP 1: Creating a New Project
From the Project menu, choose New. In the Project Name field, type the name we
want for our project. Each project we create must have a unique name, and Click
Finish. The CCS IDE creates a project file called projectname.pjt. This file stores our
project settings and references the various files used by our project.

The Project Creation wizard window displays.

Department of Electronics and Communication Engineering 49


DIGITAL SIGNAL PROCESSING LABORATORY

STEP 2: Creating a source file


Create a new source file using ‘File ->new ->source file ‘ pull down menu and save
the source file with .c extension in the current project name directory. Save as type:
c/c++ source file (*.c*).
Path: C:\CCStudio_v3.1\ MyProjects\Project Name\

STEP 3: Add files to our project (source file\ library file\ linker file)
SOURCE FILE: Add the source file in the project using ‘Project->add files to project’
pull down menu. Files of type: c/c++ source file (*.c*)
Path: C:\CCStudio_v3.1\ My Projects\Project Name\filename’s
LIBRARY FILE: Add the library file in the project using ‘Project-> add files to
project’ pull down menu. Files of type: Object and Library Files (*.o*,*.l*)
Path: C:\CCStudio_v3.1\ C6000\ cgtools\ lib \ rts6700.lib

Department of Electronics and Communication Engineering 50


DIGITAL SIGNAL PROCESSING LABORATORY

LINKER FILE: Add the linker file in the project using ‘Project-> add files to project’
pull down menu. Files of type: Linker command Files (*.cmd*,*.lcf*)
Path: C:\CCStudio_v3.1\ tutorial\ dsk6713\ hello1 \ hello.cmd

STEP 4: Building and Running the Program (compile\ Build\ Load Program\
Run)
COMPILE: Compile the program using the ‘Project-compile’ pull down menu or by clicking
the shortcut icon on the left side of program window.
BUILD: Build the program using the ‘Project-Build’ pull down menu or by clicking the
shortcut icon on the left side of program window.

Department of Electronics and Communication Engineering 51


DIGITAL SIGNAL PROCESSING LABORATORY

LOAD PROGRAM: Load the program in program memory of DSP chip using the ‘File-load
program’ pull down menu. Files of type:(*.out*)
Path: C:\CCStudio_v3.1\ MyProjects\Project Name\ Debug\ Projectame.out
RUN: Run the program using the ‘Debug->Run’ pull down menu or by clicking the shortcut
icon on the left side of program window.

STEP 5: observe output using graph Choose View-> Graph-> Time/Frequency. In The
Graph Property Dialog, Change The Graph Title, Start Address, And Acquisition Buffer Size,
Display Data Size, Dsp Data Type, Auto Scale, And Maximum Y- Value Properties To The
Values.

Department of Electronics and Communication Engineering 52


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

GENERATION OF SINE WAVE USING C6713 DSK


8
Roll No:_______________ Date:_______________

Objectives:

To generate a real time sinewave using TMS320C6713 DSK.

Apparatus:

 TMS 320C6713 Kit.


 RS232 Serial Cable
 Power Cord
 Operating System – Windows XP
 Software – CCStudio_v3.1.

PROCEDURE:
1 Connect CRO to the LINE OUT socket.
2 Now switch ON the DSK and bring up Code Composer Studio on PC
3 Create a new project with name sinewave.pjt
4 From File menu->New->DSP/BIOS Configuration->Select dsk6713.cdb and save it
as “ sinewave.cdb”
5 Add sinewave.cdb to the current project
6 Create a new source file and save it as sinewave.c
7 Add the source file sinewave.c to the project
8 Add the library file “dsk6713bsl.lib” to the project ( Path:
C:\CCStudio\C6000\dsk6713\lib\dsk6713bsl.lib)
9 Copy files “dsk6713.h” and “dsk6713_aic23.h” to the Project folder (Path:
C:\CCStudio_v3.1\C6000\dsk6713\include)
10 Build (F7) and load the program to the DSP Chip ( File->Load Program(.out file))
11 Run the program (F5)
12 Observe the waveform that appears on the CRO screen and ccstudio simulator.

Department of Electronics and Communication Engineering 53


DIGITAL SIGNAL PROCESSING LABORATORY

(A ) Program:

%% matlab code to generate the sine values of the look table


n=1:48;
x=sin(2*pi*n*1000/48000);
x1=round(x*2^15);
// c program for generation of sine wave using c6713 DSK
#include "sinewavecfg.h"
#include "dsk6713.h"
#include "dsk6713_aic23.h"
short loop=0;
short gain=1;
Int16 outbuffer[256];
const short BUFFERLENGTH=256;
int i=0;
DSK6713_AIC23_Config
config={0x0017,0x0017,0x00d8,0x00d8,0x0011,0x0000,0x0000,0x0043,0x0081,0x0001};
Int16sine_table[48]={4277,8481,12540,16384,19948,23170,25997,28378,30274,31651,3248
8, 32766,32488,31651,30274,28378,25997,23170,19948,16384,12540,8481,4277,0,-4277,-
8481, -12540,-16384,-19948,-23170,-25997,-28378,-30274,-31651,-32488,-32766,-32488,-
31651, -30274,-28378,-25997,-23170,-19948,-16384,-12540,-8481,-4277,0};
Uint32 fs=DSK6713_AIC23_FREQ_48KHZ;

void main()
{
DSK6713_AIC23_CodecHandle hCodec;
DSK6713_init();
hCodec=DSK6713_AIC23_openCodec(0, &config);
DSK6713_AIC23_setFreq(hCodec, fs);
while(1)
{
outbuffer[i]=sine_table[loop];
while(!DSK6713_AIC23_write(hCodec, sine_table[loop])*gain);
i++;
if(i==BUFFERLENGTH) i=0;
if(++loop>47) loop=0;

Department of Electronics and Communication Engineering 54


DIGITAL SIGNAL PROCESSING LABORATORY

}
}

Expected Graphs:

a) output from code composer studio

b) output from the CRO

Department of Electronics and Communication Engineering 55


DIGITAL SIGNAL PROCESSING LABORATORY

Outcomes:

Upon completion of the experiment, the student will be able to


1. Understand and generated sine wave signal using DSP processor.

Department of Electronics and Communication Engineering 56


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.
Implementation of Linear convolution & Circular

9 Convolution

Roll No:_______________ Date:_______________

Objectives:

To Implement Linear Convolution on DSP Processor

Apparatus:

1 TMS320C6748DSK
2 PC with Code Composer Studio.

PROCEDURE:

1 Open Code Composer Setup and select C6713 simulator, click save
and quit
2 Start a new project using Project New pull down menu, save it in a separate
directory
3 (C:\My projects) with file name
linearconv.pjt
4 Create a new source file using File New Source file menu and save it in the
project folder (linearconv.c)
5 Add the source file (linearconv.c) to the project
6 Project Add files to Project Select linearconv.c
7 Add the linker command file
hello.cmd
8 Project Add files to Project
(path:C:\CCstudio\tutorial\dsk6713\hello\hello.md)
9 Add the run time support library file rts6700.lib
10 Project Add files to Project (Path: C\CCStudio\cgtools\lib\rts6700.lib)
11 Compile the program using project Compile menu or by Ctrl+F7
12 Build the program using project  Build menu or by F7

Department of Electronics and Communication Engineering 57


DIGITAL SIGNAL PROCESSING LABORATORY

13 Load the linearconv.out file (from project folder impulse


response\Debug) using
14 File Load Program
15 Run the program using „Debug Run or F5
16 To view the output
graphically
17 Select ViewGraph Time and Frequency observe the values in the output window.

(A ) Program:

#include<stdio.h>
int y[20];
main(){
int m=6; /*Length of i/p samples sequence*/
int n=6; /*Length of impulse response Coefficients */
int i=0,j;
int x[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Input Signal Samples*/
int h[15]={1,2,3,4,5,6,0,0,0,0,0,0}; /*Impulse Response Coefficients*/
for(i=0;i<m+n-1;i++){
y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}

Department of Electronics and Communication Engineering 58


DIGITAL SIGNAL PROCESSING LABORATORY

Expected Graphs:

To view the values in graph


Go to

Tools  Graph Single Time

Set the Graph Properties as shown

Buffer size :9

DSP Data Type :32-Bit Signed Integer

Start Address: y

Display Data Size :9

Click :Ok

The graph has been plotted as shown below.

Department of Electronics and Communication Engineering 59


DIGITAL SIGNAL PROCESSING LABORATORY

(B ) Program:

%%% To compute circular convolution of two discrete time signals.

#include<stdio.h>
intm,n,x[30],h[30],y[30],i,j,temp[30],k,x2[30],a[30];
Void main (void ){
printf (“enter the length of the first sequence\n");
scanf ("%d", &m);
Printf (“enter the length of the second sequence\n");
scanf ("%d",&n);
Printf (“enter the first sequence\n");
for (i=0; i<m; i++)
scanf ("%d",&x[i]);
Printf (“enter the second sequence\n");
for (j=0; j<n;j++)
scanf ("%d", &h[j]);
if (m-n! =0) {
if (m>n){
for (i=n; i<m; i++){
h[i] =0; n=m;
}
for (i=m; i<n; i++)
x[i] =0; m=n;
}
y [0] =0;
a [0] =h [0];
for (j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j];
for (i=0; i<n; i++)
y[0]+=x[i]*a[i];
for (k=1; k<n; k++){
y[k] =0;
for (j=1; j<n;j++)
x2[j] =a [j-1];
x2[0] =a[n-1];

for (i=0; i<n; i++){


a[i]=x2[i];
y[k]+=x[i]*x2[i]
}

Department of Electronics and Communication Engineering 60


DIGITAL SIGNAL PROCESSING LABORATORY

}
Printf (“the circular convolution is\n");
for (i=0; i<n;i++)
Printf ("%d \t", y[i]); }

Expected Graphs:

Department of Electronics and Communication Engineering 61


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

Computation of N- Point DFT of a Given Sequence


10
Roll No:_______________ Date:_______________

Objectives:

To find the DFT of a sequence using FFT algorithm

Apparatus:

 TMS 320C6713 Kit.


 RS232 Serial Cable
 Power Cord
 Operating System – Windows XP
 Software – CCStudio_v3.1.

Program:

// N-point Fast Fourier Transform (FFT) algorithm program in c language using CC


Studio //

#include<stdio.h>
#include<math.h>
void main ()
{
short N=8;
short X[8]={1,2,3,4,4,3,2,1};//test data
float pi=3.1416;
float sumRe=0, sumlm=0;//init real/imag components
float cosine=0,sine=0;//initialize cosine/sine components
//output Real and imaginary components
float out_real[8]={0.0},out_imag[8]={0.0};
int n=0, k=0;

Department of Electronics and Communication Engineering 62


DIGITAL SIGNAL PROCESSING LABORATORY

for(k=0;k<N;k++)
{
sumRe=0;
sumlm=0;
for(n=0;n<N;n++)
{
cosine=cos(2*pi*k*n/N);
sine=sin(2*pi*k*n/N);
sumRe=sumRe+X[n]*cosine;
sumlm=sumlm-X[n]*sine;
}
out_real[k]=sumRe;
out_imag[k]=sumlm;
printf("[%d]%7.3f%7.3f\n",k,out_real[k],out_imag[k]);
}
}

Expected Graphs:

Department of Electronics and Communication Engineering 63


DIGITAL SIGNAL PROCESSING LABORATORY

Outcomes:

Upon completion of the experiment, the student will be able to

1. N-Point FFT program was written and implemented on DSP processor

Department of Electronics and Communication Engineering 64


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

IIR and FIR Filter Implementation using DSP Kits.


11
Roll No:_______________ Date:_______________

Objectives:

To Implement IIR (LPF/HPF) filters on DSP processor.

Apparatus:

 DSP processor TMS320C6713


 Operating system – Windows XP
 Constructor – Simulator
 Software – CC Studio 3

(A ) Program:

//iirfilters
#include<stdio.h>
#include<math.h>
intI,w,wc,c,N;
float H[100];
floatmul(float, int);
void main()
{
printf(“\n enter order of filter”);
scanf(“%d”,&N);
printf(“\n enter the cutoff freq”);
scanf(“%d”,&wc);
Department of Electronics and Communication Engineering 65
DIGITAL SIGNAL PROCESSING LABORATORY

printf(“\n enter the choice for IIR filter 1.LPF 2.HPF”);


scanf(“%d”,&c);
switch(c)
{
case 1:
for(w=0;w<100;w++)
{
H[w]=1/sqrt(1+mul((w/(float)wc),2*N));
printf(“H[%d]=%f\n”,w,H[w]);
}
break;
case 2:
for(w=0;w<=100;w++)
{
H[w]=1/sqrt(1+mul((float)wc/w,2*N));
printf(“H[%d]=%f\n”,w,H[w]);
}
break;
}}
floatmul(float a,int x)
{
for(i=0;i<x-1;i++)
a*=a;
return(a);
}

Department of Electronics and Communication Engineering 66


DIGITAL SIGNAL PROCESSING LABORATORY

Expected Graphs:

Department of Electronics and Communication Engineering 67


DIGITAL SIGNAL PROCESSING LABORATORY

Objectives:

To verify FIR filter using CCS Studio.

(B) Program:

#include<stdio.h>
#include<math.h>
#define pi 3.1415
int n,N,c;
float wr[64],wt[64];
void main()
{
printf("\n enter no. of samples,N= :");
scanf("%d",&N);
printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");
scanf("%d",&c);
printf("\n elements of window function are:");
switch(c)
{
case 1:
for(n=0;n<=N-1;n++)
{
wr[n]=1;
printf(" \n wr[%d]=%f",n,wr[n]);
}
break;
case 2:
for(n=0;n<=N-1;n++)
{
wt[n]=1-(2*(float)n/(N-1));
printf("\n wt[%d]=%f",n,wt[n]);
}
break;
}
}

Expected Graphs:

Department of Electronics and Communication Engineering 68


DIGITAL SIGNAL PROCESSING LABORATORY

Outcomes:

Upon completion of the experiment, the student will be able to


1. Implemented IIR (LPF/HPF) filters on DSP Processor.
2. Designed FIR filter Using DSP Processor.

Department of Electronics and Communication Engineering 69


DIGITAL SIGNAL PROCESSING LABORATORY

Experiment No.

12 Implementation of audio loopback.

Roll No:_______________ Date:_______________

Objectives:

Implementation of audio loopback using DSP Processor kit

Apparatus:

 TMS 320C6713 Kit.


 RS232 Serial Cable
 Power Cord
 Operating System – Windows XP
 Software – CCStudio_v3.1.

Programs:

#include "dsk6713.h"
#include "dsk6713_aic23.h"
#include "stdlib.h"
#include "math.h"
// Codec configuration settings
DSK6713_AIC23_Config config = { \
0x0017, /* 0 DSK6713_AIC23_LEFTINVOL Left line input channel volume */ \
0x0017, /* 1 DSK6713_AIC23_RIGHTINVOL Right line input channel volume */\
0x01F9, /* 2 DSK6713_AIC23_LEFTHPVOL Left channel headphone volume */ \
0x01F9, /* 3 DSK6713_AIC23_RIGHTHPVOL Right channel headphone volume */
\
0x0011, /* 4 DSK6713_AIC23_ANAPATH Analog audio path control */ \
0x0000, /* 5 DSK6713_AIC23_DIGPATH Digital audio path control */ \
0x0000, /* 6 DSK6713_AIC23_POWERDOWN Power down control */ \

Department of Electronics and Communication Engineering 70


DIGITAL SIGNAL PROCESSING LABORATORY

0x0043, /* 7 DSK6713_AIC23_DIGIF Digital audio interface format */ \


0x0001, /* 8 DSK6713_AIC23_SAMPLERATE Sample rate control */ \
0x0001 /* 9 DSK6713_AIC23_DIGACT Digital interface activation */ \
};
void main() // main program executed first
{
DSK6713_AIC23_CodecHandle hCodec;
// Uint32 stereo;
Uint32 xL, xR, yL, yR; // left and right input and output samples from/to codec
float g=3; // gain to demonstrate watch windows and GEL files
// Initialize BSL
DSK6713_init();
//Start codec
hCodec = DSK6713_AIC23_openCodec(0, &config);
// Set frequency to 48KHz
DSK6713_AIC23_setFreq(hCodec, DSK6713_AIC23_FREQ_48KHZ);
for(;;)
{
// Read left and right channel samples
while (!DSK6713_AIC23_read(hCodec, (&xL, &xR)))
yL = g * xL; // replace these with your sample processing
algorithm
yR = g * xR;
// write left and right channel samples
while (!DSK6713_AIC23_write(hCodec, (yL,yR)))
return;
}
}

Outcomes:

Upon completion of the experiment, the student will be able to

1. Implemented of audio loopback using DSP Processor kit in real time.

Department of Electronics and Communication Engineering 71

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy