You are on page 1of 44

Department of ECE

EC2306 Digital Signal Processing Lab

LAB MANUAL

VEL TECH HIGH TECH Dr.RANGARAJAN Dr.SAKUNTHALA ENGINEERING COLLEGE


(Owned by VEL Sree R.Rangarajan Dr. Sagunthala Rangarajan Educational Academy) Approved by AICTE, New Delhi & Affiliated to Anna University
No 42, Alamathi Road, Near Avadi Chennai 600 062

( ISO 9001: 2000 Certified Institution & NBA Accredited )

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


EC2306 - DIGITAL SIGNAL PROCESSING LAB III YEAR V SEM ECE

Department of ECE

EC2306 Digital Signal Processing Lab

Prepared By

HOD/ECE

FACULTY OF INFORMATION AND COMMUNICATION ENGINEERING V SEMESTER B. E. ELECTRONICS AND COMMUNICATION ENGINEERING (R 2008) EC2306 DIGITAL SIGNAL PROCESSING LABORATORY REQUIREMENT FOR A BATCH OF 30 STUDENTS S.No. Description of Equipment PCs with Fixed / Floating point DSP Processors (Kit / Add-on Cards) List of software required: MATLAB with Simulink and Signal Processing Tool Box Function Generators (1MHz) CRO (20MHz) Quantity required 15 Units (2 students per system) 10 Users license Quantity available Deficiency %

1.

2.

3. 4.

15 15

Department of ECE

EC2306 Digital Signal Processing Lab

EC2306 - DIGITAL SIGNAL PROCESSING LAB


AIM To introduce the student to various digital Signal Processing techniques using TMS 320c5x family processors and MATLAB. OBJECTIVES To implement the processing techniques using the instructions of TMS320C5X/TMS320C 67XX/ADSP 218X/219X/BS531/532/561 To implement the IIR and FIR filter using MATLAB. LIST OF EXPERIMENTS USING TMS320C5X/TMS320C 67XX/ADSP 218X/219X/BS531/532/561 1. 2. 3. 4. 5. 1. 2. 3. 4. 5. 6. 7. Study of various addressing modes of DSP using simple programming examples Implementation of Linear and Circular Convolution Sampling of input signal and display Waveform generation Implementation of FIR filter Generation of Signals Linear and circular convolution of two sequences Sampling and effect of aliasing Design of FIR filters Design of IIR filters Calculation of FFT of a signal Decimation by polyphase decomposition.

USING MATLAB

Department of ECE

EC2306 Digital Signal Processing Lab

S.NO 1. 2. 3. 4. 5 6. 7.

NAME OF THE EXPERIMENT

PAGE NO 5 10 13 16 20 22 24

USING MATLAB
Generation of Signals. Linear and circular convolution of two sequences. Sampling and effect of aliasing. Design of Butterworth / Chebyshev IIR filters. Design of FIR filters. Calculation of FFT of a signal. Decimation by polyphase decomposition.

USING TMS320C5X
8.
9. STUDY OF VARIOUS ADDRESSING OF DSP USING SIMPLE PROGRAMMING EXAMPLES. WAVEFORM GENERATION

27-29

1. Generation of square wave by using TMS320C50. 2. Generation of saw tooth wave by using TMS320C50. 3. Generation of Triangular wave by using TMS320C50. 10. 11. 12. Perform linear and circular convolution of two sequences. Sampling of input signal and display Implementation of FIR filters.

27 28 29 30 35 40

Department of ECE

EC2306 Digital Signal Processing Lab

GENERATION OF INPUT SIGNALS AIM


To generate a continuous time signal (Unit Step , Unit Ramp, Sine, Cosine, Square, and Saw tooth ) and discrete time signal (Unit Step , Unit Ramp, Sine, Cosine, Exponential and Unit impulse) using MATLAB function.

ALGORITHM
1. Get the length of different input sequence. 2. To plot the different input sequence.

A) PROGRAM FOR CONTINUOUS TIME SIGNALS


%program for unit step signal clc; t=0:1:10; y=ones(1,11); subplot(3,2,1); plot(t,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Unit Step Signal'); %Program for unit ramp signal t1=0:1:10; y1=t1; subplot(3,2,2); plot(t1,y1,'k'); xlabel('Time'); ylabel('Amplitude'); title('Unit Ramp Signal'); %Program for sine wave t=0:0.1:10; y=sin(2*pi*t); subplot(3,2,3); plot(t,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Sine wave'); %Program for cosine wave t=0:0.1:10; y=cos(2*pi*t); subplot(3,2,4); plot(t,y,'k'); xlabel('Time'); 5

