dsp lap man

Upload: vignesh-subramani

Post on 13-Jul-2015

83 views

Category:

Documents


0 download

TRANSCRIPT

DIGITAL SIGNAL PROCESSING LAB EX.NO:01

GENERATION OF SIGNALSOBJECTIVE: To know about how to generate various basic signals using MATLAB AIM:

To write a MATLAB program for the generation of various basic signals.

THEORY:A Signal is defined as any physical quantity that varies with time, space, or any other independent variable, For example, the functions x1(t)=2t and x2(t)=t2 describe two signals, one that varies linearly with independent variable t and a second that varies quadratically with t. A System is defined as a physical device that performs an operation on a signal, For example, a filter used to reduce the noise corrupting a desired information bearing signal is called a system. Signal processing is any operation that changes the characteristics of a signal. These characteristics include the amplitude, shape, phase and frequency content of the signal. Classification of signals: Signal in general can be of two types. 1. Continuous-time signal: A signal that varies continuously with time. It can be represented as x(t), where time t represents the independent variable. Example: sinusoidal signal.

Fig. 1.1 Continuous Time Signal 1

DIGITAL SIGNAL PROCESSING LAB 2. Discrete-time signal: A signal that has values only at discrete instants of time. One way of obtaining discrete-time signal is, sampling a continuous-time signal at regular intervals. It can be represented as x(nT) where n=0,1,2n, and T is the time interval between two consecutive signal values. A discrete-time signal is discrete in time but continuous in amplitude. Another form of discrete-time signal is a digital signal which is discrete in both time and amplitude. These signals are called digital because their samples are represented by numbers or digits.

Fig.1.2 Discrete Time Signal Standard Discrete-time signals: 1. Unit sample sequence: The unit sample sequence (unit impulse) is defined as (n) = 1 for n = 0 = 0 for n 0 The graphical representation of (n) is as shown in Fig.

Fig. 1.3 Unit Sample Sequence 2. Unit step sequence: The unit step sequence is defined as u(n) = 1 for n 0 = 0 for n < 0 The graphical representation of u(n) is shown in Fig. 2

DIGITAL SIGNAL PROCESSING LAB

Fig. 1.4

Unit Step Sequence

3. Unit ramp sequence : The unit ramp sequence is denoted as ur (n) and is defined as ur (n) = n for n 0 = 0 for n < 0 The graphical representation of ur (n) is shown in Fig.

Fig. 1.5 Unit Ramp Sequence 4. Exponential sequence The exponential signal is a sequence of the form x(n) = an for all n shows exponential sequences for different values of a.

3

DIGITAL SIGNAL PROCESSING LAB

Fig. 1.6 Exponential Sequences

UNIT STEPALGORITHM:

1.Clear Command Window [an alternative to the clc function, use Clear Command Window in the MATLAB desktop Edit menu.] 2.Get the minimum value of time 3.Get the maximum value time 4.Iterate the for loop with colon operator. 5.Plot amplitude against time

PROGRAM:

clc; clear all; close all; a=input('enter minimum value'); b=input('enter maximum value'); u=[a:1:b]; x=1; for s=[a:1:b] if(s 1

h(n)

0.5

0.5

0

0

1

2 n ---> output

3

4

0

0

1 n --->

2

3

4 amplitude ---> 3 2 1 0

0

1

2 time --->

3

4

RESULT:

Thus MATLAB program to perform convolution was written and executed successfully

17

DIGITAL SIGNAL PROCESSING LABVIVA QUESTIONS

1. What is meant by linear convolution? The linear convolution of two sequences x(n) of L no.of samples and h(n) of M no.of samples produce a result y(n) which contains N=L+M-1 samples. 2. What is meant by circular convolution? The circular convolution of two sequences x(n) of L no.of samples and h(n) with M samples, after convolution y(n) will contain N=Max (L,M) samples. 3. Why linear convolution is important in DSP? The response or output of LTI discrete time system for any input x(n) is Given by linear convolution of the input x(n) and the impulse response h(n) of the system. 4. Why circular convolution is important in DSP? The DFT supports only circular convolution. Hence, when DFT techniques are employed, the result of linear convolution are obtained only via circular convolution. 5. What are the properties of linear convolution? i) ii) iii) Commutative property. Associative property. Distributive property

6. What is the advantage of linear convolution? It can be used to find the response of a linear or a linear filter. 7. Mention the method of circular convolution? i) ii) Concentric circle method. Matrix Multiplication method.

8. What are the uses of zero padding? a) b) c) We can get better display of the frequency spectrum. With zero padding, the DFT can be used in linear filtering. In circular convolution, when the two input sequences are of different size, then they are converted to equal size by zero padding.

18

DIGITAL SIGNAL PROCESSING LAB

9. How will you perform linear convolution via circular convolution? To perform linear convolution via circular convolution, convert the input sequence to N1+N2-1 point sequences by padding with zeros. 10. Where the circular convolution uses in DSP? The DFT is used for the analysis and design of discrete time systems Using Digital Computers. 11. The MATLAB command used to convolute the two sequence is CONV 12. The MATLAB command used to display the processed sequence is DISP. 13. The ROUND command rounds the element to the nearest integers 14. The LENGTH command returns the length of vector 15. When we implement the linear convolution via circular convolution we have to use ZERO PADDING concept.

19

DIGITAL SIGNAL PROCESSING LAB

EX.NO:03

DESIGN OF IIR FILTERSOBJECTIVE: To implement IIR (Butterworth Lowpass, Highpass, Bandpass, Band stop) filter using MATLAB

