Vous êtes sur la page 1sur 38

DIGITAL SIGNAL PROCESSING

LAB MANUAL
III-B.Tech (ECE), II- SEM
(R13 REGULATION)

DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING


SANTHIRAM ENGINEERING COLLEGE
Approved by AICTE, New Delhi: Permanently Affiliated to JNTUA, Anantapuramu,
An ISO 9001:2008 Certified Institution Recognition of the college under 2 (f) & 12 (B) of the UGC ACT, 1956
NH-18, Nandyal 518501:: Kurnool Dist. A.P.

List of Experiments
Digital signal processing Lab
Part A (Software experiments)
1. Generation of random signal and plot the same as a wave form showing all the
specifications.
2. Finding power and/or energy of a given signal.
3. Convolution and Correlation (auto and cross correlation) of discrete sequences without
using built in functions for convolution and correlation operations.
4. DTFT of a given signal.
5.

N point FFT algorithm.

6. Design of FIR filter using windowing technique and verify the frequency response of the
filter.
7. Design of IIR filter using any of the available methods and verify the frequency response
of the filter.
8. Design of analog filters.
Part B (DSP Processor kits (floating point) and Code Composure Studio (CCS))
1. Generation of random signal and plot the same as a wave form showing all the
specifications.
2. Finding power and/or energy of a given signal.
3. Convolution and Correlation (auto and cross correlation) of discrete sequences without
using built in functions for convolution and correlation operations.
4. DTFT of a given signal.
5. N point FFT algorithm.
6. Design of FIR filter using windowing technique and verify the frequency response of the
filter.
7. Design of IIR filter using any of the available methods and verify the frequency response
of the filter.
8. Design of analog filters.

Part A
Software experiments in Matlab

1. GENERATION OF RANDOM SIGNALS


AIM: -

To perform the random sequence generation using MATLAB.

APPARATUS: -

Personal computer
MATLAB software

PROCEDURE:-

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:%Random Sequence Generation


clc;
close all;
clear all;
n=input('Input the length of Random sequence ');
y=linspace(1,n,n);
disp(y);
x=0+sqrt(1)*randn(1,n);
disp(x);
plot(y,x);
axis([1 10 -1.5 3.5]);
title('Random Sequence');
xlabel('Discrete Frequency');
ylabel('Amplitude');
grid on;

INPUT:
Input the length of Random sequence 100

OUTPUT:-

RESULT:-

2. FINDING POWER AND/OR ENERGY OF A GIVEN SIGNAL


AIM: - To find power and energy of a given signal using MATLAB.
APPARATUS: -

Personal computer
MATLAB software

PROCEDURE:-

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:clc;
clear all;
T=10;

%Total evaluation time

Ts=0.001; %Sampling time => 1000 samples per second


Fs=1/Ts;

% Sampling period

t=[0:Ts:T]; %define simulation time


%sample function to calculate power
% x=cos(2*pi*100*t);
% power = (norm(x)^2)/length(x)
% Energy= (norm(x)^2)
x=exp(j*pi*t);
power = (norm(x)^2)/length(x)
Energy= (norm(x)^2)

CALCULATIONS:
=

E=

OUTPUT:power =

1.0000

Energy = 1.0001e+004

RESULT:-

| ( )|^

| ( )|^

3. CONVOLUTION AND CORRELATION (AUTO AND CROSS


CORRELATION) OF DISCRETE SEQUENCES WITHOUT USING BUILT
IN FUNCTIONS FOR CONVOLUTION AND CORRELATION
OPERATIONS.
AIM: - To find convolution and correlation (auto and cross correlation) of discrete sequences
using MATLAB.
APPARATUS: PROCEDURE:-

Personal computer
MATLAB software

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:-

3.1. CONVOLUTION
clc;
clear all;
close all;
x=input('Enter the sequence 1: ');
h=input('Enter the sequence 2: ');
y=conv(x,h)
figure;
subplot(3,1,1);
stem(x);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 1');
subplot(3,1,2);
stem(y);
stem(h);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 2');
subplot(3,1,3);
stem(y);
xlabel('n->');
ylabel('Amplitude->');
title('Output sequence');
disp('The resultant is');
fliplr(y);

THEORITICAL CALCULATIONS:
r=
n= 3
2
1
2