Department of ECE ylabel('Amplitude'); title('Cosine wave'); %Program for square wave t=0:0.001:10; y=square(t); subplot(3,2,5); plot(t,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Square wave'); %Program for sawtooth wave t=0:0.1:10; y=sawtooth(t); subplot(3,2,6); plot(t,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Sawtooth wave'); %program for impulse wave t=-3:1:3; y=[zeros(1,3),ones(1,1),zeros(1,3)]; subplot(3,2,7); plot (n,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Unit impulse'); %Program for exponential sequence N=input('Enter the length of the exponential sequence(N)= '); n=0:1:N-1; a=input('Enter the value of the exponential sequence(a)= '); y=exp(a*n); subplot(3,2,1); plot (n,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Exponential sequence');

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE

Department of ECE

EC2306 Digital Signal Processing Lab

B) PROGRAM FOR DISCRETE TIME SIGNALS


%Program for unit step sequence clc; N=input('Enter the lenght of unit step sequence(N)= '); n=0:1:N-1; y=ones(1,N); subplot(3,2,1); stem(n,y,'k'); xlabel('Time') ylabel('Amplitude') title('Unit step sequence'); %Program for unit ramp sequence N1=input('Enter the length of unit ramp sequence(N1)= '); n1=0:1:N1-1; y1=n1; subplot(3,2,2); stem(n1,y1,'k'); xlabel('Time'); ylabel('Amplitude'); title('Unit ramp sequence'); 7

Department of ECE %Program for sinusoidal sequence N2=input('Enter the length of sinusoidal sequence(N2)= '); n2=0:0.1:N2-1; y2=sin(2*pi*n2); subplot(3,2,3); stem(n2,y2,'k'); xlabel('Time'); ylabel('Amplitude'); title('Sinusoidal sequence'); %Program for cosine sequence N3=input('Enter the length of the cosine sequence(N3)= '); n3=0:0.1:N3-1; y3=cos(2*pi*n3); subplot(3,2,4); stem(n3,y3,'k'); xlabel('Time'); ylabel('Amplitude'); title('Cosine sequence');

EC2306 Digital Signal Processing Lab

%Program for exponential sequence N4=input('Enter the length of the exponential sequence(N4)= '); n4=0:1:N4-1; a=input('Enter the value of the exponential sequence(a)= '); y4=exp(a*n4); subplot(3,2,5); stem(n4,y4,'k'); xlabel('Time'); ylabel('Amplitude'); title('Exponential sequence'); %Program for unit impulse n=-3:1:3; y=[zeros(1,3),ones(1,1),zeros(1,3)]; subplot(3,2,6); stem(n,y,'k'); xlabel('Time'); ylabel('Amplitude'); title('Unit impulse');

INPUT DATA
Enter the lenght of unit step sequence(N)= 10 Enter the length of unit ramp sequence(N1)= 10 Enter the length of sinusoidal sequence(N2)= 2 Enter the length of the cosine sequence(N3)= 2 Enter the length of the exponential sequence(N4)= 10 Enter the value of the exponential sequence(a)= 0.5 8

Department of ECE

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE

Department of ECE

EC2306 Digital Signal Processing Lab

RESULT
Thus the continuous time signal and discrete time signal using MATLAB program was generated.

PERFORM LINEAR AND CIRCULAR CONVOLUTION OF TWO SEQUENCES AIM


To perform Linear and Circular convolution of the two sequences using MATLAB function.

ALGORITHM
1. Get the two sequence x(n) and h(n) in matrix form. 2. The convolution of the two sequences is given by y ( n) = x ( n ) h ( n ) =
k =

x(k )h(n k )
N 1 n=0

For Linear Convolution For Linear Convolution

y ( n) = x (n) e h(n) = x (n)h(m n) ; 3. Stop the program.

PROGRAM A) PROGRAM FOR LINEAR CONVOLUTION


%Program for linear convolution %input sequence clc; x=input('Enter the input sequence x(n)= '); N1=length(x); n=0:1:(N1-1); subplot(3,1,1); stem(n,x,'k'); xlabel('n----->'); ylabel('Amplitude'); 10

Department of ECE title('input sequence x(n)'); %impulse sequence h=input('Enter the impulse sequence h(n)= '); N2=length(h); n1=0:1:(N2-1); subplot(3,1,2); stem(n1,h,'k'); xlabel('n----->'); ylabel('Amplitude'); title('Impulse sequence h(n)'); %Output Convolution y=conv(x,h) n2=0:1:(N1+N2-2); subplot(3,1,3) stem(n2,y,'k'); xlabel('n----->'); ylabel('Amplitude'); title('Linear convolution of two sequences');

EC2306 Digital Signal Processing Lab

INPUT SEQUENCE
Enter the input sequence x(n)= [1 2 3 4] Enter the impulse sequence h(n)= [4 3 2 1] y= 4 11 20 30 20 11 4

OUPUT RESPONSE

11

Department of ECE

EC2306 Digital Signal Processing Lab