AIM: To write a MATLAB program to design a Butterworth low pass, high pass. band pass & band reject filter and also convert a analog filter into digital filter. THEORY: A filter is one, which rejects unwanted frequencies from the input signal and allow the desired frequencies to obtain the required shape of output signal. The range of frequencies of signal that are passed through the filter is called pass band and those frequencies that are blocked is called stop band. The filters are of different types. 1. Low pass filter 2. High pass filter 3. Band pass filter 4. Band reject filter Design of Digital filters from Analog filters: The most common technique used for designing IIR digital filters known as indirect method, involves first designing an analog prototype filter and then transforming the prototype to a digital filter. For the given specification of a digital filter, the derivation of the digital filter transfer function requires three steps. 1. 2. 3. Map the desired digital filter specification into those for an equivalent analog filter. Derive the analog transfer function for the analog prototype. Transform the transfer function of the analog prototype into an equivalent digital filter transfer function.

Fig 5.1 Shows the magnitude response of a digital low pass filter. The various parameters in the figure are, p = Pass band frequency in radians s = Stop band frequency in radians c = 3-db cutoff frequency in radians = Parameter specifying allowable pass band 20

DIGITAL SIGNAL PROCESSING LAB = Parameter specifying allowable stop band

Fig 5.1 Magnitude response of a Low pass filter Design of IIR filters from analog filters: There are several methods that can be used to design digital filters having an infinite duration unit sample response. The techniques described are all based on converting an analog filter into digital filter. If the conversion technique is to be effective, it should posses the following desirable properties. 1. 2. The j -axis in the s-plane should map into the unit circle in the z-plane. Thus there will be a direct relationship between the two frequency variables in the two domains. The left-half plane of the s-plane should map into inside of the unit circle in the zplane. Thus a stable analog filter will be converted to a stable digital filter.

The four most widely used methods for digitizing the analog filter into a digital filter include, 1. 2. 3. 4. Approximation of derivatives. The impulse invariant transformation. The bilinear transformation. The matched z-transformation.

Impulse invariant transformation: 21

DIGITAL SIGNAL PROCESSING LAB In this method of digitizing an analog filter, the impulse response of resulting digital filter is a sampled version of the impulse response of the analog filter. First we express the transfer function of analog filter in partial fraction form,

Then the transfer function of digital filter can be obtained using the transformation. (i.e),

Bilinear transformation: The bilinear transformation is a mapping that transforms the left half of s-plane into the unit circle in the z-plane only once, thus avoiding aliasing of frequency components. The mapping from the s-plane to the z-plane is in bilinear transformation is

22

DIGITAL SIGNAL PROCESSING LAB ALGORITHM:

BUTTERWORTH LOW PASS FILTER1.Get the pass band and stop band ripples. 2.Get the pass band and stop band edge frequencies. 3.Get the sampling frequency. 4.Calculate the order the filter 5. buttord calculates the minimum order of a digital or analog Butterworth filter required to meet a set of filter design specifications. 6. butter(d,'matchexactly',match) returns a Butterworth IIR filter where the filter response matches the specified response exactly for one filter band. 7.Find the filter coefficients. 8.Draw the magnitude and phase response.

BUTTERWORTH HIGHPASS FILTER1.Get the pass band and stop band ripples. 2.Get the pass band and stop band edge frequencies. 3.Get the sampling frequency. 4.Calculate the order the filter 5. Buttord calculates the minimum order of a digital or analog Butterworth filter required to meet a set of filter design specifications. 6. Butter(d,'matchexactly',match) returns a Butterworth IIR filter where the filter response matches the specified response exactly for one filter band. 7.Find the filter coefficients. 8.Draw the magnitude and phase response.

BUTTERWORTH BANDPASS FILTER1.Get the pass band and stop band ripples. 2.Get the pass band and stop band edge frequencies. 3.Get the sampling frequency. 4.Calculate the order the filter 5. Buttord calculates the minimum order of a digital or analog Butterworth filter required to meet a set of filter design specifications. 6. Butter(d,'matchexactly',match) returns a Butterworth IIR filter where the filter response matches the specified response exactly for one filter band. 7.Find the filter coefficients. 8.Draw the magnitude and phase response.

BUTTERWORTH BANDSTOP FILTER23

DIGITAL SIGNAL PROCESSING LAB

1.Get the passband and stopband ripples 2.Get the passband and stopband edge frequencies 3.Get the sampling frequencies 4.Calculate the order of the filter 5. Buttord calculates the minimum order of a digital or analog Butterworth filter required to meet a set of filter design specifications. 6. Butter(d,'matchexactly',match) returns a Butterworth IIR filter where the filter response matches the specified response exactly for one filter band. 7.Find the filter co-efficients 8.Draw the magnitude and phase responsePROGRAM:

clc; close all; clear all; format long rp=input('enter the passband 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; [n,wn]=buttord(w1,w2,rp,rs,'s'); [z,p,k]=butter(n,wn); [b,a]=zp2tf(z,p,k); [b,a]=butter(n,wn,'s'); w=0:.01:pi; [h,om]=freqs(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)normalised frequency-->'); subplot(2,1,2); plot(om/pi,an); xlabel('(b) normalised frequency-->'); ylabel('phase in radians-->'); pause; format long rp=input('enter the passband 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; [n,wn]=buttord(w1,w2,rp,rs,'s'); 24

DIGITAL SIGNAL PROCESSING LAB [b,a]=butter(n,wn,'high','s'); w=0:.01:pi; [h,om]=freqs(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)normalised frequency-->'); subplot(2,1,2); plot(om/pi,an); xlabel('(b) normalised frequency-->'); ylabel('phase in radians-->'); pause; format long rp=input('enter the passband 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; [n]=buttord(w1,w2,rp,rs,'s'); wn=[w1,w2]; [b,a]=butter(n,wn,'bandpass','s'); w=0:.01:pi; [h,om]=freqs(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)normalised frequency-->'); subplot(2,1,2); plot(om/pi,an); xlabel('(b) normalised frequency-->'); ylabel('phase in radians-->'); pause; format long rp=input('enter the passband 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; [n]=buttord(w1,w2,rp,rs,'s'); wn=[w1,w2]; [b,a]=butter(n,wn,'stop','s'); w=0:.01:pi; [h,om]=freqs(b,a,w); m=20*log10(abs(h)); 25

DIGITAL SIGNAL PROCESSING LAB an=angle(h); subplot(2,1,1);plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); subplot(2,1,2); plot(om/pi,an); xlabel('(b) normalised frequency-->'); ylabel('phase in radians-->');

