Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
15 views93 pages

DSP Record

The document is an observation book for a Digital Signal Processing laboratory course, detailing various experiments related to discrete-time signals, convolutions, correlations, and filter design using MATLAB. It includes sections for recording student information, experiment dates, and results, as well as specific algorithms and MATLAB code for generating signals, performing convolutions, and designing filters. The document emphasizes practical applications and results verification through MATLAB outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views93 pages

DSP Record

The document is an observation book for a Digital Signal Processing laboratory course, detailing various experiments related to discrete-time signals, convolutions, correlations, and filter design using MATLAB. It includes sections for recording student information, experiment dates, and results, as well as specific algorithms and MATLAB code for generating signals, performing convolutions, and designing filters. The document emphasizes practical applications and results verification through MATLAB outputs.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 93

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

ENGINEERING

EC3492- DIGITAL SIGNAL PROCESSING LABORATORY


OBSERVATION BOOK
NAME :

REG NO :

Degree & Semester :

Branch & Section :

Subject & Code :


INDEX
Signature
Page
Marks of
S.No: Date Name of the Experiment No.
Faculty
Generation of elementary Discrete-Time
1
sequences
Linear and Circular convolutions
2
Auto correlation and Cross Correlation
3
Frequency Analysis using DFT
4
Design of FIR filters (LPF/HPF/BPF/BSF)
5 and demonstrates the filtering operation

Design of Butterworth and Chebyshev IIR


filters (LPF/HPF/BPF/BSF) and demonstrate
6
the filtering operations

7 Study of architecture of Digital Signal Processor

Perform MAC operation using various addressing


8
modes

9 Generation of various signals and random noise


Design and demonstration of FIR Filter for Low

10 pass, High pass, Band pass and Band stop


filtering
Design and demonstration of Butter worth and

11 Chebyshev IIR Filters for Low pass, High pass,


Band pass and Band stop filtering
Implement an Up-sampling and Down-sampling
12
operation in DSP Processor
EX:NO: 1 GENERATION OF ELEMENTARY DISCRETE
DATE : TIME SEQUENCES

AIM :
To generate a discrete time signal sequence (Unit impulse ,Unit step, Unit ramp, Sine, Cosine, Exponential,)
using MATLAB function.

TOOLS REQUIRED :

System with MATLAB software.

ALGORITHM :

1. Get the number of samples.


2. Generate the unit impulse, Unit step using ‘ones’, ‘zero’ matrix command.
3. Generate ramp, Sine, Cosine and Exponential signals using corresponding general formula.
4. Plot the graph.

PROCEDURE :
1. Open MATLAB window.
2. Open a new editor window by clicking file->new project->new m-file. Type the program and save it as.
3. Run the program by selecting delay->Run.
4. Output will be displayed.

Unit impulse Signal:


1. Assign the value of n.
2. Declare x as unit impulse function.
3. Plot the graph.

Unit step signal:


1. Assign the value of n.
2. Declare x as unit step function.
3. Plot the graph.

Unit ramp signal:


1. Assign the value of n.
2. Declare x as unit ramp function.
3. Plot the graph.

Exponential signal:
1. Assign the value of n.
2. Declare x as exponential function.
3. Plot the graph
.
Sinusoidal signal:
1. Assign the value of n.
2. Declare x as sine function.
3. Plot the graph.
Cosine wave:
1. Assign the value of n.
2. Declare x as cosine function.
3. Plot the graph.

PROGRAM:

Unit Impulse Signal:


clc;
clear all;
close all;
N=input('Number of samples');
n=-N:1:N
x=[zeros(1,N) 1 zeros(1,N) ]
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('Impulse response');

Unit Step Signal :