B) PROGRAM FOR CIRCULAR CONVOLUTION


%Program for circular convolution %FIRST SEQUENCE clc; x1=input('Enter the first input sequence x1(n)= '); N1=length(x1); %SECOND SEQUENCE x2=input('Enter the second input sequence x2(n)= '); N2=length(x2); N=max(N1,N2); N3=N1-N2;

%LOOP FOR GETTING EQUAL LENGTH SEQUENCE if(N3==0) x1=[x1,zeros(1,N3)] x2=[x2,zeros(1,N3)] end if(N1>N2) x2=[x2,zeros(1,N3)] end if(N1<N2) x1=[x1,zeros(1,-N3)] 12

Department of ECE end %CIRCULAR CONVOLUTION disp('The output of circular convolution is') for m=1:N %This 'for' loop is for circular shifting sum=0; for k=1:N %This 'for' loop is for summation if((m-k)>=0) %This 'if' loop is for circular folding n=m-k+1; else n=m-k+N+1; end sum=sum+x1(k)*x2(n); end disp(sum) %display the result of circular convolution end

EC2306 Digital Signal Processing Lab

INPUT AND OUTPUT SEQUENCE


Enter the first input sequence x1(n)= [1 -1 2 3] Enter the second input sequence x2(n)= [0 1 2] x2 = 0 1 2 0

The output of circular convolution is 7 7 1 0

RESULT
Thus the Linear and Circular convolution of the two sequences using MATLAB program was performed.

SAMPLING AND EFFECT OF ALIASING. AIM


To study the effect of sampling on the frequency domain quantities at different sampling frequencies. 1000 t j a) Sample xa (t ) = e at Fs = 5000 samples/sec to obtain x1 (n) .Determine and plot X 1 (e ) .
1000 t j b) Sample xa (t ) = e at Fs = 1000 samples/sec to obtain x1 (n) .Determine and plot X 1 (e ) .

ALGORITHM
1. Determine the analog value with respect to variation of time. 13

Department of ECE EC2306 Digital Signal Processing Lab 2. Get the sampling frequency. 3. Determine the discrete value with respect to variation of frequency. 4. Determine the Omega range from max to max . 5. Determine the magnitude of the signal. 6. Draw the discrete time signal and discrete Fourier transform.

PROGRAM SAMPLING AND EFFECT OF ALIASING


clc; %Analog signal t=-0.005:0.00005:0.005; xa=exp(-1000*abs(t)); %Discrete time signal Fs=input('Enter the sampling frequency(Fs)= '); Ts=1/Fs; n=-25:1:25; xn=exp(-1000*abs(n*Ts)); %Discrete time fourier transform N=500; k=0:1:N; w=(2*pi*k/N); X=xn*exp(-j*n'*w); X=abs(X); %omega range from -Wmax to Wmax W=[-fliplr(w),w(2:N+1)]; %X over -Wmax to Wmax interval X=[fliplr(X),X(2:N+1)]; subplot(2,1,1); plot(t*1000,xa,'k'); grid; hold on; stem(n*Ts*1000,xn,'k'); xlabel('time in sec'); ylabel('x(n)'); title('discrete time signal'); gtext('Ts=1msec'); hold off; subplot(2,1,2); plot(W/pi,X,'k'); 14

Department of ECE grid; xlabel('normalised frequency in rad/sec'); ylabel('|X(W)|'); title('discrete time fourier transform');

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE (a) Enter the sampling frequency (Fs) =5000


The maximum frequecy of analog signal (Wm) =1000rad/sec. i.e. sampling frequency is greater than twice the maximum frequecy. i.e.Ws >2Wm i.e.5000>2000 Therefore it satisfies the above condition hence there is no aliasing effect.

(b) Enter the sampling frequency (Fs)=1000


The maximum frequecy of analog signal (Wm)=1000rad/sec. i.e. sampling frequency is greater than twice the maximum frequecy. i.e.Ws >2Wm i.e.1000>2000 Therefore it dose not satsify the above condition hence there is aliasing effect.

15

Department of ECE

EC2306 Digital Signal Processing Lab

RESULT
Thus the effect of sampling on the frequency domain quantities at different sampling frequencies was studied MATLAB program.

DESIGN OF IIR DIGITAL FILTERS AIM


To design a digital Butterworth and chebyshev Low pass IIR Filter from the given specification using MATLAB Function.

ALGORITHM
16

Department of ECE EC2306 Digital Signal Processing Lab 1. Get the pass band and stop band attenuation. 2. Get the pass band and stop band frequencies. 3 Get the sampling frequency 4. Calculate the order and cut off frequency. 5. Find out the filter co-efficient both numerator and denominator. 6. Draw the magnitude and phase response.

A) PROGRAM FOR DESIGN OF BUTTERWORTH DIGITAL IIR FILTER