BUTTERWORTH LOW PASS FILTERINPUT:

enter the passband ripple 0.15 enter the stop band ripple 60 enter the pass band frequency 1500 enter the stop band frequency 3000 enter the sampling frequency 7000OUTPUT:100 gain in db--> 0 -100 -200 -300

0

0.1

0.2

0.3 0.4 0.5 0.6 0.7 (a)normalised frequency-->

0.8

0.9

1

4 phase in radians--> 2 0 -2 -4

0

0.1

0.2

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

0.8

0.9

1

26

DIGITAL SIGNAL PROCESSING LAB

BUTTERWORTH HIGH PASS FILTERINPUT:

enter the stop band ripple 40 enter the pass band frequency 2000 enter the stop band frequency 3500 enter the sampling frequency 8000OUTPUT:200 gain in db-->

0

-200

-400

0

0.1

0.2

0.3 0.4 0.5 0.6 0.7 (a)normalised frequency-->

0.8

0.9

1

4 phase in radians--> 2 0 -2 -4

0

0.1

0.2

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

0.8

0.9

1

27

DIGITAL SIGNAL PROCESSING LAB

BUTTERWORTH BAND PASS FILTERINPUT: enter the stop band ripple 36 enter the pass band frequency 1500 enter the stop band frequency 2000 enter the sampling frequency 6000 OUTPUT:

500 gain in db-->

0

-500

-1000

0

0.1

0.2

0.3 0.4 0.5 0.6 0.7 (a)normalised frequency-->

0.8

0.9

1

4 phase in radians--> 2 0 -2 -4

0

0.1

0.2

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

0.8

0.9

1

28

DIGITAL SIGNAL PROCESSING LAB

BUTTERWORTH BAND REJECT FILTER

INPUT:

enter the passband ripple 0.28 enter the stop band ripple28 enter the pass band frequency1000 enter the stop band frequency1400 enter the sampling frequency5000OUTPUT:

5 0 gain in db--> 0 -5 0 -1 0 0 -1 0 5

0

0 .1

0 .2

0 .3

0 .4 0 .5 0 .6 (a o a d fre u n )n rm lise q e cy-->

0 .7

0 .8

0 .9

1

phase in radians-->

4 2 0 -2 -4

0

0 .1

0 .2

0 .3 0 .4 0 .5 0 .6 (b n rm lise fre u n ) o a d q e cy-->

0 .7

0 .8

0 .9

1

29

DIGITAL SIGNAL PROCESSING LAB

RESULT:

Thus MATLAB program to design Butterworth low pass, high pass, band pass & band reject filters was written and executed successfully.

VIVA QUESTIONS 30

DIGITAL SIGNAL PROCESSING LAB 1.IIR filters has INFINITE memory 2.IF the impulse response sequence is of finite direction, then the system is called on FIR system 3. IF the impulse response sequence is of infinite direction, then the system is called on IIR system 4.When an MATLAB program is executed, if the error occurs then the errors proper code can be viewed with the help of HELP ON SELECTION. 5. When an MATLAB program is executed, if the error occurs then the error can be evaluated with the help of EVALUATE SELECTION 6. When an MATLAB program is executed, if the error occurs then the missing thing can be found with the help of open selection. 7.More memory is required in the realization of IIR system using DIRECT FORM I structure. 8.If the o/p of a system depends on the past output values, then the is called RECURSIVE system. 9.If the o/p of a system does not depends on the past output values, then the is called NON RECURSIVE system. 10.The MATLAB commands FREQZ returns the N-point complex frequency response vector H and the Npoint frequency vector W in radians/sample of the filter 11.The MATLAB commands FREQS returns the complex frequency response vector H of the filter B/A 12.The MATLAB command ABS returns the absolute value. 13..The ANGLE command computes the phase angle.

EX.NO:04 31

DIGITAL SIGNAL PROCESSING LAB

DESIGN OF FIR FILTERSOBJECTIVE: To implement FIR (Lowpass, Highpass, Bandpass, Band stop) filter using various windowing techniques in MATLAB

AIM: To design a FIR low pass, high pass, band pass &band reject filter in MATLAB using Rectangular, Hamming, Hanning, Blackman &Kaiser windowing technique. ALGORITHM:

LOW PASS FILTER USING RECTANGULAR WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function boxcar(N) 5. Draw the magnitude and phase response.

HIGH PASS FILTER USING RECTANGULAR WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function boxcar(N) 5. Draw the magnitude and phase response.

BAND PASS FILTER USING RECTANGULAR WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function boxcar(N) 5. Draw the magnitude and phase response.

BAND STOP FILTER USING RECTANGULAR WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function boxcar(N) 5. Draw the magnitude and phase response. 32

DIGITAL SIGNAL PROCESSING LAB

PROGRAM:

clc; close all; clear all; format long; %FIR Low pass filter using Rectangular window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=boxcar(n); b=fir1(n-1,w1,'low',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,1); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR high pass filter using Rectangular window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=boxcar(n); b=fir1(n-1,w1,'high',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,2); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandPass filter using Rectangular window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=boxcar(n); wn=[w1,w2]; b=fir1(n-1,wn,'bandpass',w); 33

DIGITAL SIGNAL PROCESSING LAB [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,3); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandStop filter using Rectangular window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=boxcar(n); wn=[w1,w2]; b=fir1(n-1,wn,'stop',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,4); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->');INPUT:

Enter the pass band frequency1000 Enter the stop band frequency2000 Enter the sampling frequency5000 Enter the order of the filter 8 Enter the pass band frequency1000 Enter the stop band frequency2000 Enter the sampling frequency5000 Enter the order of the filter 9 Enter the pass band frequency2000 Enter the stop band frequency4000 Enter the sampling frequency9000 Enter the order of the filter 12 Enter the pass band frequency1000 Enter the stop band frequency2000 Enter the sampling frequency5000 Enter the order of the filter 11

34

DIGITAL SIGNAL PROCESSING LABOUTPUT:

50 gain in db--> gain in db--> 0 0.5 (a)normalised frequency--> 1

20 0 -20 -40 -60

0

-50

-100

0

0.5 (a)normalised frequency-->

1

50

20 0 -20 -40 -60

gain in db-->

0

-50

-100

0

0.5 (a)normalised frequency-->

1

gain in db-->

0

0.5 (a)normalised frequency-->

1

ALGORITHM:

LOW PASS FILTER USING HAMMING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hamming (N) 5. Draw the magnitude and phase response.

HIGH PASS FILTER USING HAMMING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hamming (N) 5. Draw the magnitude and phase response.

BAND PASS FILTER USING HAMMING WINDOW35

DIGITAL SIGNAL PROCESSING LAB

1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hamming (N) 5. Draw the magnitude and phase response.

BAND STOP FILTER USING HAMMING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hamming (N) 5. Draw the magnitude and phase response.PROGRAM:

clc; close all; clear all; format long; %FIR Low pass filter using Hamming window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hamming(n); b=fir1(n-1,w1,'low',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,1); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR high pass filter using Hamming window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hamming(n); b=fir1(n-1,w1,'high',w); 36

DIGITAL SIGNAL PROCESSING LAB [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,2); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandPass filter using Hamming window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hamming(n); wn=[w1,w2]; b=fir1(n-1,wn,'bandpass',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,3); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandStop filter using Hamming window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hamming(n); wn=[w1,w2]; b=fir1(n-1,wn,'stop',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,4); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->');

37

DIGITAL SIGNAL PROCESSING LAB INPUT: enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 8 enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency8000 enter the order of the filter 9 enter the pass band frequency2000 enter the stop band frequency4000 enter the sampling frequency9000 enter the order of the filter 12 enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 11 OUTPUT:0 gain in db--> gain in db--> 0 0.5 (a)normalised frequency--> 1 -20 -40 -60 -80 10

0

-10

-20

0

0.5 (a)normalised frequency-->

1

0 -20 gain in db--> -40 -60 -80 -100 0 0.5 (a)normalised frequency--> 1 gain in db-->

0 -5 -10 -15 -20

0

0.5 (a)normalised frequency-->

1

ALGORITHM: 38

DIGITAL SIGNAL PROCESSING LAB

LOW PASS FILTER USING HANNING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hanning (N) 5. Draw the magnitude and phase response.

HIGH PASS FILTER USING HANNING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hanning (N) 5. Draw the magnitude and phase response.

BAND PASS FILTER USING HANNING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hanning (N) 5. Draw the magnitude and phase response.

BAND STOP FILTER USING HANNING WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3.Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function hanning (N) 5. Draw the magnitude and phase response.

PROGRAM:

39

DIGITAL SIGNAL PROCESSING LAB clc; close all; clear all; format long; %FIR Low pass filter using Hanning window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hanning(n); b=fir1(n-1,w1,'low',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,1); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR high pass filter using Hanning window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hanning(n); b=fir1(n-1,w1,'high',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,2); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandPass filter using Hanning window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hanning(n); wn=[w1,w2]; b=fir1(n-1,wn,'bandpass',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); 40

DIGITAL SIGNAL PROCESSING LAB subplot(2,2,3); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandStop filter using Hanning window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=hanning(n); wn=[w1,w2]; b=fir1(n-1,wn,'stop',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,4); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); INPUT: enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 8 enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 9 enter the pass band frequency2000 enter the stop band frequency4000 enter the sampling frequency9000 enter the order of the filter 12 enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 11

41

DIGITAL SIGNAL PROCESSING LAB OUTPUT:

0 gain in db--> gain in db--> 0 0.5 (a)normalised frequency--> 1

50

0

-50

-50

-100

-100

0

0.5 (a)normalised frequency-->

1

50

10 0 -10 -20 -30

gain in db-->

0

-50

-100

0

0.5 (a)normalised frequency-->

1

gain in db-->

0

0.5 (a)normalised frequency-->

1

ALGORITHM:

LOW PASS FILTER USING BLACKMAN WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3. Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function blackman (N) 5. Draw the magnitude and phase response.

HIGH PASS FILTER USING BLACKMAN WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3. Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function blackman (N) 42

DIGITAL SIGNAL PROCESSING LAB 5. Draw the magnitude and phase response.

BAND PASS FILTER USING BLACKMAN WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3. Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function blackman (N) 5. Draw the magnitude and phase response.

BAND STOP FILTER USING BLACKMAN WINDOW1. Get the pass band and stop band edge frequencies. 2. Get the sampling frequency 3. Get the order of the filter(N) 4. Find the window co-efficients using the MATLAB function blackman (N) 5. Draw the magnitude and phase response.PROGRAM:

clc; close all; clear all; format long; %FIR Low pass filter using Blackman window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=blackman(n); b=fir1(n-1,w1,'low',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,1); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR high pass filter using Blackman window fp=input('enter the pass band frequency'); 43

DIGITAL SIGNAL PROCESSING LAB fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=blackman(n); b=fir1(n-1,w1,'high',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,2); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandPass filter using Blackman window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=blackman(n); wn=[w1,w2]; b=fir1(n-1,wn,'bandpass',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,3); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->'); pause; %FIR BandStop filter using Blackman window fp=input('enter the pass band frequency'); fs=input('enter the stop band frequency'); f=input('enter the sampling frequency'); n=input('enter the order of the filter '); w1=2*fp/f;w2=2*fs/f; w=blackman(n); wn=[w1,w2]; b=fir1(n-1,wn,'stop',w); [h,om]=freqz(b,1,256); m=20*log10(abs(h)); p=angle(h); subplot(2,2,4); plot(om/pi,m); ylabel('gain in db-->'); xlabel('(a)normalised frequency-->');

44

DIGITAL SIGNAL PROCESSING LAB INPUT: enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 8 enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 9 enter the pass band frequency2000 enter the stop band frequency4000 enter the sampling frequency9000 enter the order of the filter 12 enter the pass band frequency1000 enter the stop band frequency2000 enter the sampling frequency5000 enter the order of the filter 11 OUTPUT:

0 gain in db--> gain in db--> 0 0.5 (a)normalised frequency--> 1 -20 -40 -60 -80

0

-10

-20

-30

0

0.5 (a)normalised frequency-->

1

20 0 -20 -40 -60

0

gain in db-->

gain in db--> 0 0.5 (a)normalised frequency--> 1

-5

-10

-15

0

0.5 (a)normalised frequency-->

1

45

DIGITAL SIGNAL PROCESSING LAB

RESULT:

Thus MATLAB program for design FIR low pass, high pass, band pass & band reject filters using Rectangular, Hamming, Hanning & Blackman windowing technique was written and executed successfully.

46

DIGITAL SIGNAL PROCESSING LAB VIVS QUESTION 1. What are the different types of arithmetic in digital systems? There are three types of arithmetic used in digital systems. 1. Fixed point arithmetic 2. Floating point arithmetic 3. Block Floating arithmetic. 2. What do you understand by a fixed-point number? In fixed-point arithmetic the position of the binary point is fixed. The bits to the right represent the fractional part of the number and those to the left represent the integer part. For example, the binary number 01.1100 has the value 1.75 in decimal. 3. What are the different types in fixed-point number representation? Depending on the way negative numbers are represented, there are three different forms of fixedpoint arithmetic. They are 1) sign-magnitude 2) 1s complement 3) 2s complement. 4. What do you understand by sign-magnitude representation? Write a short note on 1s complement For sign-magnitude representation the leading binary digit is used to represent the sign. If it is equal to 1 the number is negative, otherwise the number is positive. For example, the decimal number -1.75 is represented as 11.11000 and 1.75 is represented as 01.110000. in sign-magnitude form the number 0 has two representations, i.e., 00.000000 or 10.000000. With b bits only 2b 1 numbers can be represented. 5. representation? In ones complement form the positive number is represented as in the sign-magnitude system. To obtain the negative of a positive number, one simply complements all the bits of the positive number. For example, the negative of 01.110000 would be represented as (01.11000)2 = (10.001111)2 The number 0 has two representations i.e., 00.00000 and 11.11111 in a 1s complement representation.

47

DIGITAL SIGNAL PROCESSING LAB EX.NO:05

FAST FOURIER TRANSFORMOBJECTIVE: To know about how to perform Fast Fourier transform of given sequences using MATLAB AIM:

To write a MATLAB program to compute the fast fourier transformALGORITHM:

1. Clear Command Window [an alternative to the clc function, use Clear Command Window in the MATLAB desktop Edit menu.] 2.Get the input sequence (x) 3. Get the length of the sequence (y) 4. Compute the fast fourier transform using fft (x,y). 5. Plot and display the outputPROGRAM: %FAST FOURIER TRANSFORM clc; clear all; close all; x=input('ENTER THE SEQUENCE:'); y=input('ENTER THE LENGTH OF THE SEQUENCE:'); z=fft(x,y); stem(z); ylabel('Imaginary axis'); xlabel('Real axis'); disp(z);

48

DIGITAL SIGNAL PROCESSING LAB

INPUT: ENTER THE SEQUENCE:[3,2,1,4] ENTER THE LENGTH OF THE SEQUENCE:6 OUTPUT:

3

2

1 Imaginary axis

0

-1

-2

-3

1

1.5

2

2.5

3

3.5 Real axis

4

4.5

5

5.5

6

49

DIGITAL SIGNAL PROCESSING LAB

RESULT:

Thus MATLAB programs to compute fast fourier transform are written and executed successfully

50

DIGITAL SIGNAL PROCESSING LAB VIVA QUESTION 1. Explain deterministic &random signals with examples. Deterministic: A signal that can be uniquely determined by well defined mathematical expression is called deterministic signal. Example: (a).a sinusoidal signal can represented as v (t)=vmsinwt ,for t0 (b).an exponential signal DT signal =ean, for n0 CT signal= e-at, for n 4 2 0

1

1.5

2

2.5 (a)n-->

3

3.5

4

Amplitude-->

4 2 0

1

1.5

2

2.5 (b)n-->

3

3.5

4

30 Amplitude--> 20 10 0 1 2 3 4 (c)n--> 5 6 7

58

