DSP Lab Manual EC8562 (R 2017)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 82

SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

FAMILIARISATION WITH MATLAB

Aim:
To familiarize with MATLAB software, general functions and signal processing toolbox
functions.
The name MATLAB stands for MATrix LABoratory produced by Mathworks Inc., USA.
It is a matrix-based powerful software package for scientific and engineering computation
and visualization. Complex numerical problems can be solved in a fraction of the time that
required with other high level languages. It provides an interactive environment with
hundreds of built -in –functions for technical computation, graphics and animation. In
addition to built-in-functions, user can create his own functions.
MATLAB offers several optional toolboxes, such as signal processing, control systems,
neural networks etc. It is command driven software and has online help facility.
MATLAB has three basic windows normally; command window, graphics window and edit
window.
Command window is characterized by the prompt ‘>>’.
All commands and the ready to run program filename can be typed here. Graphic window
gives the display of the figures as the result of the program. Edit window is to create
program files with an extension .m.
Some important commands in MATLAB
Help - List topics on which help is available
Help command name Provides - help on the topic selected
Demo - Runs the demo program
Who - Lists variables currently in the workspace
Whos - Lists variables currently in the workspace with their size
Clear - Clears the workspace, all the variables are removed
Clear x,y,z - Clears only variables x,y,z
Quit - Quits MATLAB
Some of the frequently used built-in-functions in Signal Processing Toolbox
filter(b.a.x) - Syntax of this function is Y = filter(b.a.x)
It filters the data in vector x with the filter described by vectors
a and b to create the filtered data y.
fft (x) It is the DFT of vector x
ifft (x) It is the DFT of vector x
conv (a,b) Syntax of this function is C = conv (a,b)
It convolves vectors a and b. The resulting vector is of
Length, Length (a) + Length (b)-1
deconv(b,a) Syntax of this function is [q,r] = deconv(b,a)
It deconvolves vector q and the remainder in vector r such that
b = conv(a,q)+r
butter(N,Wn) designs an Nth order lowpass digital
Butterworth filter and returns the filter coefficients in length
N+1 vectors B (numerator) and A (denominator). The coefficients
1
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

are listed in descending powers of z. The cutoff frequency Wn must be 0.0 <
Wn < 1.0, with 1.0 corresponding to half the sample rate.