clc; alphap=input('Enter the passband attenuation in dB (alphap)= '); alphas=input('Enter the stopband attenuation in dB (alphas)= '); omp=input('Enter the stopband frequency in rad/sec (omp)= '); oms=input('Enter the stopband frequency in rad/sec (oms)= '); T=input('Enter the sampling time in sec(T)= '); %Calculate the order of filter and cut-off frequency [N,omc]=buttord(omp,oms,alphap,alphas) %Tofind out coefficient of analog filter [b,a]=butter(N,omc); %To find out the analog filter transfer function Hs=tf(b,a) %To find out the coefficient of digital filter [bz,az]=bilinear(b,a,1/T); %To find out the digital filter transfeer function Hz=tf(bz,az,T) %Draw the magnitude and phase response w=0:0.001:pi; h=freqz(b,a,w); subplot(2,1,1); plot(w/pi,20*log10(abs(h)),'k'); grid; xlabel('Normalised frequency'); ylabel('Gain in dB'); title('Magnitude response'); subplot(2,1,1); plot(w/pi,angle(h),'k'); grid; xlabel('Normalised frequency'); ylabel('Angle in radians'); title('Phase response');

INPUT AND OUTPUT DATA


Enter the passband attenuation in dB (alphap)= 3 Enter the stopband attenuation in dB (alphas)= 16 Enter the stopband frequency in rad/sec (omp)= 0.02 Enter the stopband frequency in rad/sec (oms)= 0.9 Enter the sampling time in sec(T)= 1 17

Department of ECE N= 1 omc = 0.5043 Transfer function: 0.5033 s + 0.5033 ----------------s + 0.006691 Transfer function: 0.7525 z - 0.2508 ----------------z - 0.9933 Sampling time: 1

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE

B) PROGRAM FOR DESIGN OF CHEBYSHEV DIGITAL IIR FILTER


clc; alphap=input('Enter the passband attenuation in dB (alphap)= '); alphas=input('Enter the stopband attenuation in dB (alphas)= '); omp=input('enter the passband frequency in rad/sec(omp)='); oms=input('enter the stopband frequency in rad/sec(oms)='); T=input('enter the sampling time in sec(T)='); 18

Department of ECE %Calculate the order of filter and cut-off frequency [N,omc]=cheb1ord(omp,oms,alphap,alphas); %Tofind out coefficient of analog filter [b,a]=cheby1(N,0.5,omc); %To find out the analog filter transfer function Hs=tf(b,a) %To find out the coefficient of digital filter [bz,az]=bilinear(b,a,1/T); %To find out the digital filter transfeer function Hz=tf(bz,az,T) %Draw the magnitude and phase response w=0:0.001:pi; h=freqz(b,a,w); subplot(2,1,1); plot(w/pi,20*log10(abs(h)),'k'); grid; xlabel('Normalised frequency'); ylabel('Gain in dB'); title('Magnitude response'); subplot(2,1,2); plot(w/pi,angle(h),'k'); grid; xlabel('Normalised frequency'); ylabel('Angle in radians'); title('Phase response');

EC2306 Digital Signal Processing Lab

INPUT AND OUTPUT DATA


Enter the passband attenuation in dB (alphap)= 3 Enter the stopband attenuation in dB (alphas)= 16 enter the passband frequency in rad/sec(omp)=0.02 enter the stopband frequency in rad/sec(oms)=0.9 enter the sampling time in sec(T)=1 N= 1 omc = 0.5043 19

Department of ECE Transfer function: 0.08254 s + 0.08254 ------------------s - 0.8349 Transfer function: 0.2125 z - 0.07085 -----------------z - 2.433 Sampling time: 1

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE

RESULT Thus the digital Butterworth and chebyshev Low Pass IIR Filter from the given specification was designed using MATLAB program.

DESIGN OF LINEAR PHASE FIR DIGITAL FILTERS AIM


To design a linear phase digital FIR Filter (LPF and HPF) using different window sequences in MATLAB Function. 20

Department of ECE

EC2306 Digital Signal Processing Lab

ALGORITHM
1. Get the number of samples of impulse response. 2. Get the cut off frequency. 3. Determine the value of infinite impulse response. 4. Choose the window sequence. 5. Determine the filter co-efficient of finite impulse response. 6. Draw the magnitude and phase response.