DIGITAL SIGNAL PROCESSING LAB

RESULT:

Thus MATLAB program to perform correlation was written and executed successfully.

59

DIGITAL SIGNAL PROCESSING LAB

VIVA QUESTIONS What are the classification digital signal processors? The digital signal processors are classified as (i)General purpose digital signal processors. (ii)Special purpose digital signal processors. Give some examples for fixed point DSPs. TM320C50, TMS320C54, TMS320C55, ADSP-219x, ADSP-219xx. 1. Give some example for floating point DSPs. TMS320C3x, TMS320C67x, ADSP-21xxx. 2. What are the factors that influence selection of DSPs? Architectural features Execution speed Type of arithmetic Word length 3. What are applications of PDSPs? Digital cell phones, automated inspection, voicemail, motor control, video conferencing, Noise cancellation, Medical imaging, speech synthesis, satellite communication etc. 4. What are the advantages and disadvantages of VLIW architecture? Advantages of VLIW architecture 1. Increased performance 2. Better compiler targets 3. Potentially easier to program 4. Potentially scalable 5. Can add more execution units; allow more instructions to be packed into the VLIW instruction. Disadvantages of VLIW architecture 1. New kind of programmer/ compiler complexity 2. Program must keep track of instruction scheduling 3. Increased memory use 4. High power consumption 5. Misleading MIPS ratings The program bus carries the instruction code and immediate operands from program memory to the CPU. 7. What is pipelining? Pipelining a processor mean breaking down its instruction into a serious of discrete pipeline stages which can be completed in sequence by specialized hardware. 8. What is pipeline depth? 60

DIGITAL SIGNAL PROCESSING LAB The number of pipeline stages is referred to as the pipeline depth. 9. What is the pipeline depth of TMS320C50 and TMS320C54x? TMS 320C50 4 TMSS320C54x 6. 10. What are the different stages in pipelining? (i) The fetch phase (ii) The decode phase (iii) Memory read phase (iv) The execute phase

61

DIGITAL SIGNAL PROCESSING LAB

TMS320C50 DIGITAL SIGNAL PROCESSOR

62

DIGITAL SIGNAL PROCESSING LAB

EX.NO:08 CALCULATION OF FFT USING TMS320C50OBJECTIVE:

To implement the processing technique for calculation of FFT using the instructions of TMS320c50. AIM: To write a assembly language program to calculate the Fast Fourier transform for the given sequence.

THEORY:The fast fourier transform (FFT) is an algorithm used to compute the DFT with minimum number of calculations. It makes use of the symmetry and periodicity properties of twiddle factor WkN to effectively reduce the DFT computation time. It is based on the fundamental principal of decomposing the computation of DFT of a sequence of length N into successively smaller discrete Fourier transforms. The FFT algorithm provides speed-increase factors, when compared with direct computation of the DFT. The direct evaluation of DFT using the formula

requires N2 complex multiplications and N (N-1) complex additions. Thus for reasonably large values of N (in the order of 1000) direct evaluation of the DFT requires an inordinate amount of computation. By using FFT algorithms the number of computations can be reduced. For example, for an N-point DFT, the number of complex multiplications required using FFT is N 2 log2 N. If N=16, the number of complex multiplications required for direct evaluation of DFT is 256, whereas using FFT only 32 multiplications are required.

Two Types of FFT :1. Decimation in time ( DIT ) Algorithm :

63

DIGITAL SIGNAL PROCESSING LAB Decimation in-time algorithm is used to calculate the DFT of a N-point sequence. The idea is to break the N-point sequence into two sequences, the DFTs of which can be combined to give the DFT of the original N-point sequence. Initially the N-point sequence is divided into two N 2 point sequences xe(n) and xo(n), which have the even and odd members of x(n) respectively. The N 2 point DFTs of these two sequences are evaluated and combined to give the N-point DFT. Similarly the N 2 point DFTs can be expressed as a combination of N 4 point DFTs. This process is continued until we left with 2-point DFT. This algorithm is called decimation-in-time because the sequence x(n) is often splited into smaller subsequences. 2. Decimation-in-frequency algorithm : It is a popular form of the FFT algorithm. In this the output sequence x(k) is divided into smaller and smaller subsequences, that is why the name decimation in frequency. Initially the input sequence x(n) is divided into two sequences x1(n) and x2(n) consisting of the first N 2 samples of x(n) and the last N 2 samples of x(n) respectively. Then we find the N 2 point sequences f(n) and g(n) as f(n) = x1(n) + x2(n) and g(n) = [x1(n) - x2(n)]WnN The N 2 point DFTs of the above two sequences give even numbered and odd numbered output samples respectively. The above procedure can now be iterated to express each N 2 point DFT as a combination of two N 4 point DFTs. This process is continued until we left with 2-point DFT. PROGRAM: IN .set 8010H BITREV .set 8020H REAL .set 8040H IMG .set 8050H .MMREGS .TEXT LDP #100H LAR AR1,#IN LAR AR2,#BITREV SPLK #2H,05H LMMR INDX,#8005H MAR *,AR2 RPT #3H BLDD #IN,*BR0+ LAR AR2,#BITREV LAR AR3,#8030H LAR AR0,#1H FFT1: MAR *,AR2 LACC *+ SACB 64

DIGITAL SIGNAL PROCESSING LAB LT *+ MPY #1H APAC MAR *,AR3 SACL *+ LACB SPAC SACL *+,AR0 BANZ FFT1,*LAR AR3,#8030H LAR AR4,#REAL LAR AR5,#IMG MAR *,AR3 LACC * SACB ADRK #2H LT *MPY #1H APAC MAR *,AR4 SACL * ADRK #2H LACC #0H MAR *,AR5 SACL * ADRK #2H LACB SPAC MAR *,AR4 SACL *LACC #0H MAR *,AR5 SACL *-,AR3 LACC *,AR4 SACL * ADRK #2H SACL *,AR3 ADRK #2H LT * MPY #0FFFFH MAR *,AR5 SPL *,AR3 LT * MPY #1H MAR *,AR5 ADRK #2H SPL * 65

