write a mat lab program to perform linear and circular convolution of the discrete time sequences x

32
SKILLED REPORT EC6511 – DIGITAL SIGNAL PROCESSING LABORATORY DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING 1

Upload: d-geetha-durai

Post on 20-Feb-2016

13 views

Category:

Documents


1 download

DESCRIPTION

KLMLKMJL

TRANSCRIPT

Page 1: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

SKILLED REPORT

EC6511 – DIGITAL SIGNAL PROCESSING LABORATORY

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

GANESH COLLEGE OF ENGINEERING,METTUPATTY, SALEM – 111.

1

Page 2: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 twosignals 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’ command3. 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');

2

Page 3: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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:Nj=n-i+1;

if(j<=0)j=N+j;endy(n)=y(n)+x(i)*h(j);endenddisp('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:

3

Page 4: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

RESULT:Thus the program for finding the linear and circular convolution of twosignals 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;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

%LOW PASS FILTERb=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 FILTERb=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:

4

Page 5: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 0≤ω≤0.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 using5.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);

5

Page 6: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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

frequency…>’);

Ylabel(‘phase in radians…>’);

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:6

Page 7: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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;

endy=boxcar(n1);%LOW PASS FILTERb=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 FILTERb=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: .05Enter the stopband ripple: .03Enter the passband frequency: 1300Enter the stopband frequency: 1600Enter the sampling frequency: 7400The order is:n = 26

7

Page 8: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 responseAIM

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 co- efficients.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: ');

8

Page 9: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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;enddisp('The order is:');ny=kaiser(n1,beta);

%lowpass filterb=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 filterb=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: .05Enter the stopband ripple: .03Enter the passband frequency: 1300Enter the stopband frequency: 1600Enter the sampling frequency: 7400Enter the beta value: 7The order is:

n = 26

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

9

Page 10: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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

responseAIM:

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 co- efficients.8. Plot magnitude and phase responses. 9. End the program.

PROGRAM

%Triangular 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;enddisp('The order is:');n

y=kaiser(n1,beta);

%lowpass filterb=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 filterb=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.02enter the stopband ripple0.01enter passband freq1000enter stopband freq1500

10

Page 11: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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

GRAPH:

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-60

-40

-20

0LPF

Gai

n in

dB

-->

(a) Normalized frequency-->

0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1-30

-20

-10

0HPF

Gai

n in

dB

-->

(b) Normalized frequency-->

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

PROGRAM: clear all;

clc;close all;format longrp=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

Page 12: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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

Page 13: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 of‘t’.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 sequencet1=0:.01:pi;

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

13

Page 14: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

xlabel('(a)n---->');%Generation of sine sequencey2=sin(2*pi*t1);subplot(3,2,2);plot(t1,y2);ylabel('Amplitude---->');xlabel('(b)n---->');%Generation of exponential sequencen2=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 signalt4=-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 sequencen5=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 sequencen6=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: 4Enter the value: 4Enter the N value for unit step sequence: 6Enter the length of ramp sequence: 5

14

Page 15: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 X‐label and Y‐label 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

Page 16: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

%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

Page 17: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 software2.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 the8. instruction.9. Add the accumulator content with second data, whose address is specified10. 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

Page 18: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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.textSTART:LDP #100HADD #1200HSACL 2HH: B H;program for direct addressing mode.mmregs.textSTART:LDP #100HLACC 0HADD 1HSACL 2HH: B H;program for adding two numbers with indirect addressing mode..mmregs.textSTART:LAR AR0,#8000HMAR *,AR0LACC *+,0 ;WITH ZERO SHIFTADD *+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 software2.TMS 320C50 Kit.

LINEAR CONVOLUTIONALGORITHM:

1. Start the program.

18

Page 19: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

2. LPD will load the 9LSB’s 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 datamemory 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 datamemory.8. MUL is used to multiply the content of T register.9. The LTP would load the contents of the addressed data memory locationinto T register.10. ADD will add the content of the memory.11. LACC is used to load the content of the addressed data memory intoaccumulator.

PROGRAM:

;Program for Linear Convolution.MMREGS.TEXTSTART:LDP #100HLAR AR1,#(8100H+4H)ZAC

MAR *,AR1RPT#2HSACL*+LAR AR1,#(8200H+4H)ZACMAR *,AR1RPT#2HSACL*+LAR AR3,#(8300H+6H)LAR AR4,#06H;Multiply & Accumulate:Next_YN:LAR AR1,#8100HLAR AR2,#(8200H+6H)LAR AR0,#06HZACSACL 0HMAR *,AR1LT *+,AR2Loop_MAC:

MPY *-,AR1LTP *+,AR0ADD 0HSACL 0HBANZ Loop_MAC,*-,AR2LACC 0HMAR *,AR3SACL *-;Shiftx(n) Values:LAR AR1,#(8100H+6H)LAR AR2,#5HLAR AR0,#2HMAR *,AR1LACC *-SACL 1HShift_XN:LACC *+SACL *0-,AR2BANZ Shift_XN,*-,AR1MAR *+LACC 1HSACL *,AR4BANZ Next_YN,*-

NOPH1: B H1

CIRCULAR CONVOLUTION

ALGORITHM:

19

Page 20: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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.08. Branch the contents of entire auxiliary register.9. Load the content AR.1,AR.2,AR.010. Store the content of the accumulator’11. Modify the current AR as specified.12. Stop the program.

PROGRAM:

;Program for Circular Convolution

.MMREGS

.TEXTLDP #100HLACC 0HSUB #1HSACL 1HLAR AR0,1HLAR AR2,#8010HLOOP3: LAR AR1,#8060HLAR AR3,#8050HLAR AR4,1HZAP

LOOP:MAR *,AR3LT *+,AR1MPY *+SPL 5HADD 5HMAR *,AR4BANZ LOOP,*-,AR2SACL *+CALL ROTATELOOP2:MAR *,AR0BANZ LOOP3,*-H: B H

ROTATE:LDP #100HLACC 1HSUB #1HSACL 2HLACC 0050HSACBLAR AR3,#8051HLAR AR5,#8070HLAR AR6,2HLOOP1:MAR *,AR3LACC *+,0,AR5SACL *+,0,AR6BANZ LOOP1,*-LACBMAR *,AR5SACL *+LACC #8070HSAMM BMARLAR AR3,#8050HMAR *,AR3RPT 0HBLDD 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

Page 21: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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 software2.TMS 320C50 Kit.3.CR04.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 program2. Load the LSBs of the address data memory location3. 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 memorylocation.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 program2. Load the content of address data memory location.3. Store the 16 LSBs of the accumulator into the address data memorylocation.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 10DECFREQ .SET 0LENGTH .SET 360AMPLITUDE .SET 5DELAY1 .SET 7TEMP .SET 0TEMP1 .SET 1.mmregs

.textSTART:LDP #100HSPLK #B500,TEMPLAR AR2,#((LENGTH/INCFREQ)+(LENGTH*DECFREQ))-1LAR AR3,#DECFREQCONT:CALL DELAYLACC TEMPTBLR TEMP1

21

Page 22: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

LT TEMP1MPY #AMPLITUDEPACSACL TEMP1MAR *,AR3BANZ REPEAT,*-LAR AR3,#DECFREQLACC TEMPADD #INCFREQSACL TEMPOUT TEMP1,4MAR *,AR2BANZ CONT,*-B STARTDELAY:LAR AR7,#DELAY1MAR *,AR7BACK: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 software2.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

Page 23: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

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.

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.

PROGRAM:*Approximation type:Window design- Blackmann Window*Filter type:Low Pass Filter*Filter Order:52*Cutoff frequency in KHZ=3.000000.mmregs.textB STARTCTABLE:.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

.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 memorySTART:LAR AR0,#0200HMAR *,AR0RPT #33HBLKP CTABLE,*+SETC CNF* Input data and perform convolutionISR: LDP #0AHIN 0,06HIN 0,04HNOPNOPNOPNOPLAR AR1,#0300HLACC 0AND #0FFFH

23

Page 24: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

SUB #800HMAR *,AR1SACL *LAR AR1,#0333HZAPRPT #33HMACD 0FF00H,*-APACLAR AR1,#0300H

SACH * ; give as SACH *, 1 in case of overflowLACC *ADD #800HSFR ; remove if output is less amplitudeSACL *OUT *,4 ;pulse to find sampling frequencyNOPB 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 software2.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.

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.

PROGRAM:*Approximation type:Window design- Blackmann Window

*Filter type:high Pass Filter*Filter Order:52

24

Page 25: Write a Mat Lab Program to Perform Linear and Circular Convolution of the Discrete Time Sequences x

*Cutoff frequency in KHZ=3.000000.textB STARTCTABLE:.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 memorySTART:LAR AR0,#0200HMAR *,AR0RPT #33HBLKP CTABLE,*+SETC CNF

* Input data and perform convolutionISR: LDP #0AHIN 0,06HIN 0,04HNOPNOPNOPNOPLAR AR1,#0300HLACC 0AND #0FFFHSUB #800HMAR *,AR1SACL *LAR AR1,#0333HZAPRPT #33HMACD 0FF00H,*-APACLAR AR1,#0300HSACH * ; give as SACH *, 1 in case of overflowLACC *ADD #800HSFR ; remove if output is less amplitudeSACL *OUT *,4 ;pulse to find sampling frequencyNOPB ISR.end

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

SKILLED ASSISTANT INTERNAL EXAMINER EXTERNAL EXAMINER

25