PROGRAM
%DESIGN OF DIGITAL FIR (LPF & HPF) FILTER USING RECTENGULAR WINDOW clc; rp=input('Enter the ripple of pass band (rp)='); rs=input('Enter the ripple of stop band (rs)='); fp=input('Enter the frequency of pass band (fp)='); fs=input('Enter the frequency of stop band (fs)='); f=input('Enter the Sampling Frequency (f)='); wp=(2*pi*fp)/f; ws=(2*pi*fs)/f; num=-20*log10(sqrt(rp*rs))-13; den=14.6*(fs-fp)/f; n=ceil(num/den); n1=n+1; y=boxcar(n1); %DESIGN OF LOW PASS FILTER b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(1,2,1); plot(o/pi,m,'k'); title('LPF FREQUENCY RESPONSE'); %DESIGN OF HIGH PASS FILTER b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(1,2,2); plot(o/pi,m,'k'); title('HPF FREQUENCY RESPONSE'); INPUT DATA Enter the ripple of pass band (rp) =.04 Enter the ripple of stop band (rs) =.05 Enter the frequency of pass band (fp) =1500 Enter the frequency of stop band (fs) =2000 Enter the Sampling Frequency (f) =25000 21

Department of ECE

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE FOR LPF & HPF

RESULT
Thus the linear phase Low Pass digital FIR Filter using different window was designed in MATLAB program.

COMPUTATION OF DFT AND IDFT USING FFT ALGORITHM AIM


To compute the DFT and IDFT of the given sequence using FFT Algorithm in MATLAB program.

ALGORITHM
1. Get the length of input sequence N. 2. Get the input sequence x(n) of length N in matrix form. 22

Department of ECE 2. DFT and IDFT of sequences is given by


nk DFT : X (k ) = x (n) N n=0 N 1

EC2306 Digital Signal Processing Lab

;0 k N 1
nk N

IDFT : x(n) = 3. Stop the program.

1 N

X (k )
k =0

N 1

;0 n N 1

Where = e j 2

PROGRAM FOR COMPUTATION OF DFT AND IDFT USING FFT ALGORITHM


clc; N=input('Enter the length of the sequence(N)= '); x=input('Enter the input sequence x(n)= '); n=0:1:(N-1); subplot(2,2,1); stem(n,x,'k'); xlabel('n---->'); ylabel('Amplitude'); title('Input sequence'); %Computation of DFT using FFT k=0:1:(N-1); X=fft(x,N) subplot(2,2,2); stem(k,abs(X),'k'); xlabel('k---->'); ylabel('Amplitude'); title('Magnitude plot (DFT)'); subplot(2,2,3); stem(k,angle(X),'k'); xlabel('k---->'); ylabel('Angle'); title('Phase plot (DFT)'); %Computation of IDFT using FFT n=0:1:(N-1); x=ifft(X,N) subplot(2,2,4); stem(n,abs(x),'k'); xlabel('n---->'); ylabel('Amplitude'); title('Magnitude plot (IDFT)');

INPUT AND OUTPUT SEQUENCE


Enter the length of the sequence(N)= 8 Enter the input sequence x(n)= [1 2 3 4 4 3 2 1] 23

Department of ECE X= Columns 1 through 6 20.0000 -5.8284 - 2.4142i 0

EC2306 Digital Signal Processing Lab

-0.1716 - 0.4142i

-0.1716 + 0.4142i

Columns 7 through 8 0 x= 1 2 3 4 4 3 2 1 -5.8284 + 2.4142i

OUTPUT RESPONSE

RESULT Thus the DFT and IDFT of the given sequence using FFT Algorithm in MATLAB program were
performed.

DECIMATION BY POLYPHASE DECOMPOSITION AIM


To study the effect of sampling on the frequency domain quantities at different sampling frequencies. 1000 t j b) Sample xa (t ) = e at Fs = 5000 samples/sec to obtain x1 (n) .Determine and plot X 1 (e ) .
1000 t j b) Sample xa (t ) = e at Fs = 1000 samples/sec to obtain x1 (n) .Determine and plot X 1 (e ) .

24

Department of ECE

EC2306 Digital Signal Processing Lab

ALGORITHM
1. Determine the analog value with respect to variation of time. 2. Get the sampling frequency. 3. Determine the discrete value with respect to variation of frequency. 4. Determine the Omega range from max to max . 5. Determine the magnitude of the signal. 6. Draw the discrete time signal and discrete Fourier transform.

PROGRAM DECIMATION BY POLYPHASE DECOMPOSITION