DIGITAL SIGNAL PROCESSING LAB H: B H

INPUT: 8010-0001 8011-0001 8012-0000 8013-0000 BIT_REV: 8020-0001 8021-0000 8022-0001 8023-0000 FFT1: 8030-0001 8031-0001 8032-0001 8033-0001 REAL: 8040-0002 8041-0001 8042-0000 8043-0001 IMG: 8050-0000 8051-FFFF 8052-0000 8053-0001

RESULT:

Thus assembly language program to perform FFT was written and executed successfully EX.NO:09 66

DIGITAL SIGNAL PROCESSING LAB

STUDY OF ADDRESSING MODESOBJECTIVE:

To know about the addressing modes of DSP using TMS320C50 AIM: To study the various addressing modes of DSP using simple programs. THOERY: The addressing modes in TMS320C50 are 1. Immediate addressing 2. Indirect addressing 3. Register addressing 4. Memory mapped register addressing 5. Direct addressing 6. Circular addressing modes. IMMEDIATE ADDRESSING MODES: The immediate addressing mode is used to handle constant data. It allows the program to operate an actual value the data can be either a 16 bit constant or constant length T, 9 or 13 depending on the length of data the addressing. In long addressing mode the data contained in a portion of a bit in a single word instruction. At the assembly code level the developer uses a prefix to specify immediate addressing as en: LD #80HA; The instruction load an immediate value 80H into the acculmator. ADD #K, Store immediate ADD #LK, Long immediate Long immediate may # k for multiplication 1 add # LK [for shift] 2 OR #LK [for shift] 3 XOR #LK [for shift] INDIRECT ADDRESSING MODE: The addressing modes uses the auxillary register to hold the address of operand in memory. In indirect addressing any location in the 64-k word data memory space can be accessed using a 16-bit address contained in accumulator. There are 7 types of indirect addressing modes. 1. Auto increment 2. auto decrement port inducting by adding the content AR0 3. port inducing by subtracting the content AR0 4. single indirect addressing with no increment 5. Single indirect addressing with no decrements 6. Bit reversed addressing EX: ADD {find} {shift} [ARM] SUB {shift} [ARM]. REGISTER ADDRESSING: The register addressing mode uses operands in CPU registered eitheir explicitly such as with a direct reference to a specific register or simplicity with instruction that reference contain register that if it is an BLPD- block move from the program to data memory with source address in BMAR. 67

DIGITAL SIGNAL PROCESSING LAB MEMORY MAPPED REGISTER ADDRESSING: Memory mapped register addressing is used to access efficiently the cpu on chip peripheral register. It operates like the direct addressing except that the upper bit of the address that is accessed are assumed to be 0.05. This allows the addressing and operand can be represented using a single 16-bit word. LAMM load accumulator with memory mapped register. SAMM store accumulator in memory mapped register. DIRECT ADDRESSING MODE: Direct addressing mode allowed the CPU to operate as an operand by specifying an offer from a base address defined in data pointer. In their mode the address of the operand is obtained by concatenating the 7 bit data memory address with the bit of the data page pointer 16- bit data memory address is placed or an internal direct data memory address. CIRCULAR ADDRESSING MODE: Circular addressing is the CSX addressing mode many algorithm. Such as convolution and the FIR filtering can use circular. Buffer in memory to event data to be processed. CBSR-1 circular buffer 1 start register CBSR-2 circular buffer 2 start register CBER-1 - circular buffer 1 end register. CBER-2 - circular buffer 2 end register. The 8 bit CBER enables A disables circular buffer operation to define circular first use load the start A and addressing into the corresponding buffer register. PROGRAM: IMMEDIATE ADDRESSING MODE: .mmregs .ps 0a00h .entry LACC #1000h LACC #1111h, 3 LAR AR0,#1000h LAR AR1,#1100h ADD #00FFh ADD #0011h,2 SPLK #10h,TREG0 MPY #0010h SUB #0022h SUB #0011h,3 .end DIRECT ADDRESSING MODES .mmregs .ps 0a00h 68

DIGITAL SIGNAL PROCESSING LAB .entry LDP #20h LACC 10h LACC 5h,2 LDP #22h LAR AR0,15h SACL 15h SACL 20h,3 SAMM AR7 LDP #12h ADD 25h ADD 7h,2 SUB 10h SUB 12h,2 SPLK #10h,TREG0 MPY 15h .end INDIRECT ADDRESSING MODE .mmregs .ps 0a00h .entry LAR AR0,#1000h LACC * LACC *,4,AR1 LAR AR1,#1010h SACL * SACL *+,2,AR0 LACC *-,2,AR1 LACC *0+ LACC *BR0+ ADD *+,0,AR0 SUB *-,2 SPLK #10h,TREG0 MPY * .end CIRCULAR ADDRESSING MODE .mmregs .ps 0a00h .entry SPLK #1000h,CBSR1 SPLK #1003h,CBER1 SPLK #08h,CBSR LACC AR0,#1000h LACC*# LACC *# 69

DIGITAL SIGNAL PROCESSING LAB LACC*# LACC *# .end

RESULT: Thus the various addressing modes of DSP using simple programs were studied.

EX.NO:1070

DIGITAL SIGNAL PROCESSING LAB

SAMPLING OF INPUT SIGNAL AND DISPLAYOBJECTIVE:

To implement the Sampling of input signal using the instructions of TMS320C50.AIM:

To write a assembly language program to sample the given input signal and display it. PROGRAM:.mmregs .text START: LDP #100H LAR AR1,#2FFFH REP: IN 0,06 RPT #0FH NOP IN 0,04 RPT #5FFFH NOP LACC 0 AND #0FFFH SACL 0 OUT 0,4 MAR *,AR1 BANZ REP,*B START .end

71

DIGITAL SIGNAL PROCESSING LAB

RESULT:

Thus assembly language program to perform sampling the input signal was written and executed successfully

EX.NO:1172

DIGITAL SIGNAL PROCESSING LAB

IMPLEMENTATION OF FIR FILTEROBJECTIVE: To know about the coding of TMS320C50 Processor for implementing the FIR filter of various windowing techniquesAIM:

To write an assembly language program to implement FIR filter.PROGRAM:

Approximation type: Window design - Blackmann Window * Filter type: highpass filter * Filter Order: 52

* Cutoff frequency in KHz = 3.000000 .mmregs .text B CTABLE: .word 0FCD3H .word 05H .word 0FCB9H .word 087H .word 0FD3FH .word 01ADH 73 START

DIGITAL SIGNAL PROCESSING LAB

.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 74

DIGITAL SIGNAL PROCESSING LAB .word 0E9FDH .word 04C5H .word 0D882H .word 044BCH .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 75

DIGITAL SIGNAL PROCESSING LAB

.word 0FFACH .word 0595H .word 0FFF8H .word 04ABH .word 0FF52H .word 0333H .word 0FE3DH .word 01ADH .word 0FD3FH .word 087H .word 0FCB9H .word 05H .word 0FCD3H * * * * 76 Move the Filter coefficients from program memory to data memory

DIGITAL SIGNAL PROCESSING LAB START: MAR *,AR0 LAR RPT AR0,#0200H #33H

BLKP CTABLE,*+ SETC CNF * * Input data and perform convolution * ISR: LDP #0AH

LACC #0 SACL 0 OUT 0,05 IN LAR 0,06H AR7,#0 ;change value to modify sampling freq. ;pulse to find sampling frequency

MAR *,AR7 BACK: IN NOP NOP NOP NOP MAR *,AR1 LAR AR1,#0300H 77 BANZ BACK,*0,4

DIGITAL SIGNAL PROCESSING LAB LACC 0 AND #0FFFH SUB #800H

SACL * LAR AR1,#333H

MPY #0 ZAC RPT MACD APAC LAR AR1,#0300H ;give as sach *,1 incase of overflow #33H 0FF00H,*-

SACH * LACC * ADD #800H SACL * OUT *,4 LACC #0FFH SACL 0 OUT 0,05 NOP B .end ISR

78

DIGITAL SIGNAL PROCESSING LAB

RESULT:

Thus assembly language program to perform implementation of FIR was written and executed successfully.

EX.NO:1279

DIGITAL SIGNAL PROCESSING LAB

CIRCULAR CONVOLUTION OF TWO SEQUENCESOBJECTIVE: To know about the coding of TMS320C50 Processor for circular convolution of two sequences.AIM:

To write an assembly language program to convolute the given two sequences.PROGRAM:

.MMREGS .TEXT START: LDP #100H LACC 0H SUB #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 LAR AR2,#8060H ; LAR AR3,#8050H LOOP3: LAR AR4,1H ZAP LOOP: MAR *,AR3 ; LT *+ MAR *,AR1 ; output MPY *+ SPL 5H ADD 5H MAR *,AR4 BANZ LOOP,*_, MAR *,AR2 SACL *+ CALL ROTATE 80

DIGITAL SIGNAL PROCESSING LAB LOOP2: MAR *,AR0 BANZ LOOP3,*_ H: B H ROTATE: LDP #100H ; LACC 1H SUB #1H SACL 2H LACC 0050H SACB ; ACCUMULATOR BUFFER LAR AR3,#8051H LAR AR5,#8070H LAR AR6,2H LOOP1: MAR *,AR3 LACC *+ MAR *,AR5 SACL *+ MAR *,AR6 BANZ LOOP1,*_ LACB ;

;

ACCUMULATOR AS LAST DATA MAR *,AR5 SACL *+ LACC #8070H SAMM BMAR LAR AR3,#8050H MAR *,AR3 RPT #3H ; BLDD BMAR,*+ ; RET INPUT: 8000-0004 x1(n) = 8050-0002 8051-0001 8052-0002 8053-0001 81

DIGITAL SIGNAL PROCESSING LAB h2(n) = 8060-0001 8061-0002 8062-0003 8063-0004 OUTPUT: 8010-000E 8011-0010 8012-000E 8013-0010

RESULT:

Thus assembly language program to circular convolution for two sequences was written and executed successfully. VIVA QUESTIONS 82

DIGITAL SIGNAL PROCESSING LAB 1. TMS320C5X accepts the source code from c1x,c2x, and c2xx. 2. PIPELINING is process of breaking down its instruction 3. TMS320C5X has the pipeline F-D-R-X(4 levels) 4. TMS320c50 has 16 bit processor running at 4MHz 5. TMS320c50 has programmable memory map 6. TMS320c50 address range is 224K x 16 bit words 7. TMS320c50 has onchip memory include 10K words of the RAM 8. TMS320c50 has 2K words of the ROM 9. TMS320c50 is 16 bit processor 10. TMS320c50 has the signal instruction execution time is 50nsec 11. TMS320c54x has 16 bit fixed point digital signal processor 12. TMS320c54x was introduced in JAPAN IN 1994 13. TMS320c54x has 3 data memory buses

83