Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 56

SVS COLLEGE OF ENGINEERING

COIMBATORE

DEPARTMENT OF ELECTRONICS
&
COMMUNICATION ENGINEERING

EC2306-DIGITAL SIGNAL PROCESSING LAB MANUAL

III ECE A Section

SYLLABUS
EC2306-DIGITAL SIGNAL PROCESSING LAB

USING TMS320C5X
1. Study of various addressing modes of DSP using simple programming examples
2. Implementation of Linear and Circular convolution
3. Sampling of input signal and Display
4. Waveform generation
5. Implementation of FIR filter

USING MATLAB
1. Generation of Signals
2. Linear and circular convolution of two sequences
3. Sampling and effect of aliasing
4. Design of FIR filters
5. Design of IIR filters
6. Calculation of FFT of a signal
7. Decimation by polyphase decomposition.
8. Periodogram based spectral Estimation.

INDEX

Ex no
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.

Name of the Experiment


INTRODUCTION TO MATLAB

GENERATION OF CONTINUOUS AND DISCRETE TIME SIGNAL


GENERATION OF DISCRETE TIME SIGNALS
GENERATION OF CONTINOUUS TIME WAVEFORMS
SAMPLING & EFFECT OF ALIASING
LINEAR CONVOLUTION OF TWO SEQUENCES USING MATLAB
IMPLEMENTATION OF FFT AND IFFT
DECIMATOR & INTERPOLATOR
IMPULSE RESPONSE OF A GIVEN SYSTEM
CIRCULAR CONVOLUTION
TIME AND FREQUENCY RESPONSE OF LTI SYSTEM
LINEAR & CIRCULAR CONVOLUTION USING TMS320C50
FIR FILTER USING DSP TRAINTER KIT USING TMS320C50
WAVE FROM GENERATION USING TMS320C50
SAMPLING OF INPUT SIGNAL AND DISPLAY

Pg no

EX NO:1

INTRODUCTION TO MATLAB

AIM:
To write introduction about MATLAB
MATLAB:
MATLAB is a high performance language for technical computing. It integrates computation,
visualization and programming in an easy to use environment were problems and solutions are
impressed in familiar mathematical notation. Typical uses includes.
Math and computation
Algorithm development
Data acquisition
Modelling, simulation and prototyping
Data analysis, exploration and visualization
Scientific and engineering graphics
Application development including graphical user interface building.
THE MATLAB SYSTEM:
The MATLAB system consists of five main systems.
i.

Development Environment
This is the set of tools and facilities that help you to use MATLAB functions and files.
It includes the MATLAB desktop, command window, a command history, editor, debugger,
the work space, files and search path.
The MATLAB mathematical function library:
This is vast collection of computational algorithms ranging from elementary functions
like sum, sine, cosine and complex arithmetic to more sophisticated functions like matrix
inverse, Bessel function and Fast Fourier transform

The MATLAB language:


This high level matrix/array language with control flow statement function, data
structure, input/output and object oriented programming features.

i.Graphics:
MATLAB has extensive facilities for displaying vectors and matrices as graphics, as
well as annotating and printing these graphs. It includes high level function for two
dimensional and three dimensional data visualization, image processing and animation.

ii. MATLAB application program interface (APL)


This is a library that allows C and FORTRAN programs that interact with MATLAB. It
includes facilities for calling routines from MATLAB (dynamic linking), calling MATLAB as
a computational engine and for reading writing MAT files.
Some important tool boxes in MATLAB:
Communication toolbox
Database toolbox
Image processing toolbox
Signal processing toolbox
Optimization toolbox

RESULT:

Thus the introduction of MATLAB was studied successfully.

EX.NO: 2

GENERATION OF CONTINUOUS AND DISCRETE TIME SIGNAL

AIM:
i.

To write MATLAB program to generate continuous time and discrete time signal.
Sinusoidal signal

ii.

Cosine signal

THEORY:
A signal can be designed as function of that conveys information, generally about the rate and
behavior of physical system. It can be represented mathematically as the function of one or more
independent variable. Continuous time signal that are designed at continuous time and represented by
continuous variable. Discrete time signals are designed at discrete time and represented by sequence of
numbers.
The special characteristics of analog signal is that they are continuous in amplitude and defined
at time instant for eg., Exponential e-at at t=0.1, 0.5 time instant.
Thus if it is defined at the time instants discrete time signals obtained by sampling of
continuous time signal are designed only at sampling instants.

ALGORITHM:
1. Switch on the computer
2. Select a MATLAB on the screen
3. Create a new file
i.

Select a M-file from new

ii.

New MATLAB program sheet is display, type the program in that sheet

iii.

Save it and run the program

iv.

Output figure is display

PROGRAM:
clc;
clear all;
close all;
a1=input('enter the amplitude of sine wave:');
f1=input('enter the frequency of sine wave:');
a2=input('enter the amplitude of cosine wave:');
f2=input('enter the frequency of cosine wave:');
t1=linspace(0,1/f1,20);
s1=a1*sin(2*pi*f1*t1);
t2=linspace(0,1/f2,20);
s2=a2*cos(2*pi*f2*t2);
subplot(2,2,1);
plot(t1,s1);
title('continuous sine wave');
xlabel('time');
ylabel('amplitude');
subplot(2,2,2);
plot(t2,s2);
title('continuous cosine wave');
xlabel('time');
ylabel('amplitude');
subplot(2,2,3);
stem(t1,s1);
title('discrete sine wave');
xlabel('time');
ylabel('amplitude')
subplot(2,2,4);
stem(t2,s2);
title('discrete cosine wave');
xlabel('time');
ylabel('amplitude');

