Professional Documents
Culture Documents
LIST OF EXPERIMENTS
2
INDEX
Sign of
Page
S.No. Date Name of the Experiment the
No.
faculty
1.
2.
3.
4.
5.
6.
7.
8.
9.
10
11.
12.
3
Expt. No: 1
Dt: FREQUENCY RESPONSE OF A SYSTEM
Aim: To plot & observe the frequency response of first order and second order discrete-time
systems described by the difference equations
a) y(n) - 0.5 y(n-1) = x(n)
b) y(n) + 0.8 y(n-1) + 0.125 y(n-2) = x(n) + 2x(n-1)
Equipment Required:
PC loaded with MATLAB software
Algorithm:
Program:
clc;
clear all;
close all;
b=input('enter the coefficients of x(n): ');
a=input('enter the coefficients of y(n): ');
w= -2*pi: pi/256:2*pi;
g=freqz (b,a,w);
m=abs(g);
ph=angle(g);
subplot (2,1,1);
plot(w/pi, m);
xlabel('normalized frequency');
ylabel('magnitude');
grid on;
title('Magnitude response');
subplot(2,1,2);
plot(w/pi,ph);
4
xlabel(' normalized frequency');
ylabel('Phase');
grid on;
title ('phase response');
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input 1:
enter the coefficients of x(n): [1 ]
Enter the coefficients of y(n): [1, -0.5]
Output 1:
Magnitude response
2
---> magnitude
1.5
0.5
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
---> normalized frequency
Phase response
1
0.5
---> phase
-0.5
-1
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
---> normalized frequency
Input 2:
Enter the coefficients of x(n): [1 2]
Enter the coefficients of y(n): [1, 0.8, 0.125]
5
Output 2:
Magnitude response
3.5
---> magnitude
2.5
1.5
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
---> normalized frequency
Phase response
4
2
---> phase
-2
-4
-2 -1.5 -1 -0.5 0 0.5 1 1.5 2
---> normalized frequency
Result: Hence the frequency response of a first order and second order discrete-time systems
are observed and plotted using MATLAB.
6
Expt. No: 2
Dt: IMPLEMENTAION OF DISCRETE TIME SYSTEMS IN
TIME DOMAIN
Aim: To implement the following discrete time systems described by difference equation in
time domain using MATLAB.
a) y(n) - 0.8 y(n-1) = x(n)
b) y(n) + 0.8 y(n-1) + 0.125 y(n-2) = x(n)
Equipment Required:
PC loaded with MATLAB software
Algorithm:
Program:
clc;
clear all;
close all;
b=input('enter the coefficients of x(n): ');
a=input('enter the coefficients of y(n): ');
[h,N]=impz(b,a);
stem(N,h);
xlabel('Time n');
ylabel('Amplitude');
grid on;
title('Impulse response of the system');
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
7
Input 1:
Enter the coefficients of x(n): [1]
Enter the coefficients of y(n): [1, -0.8]
Output 1:
Input 2:
Enter the coefficients of x(n): [1 ]
Enter the coefficients of y(n): [1, 0.8, 0.125]
Output 2:
Result: Hence given discrete time system is implemented and its impulse response is
observed using MATLAB.
8
Expt. No: 3
Dt: DFT and IDFT OF GIVEN SEQUENCE
Aim: To determine and plot the DFT and IDFT of a given sequence using MATLAB.
Equipment Required:
PC loaded with MATLAB software
Algorithm:
X(K) =
Program:
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); % initilise an array of same size as that of input sequence
ixk=zeros(1,ln);
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
t=0:ln-1;
subplot(221);
stem(t,xn);
grid
ylabel ('Amplitude');
xlabel ('Time Index');
9
title('Input Sequence x[n]');
magnitude=abs(xk);
t=0:ln-1;
subplot(222);
stem(t,magnitude);
grid
ylabel ('Amplitude');
xlabel ('index K');
title ('Magnitude Response of x[n]');
phase=angle(xk);
t=0:ln-1;
subplot(223);
stem(t,phase);
grid
ylabel ('Phase');
xlabel ('index K');
title('Phase Response of x[n]');
disp('DFT of the given sequence x[n] is');
disp(xk)
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;
t=0:ln-1;
subplot(224);
stem(t,ixk);
grid;
ylabel ('Amplitude');
xlabel ('Time Index');
title ('IDFT sequence');
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
Enter the sequence x(n): [1 2 3 4]
10
Output:
DFT of the given sequence x[n] is
10.0000 + 0.0000i -2.0000 + 2.0000i -2.0000 - 0.0000i -2.0000 - 2.0000i
Result: Hence DFT and IDFT of given sequence is performed and outputs are observed using
MATLAB.
11
Expt. No: 4
Dt: PROPERTIES OF DFT
Equipment Required:
PC loaded with MATLAB software
Algorithm:
Linearity Property:
Program:
clc;
close all;
clear all;
disp(' DFT properties ');
disp('1. Linearity Property');
disp('2. Circular Convolution Property');
ch=input('Enter your choice: ');
switch(ch)
case 1
disp('DFT[ax1(n)+bx2(n)] = aX1(k)+bX2(k)');
x1=input('enter the input sequence x1: ');
x2=input('enter the input sequence x2: ');
a=input('enter the value of constant a: ');
b=input('enter the value of constant b: ');
N1=length(x1);
N2=length(x2);
N=max(N1,N2);
X1=zeros(1,N);X2=zeros(1,N);X=zeros(1,N);X3=zeros(1,N);
if N1>N2
n=N2+1:N1;
x2(n)=0;
else
n=N1+1:N2;
x1(n)=0;
end
for k=1:N
for n=1:N
x(n)=a*x1(n)+b*x2(n);
X1(k)=X1(k)+x1(n)*exp(-j*2*pi*(k-1)*(n-1)/N);
X2(k)=X2(k)+x2(n)*exp(-j*2*pi*(k-1)*(n-1)/N);
X(k)=X(k)+x(n)*exp(-j*2*pi*(k-1)*(n-1)/N);
X3(k)=a*X1(k)+b*X2(k);
end
13
end
disp('DFT[ax1(n)+bx2(n)] = ');
disp(X);
disp('aX1(k)+bX2(k) = ');
disp(X3);
case 2
disp('DFT(x1(n)*x2(n_)) = X1(k).X2(k)');
x1=input('enter the sequence x1: ');
x2=input('enter the sequence x2: ');
N1=length(x1);
N2=length(x2);
N=max(N1,N2);
if N1>N2
n=N2+1:N1;
x2(n)=0;
else
n=N1+1:N2;
x1(n)=0;
end
X1=zeros(1,N);X2=zeros(1,N);X=zeros(1,N);X3=zeros(1,N);
x=cconv(x1,x2,N);
X=fft(x);
X1=fft(x1);
X2=fft(x2);
X3=X1.*X2;
disp('DFT(x1(n)*x2(n)) = ');
disp(X);
disp('X1(k).X2(k) = ');
disp(X3);
end
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
Case1:
Enter your choice: 1
Enter the input sequence x1: [1 2 3 4]
Enter the input sequence x2: [1 2 1 1]
14
Enter the value of constant a: 2
Enter the value of constant b: 3
Output1:
DFT[ax1(n)+bx2(n)] =
35.0000 + 0.0000i -4.0000 + 1.0000i -7.0000 - 0.0000i -4.0000 - 1.0000i
aX1(k)+bX2(k) =
35.0000 + 0.0000i -4.0000 + 1.0000i -7.0000 - 0.0000i -4.0000 - 1.0000i
Input:
Case2:
Output2:
DFT(x1(n)*x2(n)) =
50.0000 + 0.0000i 2.0000 + 2.0000i 2.0000 + 0.0000i 2.0000 - 2.0000i
X1(k).X2(k) =
50.0000 + 0.0000i 2.0000 + 2.0000i 2.0000 + 0.0000i 2.0000 - 2.0000i
Result: Hence the Linearity and Circular Convolution properties of DFT are verified using
MATLAB.
15
Expt. No: 5
Dt: FAST FOURIER TRANSFORM
Aim: To compute the Fast Fourier transform of a given signal using MATLAB.
Equipment Required:
PC loaded with MATLAB software
Algorithm:
Program:
clc;
clear all;
close all;
N=input('enter the length of sequence: ');
y=input('enter the samples of sequence: ');
for m= 1:N/2
w(m)=exp(-j*2*pi*(m-1)/N);
end
nos=log2(N);
legd=N/2;
for i=1:nos
for j=1:legd
for k=j:2*legd:N
ul=k;
ll=ul+legd;
temp1=y(ul) + y(ll);
temp2=y(ul)-y(ll);
y(ul)=temp1;
y(ll)=temp2*w(j);
end
end
16
legd=legd/2;
len=length(w);
w=w(1:2:len);
end
Y=bitrevorder(y);
disp(Y);
n=0:N-1;
subplot(2,1,1);
stem(n,abs(Y));
title('magnitude spectrum');
xlabel('Frequency index K');
ylabel('amplitude');
subplot(2,1,2);
stem(n,angle(Y));
title('Phase spectrum');
xlabel('Frequency index K');
ylabel('phase');
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
enter the length of sequence: 8
enter the samples of sequence: [1 2 3 4 5 6 7 8]
Output:
17
Magnitude spectrum
40
30
amplitude
20
10
0
0 1 2 3 4 5 6 7
frequency index K
Phase spectrum
4
2
Phase
-2
-4
0 1 2 3 4 5 6 7
frequency index K
Result: Hence Fast Fourier transform of a given signal is computed and its spectrum is
plotted using MATLAB
18
Expt. No: 6
Dt: DESIGN OF IIR LOW PASS DIGITAL FILTER
Aim: To design and plot the frequency response of IIR low pass digital filter using
Butterworth & Chebyshev approximations.
Equipment Required:
PC loaded with MATLAB software
Algorithm:
Program:
clc;
clear all;
close all;
rp=input('enter the passband ripple: ');
rs=input('enter the stopband ripple: ');
wp=input('enter the passband frequency: ');
ws=input('enter the stopband frequency: ');
fs=input('enter the sampling frequency: ');
w1=2*wp/fs;
19
w2=2*ws/fs;
% BUTTERWORTH FILTER
% Find the order n and cutoff frequency
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn);
w=0:.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
subplot(3,2,1);
plot(om/pi,m);
title('magnitude response using Butterworth');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
grid on;
an=angle(h);
subplot(3,2,2);
plot(om/pi,an);
title('phase response using Butterworth');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
grid on;
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
enter the passband ripple: 3
enter the stopband ripple: 50
enter the passband frequency: 1000
enter the stopband frequency: 2000
enter the sampling frequency: 10000
21
Output:
Result: Hence an IIR low pass digital filter is designed and its frequency response is
observed using MATLAB.
22
Expt. No: 7
Dt: DESIGN OF IIR HIGH PASS DIGITAL FILTER
Aim: To design and plot the frequency response of IIR high pass digital filter using
Butterworth & Chebyshev approximations.
Equipment Required:
PC loaded with MATLAB software
Algorithm:
Program:
clc;
clear all;
close all;
rp=input('enter the passband ripple: ');
rs=input('enter the stopband ripple: ');
wp=input('enter the passband frequency: ');
ws=input('enter the stopband frequency: ');
fs=input('enter the sampling frequency: ');
w1=2*wp/fs;
23
w2=2*ws/fs;
% BUTTERWORTH FILTER
% Find the order n and cutoff frequency
[n,wn]=buttord(w1,w2,rp,rs);
[b,a]=butter(n,wn,'high');
w=0:.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
subplot(3,2,1);
plot(om/pi,m);
title('magnitude response using Butterworth');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
grid on;
an=angle(h);
subplot(3,2,2);
plot(om/pi,an);
title('phase response using Butterworth');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
grid on;
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
enter the passband ripple: 2
enter the stopband ripple: 50
enter the passband frequency: 2000
enter the stopband frequency: 1000
enter the sampling frequency: 5000
25
Output:
Result: Hence an IIR high pass digital filter is designed and its frequency response is
observed using MATLAB.
26
Expt. No: 8
Dt: DESIGN OF FIR LOW PASS DIGITAL FILTER
Aim: To design and plot the frequency response of FIR low pass digital filter using
windowing technique.
Equipment Required:
PC loaded with MATLAB software
Algorithm:
27
Program:
clc;
clear all;
close all;
rp=input('enter passband ripple: ');
rs=input('enter the stopband ripple: ');
fp=input('enter passband frequency: ');
fs=input('enter stopband frequency: ');
f=input('enter 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);
if(rem(n,2)~=0)
n1=n;
n=n-1;
else
n1=n+1;
end
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
30
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
enter passband ripple: 0.02
enter the stopband ripple: 0.01
enter passband frequency: 500
enter stopband frequency: 2000
enter sampling frequency: 8000
Output:
phase in dB-->
Gain in dB-->
Result: Hence an FIR low pass digital filter is designed and its response is observed using
MATLAB.
31
Expt. No: 9
Dt: DESIGN OF FIR HIGH PASS DIGITAL FILTER
Aim: To design and plot the frequency response of FIR high pass filter using windowing
technique.
Equipment Required:
PC loaded with MATLAB software
Algorithm:
32
Program:
clc;
clear all;
close all;
rp=input('enter passband ripple: ');
rs=input('enter the stopband ripple: ');
fp=input('enter passband frequency: ');
fs=input('enter stopband frequency: ');
f=input('enter sampling frequency: ');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fp-fs)/f;
n=ceil(num/dem);
if(rem(n,2)~=0)
n1=n;
n=n-1;
else
n1=n+1;
end
% HPF Rectangular window
y=rectwin(n1);
b=fir1(n,wp,'high',y);
w=0:0.01:pi;
[h,o]=freqz(b,1,w);
m=20*log10(abs(h));
an=angle(h);
subplot(6,2,1)
plot(o/pi,m);
title('rectangular window magnitude');
ylabel('Gain in dB-->');
xlabel('Normalized frequency-->');
grid on;
subplot(6,2,2)
plot(o/pi,an);
title('rectangular window phase');
ylabel('phase in dB-->');
xlabel('Normalized frequency-->');
grid on;
% HPF Triangular window
y=bartlett(n1);
b=fir1(n,wp,'high',y);
w=0:0.01:pi;
[h,o]=freqz(b,1,w);
m=20*log10(abs(h));
an=angle(h);
subplot(6,2,3)
plot(o/pi,m);
33
title('Trinngular window magnitude');
ylabel('Gain in dB-->');
xlabel('Normalized frequency-->');
grid on;
subplot(6,2,4)
plot(o/pi,an);
title('Trinngular window phase');
ylabel('phase in dB-->');
xlabel('Normalized frequency-->');
grid on;
% HPF Hanning window
y=hanning(n1);
b=fir1(n,wp,'high',y);
w=0:0.01:pi;
[h,o]=freqz(b,1,w);
m=20*log10(abs(h));
an=angle(h);
subplot(6,2,5)
plot(o/pi,m);
title('Hanning window magnitude');
ylabel('Gain in dB-->');
xlabel('Normalized frequency-->');
grid on;
subplot(6,2,6)
plot(o/pi,an);
title('Hanning window phase');
ylabel('phase in dB-->');
xlabel('Normalized frequency-->');
grid on;
% HPF Hamming window
y=hamming(n1);
b=fir1(n,wp,'high',y);
w=0:0.01:pi;
[h,o]=freqz(b,1,w);
m=20*log10(abs(h));
an=angle(h);
subplot(6,2,7)
plot(o/pi,m);
title('Hamming window magnitude');
ylabel('Gain in dB-->');
xlabel('Normalized frequency-->');
grid on;
subplot(6,2,8)
plot(o/pi,an);
title('Hamming window phase');
ylabel('phase in dB-->');
xlabel('Normalized frequency-->');
34
grid on;
% HPF Blackman window
y=blackman(n1);
b=fir1(n,wp,'high',y);
w=0:0.01:pi;
[h,o]=freqz(b,1,w);
m=20*log10(abs(h));
an=angle(h);
subplot(6,2,9)
plot(o/pi,m);
title('Blackman window magnitude');
ylabel('Gain in dB-->');
xlabel('Normalized frequency-->');
grid on;
subplot(6,2,10)
plot(o/pi,an);
title('Blackman window phase');
ylabel('phase in dB-->');
xlabel('Normalized frequency-->');
grid on;
% HPF Kaiser window
y=kaiser(n1);
b=fir1(n,wp,'high',y);
w=0:0.01:pi;
[h,o]=freqz(b,1,w);
m=20*log10(abs(h));
an=angle(h);
subplot(6,2,11)
plot(o/pi,m);
title('Kaiser window magnitude');
ylabel('Gain in dB-->');
xlabel('Normalized frequency-->');
grid on;
subplot(6,2,12)
plot(o/pi,an);
title('Kaiser window phase');
ylabel('phase in dB-->');
xlabel('Normalized frequency-->');
grid on;
Procedure:
1. Click on the MATLAB icon on the desktop (or go to Start – All programs and click
on MATLAB) to get into the Command Window.
2. Type ‘edit’ in the MATLAB prompt ‘>>’ that appears in the Command window.
3. Write the program in the ‘Edit’ window and save it in ‘M-file’.
4. Run the program.
35
5. Enter the input in the command window.
6. The result is displayed in the Command window and the graphical output is displayed
in the Figure Window.
Input:
enter passband ripple: 0.02
enter the stopband ripple: 0.01
enter passband frequency: 5000
enter stopband frequency: 1000
enter sampling frequency: 20000
Output:
phase in dB-->
Gain in dB-->
Result: Hence an FIR high pass digital filter is designed and its Frequency Response is
observed using MATLAB.
36
Expt. No: 10
Dt: LINEAR CONVOLUTION
Equipment Required:
PC loaded with Code Composer Studio software, TMS320C6713 DSP Starter kit
Algorithm:
Program:
#include<stdio.h>
int x[10],y[10],h[20];
void main()
{
int i,j,N1,N2;
printf("enter the length of first sequence: ");
scanf("%d",&N1);
printf("enter the length of second sequence: ");
scanf("%d",&N2);
printf("enter the samples of first sequence x(n): ");
for(i=0;i<N1;i++)
{
scanf("%d",&x[i]);
}
printf("enter the samples of second sequence h(n): ");
for(i=0;i<N2;i++)
{
scanf("%d",&h[i]);
37
}
for(i=N1;i<N1+N2-1;i++)
x[i]=0;
for(i=N2;i<N1+N2-1;i++)
h[i]=0;
for(i=0;i<N1+N2-1;i++)
{
y[i]=0;
for(j=0;j<=i;j++)
y[i]=y[i]+x[j]*h[i-j];
}
printf("Linear convolution of x(n) and h(n) is y(n) = :\n");
for(i=0;i<N1+N2-1;i++)
printf("%d\t",y[i]);
}
Procedure:
1. Open CCS Version 6.1.1.
2. Go to File menu and select new CCS project.
3. Create new project with following specifications
Project → New CCS Project
Target: C671X Floating-point DSP TMS320C671X
Connection: Spectrum Digital DSK-EVM-eZdsp onboard USB Emulator
38
4. Select empty project with main.c and finish.
5. Create a new Source file
File → New →Browse the Source folder→ give file name & Save ( Eg: sum.c)
39
8. Build the project.
40
Input:
enter the length of first sequence: 6
enter the length of second sequence: 4
enter the samples of first sequence x(n): {1,2,3,4,5,6}
enter the samples of second sequence h(n): {1,2,3,4}
Output:
41
Result: Hence linear convolution of given sequences is performed and output is observed
using TMS320C6713 DSP starter kit.
42
Expt. No: 11
Dt: CIRCULAR CONVOLUTION
Algorithm:
Program:
#include<stdio.h>
#include<math.h>
int x[10],y[10],h[10],a[10],t[10];
void main()
{
int i,j,k,n,m;
printf("enter the length of first sequence:\n ");
scanf("%d",&m);
printf("enter the length of second sequence:\n ");
scanf("%d",&n);
printf("enter the samples of first sequence:\n ");
for(i=0;i<m;i++)
{
scanf("%d",&x[i]);
}
43
printf("enter the samples of second sequence:\n ");
for(i=0;i<n;i++)
{
scanf("%d",&h[i]);
}
if (m-n!=0)
{
if(m>n)
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
if(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++)
a[j]=h[n-j];
for(i=0;i<n;i++)
y[0]= y[0]+ x[i]*a[i];
for(k=1;k<n;k++)
{
y[k]=0;
for(j=1;j<n;j++)
t[j]=a[j-1];
t[0]=a[n-1];
for(i=0;i<n;i++)
{
a[i]=t[i];
y[k] = y[k] + x[i]*a[i];
}
}
printf("circular convolution of x(n) and h(n) is:\n");
for(i=0;i<n;i++)
printf("%d\t",y[i]);
}
Procedure:
1. Open Code Composer Studio 6.1.1
2. Create new project with following specifications
44
Project → New CCS Project
Target: C671X Floating -point DSP TMS320C671X
Connection: Spectrum Digital DSK - EVM-eZdsp onboard USB Emulator
3. Select empty project with main.c and finish.
4. Create a Source file
File → New →Browse the Source folder→ give file name & Save ( Eg: sum.c)
5. Write C program and save it.
6. Create New Target configuration file with extension .ccxml
File → New → Target configuration file
Connection: Spectrum Digital DSK - EVM-eZdsp onboard USB Emulator
Device type: DSK6713
Save
7. Build the project.
8. Launch the target configuration.
Select Target configuration →Right click→ Launch target configuration
9. Click on Connect Target on menu bar.
10. Load the program
Run→ Load Programme →Browse .out file
11. Run the program.
12. Observe the output in the console window
(to observe the graph, go to expressions, right click on the expression and
select the graph).
Input:
Enter the length of first sequence: 3
Enter the length of second sequence: 3
Enter the samples of first sequence:{1 2 3}
Enter the samples of second sequence:{1 2 3}
Output:
Circular convolution of x(n) and h(n) is:
13 13 10
45
Result: Hence circular convolution of given sequences is performed and output is observed
using TMS320C6713 DSP starter kit.
46
Expt. No: 12
Dt: GENERATION OF SINE WAVE AND SQUARE WAVE
Aim: To generate sine and square waves using TMS320C6713 DSP Processor.
Equipment Required:
PC loaded with Code Composer Studio software, TMS320C6713 DSP Starter kit
Program:
/*Sine wave generation*/
#include<stdio.h>
#include<math.h>
#define pi 3.14
float y[500];
voidmain()
{
47
int t,f,n;
printf("enter the frequency");
scanf("%d",&f);
printf("enter the no.of samples");
scanf("%d",&N);
for(t=0;t<=500;t++)
y[t]=sin(2*pi*f*t/N);
}
Procedure:
1. Open Code Composer Studio 6.1.1
2. Create new project with following specifications
Project → New CCS Project
Target: C671X Floating -point DSP TMS320C671X
Connection: Spectrum Digital DSK - EVM-eZdsp onboard USB Emulator
3. Select empty project with main.c and finish.
4. Create a Source file
File → New →Browse the Source folder→ give file name & Save ( Eg: sum.c)
5. Write C program and save it.
6. Create New Target configuration file with extension .ccxml
File → New → Target configuration file
Connection: Spectrum Digital DSK - EVM-eZdsp onboard USB Emulator
48
Device type: DSK6713
Save
7. Build the project.
8. Launch the target configuration.
Select Target configuration →Right click→ Launch target configuration
9. Click on Connect Target on menu bar.
10. Load the program
Run→ Load Programme →Browse .out file
11. Run the program.
12. Observe the output in the console window
(to observe the graph, go to expressions, right click on the expression and select
the graph).
Input:
enter the frequency: 10
enter the no. of samples: 512
Output:
49
Input:
enter the time period: 10
Output:
Result: Hence sine wave and square waves are generated and observed using TMS320C6713
DSP starter kit.
50