clc; %Analog signal t=-0.005:0.00005:0.005; xa=exp(-1000*abs(t)); %Discrete time signal Fs=input('Enter the sampling frequency(Fs)= '); Ts=1/Fs; n=-25:1:25; xn=exp(-1000*abs(n*Ts)); %Discrete time fourier transform N=500; k=0:1:N; w=(2*pi*k/N); X=xn*exp(-j*n'*w); X=abs(X); %omega range from -Wmax to Wmax W=[-fliplr(w),w(2:N+1)]; %X over -Wmax to Wmax interval X=[fliplr(X),X(2:N+1)]; subplot(2,1,1); plot(t*1000,xa,'k'); grid; hold on; stem(n*Ts*1000,xn,'k'); xlabel('time in sec'); ylabel('x(n)'); title('discrete time signal'); gtext('Ts=1msec'); hold off; 25

Department of ECE subplot(2,1,2); plot(W/pi,X,'k'); grid; xlabel('normalised frequency in rad/sec'); ylabel('|X(W)|'); title('discrete time fourier transform');

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE (a) Enter the sampling frequency (Fs) =5000


The maximum frequecy of analog signal (Wm) =1000rad/sec. i.e. sampling frequency is greater than twice the maximum frequecy. i.e.Ws >2Wm i.e.5000>2000 Therefore it satisfies the above condition hence there is no aliasing effect.

(b) Enter the sampling frequency (Fs)=1000


The maximum frequecy of analog signal (Wm)=1000rad/sec. i.e. sampling frequency is greater than twice the maximum frequecy. i.e.Ws >2Wm i.e.1000>2000 Therefore it dose not satsify the above condition hence there is aliasing effect. 26

Department of ECE

EC2306 Digital Signal Processing Lab

RESULT
Thus the Decimation by polyphase decomposition at different sampling frequencies was studied MATLAB program.

GENERATION OF SQUARE WAVE USING TMS320C50 AIM To generate a square wave with amplitude of 2 volts by using TMS320C50 DSP processor.
27

Department of ECE

EC2306 Digital Signal Processing Lab

APPARATUS REQUIRED TMS320C50 DSP processor kit, PC, CRO with probe. ALGORITHM 1. Start the program. 2. Load the amplitude of the square signal of 5 volts. 3. Load the frequency of the square signal. 4. Observe the square waveform by using CRO. 5. Stop the program. .END PROGRAM FOR GENERATION OF SQUARE WAVEFORM USING TMS320C50 .MMREGS .TEXT START: LDP #100H LACC #0FFFH ;change this value for amplitude. LOOP: SACL 0 RPT #0FFH ;change this value for frequency. OUT 0,04H ;address for dac. CMPL B LOOP

OBSERVATION S.No TIME PERIOD (msec)


28

AMPLITUDE (volts)

Department of ECE

EC2306 Digital Signal Processing Lab

1 RESULT

1.6 * 2 = 3.2mse

2.5 * 2 = 5 V

Thus the square wave was generated using TMS320C50 DSP Processor.

GENERATION OF SAWTOOTH WAVE USING TMS320C50 AIM To generate a saw tooth wave with amplitude of 4 volts by using TMS320C50 DSP processor. APPARATUS REQUIRED TMS320C50 DSP processor kit, PC, CRO with probe. ALGORITHM 1. Start the program. 2. Load the amplitude of the saw tooth signal of 5 volts. 3. Load the frequency of the saw tooth signal. 4. Observe the saw tooth waveform by using CRO and stop the program. PROGRAM FOR GENERATION OF SAWTOOTH WAVEFORM USING TMS320C50 .MMREGS .TEXT START: LDP #120H LACC #0H ;change lower amplitude SACL 0
29

Department of ECE

EC2306 Digital Signal Processing Lab

OUT 0,04H LOOP: LACC 0 OUT 0,04H ADD #05H ;change frequency SACL 0 SUB #0FFFH ;change upper amplitude BCND LOOP,LEQ B START .END OBSERVATION S.No TIME PERIOD (msec) 1 1.6 * 2 = 3.2mse AMPLITUDE (volts) 2.5 * 2 = 5 V

RESULT Thus the saw tooth wave was generated using TMS320C50 DSP Processor.

GENERATION OF TRIANGULAR WAVE USING TMS320C50


AIM To generate a triangular wave with amplitude of 4 volts by using TMS320C50 DSP processor. APPARATUS REQUIRED TMS320C50 DSP processor kit, PC, CRO with probe. ALGORITHM 1. Start the program. 2. Load the amplitude of the saw tooth signal of 5 volts. 3. Load the frequency of the saw tooth signal. 4. Observe the saw tooth waveform by using CRO and stop the program. 30

Department of ECE

EC2306 Digital Signal Processing Lab

PROGRAM FOR GENERATION OF TRIANGULAR WAVEFORM USING TMS320C50 PROCESSOR


.MMREGS .TEXT START: CONT1: CONT: LDP #100H SPLK #0,00H LAR AR2,#85H OUT 0,04 LACC 0 ADD #8H SACL 0 MAR *,AR2 BANZ CONT,*LAR AR2,#85H OUT 0,04 LACC 0 SUB #8H SACL 0 MAR *,AR2 BANZ CONTx B CONT1

CONTx:

OBSERVATION S.No 1 RESULT Thus the triangular wave was generated using TMS320C50 DSP Processor. TIME PERIOD (msec) 1.6 * 2 = 3.2mse AMPLITUDE (volts) 2.5 * 2 = 5 V

PERFORM LINEAR CONVOLUTION OF TWO SEQUENCES AIM To perform the linear convolution of the two sequences using TMS320C50 DSP Processor. ALGORITHM 1. Get the two sequence x(n) and h(n) in matrix form. 2. The convolution of the two sequences is given by
y ( n) = x ( n ) h ( n ) =
k =

x(k )h(n k ) For Linear Convolution


31

Department of ECE y ( n) = x (n) e h(n) = x (n)h(m n)


n=0 N 1

EC2306 Digital Signal Processing Lab

For Linear Convolution

3. Stop the program. A) PROGRAM TO PERFORM LINEAR CONVOLUTION OF TWO SEQUENCES USING TMS320C50 .MMREGS .TEXT START: LDP #02H LAR AR1,#8100H ; x(n) datas LAR AR0,#8200H ;h(n) datas LAR AR3,#8300H ;y(n) starting LAR AR4,#0007 ;N1+N2-1 ;to fold the h(n) values LAR AR0,#08203H LACC #0C100H MAR *,AR0 RPT #3 TBLW *;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+N11} MAR *,AR2 ZAP RPT #03H ;N1-1 times so that N1 times
32