clc;
clear all;
close all;
N=input('Number of samples');
n=-N:1:N
x=[ zeros(1,N) 1 ones(1,N) ];
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('unit step
response');
Unit Ramp Signal:
clc;
clear all;
close
all;
disp('unit ramp signal');
N=input('Number of samples');
a=input('amplitude');
n=-N:1:N
x=a*n
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('unit ramp response)
OUTPUT :

Unit Impulse Signal :

Unit step signal :

Unit Ramp Signal :


I. Exponential Decaying Signal :
clc;
clear all;
close all;
disp('exponential decaying
signal') N=input('number of
samples'); n=0:1:N;
x=exp(-n)
stem(n,x);
xlabel('time');
ylabel('amplitude')
title('Exponential decaying signal response');

II. Sine Signal :

clc;
clear all;
close all;
disp('sine signal');
N=input('number of
samples'); n=0:1:N;
x=sin(n) ;
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('sine response');

III. Cosine Signal

clc;
clear all;
close all;
disp('cosine signal');
N=input('number of
samples'); n=0:1:N;
x=cos(n) ;
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('cosine response');
Exponentional Growing Signal :

Exponential decaying signal :

Sine signal :

DEPARTMENT OF ECE
Cosine Signal :

DEPARTMENT OF ECE
S.No Mark Allocation Max. Marks
Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT:

Thus, the various types of discrete time sequences have been generated by using MATLAB software.

DEPARTMENT OF ECE
EX:NO:2 LINEAR AND CIRCULAR CONVOLUTION
DATE :

AIM :
To implement linear convolution and circular convolution using MATLAB software.

TOOLS REQUIRED :

System with MATLAB software.

THEORY :
Linear convolution :

The linear convolution of two discrete time sequence x1(n) and x2(n) is defined

∑∞ 𝑥1(𝑛). 𝑥2(𝑛 − 𝑚)
as x3(n)=𝑛=−

x3(n)=x1(n).x2(n)=x2(n).x1(n)

Circular convolution :

The circular convolution of two discrete time sequence x 1(n) and x2(n) with periodicity of n samples is defined as

x3(n)=∑𝑚=
𝑁−1
𝑥1(𝑚). 𝑥2(𝑛 − 𝑚)N

where x3(m) is the obtained circular convolution.


x1(n-m)N represents circular shift of x1(n).
x2(n-m)N represents circular shift of x2(n).
m is the dummy variable.

x3(n)=x1(n) x2(n)= x2(n) x1(n)

where ⊛ represents circular convolution

operation.

Linear convolution through circular convolution :


The linear convolution of two sequence of length n1 and n2 produces an output sequences of length

(n1+n2- 1).To perform linear convolution both the sequences should be converted to (n1+n2-1)point sequence by
padding with zeroes. Then perform circular convolution of (n1+n2-1) point sequence. The resultant sequence will be
same as that of linear convolution of n1 and n2 point sequence.

DEPARTMENT OF ECE
DEPARTMENT OF ECE
OUTPUT :

Linear convolution :

DEPARTMENT OF ECE
ALGORITHM :

Step 1: Open MATLAB 7.0 window.


Step 2: Open a new editor window by clicking File New project New m-file.
Step 3: Type the program and save it.
Step 4: Run the program by selecting debug Run.
Step 5: Output will be displayed.
PROGRAM :

Linear convolution :

clc;
clear all;
close
all;
x=input('Enter the first
sample'); N1=length(x);
h=input('Enter the second sample');
N2=length(h);
n=0:1: N1-1;
subplot(2,2,1);
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('x sequence response');
n=0:1: N2-1
subplot(2,2,2);
stem(n,h);
xlabel('time');
ylabel('amplitude');
title('h sequence
response'); y=conv(x,h);
N=N1+N2-1;
n=0:1:N-1;
subplot(2,2,3);
stem(n,y);
xlabel('time');
ylabel('amplitude');
title('Convolution of x and h response');

DEPARTMENT OF ECE
DEPARTMENT OF ECE
Circular convolution:

DEPARTMENT OF ECE
Circular convolution :

clc;
clear all;
close
all;
x=input('Enter the first sequence');
N1=length(x);
h=input('Enter the second sequence');
N2=length(h);
n=0:1: N1-1;
subplot(2,2,1);
stem(n,x);
xlabel('time');
ylabel('amplitude');
title('x sequence response');
n=0:1: N2-1;
subplot(2,2,2);
stem(n,h);
xlabel('time');
ylabel('amplitude');
title('h sequence of
response'); N=max(N1,N2);
x=[x,zeros(1,N-N1)];
h=[h,zeros(1,N-N2)];
for n=1: N
y(n)=0;
for i=1: N
j=n-i+1;
if(j<=0)
j=N+j;
end
y(n)=[y(n)+(x(i)*h(j))];
end
end
disp('convolution of x and h
is'); subplot(2,2,3);
stem(y);
xlabel('time');
ylabel('amplitude');
title('convolution of x and h response');

DEPARTMENT OF ECE
DEPARTMENT OF ECE
S.No Mark Allocation Max. Marks
Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT :
Thus circular and linear convolutions are implemented using MATLAB and the outputs verified displayed.

DEPARTMENT OF ECE
EX:NO: 3 Auto Correlation and Cross Correlation
DATE :

AIM :

To perform Auto Correlation and Cross Correlation using MATLAB software.

TOOLS REQUIRED :

System with MATLAB software.

ALGORITHM :

1. Cross- Correlation Sequences:


1. Assign the value of n.
2. Declare x,y as sequence length .
3. Plot the graph
2. Auto- Correlation Sequences:
1. Assign the value of n.
2. Declare x as sequence length .
3. Plot the graph

THEORY :

i) Cross- Correlation Sequences:


In signal processing, cross-correlation is a measure of similarity of two series as a function of the lag of one relative to
the other. This is also known as a sliding dot product or sliding inner-product.

ii) Auto- Correlation Sequences:


It is a mathematical tool for finding repeating patterns, such as the presence of a periodic signal obscured by noise, or
identifying the missing fundamental frequency in a signal implied by its harmonic frequencies

PROCEDURE :
1. Open MATLAB window.
2. Open a new editor window by clicking file->new project->new m-file. Type the program and save it as.
3. Run the program by selecting delay->Run.
4. Output will be displayed.

DEPARTMENT OF ECE
CROSS – CORRELATION OUTPUT:

AUTO CORRELATION OUTPUT:

DEPARTMENT OF ECE
PROGRAM :

CROSS CORRELATION
clear all;

close all;
x=input(‘enter the 1st sequence’);
h=input(‘enter the 2nd
sequence’); y=xcorr(x,h);
figure;subplot(3,1,1);
stem(x);ylabel(‘Amplitude --.’);
xlabel(‘(a) n --.’);
subplot(3,1,2);
stem(h);ylabel(‘Amplitude --.’);
xlabel(‘(b) n --.’);
subplot(3,1,3);
stem(fliplr(y));ylabel(‘Amplitude --.’);
xlabel(‘(c) n --.’);
disp(‘The resultant signal is’);fliplr(y)

AUTO CORRELATION

x=input(‘enter the sequence’);


y=xcorr(x,x);
figure;subplot(2,1,1);
stem(x);ylabel(‘Amplitude --.’);
xlabel(‘(a) n --.’);
subplot(2,1,2);
stem(fliplr(y));ylabel(‘Amplitude --.’);
xlabel(‘(a) n --.’);
disp(‘The resultant signal
is’); fliplr(y)

DEPARTMENT OF ECE
S.No Mark Allocation Max. Marks
Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT:

Thus the auto correlation and cross correlation was performed using MATLAB and the results were
plotted

DEPARTMENT OF ECE
EX:NO: 4
FREQUENCY ANALYSIS USING DFT
DATE :

AIM :

To study and plot the signal from DFT by using MATLAB software and also plot the magnitude and phase
spectrum plot.

TOOLS REQUIRED :

System with MATLAB software.

THEORY :

DFT :
The discrete Fourier transform (DFT) converts a finite list of equally spaced samples of a function into the list of
coefficients of a finite combination of complex sinusoids, ordered by their frequencies, that has those same sample values.
It can be said to convert the sampled function from its original domain (often time or position along a line) to the
frequency domain.

ALGORITHM :

a. Get the two sequence from the user.


b. DFT of the two sequence is computed.
c. Plot the magnitude and phase plot spectrum.
d. Output is obtained and verified.

PROGRAM:

clc;
close all;
clear all;
x=input('Enter the sequence x= ');
N=input('Enter the length of the DFT N=
'); len=length(x);
if N>len
x=[x zeros(1,N-len)];
elseif N<len
x=x(1:N);
end
i=sqrt(-1);
w=exp(-i*2*pi/N);
n=0:(N-1);
k=0:(N-1);
nk=n'*k;
W=w.^nk;
DEPARTMENT OF ECE
OUTPUT:

DEPARTMENT OF ECE
X=x*W;
disp(X);
subplot(211);
stem(k,abs(X));
title('Magnitude Spectrum');
xlabel('Discrete frequency');
ylabel('Amplitude');
grid on;
subplot(212);
stem(k,angle(X));
title('Phase Spectrum');
xlabel('Discrete frequency');
ylabel('Phase Angle');
grid on;

S.No Mark Allocation Max. Marks


Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT :

Thus the DFT signal is plotted and its magnitude and phase plot spectrum is obtained and the output is verified.

DEPARTMENT OF ECE
EX:NO: 5 DESIGN OF FIR FILTER

DATE :

AIM:
To design a FIR filter using MATLAB software.
1. Rectangular window
2.Hamming window
3.Hanning window

APPARATUS REQUIRED:
System with MATLAB software.

ALGORITHM:

1. Get the pass band and stop band ripple and frequency.
2. Get the sampling frequency.
3. Find the order of filter ‘N’.
4. Design the low pass, high pass, band pass and band stop filter.
5. Plot the magnitude response of all filters.

PROGRAM :

Rectangular Window :
clc;
clear all;
close all;
disp('the type of filters:');
disp('1)low pass filter');
disp('2)high pass filter');
disp('3)band pass filter');
disp('4)band stop filter');
k=input('enter the choice of filter');
N=input('enter the length of
filter'); t=(N-1)/2;
switch k
case 1
wc=input('enter the lower cutoff frequency');
for n=1:N
if (n-1)==t
hd(n)=(wc)/pi;
else
hd(n)=sin(wc*(n-1)-t)/(pi*(n-1)-t);
end
end;
case 2
DEPARTMENT OF ECE
wc=input('enter the higher cutoff frequency');

DEPARTMENT OF ECE
OUTPUT :

Rectangular Window :

Low Pass Filter :

enter the length of the filter : 12

enter the lower cutoff frequency :

0.2

hd= -0.1283 -0.3529 1.1821 0.2503 0.1415 0.0958 0.0686 0.0496 0.0350 0.0233 0.0135 0.0054

w= 1 1 1 1 1 1 1 1 1 1 1 1

h= -0.1283 -0.3529 1.1821 0.2503 0.1415 0.0958 0.0686 0.0496 0.0350 0.0233 0.0135 0.0054

DEPARTMENT OF ECE
DEPARTMENT OF ECE
for n=1:N
if (n-1)==t
hd(n)=(pi-wc)/pi;

else
hd(n)=(sin(pi*(n-1)-t))-(sin(wc*(n-1)-t))/(pi*(n-1)-t);
end
end;
case 3
wc1=input('enter the lower cutoff frequency');
wc2=input('enter the higher cutoff frequency');
for n=1:N
if (n-1)==t
hd(n)=(wc2-wc1)/pi;
else
hd(n)=(sin(wc2*(n-1)-t))-(sin(wc1*(n-1)-t))/(pi*(n-1)-t);
end
end;
case 4
wc1=input('enter the lower cutoff frequency');
wc2=input('enter the higher cutoff frequency');
for n=1:N
if (n-1)==t
hd(n)=(pi+(wc2-wc1))/pi;
else
hd(n)=(sin(pi*(n-1)-t)*sin(wc2*(n-1)-t)+sin(wc1*(n-1)-t))/(pi*((n-1)-t));
end
end
end;
disp('rectangle window');
for n=1:1:N
w(n)=1;
end;
disp('hd=');
disp(hd);
disp('w=');
disp(w);
for n=1:1:N
h(n)=hd(n)*w(n);
end;
disp('h=');
disp(h);
N=linspace(-2*pi,2*pi);
[h1,w1]=freqz(h,1,1024);
subplot(2,1,1); plot(w1,
(10*log(abs(h1)))); grid;
title('magnitude plot');
xlabel('frequency in radians');

DEPARTMENT OF ECE
High Pass Filter :

enter the length of the filter : 20

enter the higher cutoff frequency :

0.3 hd= Columns 1 through 16


0.0831 -0.1102 -0.0806 -9.8382 0.3694 0.0842 0.1808 -0.0032 0.1218 -0.0488 0.0850 -0.0785
0.0619 -0.0953 0.0510 -0.1006

Columns 17 through 20
0.0506 -0.0968 0.0578 -0.0873

w= 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

h= Columns 1 through 16
0.0831 -0.1102 -0.0806 -9.8382 0.3694 0.0842 0.1808 -0.0032 0.1218 -0.0488 0.0850 -0.0785
0.0619 -0.0953 0.0510 -0.1006

Columns 17 through 20
0.0506 -0.0968 0.0578 -0.0873

DEPARTMENT OF ECE
ylabel('magnitude in db');
subplot(2,1,2);
plot(w1,angle(h1));
grid;
title('phase plot');
xlabel('frequency in radians');
ylabel('angle');

DEPARTMENT OF ECE
Band Pass Filter :

enter the length of the filter : 15

enter the lower cutoff frequency :

0.2

enter the higher cutoff frequency : 0.4

hd= -0.6869 -0.3378 0.0633 0.4553 0.7816 1.0034 1.1416 0.0637 0.3659 0.1149 -0.2429 -0.5948 -
0.8718 -1.0243 -1.0251

w= 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

h= -0.6869 -0.3378 0.0633 0.4553 0.7816 1.0034 1.1416 0.0637 0.3659 0.1149 -0.2429 -0.5948 -
0.8718 -1.0243 -1.0251

DEPARTMENT OF ECE
DEPARTMENT OF ECE
DEPARTMENT OF ECE
Band Stop Filter :

enter the length of the filter : 20

enter the lower cutoff frequency :

0.3

enter the higher cutoff frequency : 0.4

hd= Columns 1 through 16


0.0031 0.0323 -0.0286 0.1038 -0.0229 0.1405 0.0351 0.1449 0.1534 0.2865 -0.0839 -0.0519
0.1227 -0.0114 0.1106 0.0291

Columns 17 through 20
0.0458 0.0725 -0.0254 0.0916

w= 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

h= Columns 1 through 16
0.0031 0.0323 -0.0286 0.1038 -0.0229 0.1405 0.0351 0.1449 0.1534 0.2865 -0.0839 -0.0519
0.1227 -0.0114 0.1106 0.0291

Columns 17 through 20
0.0458 0.0725 -0.0254 0.0916

DEPARTMENT OF ECE
DEPARTMENT OF ECE
Hamming Window :
clc;
clear all;close
all;
disp('the type of filters:'); disp('1)low pass filter');
disp('2)high pass filter'); disp('3)band pass filter');
disp('4)band stop filter'); k=input('enter the choice
of filter');N=input('enter the length of
filter');t=(N- 1)/2;
switch k
case 1
wc=input('enter the lower cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(wc)/pi;else
hd(n)=sin(wc*(n-1)-t)/(pi*(n-1)-t); end
end
; case 2
wc=input('enter the higher cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(pi-wc)/pi;else
hd(n)=(sin(pi*(n-1)-t))-(sin(wc*(n-1)-t))/(pi*(n-1)-t);
end
end;
case 3
wc1=input('enter the lower cutoff frequency');
wc2=input('enter the higher cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(wc2-wc1)/pi; else
hd(n)=(sin(wc2*(n-1)-t))-(sin(wc1*(n-1)-t))/(pi*(n-1)-t);
end
end;
case 4
wc1=input('enter the lower cutoff frequency');
wc2=input('enter the higher cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(pi+(wc2-wc1))/pi; else
hd(n)=(sin(pi*(n-1)-t)*sin(wc2*(n-1)-t)+sin(wc1*(n-1)-t))/(pi*((n-1)-t));
end
end
end;
disp('hamming window');for
n=1:1:N
w(n)=0.54-(0.46*cos(2*(n-1)*pi)/(N-1));
end; disp('hd=');
disp(hd);

DEPARTMENT OF ECE
Hamming window :

Low Pass Filter :

enter the length of the filter : 12

enter the higher cutoff frequency : 0.3

hd= -0.1283 -0.3746 1.2544 0.2532 0.1297 0.0741 0.0397 0.0155 -0.0021 -0.0147 -0.0231 -0.0278

w= 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982 0.4982

h= -0.0639 -0.1866 0.6249 0.1261 0.0646 0.0369 0.0198 0.0077 -0.0011 -0.0073 -0.0115 -0.0139

DEPARTMENT OF ECE
disp('w=');
disp(w); for
n=1:1:N
h(n)=hd(n)*w(n);
end; disp('h=');
disp(h);
N=linspace(-2*pi,2*pi);
[h1,w1]=freqz(h,1,1024);
subplot(2,1,1); plot(w1,
(10*log(abs(h1)))); grid;
title('magnitude plot'); xlabel('frequency
in radians');ylabel('magnitude in db');
subplot(2,1,2);
plot(w1,angle(h1)); grid;
title('phase plot'); xlabel('frequency
in radians');ylabel('angle');

DEPARTMENT OF ECE
High Pass Filter :

enter the length of the filter : 23

enter the higher cutoff frequency : 0.5

hd= Columns 1 through 16


1.0909 -0.8880 1.1153 -0.9523 1.2631 -0.8304 1.1260 -0.9146 1.0465 -0.9875 0.9863 0.8408
0.9641 -1.0327 0.9770 -1.0097

Columns 17 through 23
1.0036 -0.9859 1.0200 -0.9795 1.0162 -0.9913 1.0000

w= Columns 1 through 16
0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191
0.5191 0.5191 0.5191 0.5191

Columns 17 through 23
0.5191 0.5191 0.5191 0.5191 0.5191 0.5191 0.5191

h= Columns 1 through 16
0.5663 -0.4610 0.5790 -0.4943 0.6557 -0.4310 0.5845 -0.4748 0.5432 -0.5126 0.5120 0.4365
0.5004 -0.5361 0.5072 -0.5241

Columns 17 through 23
0.5210 -0.5118 0.5294 -0.5085 0.5275 -0.5146 0.5191

DEPARTMENT OF ECE
Band Pass Filter :

enter the length of the filter : 25

enter the lower cutoff frequency :

0.5

enter the higher cutoff frequency : 0.6

hd= Columns 1 through 16


0.5508 0.9447 1.0128 0.7310 0.1960 -0.4087 -0.8765 -1.0494 -0.8724 -0.4111 0.1749 0.7043
0.0318 0.6470 0.2899 -0.2448

Columns 17 through 25
-0.7357 -0.9962 -0.9246 -0.5374 0.0362 0.5999 0.9588 0.9877 0.6755

w= Columns 1 through 16
0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208
0.5208 0.5208 0.5208 0.5208

Columns 17 through 25
0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208 0.5208

h= Columns 1 through 16
0.2869 0.4920 0.5275 0.3807 0.1021 -0.2129 -0.4565 -0.5466 -0.4544 -0.2141 0.0911 0.3668
0.0166 0.3370 0.1510 -0.1275

Columns 17 through 25
-0.3832 -0.5188 -0.4815 -0.2799 0.0188 0.3125 0.4994 0.5144 0.3518

DEPARTMENT OF ECE
Band Stop Filter :

enter the length of the filter : 24

enter the lower cutoff frequency :

0.2

enter the higher cutoff frequency : 0.4

hd= Columns 1 through 16


0.7422 -0.8996 0.8042 -0.7093 0.3599 -0.1089 -0.3238 0.5362 -0.8314 0.8399 -0.8371 0.7174 -
0.5576 -0.0916 0.2429 -0.6903

Columns 17 through 24
0.7467 -0.9315 0.7531 -0.6440 0.2720 0.0079 -0.3962 0.6368

w= Columns 1 through 16
0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200
0.5200 0.5200 0.5200 0.5200

Columns 17 through 24
0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200 0.5200

h= Columns 1 through 16
0.3859 -0.4678 0.4182 -0.3689 0.1872 -0.0566 -0.1684 0.2788 -0.4323 0.4368 -0.4353 0.3731 -
0.2899 -0.0476 0.1263 -0.3589

Columns 17 through 24
0.3883 -0.4844 0.3916 -0.3349 0.1414 0.0041 -0.2060 0.3311

DEPARTMENT OF ECE
DEPARTMENT OF ECE
Hanning Window :
clc;
clear all;close
all;
disp('the type of filters:'); disp('1)low pass filter');
disp('2)high pass filter'); disp('3)band pass filter');
disp('4)band stop filter'); k=input('enter the choice
of filter');N=input('enter the length of
filter');t=(N- 1)/2;
switch k
case 1
wc=input('enter the lower cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(wc)/pi;else
hd(n)=sin(wc*(n-1)-t)/(pi*(n-1)-t);
end
end;
case 2
wc=input('enter the higher cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(pi-wc)/pi;else
hd(n)=(sin(pi*(n-1)-t))-(sin(wc*(n-1)-t))/(pi*(n-1)-t);
end
end;
case 3
wc1=input('enter the lower cutoff frequency');
wc2=input('enter the higher cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(wc2-wc1)/pi; else
hd(n)=(sin(wc2*(n-1)-t))-(sin(wc1*(n-1)-t))/(pi*(n-1)-t);
end
end;
case 4
wc1=input('enter the lower cutoff frequency');
wc2=input('enter the higher cutoff frequency');for n=1:N
if (n-1)==t
hd(n)=(pi+(wc2-wc1))/pi; else
hd(n)=(sin(pi*(n-1)-t)*sin(wc2*(n-1)-t)+sin(wc1*(n-1)-t))/(pi*((n-1)-t));
end
end
end;
disp('hanning window');for
n=1:1:N
w(n)=0.5-(0.5*cos(2*(n-1)*pi)/(N-1));
end; disp('hd=');
disp(hd);
disp('w=');
disp(w);

DEPARTMENT OF ECE
Hanning window :

Low Pass Filter :

enter the length of the filter : 12

enter the lower cutoff frequency :

0.2

hd= -0.1283 -0.3529 1.1821 0.2503 0.1415 0.0958 0.0686 0.0496 0.0350 0.0233 0.0135 0.0054

w= 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545 0.4545

h= -0.0583 -0.1604 0.5373 0.1138 0.0643 0.0435 0.0312 0.0226 0.0159 0.0106 0.0062 0.0025

DEPARTMENT OF ECE
DEPARTMENT OF ECE
for n=1:1:N
h(n)=hd(n)*w(n);
end; disp('h=');
disp(h);
N=linspace(-2*pi,2*pi);
[h1,w1]=freqz(h,1,1024);
subplot(2,1,1); plot(w1,
(10*log(abs(h1)))); grid;
title('magnitude plot'); xlabel('frequency
in radians');ylabel('magnitude in db');
subplot(2,1,2);
plot(w1,angle(h1)); grid;
title('phase plot'); xlabel('frequency
in radians');ylabel('angle');

DEPARTMENT OF ECE
High Pass Filter :

enter the length of the filter : 13


enter the higher cutoff frequency : 0.3
hd= 0.3260 -0.0868 -2.4494 -0.5497 0.1277 -0.3801 0.9045 -0.3224 0.2563 -0.2865 0.2850 -0.2644
0.3007

w= 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583 0.4583

0.4583

h= 0.1494 -0.0398 -1.1226 -0.2520 0.0585 -0.1742 0.4146 -0.1478 0.1175 -0.1313 0.1306 -0.1212

0.1378

DEPARTMENT OF ECE
Band Pass Filter :

enter the length of the filter : 5

enter the lower cutoff frequency rad/sec(1 to 2) : 2

enter the higher cutoff frequency rad/sec (2 to 3) :

hd= -1.0540 0 0 -0.5159 -0.2349

w= 0.3750 0.3750 0.3750 0.3750 0.3750

h= -0.3953 0 0 -0.1935 -0.0881

DEPARTMENT OF ECE
DEPARTMENT OF ECE
Band Stop Filter :

enter the length of the filter : 10

enter the lower cutoff frequency(0 to 0.5) : 0.1

enter the higher cutoff frequency (<2.5) : 2.2

hd= 0.8864 0.6424 -0.2142 -1.0288 -1.4165 0.2715 0.7940 1.0510 0.5454 -0.3565

w= 0.4444 0.4444 0.4444 0.4444 0.4444 0.4444 0.4444 0.4444 0.4444 0.4444

h= 0.3940 0.2855 -0.0952 -0.4572 -0.6296 0.1207 0.3529 0.4671 0.2424 -0.1585

DEPARTMENT OF ECE
S.No Mark Allocation Max. Marks
Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT :
Thus the program for FIR filter was executed and the output was verified using MATLAB software.

DEPARTMENT OF ECE
EX:NO: 6
BUTTERWORTH DIGITAL IIR FILTER
DATE :

AIM:
To design a Butterworth digital IIR filter using MATLAB software.

APPARATUS REQUIRED:
System with MATLAB software.

ALGORITHM:

1. Get the pass band and stop band ripples.


2. Get the pass band and stop band frequencies.
3. Get the sampling frequency.
4. Calculate the order of the filter using

log √ [10 kp
– 1 / 10 kp
– 1]
N=
log s / p

5.Find the filter co-efficient.


6.Draw the magnitude and phase response.

PROGRAM:

Butterworth Filter :

clc;
clf;
close all;
t=input('enter the sampling time');
w1=input('enter the pass band frequency in radian');
w2=input('enter the stop band frequency in radian');
k1=input('enter the stop band attenuation in db');
k2=input('enter the pass band attenuation in db');
p=input('butterworth');
q=input('1.impulse invariant \n 2.bilinear
transform'); if q==1
wp=w1/t;
ws=w2/t;
else
wp=(2/t)*tan(w1/2);
wn=(2/t)*tan(w2/2);

DEPARTMENT OF ECE
OUTPUT:

enter the sampling time1


enter the pass band frequency in radians0.2
enter the stop band frequency in radians0.4
enter the stop band attenuation in db14
enter the pass band attenuation in db21
1.butterworth1
1.impulse invarient
2.bilinear transform1
c= 0 0.0076 0
d=1.0000 -1.8725 0.8802

DEPARTMENT OF ECE
end;
x=(10^(0.1*k2)-1);
y=(10^(0.1*k1)-1);
k=wp/ws;
N=ceil(log10(x/y)/(2*log10(1/k)));
wc=wp/((10^(k1/10)-1)^(1/(2*N)));
[b,a]=butter(N,wc,'s');
if q==1
[c,d]=impinvar(b,a,t);
else
[c,d]=bilinear(b,a,t);
end;
w=linspace(-2*pi,2*pi);
h= freqz(c,d,w);
subplot(2,1,1); plot(w,
(10*log10(abs(h))));
title('magnitude plot');
xlabel('frequency in radian');
ylabel('magnitude in db');
grid;
disp('c=');
disp(c);
disp('d=');
disp(d);
subplot(2,1,2);
plot(w,angle(h));
title('phase plot');
xlabel('frequency in radian');
ylabel('angle');
grid;

DEPARTMENT OF ECE
OUTPUT:

enter the sampling time1


enter the pass band frequency in radians0.2
enter the stop band frequency in radians0.4
enter the stop band attenuation in db14
enter the pass band attenuation in db21
1.butterworth1
1. impulse invarient
2.bilinear transform2
c= 0.0019 0.0038 0.0019
d=1.0000 -1.8722 0.8799

DEPARTMENT OF ECE
S.No Mark Allocation Max. Marks
Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT :

software. Thus the butterworth program was executed and the output was verified using MATLAB

DEPARTMENT OF ECE
EX:NO: 7 CHEBYSHEV DIGITAL IIR FILTER

DATE :
AIM:
To design a digital IIR filter using Chebyshev filter with MATLAB software.

APPARATUS REQUIRED:
System with MATLAB software.

ALGORITHM:

1. Get the pass band and stop band ripples.


2. Get the pass band and stop band frequencies.
3. Get the sampling frequency.
4. Calculate the order of the filter using

log √ [10 kp – 1 / 10 kp – 1]
N=
log s / p

5.Find the filter co-efficient.


6.Draw the magnitude and phase response.

PROGRAM:
clc;
clear all;close
all;
t=input('enter the sampling time');
w1=input('enter the pass band frequency in radians');w2=input('enter
the stop band frequency in radians');k1=input('enter the stop band
attenuation in db'); k2=input('enter the pass band attenuation in db');
p=input('chebyshev');
q=input('1.impulse invariant \n 2.bilinear transform');if q==1
wp=w1/t;ws=w2/t;

else
wp=(2/t)*tan(w1/2);
ws=(2/t)*tan(w2/2);
end
;

N=ceil(cosh(sqrt((10^(0.1*k2)-1)/(10^(0.1*k1)-1)))/cosh(wp/ws)); [b,a]=cheby1(N,k2,wp,'s');

if q==1
[c,d]=impinvar(b,a,t); else
[c,d]=bilinear(b,a,t);

DEPARTMENT OF ECE
DEPARTMENT OF ECE
OUTPUT:

Impulse Invarient :

enter the sampling time1

enter the pass band frequency in radians0.2

enter the stop band frequency in radians0.4

enter the stop band attenuation in db18

enter the pass band attenuation in db21

1.chebychev1

1.impulse invariant

2.bilinear transform1

c= 0.0254 0

d= 1.0000 -0.9749

DEPARTMENT OF ECE
end;
w=linspace(-2*pi,2*pi);
h=freqz(c,d,w);
subplot(2,1,1); plot(w,
(10*log10(abs(h)))); title('magnitude
plot'); xlabel('frequency in
radians');ylabel('magnitude in db'); grid;
disp('c='); disp(c);
disp('d='); disp(d);
subplot(2,1,2);
plot(w,angle(h));
title('phase plot');
xlabel('frequency in radians');
ylabel('angle');
grid;

DEPARTMENT OF ECE
Bilinear Transform:

enter the sampling time1

enter the pass band frequency in radians.2


enter the stop band frequency in radians.4
enter the stop band attenuation in db18
enter the pass band attenuation in db21
1.chebychev1
1. impulse invarient
2.bilinear transform2
C=0.0126 0.0126
d=1.0000 -0.9749

DEPARTMENT OF ECE
S.No Mark Allocation Max. Marks
Marks Awarded

1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT :

Thus the chebyshev program was executed and the output was verified using MATLAB
software.

DEPARTMENT OF ECE
EX:NO: 8

DATE : STUDY OF ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR

AIM :
To study the architecture of DSP processor TMS320c54xx.

TMS320C54x Internal Block Diagram

Basic Architectural Features


A programmable DSP device should provide instructions similar to a conventional microprocessor. The
instruction set of a typical DSP device should include the following,
a. Arithmetic operations such as ADD, SUBTRACT, MULTIPLY etc
b. Logical operations such as AND, OR, NOT, XOR etc
c. Multiply and Accumulate (MAC) operation
d. Signal scaling operation
In addition to the above provisions, the architecture should also include,
a. On chip registers to store immediate results
b. On chip memories to store signal samples (RAM)
c. On chip memories to store filter coefficients (ROM)

DEPARTMENT OF ECE
DSP COMPUTATIONAL BUILDING BLOCKS
Each computational block of the DSP should be optimized for functionality and speed and in the meanwhile the
design should be sufficiently general so that it can be easily integrated with other blocks to implement overall
DSP systems.
Multipliers
The advent of single chip multipliers paved the way for implementing DSP functions on a VLSI chip. Parallel
multipliers replaced the traditional shift and add multipliers now days. Parallel multipliers take a single
processor cycle to fetch and execute the instruction and to store the result. They are also called as Array
multipliers. The key features to be considered for a multiplier are
a. Accuracy
b. Dynamic range
c. Speed
Shifters
Shifters are used to either scale down or scale up operands or the results.
Barrel Shifters
In conventional microprocessors, normal shift registers are used for shift operation. As it requires one clock
cycle for each shift, it is not desirable for DSP applications, which generally involves more shifts. In other
words, for DSP applications as speed is the crucial issue, several shifts are to be accomplished in a single
execution cycle. This can be accomplished using a barrel shifter, which connects the input lines representing a
word to a group of output lines with the required shifts determined by its control inputs.

Multiply and Accumulate Unit


Most of the DSP applications require the computation of the sum of the products of a series of
successive multiplications. In order to implement such functions a special unit called a multiply and
Accumulate (MAC) unit is required.

DEPARTMENT OF ECE
DEPARTMENT OF ECE
Arithmetic and Logic Unit
A typical DSP device should be capable of handling arithmetic instructions like ADD, SUB,
INC, DEC etc and logical operations like AND, OR , NOT, XOR etc.

On-chip Memories
In order to have a faster execution of the DSP functions, it is desirable to have some memory located on chip.
As dedicated buses are used to access the memory, on chip memories are faster. Speed and size are the two key
parameters to be considered with respect to the on-chip memories.
Speed:
On-chip memories should match the speeds of the ALU operations in order to maintain the single cycle
instruction execution of the DSP.
Size:
In a given area of the DSP chip, it is desirable to implement as many DSP functions as possible. Thus the area
occupied by the on-chip memory should be minimum so that there will be a scope for implementing more
number of DSP functions on-chip.

Data Addressing Capabilities


Data accessing capability of a programmable DSP device is configured by means of its addressing modes.
Immediate Addressing Mode
In this addressing mode, data is included in the instruction itself.
Register Addressing Mode
In this mode, one of the registers will be holding the data and the register has to be specified in the instruction.
Direct Addressing Mode
In this addressing mode, instruction holds the memory location of the operand.
Indirect Addressing Mode
In this addressing mode, the operand is accessed using a pointer. A pointer is generally a register, which holds
the address of the location where the operands resides. Indirect addressing mode can be extended to inculcate
automatic increment or decrement capabilities,
Special Addressing Modes
For the implementation of some real time applications in DSP, normal addressing modes will not completely
serve the purpose. Thus some special addressing modes are required for such applications.

DEPARTMENT OF ECE
Circular Addressing Mode
While processing the data samples coming continuously in a sequential manner, circular buffers are used.
In a circular buffer the data samples are stored sequentially from the initial location till the buffer gets filled up.
Once the buffer gets filled up, the next data samples will get stored once again from the initial location. This
process can go forever as long as the data samples are processed in a rate faster than the incoming data rate.

S.No Mark Allocation Max. Marks


Marks Awarded
1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT :
Thus, the architecture of digital signal processor was studied.

DEPARTMENT OF ECE
EX:NO: 9

DATE : MAC OPERATION USING VARIOUS ADDRESSING MODES

AI
M
To Study the various addressing modes of TMS320C67XX DSP processor.

THEORY:

Addressing Modes The TMS320C67XX DSP supports three types of addressing modes
that enable flexible access to data memory, to memory-mapped registers, to registerbits, and to
I/O space.The absolute addressing mode allows you to reference a location by supplying all or
part of an address as a constant in an instruction.The direct addressing mode allows you to
reference a location using an address offset. The indirect addressing mode allows you to reference
a location using a pointer.Each addressing mode provides one or more types of operands. An
instruction that supports an addressing-mode operand has one of the following syntax elements
listed below. Baddr
When an instruction contains Baddr, that instruction can access one or two bits in an
accumulator (AC0–AC3), an auxiliary register (AR0–AR7), or a temporary register (T0–T3). Only
the register bit test/set/clear/complement instructions support Baddr. As you write oneof these
instructions, replace Baddr with a compatible operand.
Cmem
When an instruction contains Cmem, that instruction can access a single word (16 bits)of
data from data memory. As you write the instruction, replace Cmem with a compatible operand.
Lmem
When an instruction contains Lmem, that instruction can access a long word (32 bits) of
data from data memory or from a memory-mapped registers. As you write the instruction, replace
Lmem with a compatible operand.
Smem
When an instruction contains Smem, that instruction can access a single word (16bits) of
data from data memory, from I/O space, or from a memory-mapped register. As you write the
instruction, replace Smem with a compatible operand.

DEPARTMENT OF ECE
Xmem and Ymem
When an instruction contains Xmem and Ymem, that instruction can perform two
simultaneous 16-bit accesses to data memory. As you write the instruction, replace Xmem and
Ymem with compatible operands.
Absolute Addressing Modes k16 absolute
This mode uses the 7-bit register called DPH (high part of the extended data page register)
and a 16-bit unsigned constant to form a 23-bit data space address. This mode isused to access a
memory location or a memory-mapped register.
k23 absolute
This mode enables you to specify a full address as a 23-bit unsigned constant. This mode is
used to access a memory location or a memory-mapped register.
I/O absolute
This mode enables you to specify an I/O address as a 16-bit unsigned constant. This mode
is used to access a location in I/O space.
Direct Addressing Modes DP direct
This mode uses the main data page specified by DPH (high part of the extended data page
register) in conjunction with the data page register (DP).This mode is used to access a memory
location or a memory-mapped register.
SP direct
This mode uses the main data page specified by SPH (high part of the extended stack
pointers) in conjunction with the data stack pointer (SP). This mode is used to access stack values
in data memory.
Register-bit direct
This mode uses an offset to specify a bit address. This mode is used to access one register
bit or two adjacent register bits.
PDP direct
This mode uses the peripheral data page register (PDP) and an offset to specify an I/O
address. This mode is used to access a location in I/O space. The DP direct and SP direct
addressing modes are mutually exclusive. The mode selected depends on the CPL bit in status
register ST1_67: 0 DP direct addressing mode 1 SP direct addressing mode The register-bit and
PDP direct addressing modes are independent of the CPL bit.

DEPARTMENT OF ECE
direct Addressing Modes
AR indirect
This mode uses one of eight auxiliary registers (AR0–AR7) to point to data. The way the
CPU uses the auxiliary register to generate an address depends on whether you are accessing data
space (memory or memory-mapped registers), individual register bits, or I/O space.
Dual AR indirect
This mode uses the same address-generation process as the AR indirect addressing mode.
This mode is used with instructions that access two or more data-memory locations.
CDP indirect
This mode uses the coefficient data pointer (CDP) to point to data. The way the CPU uses
CDP to generate an address depends on whether you are accessing data space (memory or
memory-mapped registers), individual register bits, or I/O space.
Coefficient indirect
This mode uses the same address-generation process as the CDP indirect addressing mode.
This mode is available to support instructions that can access a coefficient in data memory at the
same time they access two other data-memory values using the dual AR indirect addressing
mode.
Circular Addressing
Circular addressing can be used with any of the indirect addressing modes. Each of the
eight auxiliary registers (AR0–AR7) and the coefficient data pointer (CDP) can be independently
configured to be linearly or circularly modified as they act as pointers to data or to register bits,
see Table 3−10. This configuration is done with a bit (ARnLC) in status register ST2_67. To
choose circular modification, set the bit. Each auxiliary register ARn has its own linear/circular
configuration bit in ST2_67: 0 Linear addressing 1 Circular addressing The CDPLC bit in status
register ST2_67 configures the DSP to use CDP for linear addressing or circular addressing: 0
Linear addressing 1 Circular addressing You can use the circular addressing instruction qualifier,
.CR, if you want every pointer used by the instruction to be modified circularly, just add .CR to
the end of the instruction mnemonic (for example, ADD.CR). The circular addressing instruction
qualifier overrides the linear/circular configuration in ST2_67.

DEPARTMENT OF ECE
ADDITION

INPUT

Data Memory :

A000h 0004h - 24

A001h 0004h - 21

OUTPUT:

Data Memory :
A002h 0008h - 45

SUBTRACTION

INPUT

Data Memory :

A000h 0004h - 24

A001h 0004h - 21

OUTPUT:

Data Memory :
A002h 0008h - 03

DEPARTMENT OF ECE
ADDITION:
INP1 .SET 0H INP2 .SET
1HOUT .SET 2H
.mmregs
.textSTART:
LD #140H,DPRSBX
CPL NOP
NOPNOPNOP
LD INP1,A ADD
INP2,ASTL A,OUT
HLT: B HLT

SUBTRACTION:
INP1 .SET 0H INP2 .SET
1HOUT .SET 2H
.mmregs
.textSTART:
LD #140H,DPRSBX
CPL NOP
NOPNOPNOP
LD INP1,A SUB
INP2,ASTL A,OUT
HLT: B HLT

S.No Mark Allocation Max. Marks


Marks Awarded
1 Preparation 2

2 Interest and Involvement 2

3 Skill in completing the


4
experiments & results

4 Viva-Voce 2

Total 10

Date Sign

RESULT:

Thus, the various addressing mode of DSP processor TMS320C67XX was studied

DEPARTMENT OF ECE
EX:NO:10
IMPLEMENTATION OF LINEAR CONVOLUTION
DATE
Aim:
To write a program to find the Linear Convolution of two sequences X(n) and H(n) using
TMS320C67XX.
Apparatus required:
1. System with TMS 320C67XX debugger
software 2.TMS 320C67XX Kit.
3.Code Composer Studio 3.3v

Algorithm:
Linear convolution :
1. Start the program.
2. Enter the length of the sequences.
3. Check if the length of both sequences are equal.
4. Find linear convolution.
Program:
Linear Convolution :
#include<fastmath67x.h>
#include<math.h>

void main()
{
int *Xn,*Hn,*Output;
int *XnLength,*HnLength;
int i,k,n,l,m;
Xn=(int *)0x80010000; //input x(n)
Hn=(int *)0x80011000; //input
h(n) XnLength=(int *)0x80012000; //x(n)
length HnLength=(int *)0x80012004; //h(n)
length Output=(int *)0x80013000; // output
address

l=*XnLength; // copy x(n) from memory address to variable l


m=*HnLength; // copy h(n) from memory address to variable m

for(i=0;i<(l+m-1);i++) // memory clear


{
Output[i]=0; // o/p array
Xn[l+i]=0; // i/p array
Hn[m+i]=0; // i/p array
}
for(n=0;n<(l+m-1);n++)
{
for(k=0;k<=n;k++)
{
Output[n] =Output[n] + (Xn[k]*Hn[n-k]); // convolution operation.
DEPARTMENT OF ECE
}}}

DEPARTMENT OF ECE
OUTPUT:
Linear convolution

DEPARTMENT OF ECE
MAX MARKS

MARK ALLOCATION MARKS AWARDED

PREPARATION 2

INTEREST & INVOLVEMENT 2

SKILLS IN COMPLETING 4
THE EXPERIMENTS &
RESULT
VIVA-VOCE 2

TOTAL 10

DATE SIGN

RESULT:
Thus a program of the Linear Convolution of two sequences X(n) and H(n) using TMS320C67XX
was performed and output was verified.

DEPARTMENT OF ECE
EX:NO: 11 WAVEFORM GENERATION

DATE:

Aim:
To write the programs to generate various waveforms using TMS320C67XX debugger.
Apparatus required:
1. System with TMS 320C67XX driver software
2.TMS 320C67XX Kit.
3.Code Composer Studio 3.3v
4.CRO
5.Function Generator
Algorithm:
wave generation:
2. Open Code Composer Studio, make sure the DSP kit is turned on.
3. Load program using ‘File load_program. Which is saved in project file
4. Connect CRO and Function generator with kit.
5. Take the readings and draw the graph.

Program:
Sine wave generation:

#include
"VSK_6748.h"
#include <math.h>
#define SPIFLASH_SPI
(SPI1
) #define
SPIFLASH_SPI0 (SPI0

)
#define PI
3.14;int
main(void)
{

int count; // declare


variablesint nSamp;
int fi=1000; //input frequency
short *sin_out,val;
const float fSamp = 100000.0; //sampling
frequencyfloat tSamp;
double ang;

spi_regs_t
*spi=SPIFLASH_SPI0;spi_regs_t
*spi1=SPIFLASH_SPI; uint32_t
spi_data1 = spi->SPIDAT1;
DEPARTMENT OF ECE
sin_out = (short *)0x80001000; // output buffer

DEPARTMENT OF ECE
nSamp = fSamp / fi; //no. of
samplestSamp = 1 / fSamp; // sampling
time

for (count = 0; count < nSamp; count++)


{

ang = (2 * 3.14 * fi * tSamp * count); // sine wave generation formula


sin_out[count] = sin(ang) * 2048; // store the value in the array of the address of
sinout.

}
USTIMER_init(); // timer init
Spi_inti(); // spi init

while(1)

for (count = 0; count < nSamp; count++)


{

val = sin_out[count]; // copy the sine value to another


variable val += 2048; // increase the aplitude level
spi1->SPIDAT1 = val | 0x1000; // display the sine data via DAC
} } }

Sawtooth wave generation :


#include
"VSK_6748.h"
#include <math.h>
#define SPIFLASH_SPI (SPI1)
#define SPIFLASH_SPI0
(SPI0)
int main(void)
{

short
Count,Out,Val;
short
*sawtoothOut;

spi_regs_t *spi=SPIFLASH_SPI0;
spi_regs_t *spi1=SPIFLASH_SPI;
uint32_t spi_data1 = spi-
>SPIDAT1;

sawtoothOut = (short

*)0x80010000; Out = 0;
for (Count = 0; Count < 4096; Count++)
{
*(sawtoothOut + Out) =
Count; Out++;
}
Spi_inti(
); while(1) {
for(Count = 0; Count < 4096; Count++)
DEPARTMENT OF ECE
{
Val = *(sawtoothOut + Count) ;

spi1->SPIDAT1 = Val | 0x1000 ; } }}


Square wave generation:

#include "VSK_6748.h"
#include <math.h>
#define SPIFLASH_SPI (SPI1)
#define SPIFLASH_SPI0 (SPI0)
int main(void)
{

uint32_t j,k;

spi_regs_t *spi=SPIFLASH_SPI0;
spi_regs_t *spi1=SPIFLASH_SPI;

uint32_t spi_data1 = spi-


USTIMER_init();
>SPIDAT1; Spi_inti();

while(1) {
// copy the tmp reg to the real thing.
spi1->SPIDAT1 = 0x0fff | 0x1000;//_data1;

for(j = 0;j < 100; j++)


for(k = 0; k < 100; k++);
spi1->SPIDAT1 = 0x0000 | 0x1000;//_data1;
for(j = 0;j < 100; j++) for(k =
0; k < 100; k++);} }
Triangular wave generation:

#include "VSK_6748.h"
#include <math.h>
#define SPIFLASH_SPI (SPI1)
#define SPIFLASH_SPI0 (SPI0)
int main(void)
{

short Count,Out,Val;
short *TriangularOut;
spi_regs_t *spi=SPIFLASH_SPI0;
spi_regs_t *spi1=SPIFLASH_SPI;

DEPARTMENT OF ECE
uint32_t spi_data1 = spi->SPIDAT1;
TriangularOut = (short *)0x80010000;
Out = 0;
for (Count = 0; Count < 4096; Count++)
{
*(TriangularOut + Out) =
Count; Out++;
}

Out = 4095;
for (Count = 4095; Count >= 0; Count--)
{
*(TriangularOut + Out) =
Count; Out++;
}
USTIMER_init();
Spi_inti();
while(1)
{
for(Count = 0; Count < 8192; Count++)

{
Val = *(TriangularOut + Count) ;
spi1->SPIDAT1 = Val | 0x1000 ; } }}

DEPARTMENT OF ECE
MAX MARKS

MARK ALLOCATION MARKS AWARDED

PREPARATION 2

INTEREST & INVOLVEMENT 2

SKILLS IN COMPLETING 4
THE EXPERIMENTS &
RESULT
VIVA-VOCE 2

TOTAL 10

DATE SIGN

RESULT:
Thus the programs executed for various waveforms using TMS320C67XX debugger.

DEPARTMENT OF ECE
EXP NO: 12

DATE: IIR FILTER IMPLEMENTATION

Aim:

To design an IIR filter using TMS 320C67XX

Apparatus required:

1. Systemwith TMS 320C67XX driver


software 2.TMS 320C67XX Kit.
3.Code Composer Studio

Algorithm:

1. Open 67XX debugger software, make sure the DSP kit is turned on.
2. Create new project save
3. Go to file create new C file.
4. Type the program
5. Add files-program file, linker command file and header file.
6. Build the project
7. Go to file and Load the program.
8. Set input waveform using CRO and Function generator
9. Connect CRO to DAC 1,FG to CH1,GND.
10. See the filter output.

DEPARTMENT OF ECE
PROGRAM: (IIR Filters)

#include<stdio.h>
#include<math.h> int i,w,wc,c,N;
float H[100];
float mul(float,int);void main()
{
printf("\n Enter order of filter");scanf("%d",&N); printf("\
n Enter the cut off frequency");scanf("%d",&wc);
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;
}
}
float mul(float a,int x)
{
for(i=0;i<x-1;i++)a*=a;
return(a); }

DEPARTMENT OF ECE
INPUT: (IIR Filters)
Enter order of filter 2
Enter the cut off frequency 50
Enter the choice for IIR Filter 1.LPF 2.HPF: 1

OUTPUT: (IIR Filters)

DEPARTMENT OF ECE
MAX MARKS

MARK ALLOCATION MARKS AWARDED

PREPARATION 2

INTEREST & INVOLVEMENT 2

SKILLS IN COMPLETING 4
THE EXPERIMENTS &
RESULT
VIVA-VOCE 2

TOTAL 10

DATE SIGN

RESULT:

Thus the program for IIR filter was implemented using TMS320C67XX kit and output was
verified.

DEPARTMENT OF ECE
DEPARTMENT OF ECE
Ex. No.: 13

Date: FIR FILTER IMPLEMENTATION

Aim
To design an FIR filter using TMS 320C67XX processsor

Apparatus required:

1System with TMS 320C67XX driver software


2.TMS 320C67XX Kit.
3.Code Composer Studio
Algorithm:

1. Open 67XX debugger software, make sure the DSP kit is turned on.
2. Create new project save
3. Go to file create new C file.
4. Type the program
5. Add files-program file, linker command file and header file.
6. Build the project
7. Go to file and Load the
program. 8 See the filter output.

PROGRAM: (FIR Filters)


#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;
}}

DEPARTMENT OF ECE
OUTPUT: (FIR Filters)

DEPARTMENT OF ECE
MARK ALLOCATION MAX MARKS

MARKS AWARDED

PREPARATION 2

INTEREST & INVOLVEMENT 2

SKILLS IN COMPLETING 4
THE EXPERIMENTS &
RESULT
VIVA-VOCE 2

TOTAL 10

DATE SIGN

RESULT:
Thus the program for FIR filter was implemented using TMS320C67XX kit and output was
verified.

DEPARTMENT OF ECE

You might also like