RESULT:
Thus the MATLAB program to generate continuous time and discrete time signal were
executed successfully.

EX.NO: 3

GENERATION OF DISCRETE TIME SIGNALS

AIM:
To write MATLAB program to generate unit impulse sequence, unit step sequence,
exponential sequence and unit ramp sequence.
THEORY:
The most common sequence are unit-impulse, unit-step, unit-ramp and exponential sequences.
i.

Unit-impulse or unit sample sequence


The unit impulse sequence is represented by (n). It is very much similar to standard
unit-impulse signal (t). the unit-impulse sequence is defined as
(n) = 1 for n=0
= 0 for n0
In sequence form it can be represented as
(n) = {..0,0,0,0,1,0,0,0,0...}

ii.

Unit-step sequence
The unit step sequence is denoted by u(n) and all its sample have a value of 1 for n0
ie.,
u(n) = 1 for n0
= 0 for n<0
Thus the unit step sequence of the samples can be written as,
u(n) = {..0,0,0,1,1,1,1,1..}

iii.

Unit-ramp sequence
The unit ramp sequence is defined as r(n). Its value increases with the sample number
n linearly. It is defined as,
r(n) = n for n0
= 0 for n<0
The sequence for unit ramp can be written as follows,
r(n) = {0,0,0,1,2,3,4,5,6,7,8,9,10,}
The unit ramp sequence is similar to unit ramp signal r(t).

iv.

Exponential sequence
The exponential sequence can be represented as x(n)=an. If a>1 then r(n)
becomes rising exponential sequence. If a is complex value, then it can be
represented as a=rei. Here r is the magnitude and is the angle.

ALGORITHM:
1. Start the program
2. Clear the text
3. Give the x-coordinate and y-coordinate according to signals have to be created
4. Allocate the space for signals to be placed
5. Give the title for each signal have to be drawn
6. Indicate the x-label and y-label for the signal that has to be drawn
PROGRAM:
%Program to generate unit step sequence
clc;
close all;
clear all;
N=input('Enter the length of the sequence =');
x=ones(1,N);
n=0:1:N-1;
subplot(3,3,1);
stem(n,x);
xlabel('n->samples');
ylabel('x(n)');
title('Unit Step Sequence');
%Program to generate unit ramp sequence
clc;
n=0:10;
s=n;
subplot(3,3,2);
stem(n,s);
title('Unit Ramp Sequence');
xlabel('n->samples');
ylabel('x(n)');

%Program to generate impulse sequence


clc;
n=-5:5;
s=[zeros(1,5) 1 zeros(1,5)];
subplot(3,3,3);
stem(n,s);
title('Unit Impulse Sequence');
xlabel('n->samples');
ylabel('x(n)');
%Program to generate exponential sequence (Rising)
clc;
t=0:9;
y=exp(0.3*t);
subplot(3,3,4);
stem(t,y);
grid;
title('Exponential sequence');
xlabel('n->samples');
ylabel('x(n)');
%Program to generate exponential sequence(Falling)
clc;
N=16;
n=0:2:N-1;
x=.8.^(n);
subplot(3,3,5);
stem(n,x);
xlabel('n->samples');
ylabel('x(n)');
Title('Exponential Sequence');

RESULT:
Thus the MATLAB program to generate various discrete time signals were written and
executed.

EX.NO: 4

GENERATION OF CONTINOUUS TIME WAVEFORMS

AIM:
To generate various wave forms like sine wave, cosine wave, exponential wave and square
wave, saw tooth wave using MATLAB.
ALGORITHM
1.
2.
3.
4.
5.
6.

Start the program.


Get the amplitude and frequency of the wave to be plotted.
Use the corresponding formulae for each wave.
Plot the waves with desired amplitude, frequency and time period.
Give the titles for the X axis and Y axis using label functions.
Stop the program.

PROGRAM:

RESULT:
Thus the MATLAB program to generate various continuous time signals were written and
executed.

SAMPLING & EFFECT OF ALIASING

EX.NO: 5
AIM:

To write a MATLAB Program to verify the sampling theorem (fs>2fm).


APPARATUS REQUIRED:
Hardware: PC.
Software: MATLAB 7.10.0 .499(R2010a)version.
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.

Start the program.


Get T value.
Calculate fm value.
Plot continuous time signal.
Get assign fs1, fs2, fs3 value.
Apply fs1, fs2, fs3 value and check it fs<2fm and fs=2fm and fs>2fm.
Plotted the waveform for fs<2fm, fs=2fm, fs>2fm.
Terminate the program.

THEORY:
Minimum rate at which signal can be sampled and still be reconstructed from its sample
called Nyquist rate. It is always equal to transform where the function is the maximum frequency
present in the signal. If the sampling frequency fs < 2fm the high frequency interface with low
frequency. This phenomenon is called Aliasing .
Program:
% Sampling Theorem
clc;
clear all;
close all;
t=-10:0.1:10;
T=4;
fm=1/T;
x=cos(2*pi*fm*t);
subplot(2,2,1);
plot(t,x);
grid;
xlabel('time in second');
ylabel('x(t)');
title('continuous time signal');
fs1=1.6*fm;
fs2=2*fm;
fs3=8*fm;
n1=-4:1:4;
xn1=cos(2*pi*n1*fm/fs1);
subplot(2,2,2);
stem(n1,xn1);
hold on;
subplot(2,2,2);
plot(n1,xn1);
xlabel('n');

