Вы находитесь на странице: 1из 26

SKILLED REPORT

EC6511 DIGITAL SIGNAL PROCESSING


LABORATORY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION


ENGINEERING

GANESH COLLEGE OF ENGINEERING,


METTUPATTY, SALEM 111.

1. Write a Mat lab program to perform Linear and Circular convolution of the discrete time
sequences x(n) = { 0,1,0,1} and h(n) = { 1,2,1,2} using DFT.
AIM:
To write the program for finding the linear and circular convolution of two
signals using MATLAB 7.0.
APPARATUS REQUIRED:
System with MATLAB 7.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.
PROGRAM:
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&H Response');

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.
PROGRAM:
% PROGRAM FOR 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 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 & h is');
subplot(2,2,3);
stem(y);
xlabel('Time');
ylabel('Amplitude');
title('Convolution of
X&H Response');

OUTPUT FOR LINEAR CONVOLUTION:

OUTPUT FOR CIRCULAR CONVOLUTION:

RESULT:
Thus the program for finding the linear and circular convolution of two
signals using MATLAB 7.0. was verified successfully].
2. Write a Mat lab program to determine the impulse response of FIR low pass filter and High
pass filter by Fourier series method and hence plot the frequency response.
AIM:
To design a FIR filter using Fourier series method with MATLAB 7.0.
APPARATUS REQUIRED:
System with MATLAB 7.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 and High pass filter.
5. Plot the magnitude response of all the filters.
PROGRAM:
clc;
clear all;
%LOW PASS FILTER
close all;
b=fir1(n,wp,y);
rp=input('Pass band ripple=');
[h,o]=freqz(b,1,256);
rs=input('Stop band ripple=');
m=20*log10(abs(h));
fs=input('Stop band frequency in
subplot(2,2,1);
rad/sec=');
plot(o/pi,m,'k');
fp=input('Pass band frequency in
ylabel('Gain in db---->');
rad/sec=');
xlabel('Normalized frequency---->');
f=input('Sampling frequency in
title('LOW PASS FILTER')
rad/sec=');
wp=2*fp/f;
%HIGH PASS FILTER
ws=2*fs/f;
b=fir1(n,wp,'high',y);
num=-20*log10(sqrt(rp*rs))-13;
[h,o]=freqz(b,1,256);
dem=14.6*(fs-fp)/f;
m=20*log10(abs(h));
n=ceil(num/dem)
subplot(2,2,2);
n1=n+1;
plot(o/pi,m,'k');
if(rem(n,2)~=0);
ylabel('Gain in db---->');
n1=n;
xlabel('Normalized frequency---->');
n=n-1;
title('HIGH PASS FILTER')
end
OUTPUT:

RESULT:
Thus the FIR filter using Fourier series method with MATLAB 7.0. was designed and verified
successfully
.
3. Write a Mat lab program to design an IIR filter (Chebyshev3rd order LPF) to satisfy the
following specifications (Assume T= 1seconds) using BLT method.
0.8|H (ej) |1, for 00.2
|H (ej) |0.2, for 0.32
AIM:
To design a digital IIR filter using Chebyshev filter with MATLAB 7.0.
APPARATUS REQUIRED:
System with MATLAB 7.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.
PROGRAM:
clear all;
clc;
close all;
rp=input(enter the pass band
ripple);
rs=input(enter the stop band
ripple);
wp=input(enter the pass band
frequency );
ws=input(enter the stop band
frequency );
fs=input(enter the sampling
frequency );
w1=2*wp/fs;

w2=2*ws/fs;
%LOW PASS FILTER
[n,wn]=cheb ord(w1,w2,rp,rs];
[b,a]=cheby 1(n,wn);
W=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
Subplot(2,1,1);
Plot(om/pi,m);
Ylabel(gain in db>);
Xlabel((a)normalized
frequency>);
Subplot(2,1,2);

Plot(om/pi,an);
Xlabel((b)normalized

Ylabel(phase in
radians>);

frequency>);
OUTPUT:
OUTPUT FOR CHEBYSHEV IIR DIGITAL FILTER:
Enter the pass band ripple:0.02
Enter the stop band ripple:.03
Enter the pass band frequency:1200
Enter the stop band frequency:2400
Enter the sampling frequency:8000
Filter order
1
Cut-off frequency
0.300000000000000

RESULT:
Thus the digital IIR filter using Chebyshev filter with MATLAB 7.0 was designed and
verified successfully.
4. Write a Mat lab program to determine the impulse response of FIR Low pass filter and
High pass filter by using Rectangular window method and hence plot the frequency
response.
AIM:
To design a FIR filter using Rectangular window with MATLAB 7.0.
APPARATUS REQUIRED:

System with MATLAB 7.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 low pass, high pass, band pass and band stop filter.
5. Plot the magnitude response of all filters.
PROGRAM:
clc;
clear all;
close all;
rp=input('Pass band ripple=');
rs=input('Stop band ripple=');
fs=input('Stop band frequency in
rad/sec=');
fp=input('Pass band frequency in
rad/sec=');
f=input('Sampling frequency in
rad/sec=');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem)
n1=n+1;
if(rem(n,2)~=0);
n1=n;
n=n-1;

end
y=boxcar(n1);
%LOW PASS FILTER
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('LOW PASS FILTER')
%HIGH PASS FILTER
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(o/pi,m,'k');
ylabel('Gain in db---->');
xlabel('Normalized frequency---->');
title('HIGH PASS FILTER')

OUTPUT
Enter the passband ripple: .05
Enter the stopband ripple: .03
Enter the passband frequency: 1300
Enter the stopband frequency: 1600
Enter the sampling frequency: 7400
The order is:n = 26

RESULT:
Thus the matlab program to design a FIR filter using rectangular window was written and the
output was verified.
5. Write a Mat lab program to determine the impulse response of FIR Low pass filter and
High pass filter by using Kaiser window method and hence plot the frequency
response
AIM
To write a matlab program to design a FIR filter using Kaiser window and to verify the output.
ALGORITHM

1. Start the program.


2. Clear the command window using clc function.
3. Get the pass band and stop band ripples.
4. Get the pass band and stop band frequencies.
5. Get the sampling frequency.
6. Calculate the order of filter.
7. Calculate the transfer function of the filter using the coefficients.
8. Plot magnitude and phase responses.
9. End the program.
PROGRAM
%kaiser window computation
clc;
close all;
clear all;

rp=input('Enter the passband ripple: ');


rs=input('Enter the stopband ripple: ');
fp=input('Enter the passband frequency: ');
fs=input('Enter the stopband frequency: ');
f=input('Enter the sampling frequency: ');

beta=input('Enter the beta value:


wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
disp('The order is:');n
y=kaiser(n1,beta);
%lowpass filter
b=fir1(n,wp,y);

');

[h,om]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(om/pi,m);
ylabel('Gain in dB---->');
xlabel('Frequency in rad/sec---->');
%highpass filter
b=fir1(n,wp,'high',y);
[h,om]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(om/pi,m);
ylabel('Gain in dB---->');
xlabel('Frequency in rad/sec---->');

OUTPUT
Enter the passband ripple: .05
Enter the stopband ripple: .03
Enter the passband frequency: 1300
Enter the stopband frequency: 1600
Enter the sampling frequency: 7400
Enter the beta value:
7
The order is:
n = 26

RESULT
Thus the matlab program to design a FIR filter using Kaiser window was written and the output
was verified.

6. Write a Mat lab program to determine the impulse response of FIR Low pass filter and
High pass filter by using triangular window method and hence plot the frequency
response
AIM:
To write a matlab program to design a FIR filter using triangular window and to verify the
output.
ALGORITHM

1. Start the program.


2. Clear the command window using clc function.
3. Get the pass band and stop band ripples.
4. Get the pass band and stop band frequencies.
5. Get the sampling frequency.
6. Calculate the order of filter.
7. Calculate the transfer function of the filter using the coefficients.
8. Plot magnitude and phase responses.
9. End the program.
PROGRAM
%Triangular window computation

y=kaiser(n1,beta);

clc;
close all;
clear all;
rp=input('Enter the passband ripple: ');
rs=input('Enter the stopband ripple: ');
fp=input('Enter the passband frequency: ');
fs=input('Enter the stopband frequency: ');
f=input('Enter the sampling frequency: ');
beta=input('Enter the beta value:
');
wp=2*fp/f;
ws=2*fs/f;
num=-20*log10(sqrt(rp*rs))-13;
dem=14.6*(fs-fp)/f;
n=ceil(num/dem);
n1=n+1;
if(rem(n,2)~=0)
n1=n;
n=n-1;
end
disp('The order is:');n

%lowpass filter
b=fir1(n,wp,y);
[h,om]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,1);
plot(om/pi,m);
ylabel('Gain in dB---->');
xlabel('Frequency in rad/sec---->');
%highpass filter
b=fir1(n,wp,'high',y);
[h,om]=freqz(b,1,256);
m=20*log10(abs(h));
subplot(2,2,2);
plot(om/pi,m);
ylabel('Gain in dB---->');
xlabel('Frequency in rad/sec---->');

OUTPUT:
enter passband ripple0.02
enter the stopband ripple0.01
enter passband freq1000
enter stopband freq1500

10

enter sampling freq 10000


enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
2
Triangular window filter response

G a in in d B -->

GRAPH:
-20
-40
-60

G a in in d B -->

LPF

0.1

0.2

0.3
0.4
0.5
0.6
0.7
(a) Normalized frequency-->
HPF

0.8

0.9

0.1

0.2

0.3
0.4
0.5
0.6
0.7
(b) Normalized frequency-->

0.8

0.9

0
-10
-20
-30

RESULT:
The LP and HP FIR Filter response for the given sequence is generated based upon the choice of the
windowing function and the filter characteristics are plotted.
7. Write a Mat lab program to design an IIR filter (Butterworth 2 nd order LPF & HPF) to
satisfy the following specifications (Assume T= 0.1seconds) using BLT method.
0.6|H (ej) |1, for 0.7
|H (ej) |0.1, for 00.35
AIM:
To design a Butterworth digital IIR filter using MATLAB 7.0.
APPARATUS REQUIRED:
System with MATLAB 7.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.
PROGRAM:
clear all;
clc;
close all;
format long
rp=input(enter the pass band ripple);
rs=input(enter the stop band ripple);
wp=input(enter the pass band
frequency );
ws=input(enter the stop band frequency
);
fs=input(enter the sampling frequency
);
w1=2*wp/fs;

w2=2*ws/fs;
%LOW PASS FILTER
[n,wn]=buttord(w1,w2,rp,rs];
[b,a]=butter(n,wn);
%[b,a]=zp2tf(z,p,k);
[b,a]= butter(n,wn);
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));
an=angle(h);
%figure(1);
Subplot(2,1,1);
Plot(om/pi,m);
Ylabel(gain in db>);

11

Xlabel((a)normalized frequency>);
%figure(1);
Subplot(2,1,2);
Plot(om/pi,an);
Xlabel((b)normalized frequency>);
Ylabel(phase in radians>);
%HIGH PASS FILTER
[n,wn]=buttord(w1,w2,rp,rs];
[b,a]=butter(n,wn,high);
W=0:0.01:pi;
[h,om]=freqz(b,a,w);
m=20*log10(abs(h));

an=angle(h);
figure(2);
Subplot(2,1,1);
Plot(om/pi,m);
Ylabel(gain in db>);
Xlabel((a)normalized frequency>);
figure(2);
Subplot(2,1,2);
Plot(om/pi,an);
Xlabel((b)normalized frequency>);
Ylabel(phase in radians>);

OUTPUT:
Enter the ripple of pass band (rp)= .5
Enter the ripple of stop band (rs)= 50
Enter the frequency of pass band (fp)= 1200
Enter the frequency of stop band (fs)= 2400
Enter the sampling frequency (F)= 10000
Filter order
8
Cut-off frequency
0.273047748609120

12

RESULT:
The LP and HP IIR Filter response for the given sequence is generated and the filter characteristics are
plotted.
8. .

Write a MATLAB program to generate the CT and DT elementary signals and plot it.

AIM
To write a MATLAB program to generate various type of signals.
ALGORITHM
1. Start the program.
2. Clear the command window using clc function.
3. Create the array of time sequence by assigning values oft.
4. Get the input value using the input function for generating
various sequences.
5. Provide matrix values by giving zero and ones values in y.
6. Using subplot function plot the graph and use stem to obtain discrete sequence.
7. Label in the X and Y axis using label function.
8. End the program.
PROGRAM
clc;
clear all;
close all;
%Generation of cosine sequence
t1=0:.01:pi;

y1=cos(2*pi*t1);
figure(1);
subplot(3,2,1);
plot(t1,y1);
ylabel('Amplitude---->');

13

xlabel('(a)n---->');
%Generation of sine sequence
y2=sin(2*pi*t1);
subplot(3,2,2);
plot(t1,y2);
ylabel('Amplitude---->');
xlabel('(b)n---->');
%Generation of exponential sequence
n2=input('Enter the length of
exponential sequence: ');
t3=0:n2;
a=input('Enter the value: ');
y3=exp(a*t3);
subplot(3,2,3);
stem(t3,y3);
ylabel('Amplitude---->');
xlabel('(c)n---->');
%Generation of unit impulse signal
t4=-2:1:2;
y4=[zeros(1,2),ones(1,1),zeros(1,2)];
subplot(3,2,4);

stem(t4,y4);
ylabel('Amplitude---->');
xlabel('(d)n---->');
%Generation of unit step sequence
n5=input('Enter the N value for unit step
sequence: ');
t5=0:1:n5-1;
y5=ones(1,n5);
subplot(3,2,5);
stem(t5,y5);
ylabel('Amplitude---->');
xlabel('(e)n---->');
%Generation of unit ramp sequence
n6=input('Enter the length of ramp
sequence: ');
t6=0:n6;
subplot(3,2,6);
stem(t6,t6);
ylabel('Amplitude---->');
xlabel('(f)n---->');

OUTPUT
Enter the length of exponential sequence: 4
Enter the value: 4
Enter the N value for unit step sequence: 6
Enter the length of ramp sequence: 5

14

9. Write a Mat lab program to perform Auto Correlation and Cross correlation of the discrete
time sequences x(n) = { 1,2,3,4} and h(n) = { 4,3,2,1} using DFT.
AIM:
To perform auto- correlation and cross- correlation of given sequences in MATLAB.
ALGORITHM:

Start MATLAB.
Enter the input sequence.
Give Xlabel and Ylabel and title it.
Save and run the program.
Stop/Halt the program.

PROGRAM:
%Auto Correlation%
x= input (Enter any sequence);
subplot(3,2,1);
stem(x);
xlabel(Time period);
ylabel(Amplitude);
title(Input sequence);
y=xcorr(x);
subplot(3,2,2);
xlabel(Time period);
ylabel(Amplitude);
title(Auto correlation);

15

%Cross correlation%
x=input(Enter any sequence);
subplot(3,2,1);
stem(x);
xlabel(Time period);
ylabel(Amplitude);
title(Input sequence);
h=input(Enter any sequence);
subplot(3,2,2);
stem(h);
xlabel(Time period);
ylabel(Amplitude);
title(Impulse sequence);
y=xcorr(x,h);
subplot(3,2,3);
stem(y);
xlabel(Time period);
ylabel(Amplitude);
title(Cross correlation);

16

RESULT:
Thus, the auto- correlation and cross- correlation was performed using MATLAB
10. Write a program to study the various addressing modes of DSP using DSP processor.
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.
5. DIRECT ADDRESSING MODE:
6. Initialize data pointer with 100H data.
7. Load the accumulator with first data, whose address is specified in the
8. instruction.
9. Add the accumulator content with second data, whose address is specified
10. in the instruction.
11. Store the accumulator content in specified address location.
IN-DIRECT ADDRESSING MODE:
1. Load the auxiliary register with address location of first data.

17

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.
PROGRAM:
;program for immediate addressing mode
.mmregs
.text
START:
LDP #100H
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 addressing modes of DSP using DSP processor was studied.
11. Write and execute a DSP Processor program to the Linear/circular convolution of the any two
sequences.
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.
LINEAR CONVOLUTION
ALGORITHM:
1. Start the program.

18

2. LPD will load the 9LSBs of address data memory.


Location or immediate value into the data pointer (DP) register.
3. Load auxiliary register (LAR) loads the content of the address data
memory location into the designated auxilary register.
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
accumulator.
PROGRAM:
;Program for Linear Convolution
.
MMREGS
.TEXT
START:
LDP #100H
LAR AR1,#(8100H+4H)
ZAC
MAR *,AR1
RPT#2H
SACL*+
LAR AR1,#(8200H+4H)
ZAC
MAR *,AR1
RPT#2H
SACL*+
LAR AR3,#(8300H+6H)
LAR 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 *;Shiftx(n) Values:
LAR AR1,#(8100H+6H)
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,*NOP
H1: B H1

CIRCULAR CONVOLUTION
ALGORITHM:

19

1. Start the Program.


2. Load the LSBs 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.
PROGRAM:
;Program for Circular Convolution
.MMREGS
.TEXT
LDP #100H
LACC 0H
SUB #1H
SACL 1H
LAR AR0,1H
LAR AR2,#8010H
LOOP3: LAR AR1,#8060H
LAR AR3,#8050H
LAR AR4,1H
ZAP
LOOP:MAR *,AR3
LT *+,AR1
MPY *+
SPL 5H
ADD 5H
MAR *,AR4
BANZ LOOP,*-,AR2
SACL *+
CALL ROTATE
LOOP2:MAR *,AR0
BANZ LOOP3,*H: B H

ROTATE:
LDP #100H
LACC 1H
SUB #1H
SACL 2H
LACC 0050H
SACB
LAR AR3,#8051H
LAR AR5,#8070H
LAR AR6,2H
LOOP1:MAR *,AR3
LACC *+,0,AR5
SACL *+,0,AR6
BANZ LOOP1,*LACB
MAR *,AR5
SACL *+
LACC #8070H
SAMM BMAR
LAR AR3,#8050H
MAR *,AR3
RPT 0H
BLDD BMAR,*+
RET

RESULT:
Thus the program to find the Convolution of two sequences X(n) and H(n) using TMS320C50
debugger was designed and verified successfully.
. 12. Write and execute a DSP PROCESSOR program to Generate a Square wave using
TMS320C50.

20

AIM:
To write a program to generate Triangle Wave,Sine Wave,Square Wave and SawTooth Wave
using TMS320C50 debugger.
APPARATUS REQUIRED:
1.System with TMS 320C50 debugger software
2.TMS 320C50 Kit.
3.CR0
4.Function Generator.
ALGORITHM:
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.
SINE 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.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.
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.
SQUARE WAVE GENERATION:
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.

;Program for Sine Wave Generation


INCFREQ .SET 10
DECFREQ .SET 0
LENGTH .SET 360
AMPLITUDE .SET 5
DELAY1 .SET 7
TEMP .SET 0
TEMP1 .SET 1
.mmregs

.text
START:LDP #100H
SPLK #B500,TEMP
LAR AR2,#((LENGTH/INCFREQ)+
(LENGTH*DECFREQ))-1
LAR AR3,#DECFREQ
CONT:CALL DELAY
LACC TEMP
TBLR TEMP1

21

LT TEMP1
MPY #AMPLITUDE
PAC
SACL TEMP1
MAR *,AR3
BANZ REPEAT,*LAR AR3,#DECFREQ
LACC TEMP
ADD #INCFREQ
SACL TEMP
OUT TEMP1,4
MAR *,AR2
BANZ CONT,*B START
DELAY:LAR AR7,#DELAY1
MAR *,AR7
BACK:BANZ BACK,*RET
;
TABLE
.word 100 .word 145
.word 101 .word 146
.word 103 .word 148
.word 105 .word 150

.word 106 .word 151


.word 108 .word 152
.word 110 .word 154
.word 112 .word 155
.word 113 .word 157
.word 115 .word 158
.word 117 .word 160
.word 119 .word 161
.word 120 .word 162
.word 122 .word 164
.word 124 .word 165
.word 125 .word 166
.word 127 .word 168
.word 129 .word 169
.word 130 .word 170
.word 132 .word 171
.word 134 .word 173
.word 135 .word 174
.word 137 .word 175
.word 139 .word 176
.word 140 .word 177
.word 142 .word 178
.word 143 .word 179

RESULT:
Thus the program to generate Triangle Wave,Sine Wave,Square Wave and SawTooth Wave using
TMS320C50 debugger.
13. Write a program to determine the impulse response of FIR Low pass filter and Band pass filter
by Fourier series method and hence plot the frequency response by using DSP
Processor.
AIM:
To design a FIR low pass filter in serial mode.
APPARATUS REQUIRED:
1.System with VI debugger software
2.TMS 320C50 Kit.
3.CR0
ALGORITHM:
1. Start the program.
2. Initialize the C table value.
3. Load the auxillary register with
0200H.
4. Modify the auxillary register zero.
5. Block the C table to the program.
6. Set configuration control bit.

7. Load the data pointer with 0AH.


8. Initialize the analog to digital
conversion.
9. Load the auxillary register 1 with
0300 content.
10. Load the accumulator in 8000H.
11. AND the accumulator with 0FFFH.

22

12. Subtract the accumulator content


with data 800H.
13. Modify the auxillary register 1.
14. Store the accumulator data in
8000H.
15. Load the auxillary register 1 with
content 0333H.
16. Zero the accumulator register.
17. Multiply the accumulator with data.
PROGRAM:
*Approximation type:Window designBlackmann Window
*Filter type:Low Pass Filter
*Filter Order:52
*Cutoff frequency in KHZ=3.000000
.mmregs
.text
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
.word 0FF5FH
.word 0FE78H
.word 0FD9AH
.word 0FD10H
.word 0FD30H
.word 0FE42H
.word 071H
.word 03B5H
.word 07CAH
.word 0C34H
.word 01054H
.word 01387H
.word 01547H
.word 01547H
.word 01387H
.word 01054H
.word 0C34H
.word 07CAH

18. Load the program register, with PM


bits to accumulator.
19. Load the auxillary register 1 with
content 0300H.
20. Add accumulator content with 800H.
21. Shift the accumulator right 1 bit.
22. Store the accumulator content in
8200 location.
23. Branch the program to step 7.
.word 03B5H
.word 071H
.word 0FE42H
.word 0FD30H
.word 0FD10H
.word 0FD9AH
.word 0FE78H
.word 0FF5FH
.word 01AH
.word 092H
.word 0C2H
.word 0B9H
.word 08CH
.word 051H
.word 018H
.word 0FFECH
.word 0FFD0H
.word 0FFC4H
.word 0FFC6H
.word 0FFD3H
.word 0FFE7H
* Move the Filter coefficients
* from program memory to data memory
START:
LAR AR0,#0200H
MAR *,AR0
RPT #33H
BLKP CTABLE,*+
SETC CNF
* Input data and perform convolution
ISR: LDP #0AH
IN 0,06H
IN 0,04H
NOP
NOP
NOP
NOP
LAR AR1,#0300H
LACC 0
AND #0FFFH

23

SUB #800H
MAR *,AR1
SACL *
LAR AR1,#0333H
ZAP
RPT #33H
MACD 0FF00H,*APAC
LAR AR1,#0300H

SACH * ; give as SACH *, 1 in case of overflow


LACC *
ADD #800H
SFR ; remove if output is less amplitude
SACL *
OUT *,4 ;pulse to find sampling frequency
NOP
B ISR
.end

RESULT:
Thus the program for FIR low pass filter was designed and verified successfully using TMS
processor.
14. Write and execute a DSP PROCESSOR program to design a 9 tap FIR Low pass Filter
using TMS320C50.
For Answer Refer question no:13
15. Write a Mat lab program to determine the impulse response of IIR High pass filter and
Band stop filter by Fourier series method and hence plot the frequency response by
using DSP processor.
AIM:
To design a FIR high pass filter in serial mode.
APPARATUS REQUIRED:
1.System with VI debugger software
2.TMS 320C50 Kit.
3.CR0
ALGORITHM:
1. Start the program.
2. Initialize the C table value.
3. Load the auxillary register with 0200H.
4. Modify the auxillary register zero.
5. Block the C table to the program.
6. Set configuration control bit.
7. Load the data pointer with 0AH.
8. Initialize the analog to digital conversion.
9. Load the auxillary register 1 with 0300
content.
10. Load the accumulator in 8000H.
11. AND the accumulator with 0FFFH.
12. Subtract the accumulator content with data
800H.
13. Modify the auxillary register 1.
PROGRAM:
*Approximation type:Window designBlackmann Window

14. Store the accumulator data in 8000H.


15. Load the auxillary register 1 with content
0333H.
16. Zero the accumulator register.
17. Multiply the accumulator with data.
18. Load the program register, with PM bits to
accumulator.
19. Load the auxillary register 1 with content
0300H.
20. Add accumulator content with 800H.
21. Shift the accumulator right 1 bit.
22. Store the accumulator content in 8200
location.
23. Branch the program to step 7.

*Filter type:high Pass Filter


*Filter Order:52

24

*Cutoff frequency in
KHZ=3.000000
.text
B START
CTABLE:
.word 0FCD3H
.word 05H
.word 0FCB9H
.word 087H
.word 0FD3FH
.word 01ADH
.word 0FE3DH
.word 0333H
.word 0FF52H
.word 04ABH
.word 0FFF8H
.word 0595H
.word 0FFACH
.word 0590H
.word 0FE11H
.word 047CH
.word 0FB0BH
.word 029DH
.word 0F6BAH
.word 0AEH
.word 0F147H
.word 01CH
.word 0E9FDH
.word 04C5H
.word 0D882H
.word 044BCH
.word 0D882H
.word 04C5H

.word 0E9FDH
.word 01CH
.word 0F147H
.word 0AEH
.word 0F6BAH
.word 029DH
.word 0FB0BH
.word 047CH
.word 0FE11H
.word 0590H
.word 0FFACH
.word 0595H
.word 0FF8H
.word 04ABH
.word 0FF52H
.word 0333H
.word 0FE3DH
.word 01ADH
.word 0FD3FH
.word 087H
.word 0FCB9H
.word 05H
.word 0FCD3H
* Move the Filter coefficients
* from program memory to
data memory
START:
LAR AR0,#0200H
MAR *,AR0
RPT #33H
BLKP CTABLE,*+
SETC CNF

* Input data and perform


convolution
ISR: LDP #0AH
IN 0,06H
IN 0,04H
NOP
NOP
NOP
NOP
LAR AR1,#0300H
LACC 0
AND #0FFFH
SUB #800H
MAR *,AR1
SACL *
LAR AR1,#0333H
ZAP
RPT #33H
MACD 0FF00H,*APAC
LAR AR1,#0300H
SACH * ; give as SACH *, 1
in case of overflow
LACC *
ADD #800H
SFR ; remove if output is less
amplitude
SACL *
OUT *,4 ;pulse to find
sampling frequency
NOP
B ISR
.end

25

RESULT:
Thus the program for designing a FIR high pass filter in serial mode was performed

SKILLED ASSISTANT

INTERNAL EXAMINER

EXTERNAL EXAMINER

Вам также может понравиться