1
2
1
2
x[0]h[0] x[0]h[1] x[0]h[2] x[0]h[3]
x[1]h[0] x[1]h[1] x[1]h[2] x[1]h[3]
x[2]h[0] x[2]h[1] x[2]h[2] x[2]h[3]
x[3]h[0] x[3]h[1] x[3]h[2]

INPUT:
Enter the sequence 1: [3 2 1 2]
Enter the sequence 2: [1 2 1 2]

OUTPUT:
y=
3

8 12

x[3]h[3]

3.2. AUTO CORRELATION


clc;
clear all;
close all;
x=input('Enter the sequence 1: ');
y=xcorr(x,x)
figure;
subplot(3,1,1);
stem(x);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 1');
subplot(3,1,3);
stem(fliplr(y));
xlabel('n->');
ylabel('Amplitude->');
title('Output sequence');
disp('The resultant is');
fliplr(y);

THEORITICAL CALCULATIONS:

r=
n= 4
3
2
1

1
2
3
4
x[0]h[0] x[0]h[1] x[0]h[2] x[0]h[3]
x[1]h[0] x[1]h[1] x[1]h[2] x[1]h[3]
x[2]h[0] x[2]h[1] x[2]h[2] x[2]h[3]
x[3]h[0] x[3]h[1] x[3]h[2]

INPUT: Enter the sequence 1: [1 2 3 4]

OUTPUT:
y=
4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000

x[3]h[3]

3.3. CROSS CORRELATION


clc;
clear all;
close all;
x=input('Enter the sequence 1: ');
h=input('Enter the sequence 2: ');
y=xcorr(x,h);
figure;
subplot(3,1,1);
stem(x);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 1');
subplot(3,1,2);
stem(fliplr(y));
stem(h);
xlabel('n->');
ylabel('Amplitude->');
title('Input sequence 2');
subplot(3,1,3);
stem(fliplr(y));
xlabel('n->');
ylabel('Amplitude->');
title('Output sequence');
disp('The resultant is');
fliplr(y);

THEORITICAL CALCULATIONS:
r=
n= 1
0
1
0

1
2
3
4
x[0]h[0] x[0]h[1] x[0]h[2] x[0]h[3]
x[1]h[0] x[1]h[1] x[1]h[2] x[1]h[3]
x[2]h[0] x[2]h[1] x[2]h[2] x[2]h[3]
x[3]h[0] x[3]h[1] x[3]h[2]

INPUT:
Enter the sequence 1: [1 2 3 4]
Enter the sequence 2: [0 1 0 1]
OUTPUT:y=
1.0000 2.0000 4.0000 6.0000 3.0000 4.0000 -0.0000

RESULT:-

x[3]h[3]

4. DTFT OF A GIVEN SIGNAL


AIM: - To find convolution and correlation (auto and cross correlation) of discrete sequences
using MATLAB.
APPARATUS: -

PROCEDURE:-