ylabel('x(n)');
title('discrete time signal in fs<fm');
n2=-5:1:5;
xn2=cos(2*pi*n2*fm/fs2);
subplot(2,2,3);
stem(n2,xn2);
hold on;
subplot(2,2,3);
plot(n2,xn2);
xlabel('n');
ylabel('x(n)');
title('discrete time signal in fs=fm');
n3=-20:1:20;
xn3=cos(2*pi*n3*fm/fs3);
subplot(2,2,4);
stem(n3,xn3);
hold on;
subplot(2,2,4);
plot(n3,xn3);
xlabel('n');
ylabel('x(n)');
title('discrete time signal in fs>fm');

RESULT:
Thus the MATLAB Program for verification of sampling theorem was generated
and plotted and verified successfully.

EX.NO: 6

LINEAR CONVOLUTION OF TWO SEQUENCES USING MATLAB

AIM:
To compute linear and Circular Convolution using MATLAB Programs
ALGORITHM:
1.
2.
3.
4.
5.
6.
7.
8.

Start the Program.


Include the sequence for convolution
Specify the scale for time axis and amplitude axis
Specify the location where figure is to be plotted
Perform convolution using CONV function
Mark the Labels for X,Y axis
Mention the title
End the Program

THEORY:
LINEAR CONVOLUTION:
Convolution is used to find the output response of digital system. If x1(n) has duration N1 and
x2(n) has duration N2 then the linear convolution of x1(n) and x2(n) will have the length N1+N2-1. If
input and impulse of a system is x(n) and h(n) respectively then their convolution can be determined
by x(n)*h(n)

x ( n) * h( n)

x(k ).h(n k )

PROGRAM:
%Program to generate Linear convolution through FFT
clc;
close all;
clear all;
x=input('Enter the first sequence of x(n)=');
h=input('Enter the second sequence of h(n)=');
y=conv(x,h);
disp('The Resultant Signal is');y
subplot(3,2,1);
stem(x);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('first sequence x(n)')
subplot(3,2,2);
stem(h);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('second sequence h(n)')
subplot(3,2,[3,4]);

stem(y);
ylabel('Amplitude ---->');
xlabel('n ---->');
title('Linear convolution');
l=length(y);
m=y;
xk=fft(m,l);
disp('The Resultant Signal is');xk
subplot(3,2,[5,6]);
stem(xk);
xlabel('n samples');
ylabel('Amplitude ---->');
title('Linear Convolution through FFT');

RESULT:
Thus the linear convolution program was performed using MATLAB program.

EX.NO: 7

IMPLEMENTATION OF FFT AND IFFT

AIM:
To write a MATLAB Program to obtain discrete Fourier transform for the system given
in any form of the sequence using FFT algorithm and verify manual and practical value.
APPARATUS REQUIRED:
Hardware: PC.
Software: MATLAB 7.0 Version.
ALGORITHM:
1.
2.
3.
4.

5.
6.
7.
8.

Start the program.


Get the finite duration sequence x(n).
Calculate the value of N.
Using FFT command DFT is calculated.
a. Calculate the magnitude and phase response.
b. Plot the magnitude and phase response.
The DFT output applied to IFFT input.
Calculate IFFT length.
To verify manual and practical value.
Terminate the process.

PROGRAM:
%Program to generate FFT
clc;
close all;
clear all;
xn=input('Enter the sequence x(n)=');
N=input('Enter the number of points in the DFT N=');
Xk=fft(xn,N);
disp('The Resultant Signal is');Xk
%Computation of magnitude response of X(k)
subplot(2,1,1);
z=abs(Xk);
disp('Magnitude response is');
disp(z);
stem(z);
grid;
title('Plot of magnitude of X(k)');
xlabel('index k');
ylabel('magnitude');
%Computation of phase response
subplot(2,1,2);
t=angle(Xk);
disp('Phase response is');
disp(t);

stem(t);
grid;
title('Plot of phase of X(K)');
xlabel('index k');
ylabel('angle in radians');
%Program to generate IFFT
clc;
close all;
clear all;
Xk=input('Enter the sequence X(k)=');
N=input('Enter the number of points in the DFT N=');
xn=ifft(Xk,N);
disp('The Resultant Signal is');xn
%Computation of magnitude response of x(n)
subplot(2,1,1);
z=abs(xn);
disp('Magnitude response is');
disp(z);
stem(z);
grid;
title('plot of magnitude of x(n)');
xlabel('index n');
ylabel('magnitude');
%Computation of phase response
subplot(2,1,2);
t=angle(xn);
disp('Phase response is');
disp(t);
stem(t);
grid;
title('plot of phase of x(n)');
xlabel('index n');
ylabel('angle in radians');

RESULT:
Thus the MATLAB Programs for FFT and IFFT for the given finite duration
were generated and plotted successfully.

EX.NO: 8

DECIMATOR & INTERPOLATOR

AIM
To generate a decimated and interpolated signal for the given input signal using MATLAB

APPARATUS REQUIRED
Hardware: PC.
Software: MATLAB 7.0 Version.
THEORY
Multi-rate signal processing studies digital signal processing systems which include sample rate
conversion. Multirate signal processing techniques are necessary for systems with different input and
output sample rates, but may also be used to implement systems with equal input and output rates.
Changing the sampling rate

The process of changing the sampling rate of a signal (resampling) is called downsampling if the
sample rate is decreased and upsampling if the sample rate is increased. Integer rate changes are far
more common than non-integer rate changes.
Downsampling(Decimation)