Department of ECE

EC2306 Digital Signal Processing Lab

MACD 0C100H,*APAC ;to accmulate the final product sample MAR *,AR3 SACL *+ MAR *,AR4 BANZ LOP,*H: B H

INPUT AND OUTPUT SEQUENCE ;INPUT ( x(n) ) ;8100 - 1 ;8101 - 3 ;8102 - 1 ;8103 - 3 ;INPUT ( h(n) ) ; 8200 - 0 ; 8201 - 1 ; 8202 - 2 ; 8203 - 1 ;OUTPUT ( y(n) ) ; 8300 - 0 ; 8301 - 1 ; 8302 - 5 ; 8303 - 8 ; 8304 - 8 ; 8305 - 7 ; 8306 - 3
33

Department of ECE

EC2306 Digital Signal Processing Lab

B) PROGRAM TO PERFORM CIRCULAR CONVOLUTION OF TWO SEQUENCES USING TMS320C50

.MMREGS .TEXT 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 34

Department of ECE EC2306 Digital Signal Processing Lab 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,*002D`jhmgjmh 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

35

Department of ECE

EC2306 Digital Signal Processing Lab

INPUT AND OUTPUT SEQUENCE


;INPUT: ; 8000-0004 ; ;X1(n) = ; ; ; ; ;H2(n ) = ; ; ; 8050 - 0002 8051 - 0001 8052 - 0002 8053 - 0001 8060 - 0001 8061 - 0002 8062 - 0003 8063 - 0004

;OUTPUT: ; 8010-000E ; 8011-0010 ; 8012-000E ; 8013-0010 ;

RESULT Thus the linear convolution of the two sequences was performed using TMS320C50 DSP Processor.

36

Department of ECE

EC2306 Digital Signal Processing Lab

SAMPLING OF INPUT SIGNAL AND DISPLAY AIM


To perform the sampling of the given input signal using TMS320C50 DSP Processor and plot its wave form.

ALGORITHM
1. Start the program. 2. Switch off the trainer kit. 3. Connect the function generator in the corresponding terminals. 4. Download the program to the trainer kit using Xtalk.exe 5. Quit from the Xtalk. 6. Enter into the basic TB.exe 7. Load and run the program "sample50.bas" which executes the ASM program and plots the samples on the screen.

SAMPLING THEOREM
;PROGRAM DESCRIPTION: In this program the samples are taken from the ADC with the desired sampling rate and the sample values are stored in the memory locations from the data memory 9000H. After taking 720 samples from the ADC the samples are sent through the serial port which is received by the basic program named "sample50.bas",and plots the samples in the pc screen.In this program the sampling rate is varied by varying the number in the address named DELAY. The delay value is also sent to the basic programas a first data. The distance between the samples in the basic program varies according to the delay value which it receives as a first data. ;Note: 37

Department of ECE EC2306 Digital Signal Processing Lab ;1. Swith off the trainer kit. ;2. Connect the function generator in the corresponding terminals. ;3. Download the program to the trainer kit using Xtalk.exe ;4. Quit from the Xtalk. ;5. Enter into the basic TB.exe ;6. Load and run the program "sample50.bas" which executes the asm program ; and plots the samples on the screen. ; TXD .SET 0H STS .SET 1H DATA .SET 2H DELAY B3 B2 B1 B0 .SET 3H

.SET 0F000H .SET 0F00H .SET 00F0H .SET 000FH .mmregs .text START: LDP #100H LAR AR0,#9000H LAR AR1,#719 REP: IN 0,06 RPT #0FH NOP IN 0,04 SPLK #5FFH,DELAY RPT DELAY NOP LACC 0 AND #0FFFH MAR *,AR0 SACL *+,0,AR1 BANZ REP,*LACC SACL CALL REPSER: LAR LAR REPSAMP: MAR LACC SACL CALL DELAY DATA SERIAL AR2,#9000H AR0,#719 *,AR2 *+ DATA SERIAL 38

Department of ECE MAR *,AR0 BANZ REPSAMP,*B REPSER

EC2306 Digital Signal Processing Lab

;routine to send each digit of DATA individually to the serial port ;first send the start of character "%" ;seperate and send each digits of DATA from MSB ;send end of character "$" SERIAL SPLK #25H,TXD ;start of character "%" CALL TXDATA RPT #0FFFH

NOP LACC AND BSAR SACL CALL CALL RPT NOP LACC AND BSAR SACL CALL CALL RPT NOP LACC AND BSAR SACL CALL CALL RPT NOP LACC AND SACL CALL CALL RPT

DATA #B3 ;1st digit (from msb) 12 TXD HEXASC TXDATA #0FFFH DATA #B2 ;second digit 8 TXD HEXASC TXDATA #0FFFH DATA #B1 ;3rd digit 4 TXD HEXASC TXDATA #0FFFH DATA #B0 ;4th digit TXD HEXASC TXDATA #0FFFH 39

Department of ECE NOP SPLK #24H,TXD CALL TXDATA RPT #0FFFH NOP RET ;end of character "$"

EC2306 Digital Signal Processing Lab

;loop to conver hex data to ascii ;input is in address TXD ;output is also in TXD ;subtracts 9 from input hex data ;if >0 add 37h to input hex data ;Otherwise add 30h to input hex data HEXASC: LACC TXD SUB #9H BCND GRT9,GT LACC TXD ADD #30H SACL TXD RET GRT9: LACC TXD ADD #37H SACL TXD RET ;loop to send a character to the serial port ;checks the status of the serial port(TXREADY-bit2). ;if not 0, send that character. Otherwise checks it repeatedly. TXDATA: REPCHK: IN STS,9 LACC STS AND #04H BCND REPCHK,EQ OUT RET TXD,8

OUTPUT RESPONSE (a) Enter the sampling frequency (Fs) =5000


The maximum frequecy of analog signal (Wm) =1000rad/sec. i.e. sampling frequency is greater than twice the maximum frequecy. i.e.Ws >2Wm i.e.5000>2000 40

Department of ECE EC2306 Digital Signal Processing Lab Therefore it satisfies the above condition hence there is no aliasing effect.

RESULT
Thus the sampling of the given input signal was performed using TMS320C50 DSP Processor.

41

Department of ECE

EC2306 Digital Signal Processing Lab

IMPLEMENTATION OF FIR FILTERS AIM


To implementation digital FIR Filter (LPF and HPF) using TMS320C50 DSP Processor.

ALGORITHM
1. Get the pass band and stop band ripples. 2. Get the pass band and stop band frequency. 3 Get the sampling frequency 4. Calculate the order the filter by using the formula,
2 1 2 1 A2 log 2 1 1 A2 1 1 N 2 log 2 1

5. Find the filter co-efficient. 6. Draw the magnitude and phase response.

PROGRAM
%DESIGN OF DIGITAL FIR (LPF & HPF) FILTER USING RECTENGULAR WINDOW clc; rp=input('Enter the ripple of pass band (rp)='); rs=input('Enter the ripple of stop band (rs)='); fp=input('Enter the frequency of pass band (fp)='); fs=input('Enter the frequency of stop band (fs)='); f=input('Enter the Sampling Frequency (f)='); wp=(2*pi*fp)/f; ws=(2*pi*fs)/f; num=-20*log10(sqrt(rp*rs))-13; den=14.6*(fs-fp)/f; n=ceil(num/den); n1=n+1; y=boxcar(n1); %DESIGN OF LOW PASS FILTER b=fir1(n,wp,y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(1,2,1); plot(o/pi,m,'k'); title('LPF FREQUENCY RESPONSE'); 42

Department of ECE %DESIGN OF HIGH PASS FILTER b=fir1(n,wp,'high',y); [h,o]=freqz(b,1,256); m=20*log10(abs(h)); subplot(1,2,2); plot(o/pi,m,'k'); title('HPF FREQUENCY RESPONSE'); INPUT DATA Enter the ripple of pass band (rp) =.04 Enter the ripple of stop band (rs) =.05 Enter the frequency of pass band (fp) =1500 Enter the frequency of stop band (fs) =2000 Enter the Sampling Frequency (f) =25000

EC2306 Digital Signal Processing Lab

OUTPUT RESPONSE FOR LPF & HPF

RESULT Thus the digital FIR Filter (LPF and HPF) was implemented using TMS320C50 DSP Processor.
43

Department of ECE

EC2306 Digital Signal Processing Lab

44

You might also like