Personal computer
MATLAB software

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM: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); %initilise 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
%-----------------------------------------------------------%code block to plot the input sequence
%-----------------------------------------------------------t=0:ln-1;
subplot(221);
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(222);
stem(t,magnitude);
ylabel ('Amplitude');
xlabel ('K');
TITLE ('Magnitude Response');
%-----------------------------------------------------------phase=angle(xk); % Find the phases of individual DFT points
%code block to plot the magnitude sequence
%-----------------------------------------------------------t=0:ln-1;
subplot(223);
stem(t,phase);
ylabel ('Phase');
xlabel ('K');
TITLE ('Phase 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(224);
stem(t,xn);
ylabel ('Amplitude');
xlabel ('Time Index');
TITLE ('IDFT sequence');
%-----------------------------------------------------------

THEORITICAL CALCULATIONS:

INPUT:
Enter the sequence x(n) [1 1 0 0]
OUTPUT:
Magnitude =
2.0000

1.0000 - 1.0000i

0 - 0.0000i 1.0000 + 1.0000i

Phase =
0 -0.7854 -1.5708 0.7854
ixk =
1.0000 - 0.0000i 1.0000

RESULT:-

-0.0000 + 0.0000i 0.0000 + 0.0000i

5. N- point FFT Algorithm


AIM: - To find the N-point FFT for given sequence using MATLAB.
APPARATUS: -

PROCEDURE:-

Personal computer
MATLAB software

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:clc;
clear all;
x = input('Enter the input sequence = ');
N = length(x);
for k = 1:N
y(k) = 0;
for n = 1:N
y(k) = y(k)+x(n)*exp(-1i*2*pi*(k-1)*(n-1)/N);
end
end
%code block to plot the input sequence
t = 0:N-1;
subplot(2,2,1);
stem(t,x);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('Input Sequence');
grid on;
magnitude = (y); % Find the magnitudes of individual FFT points
disp('FFT Sequence = ');
disp(magnitude);
%code block to plot the FFT sequence
t = 0:N-1;
subplot(2,2,2);
stem(t,magnitude);
ylabel('Amplitude ---->');
xlabel('K ---->');
title('FFT Sequence');
grid on;
R = length(y);
for n = 1:R
x1(n) = 0;
for k = 1:R

x1(n) = x1(n)+(1/R)*y(k)*exp(1i*2*pi*(k-1)*(n-1)/R);
end
end
%code block to plot the IFFT sequence
t = 0:R-1;
subplot(2,2,3);
stem(t,x1);
disp('IFFT Sequence = ');
disp(x1);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('IFFT sequence');
grid on;
THEORITICAL CALCULATIONS:

INPUT: Enter the input sequence = [1 1 1 1 1 1 0 0]


OUTPUT:
FFT Sequence =
Columns 1 through 5
6.0000

-0.7071 - 1.7071i 1.0000 - 1.0000i 0.7071 + 0.2929i

0 - 0.0000i

Columns 6 through 8
0.7071 - 0.2929i 1.0000 + 1.0000i -0.7071 + 1.7071i
IFFT Sequence =
Columns 1 through 5
1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 - 0.0000i 1.0000 + 0.0000i
Columns 6 through 8
1.0000 + 0.0000i 0.0000 + 0.0000i 0.0000 + 0.0000i

RESULT:-

6. Design of FIR filter using windowing technique and verify


the frequency response of the filter.
Experiment No: - 6(a)
AIM: - TO write a MATLAB program to design FIR LP\HP using Kaiser Window
Techniques.
APPARATUS: Personal computer
MATLAB software
PROCEDURE: Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:clc;
close all;
clear all;
format long;
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');
beta=input('enter the 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;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=kaiser(n1,beta);
%Lowpass filter
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,1);
plot(o/pi,m);
ylabel('gain in db---->');
xlabel('Normalised frequency---->');
title('FIR filter using Kaiser window of LPF ----');
grid on;
%Highpass filter
b=fir1(n,wp,'high',y);

[h,o]=freqz(b,1,256);
m=20*log10(abs(h));subplot(2,1,2);
plot(o/pi,m);
ylabel('gain in db---->');
xlabel('Normalised frequency---->');
title('FIR filter using Kaiser window of HPF ----');
grid on;

INPUT:Enter the pass band ripple


0.02
Enter the stop band ripple
0.01
Enter the pass band frequency 1000
Enter the stop band frequency 1500
Enter the sampling frequency 10000
Enter the beta value
5.8
OUTPUT:

RESULTS: - Thus the MATLAB program for FIR LP\HP using Kaiser Window
Techniques was executed.

FIR LP\HP FILTERUSING TRIANGULAR WINDOWING TECHNIQUES


Experiment No: - 6(b)
AIM: - TO write a MATLAB program to design FIR LP\HP using Triangular window
Techniques.
APPARATUS: -

PROCEDURE:-

Personal computer
MATLAB software

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:
clc;
close all;
clear all;
format long;
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');
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;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=triang(n1);
%Lowpass filter
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,1);
plot(o/pi,m);
ylabel('gain in db---->');
xlabel('Normalised frequency---->');
title('FIR filter using Triangular window of LPF ----');
grid on;
%Highpass filter
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);

m=20*log10(abs(h));
subplot(2,1,2);
plot(o/pi,m);
ylabel('gain in db---->');
xlabel('Normalised frequency---->');
title('FIR filter using Triangular window of HPF ----');
grid on ;

INPUT:Enter the pass band ripple


0.04
Enter the stop band ripple
0.02
Enter the pass band frequency 1500
Enter the stop band frequency 2000
Enter the sampling frequency 8000
OUTPUT:

RESULTS: - Thus the MATLAB program for FIR LP\HP using triangular window
Techniques was executed.

FIR LP\HP FILTER USING RECTANGULAR WINDOWING TECHNIQUES


Experiment No: - 6(c)
AIM: - TO write a MATLAB program to design FIR LP\HP using Rectangular window
Techniques.
APPARATUS:Personal computer
MATLAB software
PROCEDURE: Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window
PROGRAM:
clc;
close all;
clear all;
format long;
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
fp=input('enter the passband frequency');
fs=input('enter the stopband frequency');
f=input('enter the sampling frequency');
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;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end;
y=boxcar(n1);
%Lowpass filter
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,1);
plot(o/pi,m);
ylabel('gain in db---->');
xlabel('Normalised frequency---->');
title('FIR filter using Rectangular window of LPF ----');
grid on;
%Highpass filter
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,1,2);
plot(o/pi,m);
ylabel('gain in db---->');

xlabel('Normalised frequency---->');
title('FIR filter using Rectangular window of HPF ----');
title('Magnitude response of high pass filter');
grid on;

INPUT:Enter the passband ripple


0.04
Enter the stopband ripple
0.05
Enter the passband frequency 1500
Enter the stopband frequency 2000
Enter the sampling frequency 9000
OUTPUT:

RESULTS: - Thus the MATLAB program for FIR LP\HP using rectangular window
Techniques was executed.

7. Design of IIR filter using any of the available methods and verify the
frequency response of the filter.
AIM: - TO write a MATLAB program to design IIR LP\HP Filter
APPARATUS: -

PROCEDURE:-

Personal computer
MATLAB software

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:
IIR/LP
clear all;
close all;
fp=input('Enter the pass band frequency fp = ');
fs=input('Enter the stop band frequency fs = ');
rp=input('Enter the pass band attenuation rp = ');
rs=input('Enter the stop band attenuation rs = ');
f=input ('Enter the sampling frequency f = ');
wp=2*fp/f;
ws=2*fs/f;
[n,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(n,wn,'low');
freqz(b,a,500,f);
TITLE ('Magnitude and phase respose of the IIR butterworth filter');

INPUT:Enter the pass band frequency fp = 20


Enter the stop band frequency fs = 50
Enter the pass band attenuation rp = 1
Enter the stop band attenuation rs = 2
Enter the sampling frequency f = 1000
OUTPUT:-

IIR/HP
clear all;
close all;
fp=input('Enter the pass band frequency fp = ');
fs=input('Enter the stop band frequency fs = ');
rp=input('Enter the pass band attenuation rp = ');
rs=input('Enter the stop band attenuation rs = ');
f=input ('Enter the sampling frequency f = ');
wp=2*fp/f;
ws=2*fs/f;

[n,wn]=buttord(wp,ws,rp,rs);
[b,a]=butter(n,wn,'high');
freqz(b,a,500,f);
TITLE ('Magnitude and phase respose of the IIR butterworth filter');

INPUT:Enter the pass band frequency fp = 20


Enter the stop band frequency fs = 50
Enter the pass band attenuation rp = 1
Enter the stop band attenuation rs = 2
Enter the sampling frequency f = 1000
OUTPUT:-

RESULT:- Thus the MATLAB program for IIR filter was executed and verified frequency
response.

8. Design of analog filters


AIM: - TO write a MATLAB program to design of analog Filter
APPARATUS: -

PROCEDURE:-

Personal computer
MATLAB software

Open MATLAB
Open new M-file
Type the program
Save in current directory
Compile and Run the program
For the output see command window\ Figure window

PROGRAM:
ANALOG HIGH PASS
clc;
close all;
clear all;
f=100:20:8000;
fl=400;
k=length(f);
for i=1:k;
m(i)=1/sqrt(1+(fl/f(i))^2);
mag(i)=20*log10(m(i));
end;
figure;
semilogx(f,mag);
title('magnitude response of analog of high pass filter');
xlabel('frequency----->');
ylabel('magnitude in db');
grid on;

ANALOG LOW PASS


clc;
close all;
clear all;
f=100:20:8000;
fh=900;
k=length(f);
for i=1:k;
m(i)=1/sqrt(1+(f(i)/fh)^2);
mag(i)=20*log10(m(i));
end;
figure;
semilogx(f,mag);
title('magnitude response of analog of low pass filter')
xlabel('frequency----->');
ylabel('magnitude in db');
grid on;

OUTPUT: - High pass and Low pass

RESULT:- Thus the MATLAB program for Analog filter was executed and verified frequency
response.

Part B
DSP Processor kits (floating point)
&
Code Composure Studio (CCS)

1. GENERATION OF RANDOM SIGNALS


Aim:
To perform the random sequence generation using Code composer studio (CCS) V3.1.
:

Apparatus:
1. Host (PC) with windows (95/98/Me/XP/NT/2000).
2. TMS320C6713 DSP Starter Kit (DSK).

Procedure:
1 .Open Code Composer Studio, make sure the DSP kit is turned on.
2. Open 6713DSK Diagnostics icon from desktop and press button start and then you can
absorb the diagnostic status pass.
3. Open 6713DSK CCStudion V3.1 icon from desktop.
4. Start a new project using Project-new and give the project name then select the target
TMS320C67XX pull down menu, save it in a separate directory(c:\ti\myprojects) with
name sss.pjt.
5. Select file-newnew source and type the program then save with .C extension
name
6. Add the source files sss.c to the project using
Projectadd files to project select sss.c and open it, pull down menu.
7. Add the object library files.
Projectadd files to project
(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)
8. Add the linker command file hello.cmd .
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
9. Compile the program using the Project-compile pull down menu or by
Clicking the shortcut icon on the left side of program window.
10. Build the program using the Project-Build pull down menu or by
Clicking the shortcut icon on the left side of program window.
11. Load the program (sss.out) in program memory of DSP chip using the
File-load program pull down menu.
12. Go to debug menu and selected the run.

C Program:
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i ,num, c;
printf("\n Time in INDEX: --->Amptitude:\n");
for(i=0;i<=3;i++)
printf("-----------");
printf("\n");
for (c = 1; c <= 20; c++)
{ printf("\t %d--------->",c);
num = rand()%10;
printf("%d \n ",num);
}
return 0;
}