Downsampling a sequence x(n) by retaining only every Mth sample creates a new sequence
xd(n)=x(nM). If the original sequence contains frequency components above /M, the downsampler
should be preceded by a low-pass filter with cutoff frequency /M. In this application, such an antialiasing filter is referred to as a decimation filter and the combined process of filtering and
downsampling is called decimation.
Upsampling(Interpolation)

Upsampling a sequence x(n) creates a new sequence xe(n) where every Lth sample is taken from
x(n)with all others zero. The upsampled sequence contains Lreplicas of the original signal's spectrum.
To restore the original spectrum, the upsampler should be followed by a low-pass filter with gain Land
cutoff frequency /L. In this application, such an anti-aliasing filter is referred to as an interpolation
filter and the combined process of upsampling and filtering is called interpolation.
PROCEDURE
1.
2.
3.
4.
5.
6.

Open Matlab application


In the file tab open new m- file
Type the program in the editor window
Save the file with a file name other than the function name
Execute using the run command
Observe the waveforms.

PROGRAM
%Generate the input sequence for fs=200Hz, f1=50Hz and f2=100 Hz
t=0:1/200:10;
y=3*cos(2*pi*50*t/200)+ 5*cos(2*pi*100*t/200);
figure(1)
stem(y);
xlabel('Times in Seconds');
ylabel('Amplitude');
%Generate the decimated and interpolated signals
figure(2)
stem(decimate(y,20));
xlabel('Times in Seconds');
ylabel('Amplitude');
figure(3)
stem(interp(decimate(y,20),2));
xlabel('Times in Seconds')
ylabel('Amplitude');

RESULT:
Thus Up sampling & down sampling program was executed successfully

EX.NO: 9

IMPULSE RESPONSE OF A GIVEN SYSTEM

AIM:
To Verify the Impulse Response of a given system using MATLAB.
APPARATUS REQUIRED:
Hardware: PC.
Software: MATLAB 7.0 version.
THEORY:
A complete characterization of any LTI system can be represented in terms of its response
to an Unit Impulse, which is referred to as Impulse response of the system. Alternatively,
the impulse response is the output of a LTI system due to an impulse input applied at t=0,
or n=0.

PROCEDURE
1.
2.
3.
4.
5.
6.

Open Matlab application


In the file tab open new m- file
Type the program in the editor window
Save the file with a file name other than the function name
Execute using the run command
Observe the waveforms.

PROGRAM
N=input('enter the length of impulse response');
b=input('enter the numerator coeff');
a=input('enter the denominator coeff');
[r,p,k]=residuez(b,a)
[h,t]=impz(b,a,N)
stem(t,h);
grid;
xlabel('time index');
ylabel('amplitude');
title('impulse response');
INPUT:
enter the length of impulse response =5
enter the numerator coeff [1 -1/3]
enter the denominator coeff [1 -3/4 1/8]

RESULT:
Thus impulse response program was executed successfully by using MATLAB.

EX.NO: 10

CIRCULAR CONVOLUTION

AIM:
To compute the circular convolution of the given input sequences using FFT method
APPARATUS REQUIRED:
Hardware: PC.
Software: MATLAB 7.0 Version
ALGORITHM:
1. Clear the command window and workspace.
2. Input the sequences x1(n) & x2(n).
3. Find length of output sequence N=max (length(x1), length(x2)).
4.If length (x2) <N, zero padding is done and the resulting x2(n) is circular
shifted to form N*N matrix
5. If length (xl) <N, zero padding is done and the resulting sequence
is taken as column matrix
6. Multiplication of the two sequences gives the required
sequence x3 (n).
7: Display the result.
PROGRAM:
clc;
a=input('Enter the array a');
n1=length(a)
b=input('Enter the array b');
n2=length(b)
subplot(2,2,1);
stem(a);
title('INPUT-A');
xlabel('n');
ylabel('a(n)');
subplot(2,2,2);
stem(b);
title('INPUT-B');
xlabel('n');
ylabel('b(n)');
if n1<n2
for m=n1+1:n2;
a(m)=0;
end
else
for m=n2+1:n1;
b(m)=0;
end