buttord(Wp, Ws, Rp, Rs) returns the order N of the lowest order digita Butterworth filter
that loses no more than Rp dB in the passband and has at least Rs dB of
attenuation in the stopband. Wp and Ws are the passband and stopband
edge frequencies, Normalized from 0 to 1 ,(where 1 corresponds to pi
rad/sec)
Cheby1(N,R,Wn) designs an Nth order lowpass digital Chebyshev filter with R decibels of
peak-to-peak ripple in the passband. CHEBY1 returns the filter
coefficients in length N+1 vectors B (numerator) and A (denominator).
The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0
corresponding to half the
sample rate.
Cheby1(N,R,Wn,'high') designs a highpass filter.
Cheb1ord(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital Chebyshev Type
I filter that loses no more than Rp dB in the passband and has at
least Rs dB of attenuation in the stopband. Wp and Ws are the
passband and stopband edge frequencies, normalized from 0 to 1
(where 1 corresponds to pi radians/sample)
cheby2(N,R,Wn) designs an Nth order lowpass digital Chebyshev filter with the
stopband ripple R decibels down and stopband edge frequency Wn.
CHEBY2 returns the filter coefficients in length N+1 vectors B
(numerator) and A . The cutoff frequency Wn must be 0.0 < Wn < 1.0,
with 1.0 corresponding to half the sample rate.
cheb2ord(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital Chebyshev Type II
filter that loses no more than Rp dB in the passband and has at least Rs dB of attenuation
in the stopband. Wp and Ws are the passband and stopband edge frequencies,
abs(x) - It gives the absolute value of the elements of x. When x is complex abs(x) is the
complex modulus (magnitude) of the elements of x.
angle(H) - It returns the phase angles of a matrix with complex elements in radians.
freqz(b,a,N) -Syntax of this function is [h,w] = freqz(b,a,N) returns the N-
point frequency vector w in radians and the N-point complex
frequency response vector h of the filter b/a.
stem(y) It plots the data sequence y aa stems from the x axis terminated
with circles for the data value.
stem(x,y) It plots the data sequence y at the values specified in x.
ploy(x,y) It plots vector y versus vector x. If x or y is a matrix, then the
vector is plotted versus the rows or columns of the matrix,
whichever line up.
title(‘text’) It adds text at the top of the current axis.
xlabel(‘text’) It adds text beside the x-axis on the current axis.

ylabel(‘text’) It adds text beside the y-axis on the current axis.

2
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 1

Date: GENERATION OF SIGNALS

AIM:
To generate the following signals using MATLAB 9.0
1. Unit impulse signal
2. Unit step signal
3. Unit ramp signal
4. Exponential growing signal
5. Exponential decaying signal
6. Sine signal
7. Cosine signal

APPARATUS REQUIRED:
System with MATLAB 9.0.

ALGORITHM:
1. Get the number of samples.
2. Generate the unit impulse, unit step using ‘ones’, ‘zeros’ matrix
command.
3. Generate ramp, sine, cosine and exponential signals using corresponding
general formula.
4. Plot the graph.

3
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

UNIT IMPULSE

clc;
clear all;
close all;
t=-2:1:2;
y=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(2,2,1);
stem(t,y);
xlabel('time-->.');
ylabel('amplitude-->');

OUTPUT:

4
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 1(b) UNIT RAMP

Date:

clc;
close all;
clear all;
n=input ('Enter the length of ramp sequence:');
t=0:1:n;
subplot(2,2,3);
stem(t,t);
xlabel('time-->.');
ylabel('amplitude-->');

INPUT: Enter the length of ramp sequence: 6

OUTPUT:

5
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 1(c) UNIT SINE

Date:

clc;
clear all;
t=0:.05:pi;
y=sin(2*pi*t);
figure(2);
subplot(2,1,2);
plot(t,y);
xlabel('time-->.');
ylabel('amplitude-->');

OUTPUT:

6
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 1(d) UNIT COSINE

Date:

clc;

clear all;

t=0:0.05:pi;

y=cos(2*pi*t);

subplot(2,2,2);

plot(t,y);

xlabel('time-->.');

ylabel('amplitude-->');

OUTPUT:

7
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 1(e) UNIT EXPONENTIAL

Date:

clear all;
close all;
n=input('Enter the length of the exponential sequence');
t=0:1:n;
a=input('Enter value');
y=exp(a*t);
subplot(2,2,4);
stem(t,y);
ylabel('amplitude-->');
xlabel('time-->.');

INPUT: Enter the length of the exponential sequence 3

Enter value 1

OUTPUT:

RESULTS:-

Thus the generation of continues time signals using matlab was verified
8
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 2(a)

Date: (a). LINEAR CONVOLUTION

AIM:
To write the program for finding the linear convolution of two signals using
MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

LINEAR CONVOLUTION:

ALGORITHM:
1. Get the number of samples.
2. Generate the output sequence of the given two input signals using
‘conv’ command.
3. Plot the graph.

9
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;

clear all;

close all;

x=input('enter the 1st sequences');

h=input('enter the 2nd sequences');

y=conv(x,h);

subplot(3,1,1);

stem(x);

ylabel('amplitude x(n)-->');

xlabel('n-->');

subplot(3,1,2);

stem(h);

ylabel('amplitude h(n)-->');

xlabel('n-->');

subplot(3,1,3);

stem(y);

ylabel('amplitude y(n)-->');

xlabel('n-->');

disp('the result b');y

10
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

INPUT:

Enter the 1st sequences [1 2 3 4]

Enter the 2nd sequences [4 3 2 1]

the resultant b

y = 4 11 20 30 20 11 4

OUTPUT:

RESULTS :-

Thus the program for linear convolution is written using MATLAB and
verified.
11
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 2(b)

Date: (b)CIRCULAR CONVOLUTION

AIM:
To write the program for finding the circular convolution of two signals using
MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

CIRCULAR CONVOLUTION:
ALGORITHM:
1. Get the number of samples.
2. Generate the sequence for the given two input signals using ‘zeros’ and
‘ones’ matrix command.
3. Generate the convoluted output sequence of the given two input signals
using ‘conv’ command.
4. Plot the graph.

12
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;

clear all;

close all;

a=input('x1(n)');

b=input('x2(n)');

N=length(b);

M=length(a);
c=fft(a,N);

d=fft(b);

e=c.*d;

f=ifft(e);

disp('circular convolution output');

disp(f);

subplot(1,3,1);

stem(a);

xlabel('time-->');

ylabel('amplitude');
title('x1(n)');

subplot(1,3,2);

stem(b);

xlabel('time');

ylabel('amplitude');

title('x2(n)');

subplot(1,3,3);

stem(f);

xlabel('time');

13
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

ylabel('amplitude');

title('output');

INPUT:

x1(n) [1 2 3 4]

x2(n) [4 3 2 1]

Circular convolution output:

24 22 24 30

RESULTS:-

Thus the program for circular convolution is written using MATLAB and
verified.

14
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 3

Date: CORRELATION

%Cross-CorrelationandAuto-Correlationoffinitesequences

AIM:
To write the program for finding the correlation of two signals using MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

CIRCULAR CONVOLUTION:
ALGORITHM:
1. Get the number of samples.
2. Generate the sequence for the given two input signals using ‘zeros’ and
‘ones’ matrix command.
3. Generate the convoluted output sequence of the given two input signals
using ‘conv’ command.
4. Plot the graph.

15
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;clearall;closeall;

x=input('EntertheSignalx=');

y=input('EntertheSignaly=');

rxy=xcorr(x,y);%cross-correlation of x and y

rxx=xcorr(x);%Auto-Correlation of x

subplot(221);

stem(x);

xlabel(Time');

ylabel('Amplitude');

title('x(n)');

subplot(222);

stem(y);

xlabel('Time');

ylabel('Amplitude');

title('y(n)');

subplot(223);

stem(rxy);

xlabel('Lag');

ylabel('Amplitude');

title('rxy(k)');

subplot(224);

stem(rxx);

xlabel('Lag');

ylabel('Amplitude'); title('rxx(k)');

16
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Enter the Signal x=[1 -1 2 3 1]

Enter the Signal y=[2 1 -2 1 4 4 1]

RESULTS:-

Thus the program for correlation of two signals is written using MATLAB and
verified.

Expt. No: 4
17
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date: CALCULATION OF FFT

AIM:
To write the program for calculating the N-point FFT and IFFT of given input
sequence using MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

ALGORITHM:
1. Get the input sequence and its length.
2. Calculate the Fast Fourier Transform and Inverse Fast Fourier Transform
of given sequence using user defined function.
3. Plot the magnitude and phase response of FFT sequence.
4. Plot the IFFT response.

clc;
18
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clear all;

close all;

a=input('enter the sequence');

b=fft(a);

disp('fft of a sequence');

disp(b);

c=abs(b);
disp('magnitude plot');

disp(c);

d=angle(b);

disp('phase plot');

disp(d);

subplot(3,3,1);

stem(a);

xlabel('time');

ylabel('amplitude');

title('input');
subplot(3,3,2);

stem(b);

xlabel('time');

ylabel('amplitude');

title('fft');

subplot(3,3,3);

stem(c);

xlabel('time');

ylabel('amplitude');
title('magnitude plot');
19
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

subplot(3,3,4);
stem(d);
xlabel('time');
ylabel('amplitude');
title('phaseplot');
Enter the sequence [2 2 2 2 1 1 1 1]

OUTPUT:

fft of a sequence
Columns 1 through 8
12.0000, 1.0000 - 2.4142i , 0 ,1.0000 - 0.4142i ,0 , 1.0000 + 0.4142i , 0 , 1.0000 + 2.4142i
Magnitude plot
12.0000 2.6131 0 1.0824 0 1.0824 0 2.6131
Phase plot
0 -1.1781 0 -0.3927 0 0.3927 0 1.1781

RESULTS:-

Thus the program for fft is written using MATLAB and verified.

Expt. No: 5

20
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date: CALCULATION OF DFT

AIM:
To write the program for calculating the N-point DFT and IDFT of given input
sequence using MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

ALGORITHM:
1. Get the input sequence and its length.
2. Calculate the DFT and Inverse DFT
of given sequence using user defined function.
3. Plot the magnitude and phase response of DFT sequence.
4. Plot the IDFT response.

clear all;
21
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;

n=8;

x=[1,1,1,1,1,1,0,0];

subplot(3,1,1);

stem(x);

xlabel('n-->');

ylabel('amp-->');
title('input');

A=dftmtx(n);

y=A*x';

subplot(3,1,2);

stem(y);

xlabel('n-->');

ylabel('amp-->');

title('dft');

disp(y);

c=abs(y);
disp('magnitude plot');

disp(c);

d=angle(y);

disp('phase plot');

disp(d);

subplot(3,3,1);

stem(x);

xlabel('time');

ylabel('amp');

22
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

title('input');

subplot(3,3,2);

stem(y);

xlabel('time');

ylabel('amp');

title('dft');

subplot(3,3,3);
stem(c);

xlabel('time');

ylabel('amplitude');

title('magnitude plot');

subplot(3,3,4);

stem(d);

xlabel('time');

ylabel('amplitude');

title('phaseplot');

OUTPUT:
23
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

6.0000
-0.7071 - 1.7071i
1.0000 - 1.0000i
0.7071 + 0.2929i
0
0.7071 - 0.2929i
1.0000 + 1.0000i
-0.7071 + 1.7071i

magnitude plot:
6.0000, 1.8478 , 1.4142, 0.7654, 0, 0.7654, 1.4142, 1.8478
phase plot:
0, -1.9635, -0.7854, 0.3927, 0, -0.3927, 0.7854, 1.9635

RESULTS:-

Thus the program for dft is written using MATLAB and verified.

Expt. No: 6
24
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date: SAMPLING AND ALIASING OF EFFECT

AIM
To sample the signal and observe the aliasing effect of that signal using
MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

ALGORITHM:
1. Get the input frequency and number of samples.
2. The input signal is sampled at the frequencies fs1=2fm, fs2>2fm and
fs3<2fm.
3. Plot the input and sampled signal at various frequencies.

clear all;
25
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;

close all;

t=-5:0.1:5;

T=1;

fm=1/T;

x=cos(2*pi*fm*t);

fs1=input('enter the 1st frequency if input frequency is Hz');

fs2=input('enter the 2nd frequency if input frequency is Hz');

fs3=input('enter the 3rd frequency if input frequency is Hz');

n=-5:0.1:5;

y1=cos(2*pi*fm*n/fs1);

y2=cos(2*pi*fm*n/fs2);

y3=cos(2*pi*fm*n/fs3);

subplot(4,1,1);

plot(t,x);

xlabel('times-->');

ylabel('x(t)-->');

title('input');

subplot(4,1,2);

stem(n,y1);

xlabel('n-->');

ylabel('x(n)==>');

if fs1<2*fm

title('sampled signal for fs1 aliasing');

26
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

else

title('sampled for fs1');

end

subplot(4,1,3);

stem(n,y2);

xlabel('n-->');

ylabel('x(n)-->');

if fs2<2*fm

title('sampled signal for fs2 aliasing');

else

title('sampled signal for fs2');

end

subplot(4,1,4);

stem(n,y3);

xlabel('n-->');

ylabel('x(n)-->');

if fs3<2*fm

title('sampled signal for fs3 aliasing');

else

title('sampled signal for fs3');

end

INPUT:

27
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Enter the 1st frequency if input frequency is hz 2

Enter the 2nd frequency if input frequency is hz 3

Enter the 3rd frequency if input frequency is hz 1

RESULTS:-

Thus the sample the signal and observe the aliasing effect of that signal using matlab
was verified

Expt. No: 7(a)


28
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date:

(a) BUTTERWORTH LOW PASS IIR FIFTER

AIM:
To design a Butterworth low pass digital IIR filter using MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

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
5.Find the filter co-efficient.
6.Draw the magnitude and phase response.

clc;

29
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clear all;

clf;

alphap=input('Enter the passband attenuation:');

alphas=input('Enter the stopband attenuation:');

fp=input('Enter the passband frequency:');

fs=input('Enter the stopband frequency:');

f=input('Enter the sampling frequency:');

sip=2*fp/f;

sis=2*fs/f;

[n,sic]=buttord(sip,sis,alphap,alphas,'s');

[b a]=butter(n,sic,'low','s');

t=0:0.01:pi;

[h,p]=freqs(b,a,t);

magnitude=20*log(abs(h));

subplot(2,2,1);

plot(p/pi,magnitude);

xlabel('Normailsed frequency-->');

ylabel('Gain in db-->');

title('Magnitude response of Analog LPF');

ang=angle(h);

subplot(2,2,2);

plot(p/pi,ang);

xlabel('Normalised frequency-->');

ylabel('Phase in radian-->');

30
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

title('Phase response of analog LPF');

disp('Order of filter:');

disp(n);

disp('cut of frequency:');

disp(sic);

disp('TRANSFER FUNCTION FOR ANALOG LPF FILTER');

disp('coefficient of numerator');

disp(b);

disp('coefficient of denominator');

disp(a);

[bz,az]=bilinear(b,a,f);

w=0:0.01:pi;

[hz,pz]=freqz(bz,az,w);

magnitude=20*log(abs(hz));

subplot(2,2,3);

plot(pz/pi,magnitude);

xlabel('Normalised frequency-->');

ylabel('Gain in db-->');

title('Magnitdue response of Digital LPF');

ang=angle(hz);

subplot(2,2,4);

plot(pz/pi,ang);

xlabel('Normalised frequency-->');

ylabel('phase in radian-->');

31
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

title('Phase response of Digital LPF');

disp('TRANSFER FUNCTION FOR DIGITAL; LPF FILTER');

disp('coefficient of numerator');

disp(bz);

disp('coefficient of denominator');

disp(az);

INPUT:

Enter the passband attenuation: 2

Enter the stopband attenuation: 4

Enter the passband frequency: 50

Enter the stopband frequency: 70

Enter the sampling frequency: 50

OUTPUT:

Order of filter:

cut of frequency:

2.5251

TRANSFER FUNCTION FOR ANALOG LPF FILTER

coefficient of numerator

0 0 6.3761

coefficient of denominator

1.0000 3.5710 6.3761

TRANSFER FUNCTION FOR DIGITAL; LPF FILTER

32
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

coefficient of numerator

0.0006 0.0012 0.0006

coefficient of denominator

1.0000 -1.9286 0.9311

RESULTS:-

Thus the magnitude response and phase response of Digital Butter


worth Low pass filter was verified.

Expt. No: 7(b)

33
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date: (b) BUTTERWORTH HIGH PASS IIR FIFTER

AIM:
To design a Butterworth high pass digital IIR filter using MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0.

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
5.Find the filter co-efficient.
6.Draw the magnitude and phase response.

clc;

34
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clear all;

clf;

alphap=input('Enter the passband attenuation:');

alphas=input('Enter the stopband attenuation:');

fp=input('Enter the passband frequency:');

fs=input('Enter the stopband frequency:');

f=input('Enter the sampling frequency:');

sip=2*fp/f;

sis=2*fs/f;

[n,sic]=buttord(sip,sis,alphap,alphas,'s');

[b a]=butter(n,sic,'high','s');

t=0:0.01:pi;

[h,p]=freqs(b,a,t);

magnitude=20*log(abs(h));

subplot(2,2,1);

plot(p/pi,magnitude);

xlabel('Normailsed frequency-->');

ylabel('Gain in db-->');

title('Magnitude response of Analog HPF');

ang=angle(h);

subplot(2,2,2);

plot(p/pi,ang);

xlabel('Normalised frequency-->');

ylabel('Phase in radian-->');

35
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

title('Phase response of analog HPF');

disp('Order of filter:');

disp(n);

disp('cut of frequency:');

disp(sic);

disp('TRANSFER FUNCTION FOR ANALOG HPF FILTER');

disp('coefficient of numerator');

disp(b);

disp('coefficient of denominator');

disp(a);

[bz,az]=bilinear(b,a,f);

w=0:0.01:pi/10;

[hz,pz]=freqz(bz,az,w);

magnitude=20*log(abs(hz));

subplot(2,2,3);

plot(pz/pi,magnitude);

xlabel('Normalised frequency-->');

ylabel('Gain in db-->');

title('Magnitdue response of Digital HPF');

ang=angle(hz);

subplot(2,2,4);

plot(pz/pi,ang);

xlabel('Normalised frequency-->');

ylabel('phase in radian-->');

36
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

title('Phase response of Digital HPF');

disp('TRANSFER FUNCTION FOR DIGITAL; HPF FILTER');

disp('coefficient of numerator');

disp(bz);

disp('coefficient of denominator');

disp(az);

INPUT:

Enter the passband attenuation: 2

Enter the stopband attenuation: 4

Enter the passband frequency: 70

Enter the stopband frequency:50

Enter the sampling frequency:50

OUTPUT:

Order of filter:

cut of frequency:

2.2177

TRANSFER FUNCTION FOR ANALOG HPF FILTER

coefficient of numerator

1 0 0

coefficient of denominator 1.0000 3.1364 4.9184

TRANSFER FUNCTION FOR DIGITAL; HPF FILTER

37
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

coefficient of numerator

0.9691 -1.9383 0.9691

coefficient of denominator

1.0000 -1.9373 0.9392

RESULTS:-

Thus the magnitude response and phase response of Digital

Butter worth High pass filter was verified

Expt. No: 8

38
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date: CHEBSHEV FILTER

AIM: -

TO write a MATLAB program to plot magnitude response and phase response of


digital Chebyshev type-1 Low pass filter

ALGORITHM:-

1. Get the passband and stopband ripples


2. Get the passband and stopband edge frequencies
3. Calculate the order of the filter using ‘ cheb1ord ’ function
4. Find the filter coefficients, using ‘cheby1’ function
5. Draw the magnitude and phase response

39
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clear all;

alphap=2;

alphas=20;

wp=[0.2*pi,0.4*pi];

ws=[0.1*pi,0.5*pi];

[n,wn]=cheb1ord(wp/pi,ws/pi,alphap,alphas);

[b,a]=cheby1(n,alphap,wn);

w=0.1:0.01:pi;

[h,ph]=freqz(b,a,w);

m=20*log10(abs(h));

an=angle(h);

subplot(2,1,1);

plot((ph/pi),m);

grid;

ylabel('gain in db');

xlabel('Normalised Frequency');

title('chebshev type I band pass filter');

subplot(2,1,2);

plot((ph/pi),an);

grid;

xlabel('Normalised Frequency');

ylabel('Phase in radians');

40
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

RESULTS:-

Thus the Amplitude response and phase response of chebyshev type 1 Low
pass filter was verified

Expt. No: 9(a)

41
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date: (a) FIR FILTER USING HANNING WINDOW

AIM:
To design a FIR filter using Hanning window with MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0

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 lowpass,High pass,Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.

clc;
clf;
42
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clear all;
wp=input('enter the passband frequency:');
ws=input('enter the stopband frequency:');
n=input('enter the samples:');
m=max(wp,ws);
fs=3*m;
fp=2*wp/fs;
fstop=2*ws/fs;
w=0:.01:pi;
%LPF:
b=fir1(n,fp,'low',hanning(n+1));
h=freqz(b,1,w);
subplot(2,2,1);
plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('low pass filter');
%HPF:
b=fir1(n,fp,'high',hanning(n+1));
h=freqz(b,1,w);
subplot(2,2,2);
plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('high pass filter');
%BPF:
b=fir1(n,[fp fstop],'bandpass',hanning(n+1));
h=freqz(b,1,w);
subplot(2,2,3);
plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('band pass filter');
%BSF:
b=fir1(n,[fp fstop],'stop',hanning(n+1));
h=freqz(b,1,w);
subplot(2,2,4);
plot(w/pi,abs(h));
xlabel('normalised frequency');

43
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

ylabel('magnitude');
title('band stop filter');

INPUT: Enter the passband frequency:3.15


Enter the stopband frequency:7.5
Enter the samples:38

OUTPUT:

RESULTS:-

Thus the magnitude response and phase response of fir LPF, HPF,BPF, BSF
using hanning window was verified.

Expt. No: 9(b)


44
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Date:

(b) FIR FILTER USING HAMMING WINDOW

AIM:
To design a FIR filter using Hamming window with MATLAB 9.0.

APPARATUS REQUIRED:
System with MATLAB 9.0

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 lowpass,High pass,Band pass and Band stop filter.
5. Plot the magnitude response of all the filters.

45
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;
clf;
clear all;
wp=input('enter the passband frequency:');
ws=input('enter the stopband frequency:');
n=input('enter the samples:');
m=max(wp,ws);
fs=3*m;
fp=2*wp/fs;
fe=2*ws/fs;
w=0:.01:pi;
%LPF:
b=fir1(n,fp,'low',hamming(n+1));
h=freqz(b,1,w);
subplot(2,2,1);
plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('low pass filter');
%HPF:
b=fir1(n,fp,'high',hamming(n+1));
h=freqz(b,1,w);
subplot(2,2,2);
plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('high pass filter');
%BPF:
b=fir1(n,[fp fe],'bandpass',hamming(n+1));
h=freqz(b,1,w);
subplot(2,2,3);
plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('band pass filter');
%BSF:
b=fir1(n,[fp fe],'stop',hamming(n+1));
h=freqz(b,1,w);
subplot(2,2,4);

46
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

plot(w/pi,abs(h));
xlabel('normalised frequency');
ylabel('magnitude');
title('band stop filter');

INPUT:

Enter the passband frequency:3.15


Enter the stopband frequency:7.5
Enter the samples:38

OUTPUT:

RESULTS:-

Thus the magnitude response and phase response of fir LPF, HPF,BPF, BSF
using hamming window was verified.

47
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 10 (a)

Date: INTERPOLATION BY POLYPHASE DECOMPOSITION

(a) UP SAMPLING

AIM:
To write a program to compute Convolution and m-fold interpolation by
polyphase decomposition.

APPARATUS REQUIRED:
System with MATLAB 9.0.

ALGORITHM:
1. Get the input sequence.
2. Get the filter coefficients and also the interpolation factor.
3. Find the response by using convolution.
4. Plot the graph.

clc;
48
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

N=10;
n=0:1:N-1;
x=sin(2*pi*n/10)+sin(2*pi*n/5);
L=3;
x1=[zeros(1,L*N)];
n1=1:1:L*N;
j=1:L:L*N;
x1(j)=x;
subplot(2,1,1);
stem(n,x);
xlabel('n');
ylabel('x');
title('input sequence');
subplot(2,1,2);
stem(n1,x1);
xlabel('n');
ylabel('x1');
title('upsampled sequence');

OUTPUT :

RESULT:

Thus we compute Convolution and m-fold interpolation by Polyphase


decomposition in MATLA

49
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 10 (b)

Date:

DECIMATION BY POLYPHASE DECOMPOSITION

(b)DOWN SAMPLING

AIM:
To write a program to compute Convolution and m-fold decimation by
polyphase decomposition.

APPARATUS REQUIRED:
System with MATLAB 9.0.

ALGORITHM:
1. Get the input sequence.
2. Get the filter coefficients and also the decimation factor.
3. Find the response by using convolution.
4. Plot the graph.

50
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

clc;
N=50;
n=0:1:N-1;
x=sin(2*pi*n/20)+sin(2*pi*n/15);
M=2;
x1=x(1:M:N);
n1=1:1:N/M;
subplot(2,1,1);
stem(n,x);
xlabel('n');
ylabel('x');
title('input sequence');
subplot(2,1,2);
stem(n1-1,x1);
xlabel('n');
ylabel('x1');
title('downsampled sequence');

OUTPUT:

RESULT:

Thus we compute Convolution and m-fold decimation by Polyphase


decomposition in MATLAB
51
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

TMS320C5XProcessor Based
Experiments

1. STUDY OF VARIOUS ADDRESSING MODES

2. (a) CIRCULAR CONVOLUTION

(b) LINEAR CONVALUTION

3. SINE WAVE GENERATION

4. SQUAREWAVE GENERRATION

5. SAWTOOTH WAVE GENERRATION

6. TRIANGULAR WAVEFORM GENERRATION

7. IMPLEMENTATION OF IIR FILTER

8. IMPLEMENTATION OF FIR FILTER

52
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 1

STUDY OF TMS320C50 PROCESSOR


Expt. No: 1

STUDY OF ARCHITECTURE OF DIGITAL SIGNAL PROCESSOR

AIM:

To study the Architecture of TMS320VC67XX DSP processor. And TMS320C50


PROCESSOR

Architecture of TMS320VC67XX DSP processor

he hardware experiments in the DSP lab are carried out on the Texas
Instruments TMS320C6713 DSP Starter Kit (DSK), based on the TMS320C6713
floating point DSP running at 225MHz. The basic clock cycle instruction time is
1/(225 MHz)= 4.44 nanoseconds. During each clock cycle, up to eight instructions
can be carried out in parallel, achieving up to 8×225 = 1800 million instructions per
second (MIPS). The DSK board includes a 16MB SDRAM memory and a 512KB
Flash ROM. It has an on-board 16-bit audio stereo codec (the Texas Instruments
AIC23B) that serves both as an A/D and a D/A converter. There are four 3.5 mm
audio jacks for microphone and stereo line input, and speaker and headphone
outputs. The AIC23 codec can be programmed to sample audio inputs at the
following sampling rates: fs = 8, 16, 24, 32, 44.1, 48, 96 kHz The ADC part of the
codec is implemented as a multi-bit third-order noise-shaping delta-sigma
converter) that allows a variety of oversampling ratios that can realize the above
choices of fs. The corresponding oversampling decimation filters act as anti-
aliasing pre-filters that limit the spectrum of the input analog signals effectively to
the Nyquist interval [−fs/2,fs/2]. The DAC part is similarly implemented as a multi-
53
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

bit second-order noise-shaping delta-sigma converter whose oversampling


interpolation filters act as almost ideal reconstruction filters with the Nyquist
interval as their pass band. The DSK also has four user-programmable DIP
switches and four LEDs that can be used to control and monitor programs running
on the DSP. All features of the DSK are managed by the Code Composer Studio
(CCS). The CCS is a complete integrated development environment (IDE) that
includes an optimizing C/C++ compiler, assembler, linker, debugger, and program
loader. The CCS communicates with the DSK via a USB connection to a PC. In
addition to facilitating all programming aspects of the C6713 DSP, the CCS can
also read signals stored on the DSP‟s memory, or the SDRAM, and plot them in
the time or frequency domains. The following block diagram depicts the overall
operations involved in all of the hardware experiments in the DSP lab. Processing
is interrupt-driven at the sampling rate fs, as explained below.

Architecture généraledu starter kit TMS320C50


Architecture generated starter kit TMS320C50

Schéma de la carte
La carte starter kit TMS320C50 que vous avez à disposition contient (Cf. Figure 1)
- Un DSP TMS320C50 (16 bits, virgule fixe, cycle 50ns)
- Une mémoire PROM de 32 ko
- Un circuit analogique d'interface (AIC) TLC32040
54
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

- Des connecteurs RCA entrée/sortie audio


- Un circuit d'horloge
- Un port-série qui permet le chargement de codes via un PC

Figure 1 : Schéma général de la carte starterkit TMS320C5x

Organisation de la mémoire
La carte starter kit TMS320C50 comprend une mémoire PROM-8bits de 32 K
réservée pour le noyau (kernel) qui est parcourue au démarrage du DSP et une
mémoire RAM de 10 K pour les programmes application. Au niveau CPU (Voir
Figure 3) du TMS320C50, on trouve une Single-Access RAM (SARAM) et trois
(B0,B1,B2) Dual-Access RAM (DARAM). La DARAM B2 est une mémoire tampon
des registres de status.La plan général d'adressage mémoire de la carte TMS320C50
est donnée Figure 2.

55
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Figure 2 : Plan d'adressagemémoire de la carte starterkit TMS320C5x


Dans le fichier pass.asm (Cf. Annexe 6.2), on peut relever les instructions .ds
0F00h, .ps 080Ah et .ps 0A00h qui permettent d'implanter à différentes adresses
mémoire les mots de données, les routines d'interruption et le code d'initialisation.

Schéma fonctionnel de l'unité centrale de calcul (CPU)


Le schéma fonctionnel du CPU du TMS320C50 est donné Figure 2. Vous en
trouverez une description complète p. 3-4 de la référence [1].

On peut noter sur ce schéma :

- la présence de deux bus (data, Program),

- le type d'opérande du multiplieur et leur taille,

- le nombre et la position des 'scaler',


- la taille de l'accumulateur.

56
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

57
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

STUDY OF ADDRESSING MODES

AIM:
To study about direct, indirect and immediate addressing modes in
TMS320C50 debugger.

APPARATUS REQUIRED:
1.System with TMS 320C50 debugger software
2.TMS 320C50 Kit.

ALGORITHM:
IMMEDIATE ADDRESSING MODE:
1. Initialize data pointer with 100H data.
2. Load the accumulator with first data.
3. Add the second data with accumulator content.
4. Store the accumulator content in specified address location.
DIRECT ADDRESSING MODE:
1. Initialize data pointer with 100H data.
2. Load the accumulator with first data, whose address is specified in the
instruction.
3. Add the accumulator content with second data, whose address is specified
in the instruction.
4. Store the accumulator content in specified address location.
IN-DIRECT ADDRESSING MODE:
1. Load the auxiliary register with address location of first data.
2. The auxiliary register (AR0) is modified indirectly as # symbol.
3. Load the second data into accumulator and perform addition operation.
4. Store the result.

58
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

PROGRAM:
;program for immediate addressing mode
.mmregs
.text
START:
LDP #100H
LACC #1241H
ADD #1200H
SACL 2H
H: B H
;program for direct addressing mode
.mmregs
.text
START:
LDP #100H
LACC 0H
ADD 1H
SACL 2H
H: B H
;program for adding two numbers with indirect addressing mode.
.mmregs
.text
START:
LAR AR0,#8000H
MAR *,AR0
LACC *+,0 ;WITH ZERO SHIFT
ADD *+
SACL *+
H: B H

RESULT:
Thus, the arithmetic operations using TMS320 kit was performed
successfully.

59
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 2(a)

Date: CIRCULAR CONVOLUTION

AIM:

To write a program to find the Convolution of two sequences X(n) and


H(n) Using TMS320C50 debugger.

APPARATUS REQUIRED:

1. System with TMS 320C50 debugger software

2. TMS 320C50 Kit.

3. RS232 cable
PROGRAM LOGIC:

1. Start the Program.

2. Load the LSB’s of the address data memory location.

3. Load the contents of the address data memory location into auxiliary register.

4. Modify the current AR as specified.

5. Load the content of addressed data memory location.

6. Store the 16 LSBs of the accumulator into the address data memory location.

7. Load the content in ARL Z.0

8. Branch the contents of entire auxiliary register.

9. Load the content AR.1,AR.2,AR.0

10. Store the content of the accumulator ’

11. Modify the current AR as specified.

12. Stop the program.

.mmregs
.text
60
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

START:
LDP #100H
LACC 0H ;length of the input is given in 8000
SUB #1H
SACL 1H
LAR AR0,1H
LAR AR1,#8060H;
LAR AR2,#8100H
COPYX2:
MAR *,AR1
LACC *+
MAR *,AR2
SACL *+
MAR *,AR0
BANZ COPYX2,*-
LAR AR0,1H
LAR AR2,#8010H
LOOP3:
LAR AR1,#8060H ;give the inputs x1[n] & h2[n] in AR1 & AR3
LAR AR3,#8050H
LAR AR4,1H
ZAP
LOOP:
MAR *,AR3 ;multiply x1[n] & X2[n] and add the
;multiplication
LT *+
MAR *,AR1 ;output
MPY *+
SPL 5H ;store the partial result at location 8005
ADD 5H ; add the partial result with accumulator
MAR *,AR4
BANZ LOOP,*-,
MAR *,AR2
;outputs of correlation are stored in AR2
SACL *+
CALL ROTATE
LOOP2:
MAR *,AR0
BANZ LOOP3,*-

61
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

H: B H
ROTATE:
LDP #100H ;rotate the values of X1[n]
LACC 1H
SUB #1H
SACL 2H
LACC 0050H
SACB ; 8050 DATA MOVED TO THE ACCUMULATOR TO THE
ACCUMULATOR BUFFER
LAR AR3,#8051H
LAR AR5,#8070H
LAR AR6,2H
LOOP1:
MAR *,AR3
LACC *+
MAR *,AR5
SACL *+,
MAR *,AR6
BANZ LOOP1,*-; DATA FROM 8051-8053 TO 8070-8072
LACB ;MOVE THE DATA ACCUMULATOR BUFFER TO
ACCUMULATOR AS LAST DATA
MAR *,AR5
SACL *+
LACC #8070H
SAMM BMAR
LAR AR3,#8050H
MAR *,AR3
RPT #3H ;ROTATE 4 TIMES
BLDD BMAR,*+ ;BMAR AUTOMATICALLY INCREMENTED ,TO
COPY SHIFTED DATA TO 8050
RET

62
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

INPUT:

; 8000-0004

;X1(n) = 8050 - 0002

; 8051 - 0001

; 8052 - 0002

; 8053 - 0001

;H2(n ) = 8060 - 0001

; 8061 - 0002

; 8062 - 0003

; 8063 - 0004

;OUTPUT:

; 8010-000E

; 8011-0010

; 8012-000E

; 8013-0010

RESULT:

Thus the circular convolution of two sequences is done successfully by


using TMS320C50.

63
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 2 (b)

Date: LINEAR CONVALUTION

AIM:

To write a program to find the Convolution of two sequences X(n) and


H(n) Using TMS320C50 debugger.

APPARATUS REQUIRED:

1. System with TMS 320C50 debugger software

2. TMS 320C50 Kit.

3. RS232 cable
LINEAR CONVOLUTION

1. Start the program.

2. LPD will load the 9LSB’s of address data memory. Location or immediate value
into the data pointer (DP) registers.

3. Load auxiliary register (LAR) loads the content of the address data

Memory location into the designated auxilary registers.

4. Then ZC clears the content of accumulator too.

5. MAR modify current AR and ARP as specified.

6. The RPT load the 8 bit LSBs of the addressed value of the RPT.

7. The SACL store the 16 LSBs of the accumulator into the addressed data

memory.

8. MUL is used to multiply the content of T register.

9. The LTP would load the contents of the addressed data memory location into T
register.

10. ADD will add the content of the memory.

11. LACC is used to load the content of the addressed data memory into acc.

64
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.mmregs
.text
START:
LDP #02H
LAR AR1,#8100H ; x(n) datas
lar ar0,#08200H ;h(n) datas
LAR AR3,#8300H ;y(n) starting
LAR AR4,#0007 ;N1+N2-1
;to fold the h(n) values
;************************
lar ar0,#8203H ; data mem 8200 to program mem c100(tblw)
lacc #0c100h
mar *,ar0
rpt #3
tblw *- ;to move 8203- 8200 to c100- c103
;padding of zerros for x(n) values
;**********************************
lar ar6,#8104h
mar *,ar6
lacc #0h
rpt #3h
sacl *+
;convalution operation starts
;******************************
LOP: MAR *,AR1
LACC *+
SACL 050H ;starting of the scope of multiplication
LAR AR2,#0153H ; end of the array, to be multiplied with h(n) {150+N1-1}
MAR *,AR2
ZAP
RPT #03H ;N1-1 times so that N1 times
MACD 0C100H,*-
APAC ;to accmulate the final product sample
MAR *,AR3
SACL *+
MAR *,AR4
BANZ LOP,*-

H: B H

INPUT ( x(n) )

65
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

;8100 - 1

;8101 - 3

;8102 - 1

;8103 - 3

;INPUT ( h(n) )

; 8200 - 0

; 8201 - 1

; 8202 - 2

; 8203 - 1

;OUTPUT ( y(n) )

; 8300 - 1

; 8301 - 5

; 8302 - 8

; 8303 - 8

; 8304 - 7

; 8305 - 3

; 8306 - 0

RESULT:

Thus the linear convolution of two sequences is done successfully by using


TMS320C50.

66
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 3

Date: SINE WAVE GENERATION

AIM:

To write a program to generate Sine Wave using TMS320C50 debugger.

APPARATUS REQUIRED:

1.System with TMS 320C50 debugger software

2.TMS 320C50 Kit.

3.CR0

4.Function Generator.

ALGORITHM:
1. Start the program

2. Load the LSBs of the address data memory location

3. Write full 16 bit pattern into address data memory location.

4. Load the content of address data memory location.Specify the address of a

subroutine.

5. Multiply the content of the register.

6. Load the content of the register into accumulator.

7. Store the 16 LSBs of the accumulator into the address data memory

location.

8. Modify the current AR & ARP as specified.

9. Branch the contents of entire auxiliary register.

10. Load the content of address data memory location.

11. Repeat the Step.

12. Stop the program.

67
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

SINE WAVE GENERATION ( 1 KHZ)


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 100
.word 101

68
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 103
.word 105
.word 106
.word 108
.word 110
.word 112
.word 113
.word 115
.word 117
.word 119
.word 120
.word 122
.word 124
.word 125
.word 127
.word 129
.word 130
.word 132
.word 134
.word 135
.word 137
.word 139
.word 140
.word 142
.word 143
.word 145
.word 146
.word 148
.word 150
.word 151
.word 152
.word 154
.word 155
.word 157
.word 158
.word 160
.word 161
.word 162
.word 164
.word 165
.word 166
.word 168
.word 169
.word 170
.word 171
.word 173
.word 174
.word 175
.word 176
.word 177
.word 178
.word 179
.word 180
.word 181
.word 182
.word 183
.word 184
.word 185
69
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 186
.word 187
.word 188
.word 189
.word 189
.word 190
.word 191
.word 192
.word 192
.word 193
.word 193
.word 194
.word 195
.word 195
.word 196
.word 196
.word 197
.word 197
.word 197
.word 198
.word 198
.word 198
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 200
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 199
.word 198
.word 198
.word 198
.word 197
.word 197
.word 197
.word 196
.word 196
.word 195
.word 195
.word 194
.word 193
.word 193
.word 192
.word 192
.word 191
.word 190
.word 189
.word 189
70
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 188
.word 187
.word 186
.word 185
.word 184
.word 183
.word 182
.word 181
.word 180
.word 179
.word 178
.word 177
.word 176
.word 175
.word 174
.word 173
.word 171
.word 170
.word 169
.word 168
.word 166
.word 165
.word 164
.word 162
.word 161
.word 160
.word 158
.word 157
.word 155
.word 154
.word 152
.word 151
.word 149
.word 148
.word 146
.word 145
.word 143
.word 142
.word 140
.word 139
.word 137
.word 135
.word 134
.word 132
.word 130
.word 129
.word 127
.word 125
.word 124
.word 122
.word 120
.word 119
.word 117
.word 115
.word 113
.word 112
.word 110
.word 108
71
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 106
.word 105
.word 103
.word 101
.word 99
.word 98
.word 96
.word 94
.word 93
.word 91
.word 89
.word 87
.word 86
.word 84
.word 82
.word 80
.word 79
.word 77
.word 75
.word 74
.word 72
.word 70
.word 69
.word 67
.word 65
.word 64
.word 62
.word 60
.word 59
.word 57
.word 56
.word 54
.word 53
.word 51
.word 49
.word 48
.word 47
.word 45
.word 44
.word 42
.word 41
.word 39
.word 38
.word 37
.word 35
.word 34
.word 33
.word 31
.word 30
.word 29
.word 28
.word 26
.word 25
.word 24
.word 23
.word 22
.word 21
.word 20
72
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 19
.word 18
.word 17
.word 16
.word 15
.word 14
.word 13
.word 12
.word 11
.word 10
.word 10
.word 9
.word 8
.word 7
.word 7
.word 6
.word 6
.word 5
.word 4
.word 4
.word 3
.word 3
.word 2
.word 2
.word 2
.word 1
.word 1
.word 1
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 0
.word 1
.word 1
.word 1
.word 2
.word 2
.word 2
.word 3
.word 3
.word 4
.word 4
.word 5
.word 6
.word 6
73
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 7
.word 7
.word 8
.word 9
.word 10
.word 10
.word 11
.word 12
.word 13
.word 14
.word 15
.word 16
.word 17
.word 18
.word 19
.word 20
.word 21
.word 22
.word 23
.word 24
.word 25
.word 26
.word 28
.word 29
.word 30
.word 31
.word 33
.word 34
.word 35
.word 37
.word 38
.word 39
.word 41
.word 42
.word 44
.word 45
.word 47
.word 48
.word 50
.word 51
.word 53
.word 54
.word 56
.word 57
.word 59
.word 60
.word 62
.word 64
.word 65
.word 67
.word 69
.word 70
.word 72
.word 74
.word 75
.word 77
.word 79
.word 80
74
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.word 82
.word 84
.word 86
.word 87
.word 89
.word 91
.word 93
.word 94
.word 96
.word 98
.word 100
.end

RESULT:

Thus the sine waveform was generated and executed using


TMS320C5X.

75
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

EX.NO:4

Date:

SQUAREWAVE GENERATION

AIM:

To write a program to generate square Wave using TMS320C50 debugger.

APPARATUS REQUIRED:

1. System with TMS 320C50 debugger software

2. TMS320C50 Kit.

3. CR0

4. Function Generator.

ALGORITHM:

1. Start the program

2. Load the content of address data memory location.

3. Store the 16 LSBs of the accumulator into the address data memory

location.

4. Load the content of address data memory location.

5. Complement the contents of the accumulator.

6. Stop the program.

76
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.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

RESULT:

Thus the square waveform was generated and executed using


TMS320C5X.

77
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 5

Date: SAWTOOTH WAVEFORM GENERRATION

AIM:

To write a program to generate saw tooth Wave using TMS320C50 debugger.

APPARATUS REQUIRED:

1. System with TMS 320C50 debugger software

2. TMS320C50 Kit.

3. CR0

4. Function Generator.

ALGORITHM:

1. Start the program.

2. Load the LSBs of the address data memory location

3. Load the content of address data memory location into

accumulator.

4. Store the 16 LSBs of the accumulator into the address data

memory location

5. Write 16 bit value from from a data memory location to the

specified I/O Port.

6. Add the content of address data memory location.

7. Subtract the content of the register.

8. Branch the program memory address if the specified conditions are met.

9. Stop the program.

78
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

.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

RESULT:

Thus the saw tooth waveform was generated and executed using
TMS320C5X.

79
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 6

Date: TRIANGULAR WAVEFORM GENERRATION

AIM:

To write a program to generate Triangular Wave using TMS320C50 debugger.

APPARATUS REQUIRED:

1. System with TMS 320C50 debugger software

2. TMS320C50 Kit.

3. CR0

4. Function Generator.

TRIANGLE WAVE GENERATION:

1. Start the program.

2. Load the LSBs of the address data memory location.

3. Write full 16 bit pattern into address data memory location.

4. Load the content of address data memory location.

5. Add the content of address data memory location.

6. Store the data of accumulator into address data memory location.

7. Modify the current AR as specified.

8. Repeat the step 2,3.

9. Subtract the contents of address data memory location.

10. Repeat the steps 5, 6, 7.

11. Stop the program.

80
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

AMPLITUDE .SET 15
FREQ .SET 43
TEMP .SET 0;
.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 Triangular waveform was generated and executed using


TMS320C5X.
81
SEC - ECE EC8562 – DIGITAL SIGNAL PROCESSING

Expt. No: 7

Date: FIR FILTER

AIM:

To design a FIR low pass filter in serial mode.

82

You might also like