Input:

Output:

2. CONVOLUTION AND CORRELATION (AUTO AND CROSS


CORRELATION) OF DISCRETE SEQUENCES WITHOUT USING BUILT IN
FUNCTIONS FOR CONVOLUTION AND CORRELATION OPERATIONS.

Aim:
To find convolution and correlation (auto and cross correlation) of discrete sequences
using Code composer studio (CCS) v3.1.

Apparatus:
1. Host (PC) with windows (95/98/Me/XP/NT/2000).
2. TMS320C6713 DSP Starter Kit (DSK).

Procedure:
1 .Open Code Composer Studio, make sure the DSP kit is turned on.
2. Open 6713DSK Diagnostics icon from desktop and press button start and then you can
absorb the diagnostic status pass.
3. Open 6713DSK CCStudion V3.1 icon from desktop.
4. Start a new project using Project-new and give the project name then select the target
TMS320C67XX pull down menu, save it in a separate directory(c:\ti\myprojects) with
name sss.pjt.
5. Select file-newnew source and type the program then save with .C extension
name
6. Add the source files sss.c to the project using
Projectadd files to project select sss.c and open it, pull down menu.
7. Add the object library files.
Projectadd files to project
(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)
8. Add the linker command file hello.cmd .
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
9. Compile the program using the Project-compile pull down menu or by
Clicking the shortcut icon on the left side of program window.
10. Build the program using the Project-Build pull down menu or by
Clicking the shortcut icon on the left side of program window.
11. Load the program (sss.out) in program memory of DSP chip using the
File-load program pull down menu.
12. Go to debug menu and selected the run.

C Program:
A) Linear convolation:
#include<stdio.h>
int x[15],h[15],y[15];
main()
{
int i,j,m,n;
printf("\n enter value for m");
scanf("%d",&m);
printf("\n enter value for n");
scanf("%d",&n);
printf("Enter values for i/p\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for n \n");
for(i=0;i<n;i++)
scanf("%d",&h[i]);
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}
}
for(i=0;i<m+n-1;i++)
printf("\n The Value of output y[%d]=%d",i,y[i]);
}

Input:

Output:

B) Auto correlation:
#include<stdio.h>
int x[15],h[15],y[15],h1[15];
main()
{
int i,j,m,;
printf("\n enter lenth of series:");
scanf("%d",&m);
printf("Enter values for series:\n");
for(i=0;i<m;i++)
scanf("%d",&h1[i]);
j=0;
for(i=m-1;i>=0;i--)
h[j++]=h1[i];
for(i=m;i<=m+m-1;i++)
h[i]=0;
for(i=m;i<=m+m-1;i++)
h1[i]=0;
for(i=0;i<m+m-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(h1[j]*h[i-j]);
}
}
for(i=0;i<m+m-1;i++)
printf("\n The correlation output is: y[%d]=%d",i,y[i]);
}

Input:

Output:

C) Correlation:
#include<stdio.h>
int x[15],h[15],y[15],h1[15];
main()
{
int i,j,m,n;
printf("\n enter lenth of first series:");
scanf("%d",&m);
printf("\n enterlenth of second series:");
scanf("%d",&n);
printf("Enter values for first series:\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf("Enter Values for second series: \n");
for(i=0;i<n;i++)
scanf("%d",&h1[i]);
j=0;
for(i=n-1;i>=0;i--)
h[j++]=h1[i];
for(i=m;i<=m+n-1;i++)
x[i]=0;
for(i=n;i<=m+n-1;i++)
h[i]=0;
for(i=0;i<m+n-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
{
y[i]=y[i]+(x[j]*h[i-j]);
}
}
for(i=0;i<m+n-1;i++)
printf("\n The correlation output is: y[%d]=%d",i,y[i]);
}
Input:

Output:

Result:

3. DTFT OF A GIVEN SIGNAL


AIM: To find convolution and correlation (auto and cross correlation) of discrete sequences
using Code composer studio (CCS) v3.1.

Apparatus:
1. Host (PC) with windows (95/98/Me/XP/NT/2000).
2. TMS320C6713 DSP Starter Kit (DSK).

Procedure:
1 .Open Code Composer Studio, make sure the DSP kit is turned on.
2. Open 6713DSK Diagnostics icon from desktop and press button start and then you can
absorb the diagnostic status pass.
3. Open 6713DSK CCStudion V3.1 icon from desktop.
4. Start a new project using Project-new and give the project name then select the target
TMS320C67XX pull down menu, save it in a separate directory(c:\ti\myprojects) with
name sss.pjt.
5. Select file-newnew source and type the program then save with .C extension
name
6. Add the source files sss.c to the project using
Projectadd files to project select sss.c and open it, pull down menu.
7. Add the object library files.
Projectadd files to project
(Path: c:\ti\c6000\cgtools\lib\rts6700.lib)
8. Add the linker command file hello.cmd .
(Path: c:\ti\tutorial\dsk6713\hello1\hello.cmd)
9. Compile the program using the Project-compile pull down menu or by
Clicking the shortcut icon on the left side of program window.
10. Build the program using the Project-Build pull down menu or by
Clicking the shortcut icon on the left side of program window.
11. Load the program (sss.out) in program memory of DSP chip using the
File-load program pull down menu.
12. Go to debug menu and selected the run.

C Program:
#include<stdio.h>
#include<math.h>
void main()
{
int k,n,N;
static float X[100],X_Real[100],X_Imag[100];
printf("\tDiscrete Fourier Transform(DFT)\n");
printf("\n Enter the number samples in the sequence X(n)=");
scanf("%d",&N);
printf("Enter the number samples of sequence X(n)\n");
for(n=0;n<N;n++)
{
printf("X(%d)=",n);
scanf("%f",&X[n]);
}
for(n=0;n<N;n++)
{
for(k=0;k<N;k++)
{
X_Real[k] = X_Imag[k]=0.0;
for(n=0;n<N;n++)
{
X_Real[k]=X_Real[k]+X[n]*cos((2*3.14*k*n)/N);
X_Imag[k]=X_Imag[k]+X[n]*sin((2*3.14*k*n)/N);
}
X_Imag[k]=X_Imag[k]*(-1.0);
}
}
printf("\nThe %d point DFT of given sequence is:\n",N);
printf("\n\nReal X(k)\t\tImaginary X(k)\n");
for(k=0;k<N;k++)
printf("\nX(%d)= %f\t\t\t%f\t\t",k,X_Real[k],X_Imag[k]);
}

Input:

Output:

Result:

Vous aimerez peut-être aussi