end
A=a'
B=b'
for i=1:1:n1-1;
e=circshift(a',i)
A=[A,e]
end
f=A*b'
subplot(2,2,3);
stem(f);
title('OUTPUT-MATRIX');
xlabel('n');
ylabel('f(n)');
A=fft(a)
B=fft(b)
C=A.*B
c=ifft(C)
subplot(2,2,4);
stem(c);
title('OUTPUT-FFT');
xlabel('n');
ylabel('c(n)');

OUTPUT:
Enter the array a[1 2 3 4]
n1 =
4
Enter the array b[1 2]
n2 =

RESULT:
Thus circular convolution has been implemented using FFT method.

EX.NO: 11

TIME AND FREQUENCY RESPONSE OF LTI SYSTEM

AIM:
To determine the frequency response of a low pass filter LTI system
APPARATUS REQUIRED:
Hardware: PC.
Software: MATLAB 7.0 Version.
ALGORITHM:
1. Clear the command window and workspace.
2. Obtain the numerator and denominator polynomial coefficients.
3. Using freqzcommand, determine the response of the filter.
4. Plot the magnitude and phase spectrum.
5. Define the time domain transfer function of a LTI system
PROGRAM:
%frequency response
clc;
clear all;
close all;
b=input('Enter the numerator polynomial coefficients');
a=input('Enter the denominator polynomial coefficients');
w=0:0.01:2*pi;
h=freqz(b,a,w);
m=abs(h);
p=angle(h);
subplot(2,1,1);
plot(w,m);
title('Magnitude spectrum');
xlabel('Frequency X2pi radians/sample');
ylabel('Magnitude in volts');
subplot(2,1,2);
plot(w,p);
title('Phase spectrum');
xlabel('Frequency X2pi radians/sample');
ylabel('Phase in radians');
% time response
clc;
t=0:.01:1;
h=5*exp(-5*t);
plot(t,h);
title('time response');
xlabel('time in sec');
ylabel('amplitude')

FREQUENCY RESPONSE
Enter the numerator polynomial coefficients[1 0]
Enter the denominator polynomial coefficients[1 -0.8]

RESULT:
Thus the time and frequency responses of LTI system are plotted.

DSP LAB EXPERIMENTS


USING TMS320C50

EX.NO: 12

LINEAR & CIRCULAR CONVOLUTION USING TMS320C50

AIM:
To implement Linear & Circular convolution using TMS320C50
APPARATUS REQUIED:
1. TMS320C50 Processor
2. Serial cable
PROCEDURE:

1.View
Workspace
2.Project
New project
Filename
Save
3.File
Open
My projects
program open
4.File
Save as
Filename.asm
Save
5.Project
Add file project
File name
open
6.Project
Add file project
Micro50
open
7. Project
Save project
8.Project
Save project
9.Project
Built
Complete
Reset
10.Serial
port setting
Auto detect
ok
11.Serial
Load program
Browse
ok
Communication window
open (f11)
PROGRAM:
CIRCULAR CONVOLUTION (4*4 MATRIX)
.mmregs
.text
START

LDP
#100H
LAR
AR2,#8200H
; X2(n)
LAR
AR1,#8400H
; Re_arange X2(n)
LAR
AR4,#8300H
; Output Memory
LAR
AR3,#03H
; Count
; Re_Arrange the Data of X2(n):
MAR
*,AR2
LACC *,AR1
SACL *+,AR2
LAR AR2,#(8200h+3h)
; X2(N) End of location
LAR
AR0,#2H
Re_arange:
LACC *-,AR1
SACL *+,AR0
BANZ Re_arange,*-,AR2;Multiply & Accumulate:
Next_YN:
LAR AR1,#8100H
; X1(n)
LAR
AR2,#8400H
; Re_arange X2(n)
LAR
AR0,#3H
ZAC

SACL 0H
MAR
LT

*,AR1
*+,AR2

Loop_MAC:
MPY
*+,AR1
LTP
*+,AR0
ADD
0H
SACL 0H
BANZ Loop_MAC,*-,AR2
LACC 0H
MAR
*,AR4
SACL *+

; Store O/P Data YN

; Shift X2(n) Values:


LAR AR1,#(8400h+3h)
LAR
AR2,#2H
LAR
AR0,#2H
MAR
*,AR1
LACC *SACL 1H
Shift_X2N:
LACC *+
SACL *0-,AR2
BANZ Shift_X2N,*-,AR1
MAR
*+
LACC 1H
SACL *,AR3
BANZ Next_YN,*NOP
H:

;
;X1(n) =
8100 - 0002
;
8101 0001
8102 - 0002
;
8103 - 0001
;
;X2(n) =
8200 - 0001
;
8201 - 0002
;
8202 - 0003
;
8203 - 0004
;OUTPUT:
;
8300 - 000E
;
8301 - 0010
;
8302 - 000E
;
8303 - 0010
;
LINEAR CONVOLUTION
" y(n) = x(n)*h(n)"

; X2(n)
; Index Value 2H

.mmregs
.text
START:
LDP
LAR
ZAC
MAR
RPT
SACL *+
LAR
ZAC
MAR
RPT
SACL *+
LAR
LAR

#100H
AR1,#(8100H+4H)

; x(n) Input Location (8100h)

*,AR1
#2H
AR1,#(8200H+4H)

; h(n) Input Location (8200h)

*,AR1
#2H
AR3,#(8300H+6H)
AR4,#06H

;Multiply & Accumulate:


Next_YN:
LAR
AR1,#8100H
LAR
AR2,#(8200H+6H)
LAR
AR0,#06H
ZAC
SACL 0H
MAR
*,AR1
LT
*+,AR2
Loop_MAC:
MPY
*-,AR1
LTP
*+,AR0
ADD
0H
SACL 0H
BANZ Loop_MAC,*-,AR2
LACC 0H
MAR
*,AR3
SACL *; Shift x(n) Values:
LAR AR1,#(8100H+6H)
; x(n)
LAR
AR2,#5H
LAR
AR0,#2H
MAR
*,AR1
LACC *SACL 1H
Shift_XN:
LACC *+
SACL *0-,AR2
BANZ Shift_XN,*-,AR1
MAR
*+
LACC 1H
SACL *,AR4
BANZ Next_YN,*-

; y(n) Output Location (8200h)


; Count-1 ie, N1+N2-1

; Store O/P Data "y(n)"

; Shift Count-1
; Index Value 2H

H1:
;INPUT ( x(n) )
;
;
;
;
;INPUT ( y(n)
;
;
;

NOP
B

H1

8100
8101
8102
8103

-1
-3
-1
-3

8200
8201
8202
8203

-1
-2
-1
-0

;OUTPUT ( xy(n) )
;
;
;
;
;
;
;

8300 - 1
8301 - 5
8302 - 8
8303 - 8
8304 - 7
8305 - 3
8306 - 0
CROSS _ CORRELATION

" xy(n) = x(n)*y(-n)"


.mmregs
.text
START:
LDP
LAR
ZAC
MAR
RPT
SACL *+
LAR
ZAC
MAR
RPT
SACL *+
LAR
LAR
;Multiply & Accumulate:
Next_XYN:
LAR
LAR
LAR
ZAC
SACL 0H
MAR
LT

#100H
AR1,#(8100H-3H)
*,AR1
#2H
AR1,#(8200H+4H)
*,AR1
#2H
AR3,#8300H
AR4,#06H

AR1,#(8100H-3H)
AR2,#8200H
AR0,#06H

*,AR1
*+,AR2

; O/P Data Stored Mem.Location

Loop_MAC:
MPY
*+,AR1
LTP
*+,AR0
ADD
0H
SACL 0H
BANZ Loop_MAC,*-,AR2
LACC 0H
MAR
*,AR3
SACL *+
; Shift x(n) Values:
LAR AR1,#(8100h-3h)
; x(n)
LAR
AR2,#5H
LAR
AR0,#2H
MAR
*,AR1
LACC *+
SACL 1H
Shift_XN:
LACC *SACL *0+,AR2
BANZ Shift_XN,*-,AR1
MAR
*LACC 1H
SACL *,AR4
BANZ Next_XYN,*NOP
H1:
B
H1
;INPUT ( x(n) )
;
;
;
;
;INPUT ( y(n) )
;
;
;

;OUTPUT ( xy(n) )
;
;
;
;
;
;
;

8100
8101
8102
8103

-1
-2
-1
-1

8200
8201
8202
8203

-1
-1
-2
-1

8300
8301
8302
8303
8304
8305
8306

-1
-4
-6
-6
-5
-2
-1

; Store O/P Data "xy(n)"

; Shift Count-1
; Index Value 2H

RESULT:
Thus the convolution program was verified successfully.

EX.NO:13

FIR FILTER USING DSP TRAINTER KIT USING TMS320C50

AIM:
To study the FIR filter program using DSP trainer kit using TMS320C50
APPARATUS REQUIED:
1.
2.
3.
4.

DSP trainer kit


Serial cable
CRO
Function generator

PROCEDURE:

1. View
Workspace
2. Project
New project
Filename
Save
3.File
Open
My projects
program open
4.File
Save as
Filename.asm
Save
5.Project
Add file project
File name
open
6.Project
Add file project
Micro50
open
7. Project
Save project
8.Project
Save project
9.Project
Built
Complete
Reset
10.Serial
port setting
Auto detect
ok
11.Serial
Load program
Browse
ok
12. Set the frequency in the function generator
verify the output in CRO

PROGARM:
FIR FILTER
High pass filter
* Cutoff frequency in KHz = 3.000000
.mmregs
.text
B START
CTABLE:
.word 0FCD3H
.word 05H
.word 0FCB9
.word 087H
.word 0FD3FH
.word 01ADH
.word 0FE3DH.word 0333H
.word 0FF52H
.word 04ABH
.word 0FFF8H
.word 0595H

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

0FFACH
0590
0FE11H
047CH
0FB0BH
029DH
0F6BAH
0AEH
0F147H
01CH
0E9FDH
04C5H
0D882H
044BCH
044BCH
0D882
04C5H
0E9FDH
01CH
0F147H
0AEH
0F6BAH
029DH
0FB0BH
047CH
0FE11H
0590H
0FFACH
0595H
0FFF8
04ABH
0FF52H
0333H
0FE3D
01ADH
0FD3FH
087H
0FCB9H
05H
0FCD3H

START:
MAR *,AR0
LAR
AR0,#0200H
RPT
#33H
BLKP CTABLE,*+
SETC CNF
* Input data and perform convolution
ISR:
LDP
#0AH
LACC #0
SACL 0
OUT
0,05
;pulse to find sampling frequency
IN
0,06H

BACK:

LAR
MAR
BANZ
IN
NOP
NOP
NOP
NOP
MAR
LAR
LACC
AND
SUB
SACL
LAR
MPY
ZAC
RPT
MACD
APAC
LAR
SACH
LACC
ADD
SACL
OUT
LACC
SACL
OUT
NOP
B ISR
.end

AR7,#0
*,AR7
BACK,*0,4

;change value to modify sampling freq.

*,AR1
AR1,#0300H
0
#0FFFH
#800H
*
AR1,#333H
#0
#33H
0FF00H,*AR1,#0300H
*
;give as sach *,1 incase of overflow
*
#800H
*
*,4
#0FFH
0
0,05

LOW PASS FILTER


* Cutoff frequency in KHz = 3.000000
B START
CTABLE:
.word 0FFE7H
.word 0FFD3H
.word 0FFC6H
.word 0FFC4H
.word 0FFD0H
.word 0FFECH
.word 018H
.word 051H
.word 08CH
.word 0B9H
.word 0C2H
.word 092H
.word 01AH

.mmregs

.text

;Filter coefficients n=0

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

0FF5FH
0FE78H
0FD9AH
0FD10H
0FD30H
0FE42H
071H
03B5H
07CAH
0C34H
01054H
01387H
01547H
01547H
01387H
01054H
0C34H
07CAH
03B5H
071H
0FE42H
0FD30H
0FD10H
0FD9AH
0FE78H
0FF5FH
01AH
092H
0C2H
0B9H
08CH
051H
018H
0FFECH
0FFD0H
0FFC4H
0FFC6H
0FFD3H
0FFE7H

START:
MAR *,AR0
memory to data memory.
LAR
AR0,#0200H
RPT
#33H
BLKP CTABLE,*+
SETC CNF
* Input data and perform convolution
ISR:
LDP
#0AH
LACC #0
SACL 0
OUT
0,05
IN
0,06H

;This block moves the filter coefficient from pgm

LAR
MAR
BANZ
IN
NOP
NOP
NOP
NOP
MAR
LAR
LACC
AND
SUB
SACL
LAR
MPY
ZAC
RPT
MACD
APAC
LAR
SACH
LACC
ADD
SACL
OUT
LACC
SACL
OUT
NOP
B ISR
.end

BACK:

AR7,#0
*,AR7
BACK,*0,4

*,AR1
AR1,#0300H
0
#0FFFH
#800H
*
AR1,#333H
#0
#33H
0FF00H,*AR1,#0300H
*
*
#800h
*
*,4
#0FFH
0
0,05

Bandpass Filter
* Filter Order: 52
* lower Cutoff frequency in KHz = 3.000000Hz
* upper Cutoff frequency in KHz = 5.000000Hz
.mmregs
.text
B
START
CTABLE:
.word
.word
.word
.word
.word
.word

024AH
010FH
0FH
0FFECH
0C6H
0220H

;CONVOLUTION OPERATION

.word 0312H

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

02D3H
012FH
0FEBDH
0FC97H
0FBCBH
0FCB0H
0FE9EH
029H
0FFDCH
0FD11H
0F884H
0F436H
0F2A0H
0F58AH
0FD12H
075FH
01135H
01732H

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

01732H
01135H
075FH
0FD12H
0F58AH
0F2A0H
0F436H
0F884H
0FD11H
0FFDCH
029H
0FE9EH
0FCB0H
0FBCBH
0FC97H
0FEBDH
012FH

.word
.word
.word
.word

02D3H
0312H
0220H
0C6H

.word
.word
.word
.word

0FFECH
0FH
010FH
024AH

Move the Filter coefficients

from program memory to data memory

START:
MAR
LAR
RPT
BLKP
SETC

*,AR0
AR0,#0200H
#33H
CTABLE,*+
CNF

* Input data and perform convolution

ISR:

LDP
LACC
SACL
OUT
IN
LAR
MAR

BACK:

#0AH
#0
0
0,05
0,06H
AR7,#0
*,AR7

;pulse to find sampling frequency


;change value to modify sampling freq.

BANZ BACK,*-

IN
0,4
NOP
NOP
NOP
NOP
MAR *,AR1
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
SACL *
LAR AR1,#333H
MPY #0
ZAC
RPT #33H
MACD
0FF00H,*APAC
LAR AR1,#0300H
SACH
LACC
ADD
SACL
OUT
LACC
SACL
OUT
NOP
B

*
*
#800H
*
*,4
#0FFH
0
0,05
ISR

;give as sach *,1 incase of overflow

.end
Bandreject Filter
* Filter Order: 52
* lower Cutoff frequency in KHz = .000000Hz
* upper Cutoff frequency in KHz = .000000Hz
.mmregs
.text
B
START
CTABLE:
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

0FEB9H
14EH
0FDA1H
155H
0FE1BH
282H
0FEAFH
2ACH
0FD35H
8DH
0F9D9H
0FE07H
0F7CCH
0FEE2H
0FA2FH
4BAH
1AH
25CH
420H
1008H
89H
0D61H
0F3F2H
0AF9H
0DB7EH
045DFH
045DFH
0DB7EH
0AF9H
0F3F2H

.word
.word
.word
.word
.word
.word
.word

0D61H
89H
1008H
420H
25CH
1AH
4BAH

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

0FA2FH
0FEE2H
0F7CCH
0FE07H
0F9D9H
8DH
0FD35H
2ACH
0FEAFH
282H
0FE1BH
155H
0FDA1H
14EH
0FEB9H

Move the Filter coefficients

from program memory to data memory

START:
MAR *,AR0
LAR AR0,#0200H
RPT #33H
BLKP CTABLE,*+
SETC CNF
* Input data and perform convolution
ISR:

LDP
LACC
SACL
OUT
IN
LAR
MAR
BACK:
IN
NOP
NOP
NOP
NOP
MAR
LAR
LACC
AND
SUB
SACL
LAR

#0AH
#0
0
0,05
;pulse to find sampling frequency
0,06H
AR7,#0
;change value to modify sampling freq.
*,AR7
BANZ BACK,*0,4

*,AR1
AR1,#0300H
0
#0FFFH
#800H
*
AR1,#333H

MPY #0
ZAC
RPT #33H
MACD
0FF00H,*APAC
LAR AR1,#0300H
SACH *
;give as sach *,1 incase of overflow
LACC *
ADD #800H
SACL *
OUT *,4
LACC #0FFH
SACL 0
OUT 0,05
NOP
B
ISR
.end

RESULT:
Thus the FIR filter program was verified successfully.

EX.NO: 14

WAVE FROM GENERATION USING TMS320C50

AIM:
To implement the wave from generation in using DSP trainer kit using TMS320C50
APPARATUS REQUIED:
1. DSP trainer kit
2. Serial cable
3. CRO
PROCEDURE:

1. View
Workspace
2. Project
New project
Filename
Save
3.File
Open
My projects
program open
4.File
Save as
Filename.asm
Save
5.Project
Add file project
File name
open
6.Project
Add file project
Micro50
open
7. Project
Save project
8.Project
Save project
9.Project
Built
Complete
Reset
10.Serial
port setting
Auto detect
ok
11.Serial
Load program
Browse
ok
12. Verify the output in CRO
PROGRAM:
SINE WAVE GENERATION. (With these default values sine generated is 100 Hz)

INCFREQ .set 10 ;minimum value 1 - change for increasing frequency


;every count will increase frequency in steps of 100hz
DECFREQ .set 0 ;minimu value 0 - change for decreasing frequency
;every count will decrease frequency by half
LENGTH .set 360
AMPLITUDE .set 5
delay .set 7 ;change to increase/decrease frequency in
;different steps;
TEMP .set 0
TEMP1 .set 1
.mmregs
.text
START:
LDP #100H
SPLK #TABLE,TEMP ;load start address of table
lar AR2,#( (LENGTH/INCFREQ)+(LENGTH*DECFREQ) )-1
lar ar3,#DECFREQ ;repeat counter for reducing frequency
CONT:
CALL DELAY
LACC TEMP
;load address of sine value
TBLR TEMP1
;read sine data to TEMP1

LT
TEMP1
MPY #AMPLITUDE
PAC
SACL TEMP1
mar *,ar3
banz repeat,*lar ar3,#DECFREQ ;repeat counter for reducing frequency
LACC TEMP
ADD #INCFREQ
;increase table value
repeat:
SACL TEMP
;store it
OUT TEMP1,4
;send sine data to DAC
MAR *,AR2
BANZ CONT,*b
START
DELAY:
lar ar7,#delay
mar *,ar7
back: banz back,*ret
;
TABLE
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

100
101
103
105
106
108
110
112
113
115
117
119
120
122
124
125
127
129
130
132
134
135
137
139
140
142

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

143
145
146
148
150
151
152
154
155
157
158
160
161
162
164
165
166
168
169
170
171
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
189
190
191
192
192
193
193
194
195
195
196
196
197
197

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

197
198
198
198
199
199
199
199
199
199
199
199
200
199
199
199
199
199
199
199
199
198
198
198
197
197
197
196
196
195
195
194
193
193
192
192
191
190
189
189
188
187
186
185
184
183
182
181
180
179
178
177

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

176
175
174
173
171
170
169
168
166
165
164
162
161
160
158
157
155
154
152
151
149
148
146
145
143
142
140
139
137
135
134
132
130
129
127
125
124
122
120
119
117
115
113
112
110
108
106
105
103
101
99
98

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

96
94
93
91
89
87
86
84
82
80
79
77
75
74
72
70
69
67
65
64
62
60
59
57
56
54
53
51
49
48
47
45
44
42
41
39
38
37
35
34
33
31
30
29
28
26
25
24
23
22
21
20

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

19
18
17
16
15
14
13
12
11
10
10
9
8
7
7
6
6
5
4
4
3
3
2
2
2
1
1
1
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
1
2
2
2
3

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word

3
4
4
5
6
6
7
7
8
9
10
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
28
29
30
31
33
34
35
37
38
39
41
42
44
45
47
48
50
51
53
54
56
57
59
60

.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.word
.end

62
64
65
67
69
70
72
74
75
77
79
80
82
84
86
87
89
91
93
94
96
98
100

SAWTOOTH WAVEFORM GENERRATION


.MMREGS
.TEXT
START:
LDP #120H
LACC #0H ;change lower amplitude
SACL 0
LOOP: LACC 0
OUT 0,04H
ADD #05h ;change frequency
SACL 0
SUB #0FFFh ;change upper amplitude
BCND LOOP,LEQ
B
START
.END

SQUARE WAVEFORM GENERATION.

.mmregs
.text
start:
ldp #100h
lacc #0fffh ;change this value for amplitude.
loop: sacl 0
rpt #0ffh ;change this value for frequency.
out 0,04
;address for dac.
cmpl
b
loop
.end
TRIANGULAR WAVE FORM GENERATION
AMPLITUDE .SET 4
FREQ .SET 350
TEMP
;

.SET

.mmregs
.text
START:
LDP #100H
splk #0,TEMP
CONT1:
lar AR2,#FREQ
CONT:
out TEMP,4
LACC TEMP
ADD #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONT,*LAR AR2,#FREQ
CONTx:
OUT TEMP,4
LACC TEMP
SUB #AMPLITUDE
SACL TEMP
MAR *,AR2
BANZ CONTx
B
CONT1
.end

RESULT:
Thus the above wave from generation was verified successfully.

EX.NO: 15

SAMPLING OF INPUT SIGNAL AND DISPLAY

AIM:
To implement Sampling of input signal using DSP trainer kit using TMS320C50
APPARATUS REQUIED:
1. DSP trainer kit
2. Serial cable
3. CRO
PROCEDURE:

1. View
Workspace
2. Project
New project
Filename
Save
3.File
Open
My projects
program open
4.File
Save as
Filename.asm
Save
5.Project
Add file project
File name
open
6.Project
Add file project
Micro50
open
7. Project
Save project
8.Project
Save project
9.Project
Built
Complete
Reset
10.Serial
port setting
Auto detect
ok
11.Serial
Load program
Browse
ok
12. Verify the output in CRO
PROGRAM:
.mmregs
.text
start:
ldp

#140h

in
nop
nop
in
lacc
and
add
sacl
out
b

0,06

loop:

0,04
0
#0fffh
#0800h
0
0,04
loop

RESULT:

Thus the sampling of input signal was verified successfully.

You might also like