+ All Categories
Home > Documents > Trinity Dsp Lab Manual

Trinity Dsp Lab Manual

Date post: 27-Nov-2015
Category:
Upload: blzz2net
View: 88 times
Download: 5 times
Share this document with a friend
Description:
dsp lab manual
Popular Tags:
109
Department of Electronics & Comm. Engineering LAB MANUAL SUBJECT: LAB 508 DIGITAL SIGNAL PROCESSING B.Tech III Year – V Semester (Branch: ECE)
Transcript
Page 1: Trinity Dsp Lab Manual

Department of Electronics & Comm. Engineering

LAB MANUAL

SUBJECT: LAB 508 DIGITAL SIGNAL PROCESSING

B.Tech III Year – V Semester (Branch: ECE)

TRINITY COLLEGE OF ENGINEERING

Page 2: Trinity Dsp Lab Manual

 Naruvamoodu, Kerala, 695020

TABLE OF CONTENTS

EXP.No. Topic Page No.

1FAMILIARISATION WITH MATLAB

4

2GENERATION OF BASIC CONTINUES ELEMENTARY SIGNALS 7

3GENERATION OF BASIC DISCRETE ELEMENTARY SIGNALS 10

4GENERATION OF AM , FM AND PWM WAVE 13

5

GENERATION OF LINEAR CONVOLUTION USING

FUNCTION ONLY DFT WITH OUT FUNCTION

18

6

GENERATION OF CIRCULAR CONVOLUTION USING

DFT WITH OUT

FUNCTION

21

7GENERATION OF LINEAR CONVOLUTION USING CIRCULAR CONVOLUTION 24

8 GENERATION OF DFT 26

9 GENERATION OF IDFT 28

10

TO GENERATE A PROGRAM FOR EXPLAINING THE CONCEPT OF ALLIASING. 30

11 TO GENERATE A PROGRAM FOR IMPULSE RESPONSE OF A LTI SYSTEM

32

2

Page 3: Trinity Dsp Lab Manual

12GENERATION OF BUTTERWORTH IIR FILTER 34

13GENERATION OF CHEBYSHEV FIRST ORDER FILTER 39

14GENERATION OF CHEBYSHEV SECOND ORDER FILTER 44

15

GENERATION OF FIR FILTER USING RECTANGULAR WINDOW BARTLET WINDOW BLACKMANN WINDOW KAISER WINDOW HANNING WINDOW HAMMINGB WINDOW

49

16 GENERATION OF EQUIRIPPLE FILTER 55

17GENERATION OF LINEAR CONVOLUTION USING DFT(OVERLAP ADD AND OVERLAP SAVE METHOD

60

18GENERATION OF FIR FILTER DESIGN USING FREQUENCY SAMPLING METHOD 64

19GENERATION OF Z-TRANSFORM AND INVERSE Z- TRANSFORM 66

3

Page 4: Trinity Dsp Lab Manual

FAMILIARISATION WITH MATLAB

Aim: To familiarize with MATLAB software, general functions and signal processing toolbox functions.

The name MATLAB stands for MATrix LABoratory produced by Math works Inc., USA. It is a matrix-based powerful software package for scientific and engineering computation and visualization. Complex numerical problems can be solved in a fraction of the time that required with other high level languages. It provides an interactive environment with hundreds of built -in –functions for technical computation, graphics and animation. In addition to built-in-functions, user can create his own functions. MATLAB offers several optional toolboxes, such as signal processing, control systems, neural networks etc. It is command driven software and has online help facility.

MATLAB has three basic windows normally; command window, graphics window and edit window. Command window is characterized by the prompt ‘>>’.All commands and the ready to run program filename can be typed here. Graphic window gives the display of the figures as the result of the program. Edit window is to create program files with an extension .m.

Some important commands in MATLAB

Help List topics on which help is available

Help command name Provides help on the topic selected

Demo runs the demo program

Who Lists variables currently in the workspace

Whos Lists variables currently in the workspace with their size

Clear clears the workspace, all the variables are removed

Clear x,y,z Clears only variables x,y,z

Quit Quits MATLAB

4

Page 5: Trinity Dsp Lab Manual

Some of the frequently used built-in-functions in Signal Processing Toolbox

filter(b.a.x) Syntax of this function is Y = filter(b.a.x) It filters the data in vector x with the filter described by vectors a and b to create the filtered data y.

fft (x) It is the DFT of vector x

ifft (x) It is the DFT of vector x

conv (a,b) Syntax of this function is C = conv (a,b) It convolves vectors a and b. The resulting vector is of Length, Length (a) + Length (b)-1

deconv(b,a) Syntax of this function is [q,r] = deconv(b,a) It deconvolves vector q and the remainder in vector r such that b = conv(a,q)+r

butter(N,Wn) designs an Nth order lowpass digitalButterworth filter and returns the filter coefficients in length N+1 vectors B (numerator) and a (denominator). The coefficients are listed in descending powers of z. The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

buttord(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital Butterworth filter that loses no more than Rp dB in the passband and has at least Rs dB of attenuation in the stopband. Wp and Ws are the passband and stopband edge frequencies, Normalized from 0 to 1, (where 1 corresponds to pi rad/sec)

Cheby1(N,R,Wn) designs an Nth order lowpass digital Chebyshev filter with R decibels of peak-to-peak ripple in the passband. CHEBY1 returns the filter coefficients in length N+1 vectors B (numerator) and A (denominator). The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

Cheby1(N,R,Wn,'high') designs a highpass filter.

Cheb1ord(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital Chebyshev Type I filter that loses no more than Rp dB in the passband and has at least Rs dB of attenuation in the stopband. Wp and Ws are the passband and stopband edge frequencies, normalized from 0 to 1 (where 1 corresponds to pi radians/sample)

cheby2(N,R,Wn) designs an Nth order lowpass digital Chebyshev filter with the stopband ripple R decibels down andstopband edge frequency Wn. CHEBY2 returns the filter coefficients in length N+1 vectors B

5

Page 6: Trinity Dsp Lab Manual

(numerator) and A . The cutoff frequency Wn must be 0.0 < Wn < 1.0, with 1.0 corresponding to half the sample rate.

cheb2ord(Wp, Ws, Rp, Rs) returns the order N of the lowest order digital Chebyshev Type II filter that loses no more than Rp dB in the passband and has at least Rs dB of attenuation in the stopband. Wp and Ws are the passband and stopband edge frequencies.

abs(x) It gives the absolute value of the elements of x. When x is complex, abs(x) is the complex modulus (magnitude) of the elements of x.

angle(H) It returns the phase angles of a matrix with complex elements in radians.

freqz(b,a,N) Syntax of this function is [h,w] = freqz(b,a,N) returns the Npoint frequency vector w in radians and the N-point complex frequency response vector h of the filter b/a.

stem(y) It plots the data sequence y aa stems from the x axis terminated with circles for the data value.

stem(x,y) It plots the data sequence y at the values specified in x.

plot(x,y) It plots vector y versus vector x. If x or y is a matrix, then the vector is plotted versus the rows or columns of the matrix, whichever line up.

title(‘text’) It adds text at the top of the current axis.

xlabel(‘text’) It adds text beside the x-axis on the current axis.

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

6

Page 7: Trinity Dsp Lab Manual

GENERATION OF BASIC CONTINUES SIGNALS

Experiment No: - 01

AIM: - To write a MATLAB program to common continues time signals

PROCEDURE:- Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program for the output see command window\ Figure window

ALGORITHM:- Get the amplitude and frequency of the signal Use ‘sin’, ’cos ,’square’ matlab built in functions Using ‘plot’ function plot the signal

MATLAB CODE:-

clc;clear all;close all;t=0:0.001:1;f=input('Enter the value of frequency');a=input('Enter the value of amplitude');subplot(3,3,1);y=a*sin(2*pi*f*t);plot(t,y,);xlabel('time');ylabel('amplitude');title('sine wave')grid on;subplot(3,3,2);z=a*cos(2*pi*f*t);plot(t,z);xlabel('time');ylabel('amplitude');

7

Page 8: Trinity Dsp Lab Manual

title('cosine wave')grid on;subplot(3,3,3);s=a*square(2*pi*f*t);plot(t,s);xlabel('time');ylabel('amplitude');title('square wave')grid on;subplot(3,3,4);plot(t,t);xlabel('time');ylabel('amplitude');title('ramp wave')grid on;subplot(3,3,5);plot(t,a,'r');xlabel('time');ylabel('amplitude');title('unit step wave')grid on;x=a*exp(-t);subplot(3,3,6);plot(t,x);xlabel('Time');ylabel('Amplitude');title('Exponentially Decaying Signal');grid on;

FIGURE:-

8

Page 9: Trinity Dsp Lab Manual

SAMPLE INPUT:-

Enter the value of frequency2Enter the value of amplitude1

RESULTS: - Thus the generation of continues time signals using matlab was verified

9

Page 10: Trinity Dsp Lab Manual

GENERATION OF BASIC DISCRETE SIGNALS

Experiment No: - 02

AIM: - To write a MATLAB program to common discrete time signals

PROCEDURE:- Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program for the output see command window\ Figure window

ALGORITHM:- Get the amplitude and frequency of the signal Use ‘sin’, ’cos ,’square’ matlab built in functions Using ‘stem’ function plot the signal

MATLAB CODE:-

clc;clear all;close all;n=0:1:50;f=input('Enter the value of frequency');a=input('Enter the value of amplitude');N=input('Enter the length of unit step');subplot(3,3,1);y=a*sin(2*pi*f*n);stem(n,y,'r');xlabel('time');ylabel('amplitude');title('sine wave')grid on;subplot(3,3,2);z=a*cos(2*pi*f*n);stem(n,z);xlabel('time');ylabel('amplitude');

10

Page 11: Trinity Dsp Lab Manual

title('cosine wave')grid on;subplot(3,3,3);s=a*square(2*pi*f*n);stem(n,s);xlabel('time');ylabel('amplitude');title('square wave')grid on;subplot(3,3,4);stem(n,n);xlabel('time');ylabel('amplitude');title('ramp wave')grid on;x=0:N-1;d=ones(1,N);subplot(3,3,5);stem(x,d,'r');xlabel('time');ylabel('amplitude');title('unit step wave')grid on;x=a*exp(-t);subplot(3,3,6);stem(t,x);xlabel('Time');ylabel('Amplitude');title('Exponentially Decaying Signal');grid on;

FIGURE:-

11

Page 12: Trinity Dsp Lab Manual

SAMPLE INPUT:-

Enter the value of frequency 0.03Enter the value of amplitude 1Enter the length of unit step 9

RESULTS: - Thus the generation of discrete time signals using matlab was verified.

12

Page 13: Trinity Dsp Lab Manual

GENERATION OF AM, FM AND PWM WAVE

Experiment No: - 03

AIM: - To write MATLAB program to generating AM, FM and PWM wave

PROCEDURE:- Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program for the output see command window\ Figure window

ALGORITHM:- Get the amplitude and frequency of the signal Use ‘sin’ matlab built in functions Using ‘plot’ function plot the signal

(a) AM WAVE

MATLAB CODE:-

clc;clear all;close all;t=0:0.001:1;set(0,'defaultlinelinewidth',2);A=5;fm=input('Message frequency=');fc=input('Carrier frequency=');mi=input('Modulation Index='); Sm=A*sin(2*pi*fm*t);subplot(3,1,1);plot(t,Sm);xlabel('Time');ylabel('Amplitude');title('Message Signal');grid on;

13

Page 14: Trinity Dsp Lab Manual

Sc=A*sin(2*pi*fc*t);subplot(3,1,2);plot(t,Sc);xlabel('Time');ylabel('Amplitude');title('Carrier Signal');grid on; Sfm=(A+mi*Sm).*sin(2*pi*fc*t);subplot(3,1,3);plot(t,Sfm);xlabel('Time');ylabel('Amplitude');title('AM Signal');grid on;

FIGURE:-

SAMPLE INPUT:-

Enter the value of message frequency 10Enter the value of carrier frequency 100Enter the value of modulation index 0.5

14

Page 15: Trinity Dsp Lab Manual

(b)FM WAVE

MATLAB CODE:-

clc;clear all;close all;fm=input('Message Frequency=');fc=input('Carrier Frequency=');mi=input('Modulation Index=');t=0:0.0001:0.1;m=sin(2*pi*fm*t);subplot(3,1,1);plot(t,m);xlabel('Time');ylabel('Amplitude');title('Message Signal');grid on; c=sin(2*pi*fc*t);subplot(3,1,2);plot(t,c);xlabel('Time');ylabel('Amplitude');title('Carrier Signal');grid on; y=sin(2*pi*fc*t+(mi.*sin(2*pi*fm*t)));subplot(3,1,3);plot(t,y);xlabel('Time');ylabel('Amplitude');title('FM Signal');grid on;

15

Page 16: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the value of message frequency 25Enter the value of carrier frequency 400Enter the value of modulation index 10

(c) PWM WAVE

MATLAB CODE:-

clc;clear all;close all;F2=input('Message frequency=');F1=input('Carrier Sawtooth frequency=');A=5;t=0:0.001:1;c=A.*sawtooth(2*pi*F1*t);subplot(3,1,1);plot(t,c);xlabel('time');ylabel('Amplitude');title('Carrier sawtooth wave');grid on;m=0.75*A.*sin(2*pi*F2*t);subplot(3,1,2);

16

Page 17: Trinity Dsp Lab Manual

plot(t,m);xlabel('Time');ylabel('Amplitude');title('Message Signal');grid on; n=length(c);for i=1:nif (m(i)>=c(i)) pwm(i)=1;else pwm(i)=0;endendsubplot(3,1,3);plot(t,pwm);xlabel('Time');ylabel('Amplitude');title('plot of PWM');axis([0 1 0 2]);grid on;

FIGURE:-

SAMPLE INPUT:-

Message frequency=1Carrier Saw tooth frequency=10

RESULTS: - Thus the program for FM, AM and PWM is written using MATLAB and verified.

17

Page 18: Trinity Dsp Lab Manual

GENERATION OF LINEAR CONVOLUTION USING FUNCTION ONLY, DFTAND WITH OUT FUNCTION

Experiment No: - 04

AIM: - TO write a MATLAB program to compute linear convolution of two given sequences

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Read the input sequence x[n] ,and plot Read the impulse sequence h[n] , and plot Use the matlab function ‘conv’or dft or loop Convolve the two sequence and plot the result

a) Linear convolution using function

MATLAB CODE:-

clc;x=input('Enter the sequence 1:');h=input('Enter the sequence 2:');y=conv(x,h);subplot(3,1,1);stem(x);ylabel('Amplitude->');xlabel('N');subplot(3,1,2);stem(h);ylabel('Amplitude->');xlabel('N');subplot(3,1,3);stem(y);ylabel('Amplitude->');xlabel('N');

18

Page 19: Trinity Dsp Lab Manual

b)Linear convolution using DFT

MATLAB CODE:-

clc;n1=input('enter the length of sequence');x=input('Enter the sequence 1:');n2=input('enter the length of sequence');h=input('Enter the sequence 2:');x=[x,zeros(1,n2-1)];h=[h,zeros(1,n1-1)];X=fft(x);H=fft(h);Y=X.*H;y=ifft(Y);subplot(311);stem(x);subplot(312);stem(h);title('using DFT');subplot(313);stem(y)

c)Linear convolution without using Function

MATLAB CODE:-

close all clear all x=input('Enter x: ') h=input('Enter h: ') m=length(x); n=length(h); X=[x,zeros(1,n)]; H=[h,zeros(1,m)]; for i=1:n+m-1 Y(i)=0; for j=1:m if(i-j+1>0) Y(i)=Y(i)+X(j)*H(i-j+1); else end end end Y stem(Y);

19

Page 20: Trinity Dsp Lab Manual

ylabel('Y[n]'); xlabel('----->n'); title('Convolution of Two Signals without conv function');

FIGURE:

SAMPLE INPUT:-

Enter the co-efficient of x(n)=[1 2 3]

Enter the co-efficient of h(n)=[1 1 1]

RESULTS: - Thus the program for linear convolution is written using MATLAB and verified.

y= 1 3 6 5 3

20

Page 21: Trinity Dsp Lab Manual

GENERATION OF CIRCULAR CONVOLUTION USING DFT AND WITH OUT FUNCTION

Experiment No: - 05

AIM: - TO write a MATLAB program to compute circular convolution of two given sequences

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:- Read the input sequence x1[n], and plot Read the input sequence x2[n], and plot Use the user defined matlab function ‘crconc’ convolve the two sequences and plot the result

a)Circular convolution using DFT

MATLAB CODE:-

clc;n1=input('enter the length of sequence');x=input('Enter the sequence 1:');h=input('Enter the sequence 2:');X=fft(x);H=fft(h);Y=X.*H;y=ifft(Y);subplot(311);stem(x);title('sequence1')subplot(312);stem(h);title('sequence2');subplot(313);stem(y);title('using dft');

21

Page 22: Trinity Dsp Lab Manual

b)Circular convolution without using Function

MATLAB CODE:-

clc;x=input('Enter the sequence 1:');h=input('Enter the sequence 2:');n1=length(x); n2=length(h); N=max(n1,n2);x=[x,zeros(1,N-n1)]; h=[h,zeros(1,N-n2)];for n=0:N-1 y(n+1)=0;for i=0:N-1 j=mod(n-i,N); y(n+1)=y(n+1)+x(i+1)*h(j+1);endenddisplay(y)subplot(131);stem(x);title('firstsequence');subplot(132);stem(h);title('second sequence');subplot(133);stem(y);title('circular convolution');

FIGURE:

22

Page 23: Trinity Dsp Lab Manual

SAMPLE INPUT:-

Enter the co-efficient of x(n)=[1 2 3]

Enter the co-efficient of h(n)=[1 1 1]

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

y = 6 6 6

23

Page 24: Trinity Dsp Lab Manual

GENERATION OF LINEAR CONVOLUTION USING CIRCULAR CONVOLUTION

Experiment No: - 06

AIM: - TO write a MATLAB program to compute linear convolution using circular convolution.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program for the output see command window\ Figure window

ALGORITHM:- Read the input sequence x1[n], and plot Read the input sequence x2[n], and plot Use the user defined matlab functions convolve the two sequences and plot the result

MATLAB CODE:-

clear all;close all;x1=input('Enter the sequence 1: ');x2=input('Enter the sequence 2: ');subplot(311);stem(x1);title('Input sequence1');subplot(312);stem(x2);title('Input sequence2');N1=numel(x1);N2=numel(x2);x1=[x1 zeros(1,N2-1)];x2=[x2 zeros(1,N1-1)];y=cconv(x1,x2);subplot(313);stem(y);title('Lin Using Circular');

24

Page 25: Trinity Dsp Lab Manual

FIGURE:

SAMPLE INPUT:-

Enter the co-efficient of x(n)=[1 2 3 4]

Enter the co-efficient of h(n)=[1 1 0 0]

RESULTS: - Thus the program for linear convolution using circular convolution is written using MATLAB and verified.

25

Page 26: Trinity Dsp Lab Manual

GENERATION OF DISCRETE FOURIER TRANSFORM

Experiment No: - 07

AIM: - TO write a MATLAB program to find the DFT of a sequence

PROCEDURE:- Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Enter the input sequence x[n] Enter the length of sequence Use the matlab function ‘fft’ Plot the input and output sequence

MATLAB CODE:-

clc;clear all;close all;N=input('Enter the value of N');x=input('Enter the input sequence X(n):');t=0:N-1;subplot(2,1,1);stem(t,x);xlabel('TIME');ylabel('AMPLITUDE');title('INPUT SIGNAL');grid on;y=fft(x,N)subplot(2,1,2);stem(t,y);xlabel('TIME');ylabel('AMPLITUDE');title('OUTPUT SIGNAL');grid on;

26

Page 27: Trinity Dsp Lab Manual

FIGURE:

SAMPLE INPUT:-

Enter the value of N 4

Enter the input sequence X(n):[1 2 3 4]

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

y = 10.0000 -2.0000 + 2.0000i -2.0000 -2.0000 - 2.0000i

27

Page 28: Trinity Dsp Lab Manual

INVERSE DISCRETE FOURIER TRANSFORM

Experiment No: - 08

AIM: - TO write a MATLAB program to find the IDFT of a sequence

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Enter the output sequence y[n] Enter the length of sequence,N Use the matlab function ‘ifft’ Plot the input and output sequence

MATLAB CODE:-

clc;clear all;close all;N=input('Enter the value of N=');y=input('Enter the sequence y[n]=');t=0:N-1;subplot(2,1,1);stem(t,y);xlabel('TIME');ylabel('AMPLITUDE');title('INPUT SIGNAL');grid on;x=ifft(y,N)subplot(2,1,2);stem(t,x);xlabel('TIME');ylabel('AMPLITUDE');title('OUTPUT SIGNAL');grid on;;

28

Page 29: Trinity Dsp Lab Manual

FIGURE:

SAMPLE INPUT:-

Enter the value of N=4

Enter the sequence y[n]=[10 -2+2i -2 -2-2i]

RESULTS: - Thus the program for idft is written using MATLAB and verified.

x =1 2 3 4

29

Page 30: Trinity Dsp Lab Manual

GENERATE A PROGRAM FOR EXPLAINING THE CONCEPT OF ALLIASING

Experiment No: - 09

AIM: - TO write a MATLAB program to find the concept of aliasing.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Get the amplitude and frequency of the signal Use ‘sin’ matlab built in functions Using ‘plot’ function plot the signal

MATLAB CODE:-

clc;t=-10:.01:10;T=4;fm=1/T;x=cos(2*pi*fm*t);fs1=1.6*fm;fs2=2*fm;fs3=8*fm;n1=-4:1:4;xn1=cos(2*pi*n1*fm/fs1);subplot(331);plot(t,x);xlabel('time in sec');ylabel('x(t)');title('continous time signal'); subplot(332);stem(n1,xn1);hold on;subplot(332);plot(n1,xn1);xlabel('n');ylabel('x(n)');

30

Page 31: Trinity Dsp Lab Manual

title('discrete signal with fs<fm'); n2=-5:1:5;xn2=cos(2*pi*n2*fm/fs2);subplot(333);stem(n2,xn2);hold on;subplot(333);plot(n2,xn2);xlabel('n');ylabel('x(n)');title('discrete signal with fs=fm'); n3=-20:1:20;xn3=cos(2*pi*n3*fm/fs3);subplot(334);stem(n3,xn3);hold on;subplot(334);plot(n3,xn3);xlabel('n');ylabel('x(n)');title('discrete signal with fs>fm');

FIGURE:

RESULTS: - Thus the program to find the concept of Aliasing is written using MATLAB and verified.

31

Page 32: Trinity Dsp Lab Manual

GENERATE A PROGRAM FOR IMPULSE RESPONSE OF A LTI SYSTEM

Experiment No: - 10

AIM: - TO write a MATLAB program to find the impulse response of a system defined by a difference equation

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Create a matrix a for the coefficient of y[n] Create a matrix b for the coefficient of x[n] Generate an impulse signal Find the response h[n] of the system defined by a and b coefficient to the impulse signal using ‘filter ‘command

MATLAB CODE:-

clc;clear all;close all;N=input('Enter the required length of impulse response N=');n=0:N-1;b=input('Enter the co-efficients of x(n),b=');a=input('Enter the co=efficients of y(n),a=');x=[1,zeros(1,N-1)];y=filter(b,a,x);stem(n,y);xlabel('time');ylabel('amplitude');title('IMPULSE RESPONSE');grid on;

FIGURE:32

Page 33: Trinity Dsp Lab Manual

SAMPLE INPUT:-

Y[n]+0.7y[n-1]-0.45y[n-2]-0.6y[n-3]=0.8x[n]-0.44x[n-1]+0.36x[n-2]+0.2x[n-3]

Enter the required length of impulse response N=40Enter the co-efficient of x (n),b=[0.8 -0.44 0.36 0.02]Enter the co-efficient of y (n),a=[1 0.7 -0.45 -0.6]

RESULTS: - Thus the program for impulse response of an LTI system is written using MATLAB and verified.

GENERATION OF BUTTERWORTH IIR FILTER

33

Page 34: Trinity Dsp Lab Manual

Experiment No: - 11

AIM: - TO write a MATLAB program to plot magnitude response and phase response of digital Butter worth filters.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Get the passband and stopband ripples Get the passband and stopband edge frequencies Calculate the order of the filter using ‘ buttord ’ function Find the filter coefficients, using ‘butter’ function Draw the magnitude and phase response

(i) BUTTERWORTH LOW PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input('enter the passband attenuation:'); rs=input('enter the stop band attenuation:'); wp=input('enter the pass band frequency:'); ws=input('enter the stop band frequency:'); [N,wn]=buttord(wp/pi,ws/pi,rp,rs); [b,a]=butter(N,wn); freqz(b,a)

34

Page 35: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:- Enter the passband attenuation:0.4 Enter the stop band attenuation:30 Enter the pass band frequency:0.2*pi Enter the stop band frequency:0.4*pi

(ii)BUTTERWORTH HIGH PASS FILTER

MATLAB CODE:- clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=buttord(wp/pi,ws/pi,rp,rs); [b,a]=butter(N,wn,'high'); freqz(b,a);

35

Page 36: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:- Enter the pass band attenuation:0.4 Enter the stop band attenuation:30 Enter the pass band frequency:0.6*pi Enter the stop band frequency:0.2*pi

(iii)BUTTERWORTH BAND PASS FILTER

MATLAB CODE:- clc; clear all; close all; rp=input('enter the passband attenuation:'); rs=input('enter the stop band attenuation:'); wp=input('enter the pass band frequency:'); ws=input('enter the stop band frequency:'); [N,wn]=buttord(wp/pi,ws/pi,rp,rs); [b,a]=butter(N,wn); freqz(b,a);

36

Page 37: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the passband attenuation:0.2 Enter the stop band attenuation:20 Enter the pass band frequency:[0.2*pi,0.4*pi] Enter the stop band frequency: [0.1*pi, 0.5*pi]

(iv) BUTTERWORTH BAND STOP FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input('enter the passband attenuation:'); rs=input('enter the stop band attenuation:'); wp=input('enter the pass band frequency:'); ws=input('enter the stop band frequency:'); [N,wn]=buttord(wp/pi,ws/pi,rp,rs); [b,a]=butter(N,wn,’stop’); freqz(b,a);

37

Page 38: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:- Enter the passband attenuation:0.2 Enter the stop band attenuation:20 Enter the pass band frequency:[0.1*pi,0.5*pi] Enter the stop band frequency:[0.2*pi,0.4*pi]

RESULTS:- Thus the magnitude response and phase response of Digital Butter worth filters was verified.

38

Page 39: Trinity Dsp Lab Manual

GENERATION OF CHEBYSHEV FIRST ORDER FILTERS

Experiment No: - 12

AIM: - TO write MATLAB programs to plot magnitude response and phase response of digital Chebyshev type-1 Low pass, High pass, Band pass and Band stop filters.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

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

(i) CHEBYSHEV(TYPE-1) LOW PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby1(N,rp,wn); freqz(b,a);

39

Page 40: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the pass band attenuation:20 Enter the stop band attenuation:50 Enter the pass band frequency:0.3*pi Enter the stop band frequency:0.4*pi

(ii) CHEBYSHEV(TYPE-1)HIGH PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby1(N,rp,wn,'high'); freqz(b,a);

40

Page 41: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:- Enter the pass band attenuation:20 Enter the stop band attenuation:50 Enter the pass band frequency:0.4*pi Enter the stop band frequency:0.3*pi

(iii) CHEBYSHEV(TYPE-1) BAND PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby1(N,rp,wn);

41

Page 42: Trinity Dsp Lab Manual

freqz(b,a); FIGURE:-

SAMPLE INPUT:-

Enter the pass band attenuation:20 Enter the stop band attenuation:98 Enter the pass band frequency:[0.3*pi,0.5*pi] Enter the stop band frequency:[0.1*pi,0.8*pi]

(iv) CHEBYSHEV(TYPE-1)BAND STOP FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input('Enter the pass band attenuation:'); rs=input('Enter the stop band attenuation:'); wp=input('Enter the pass band frequency:'); ws=input('Enter the stop band frequency:'); [N,wn]=cheb1ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby1(N,rp,wn,'stop'); freqz(b,a);

42

Page 43: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the pass band attenuation:20 Enter the stop band attenuation:98 Enter the pass band frequency:[0.1*pi,0.8*pi] Enter the stop band frequency:[0.3*pi,0.5*pi]

RESULTS: - Thus the Amplitude response and phase response of chebyshev type 1 filters were verified.

43

Page 44: Trinity Dsp Lab Manual

GENERATION OF CHEBYSHEV SECOND ORDER FILTERS

Experiment No: -13

AIM: - TO write MATLAB programs to plot magnitude response and phase response of digital Chebyshev type-2 Low pass, High pass, Band pass and Band stop filters

PROCEDURE:- ‘

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Get the passband and stopband ripples Get the passband and stopband edge frequencies Calculate the order of the filter using ‘ cheb2ord ’ function Find the filter coefficients, using ‘cheby2’ function Draw the magnitude and phase response

(i) CHEBYSHEV(TYPE-2) LOW PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=cheb2ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby2(N,rp,wn); freqz(b,a);

44

Page 45: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the pass band attenuation:20 Enter the stop band attenuation:70 Enter the pass band frequency:0.3*pi Enter the stop band frequency:0.4*pi

(ii) CHEBYSHEV (TYPE-2) HIGH PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=cheb2ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby2(N,rp,wn,'high'); freqz(b,a)

45

Page 46: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the pass band attenuation:20 Enter the stop band attenuation:70 Enter the pass band frequency:0.4*pi Enter the stop band frequency:0.3*pi

(iii) CHEBYSHEV (TYPE-2) BAND PASS FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input ('Enter the pass band attenuation:'); rs=input ('Enter the stop band attenuation:'); wp=input ('Enter the pass band frequency:'); ws=input ('Enter the stop band frequency:'); [N,wn]=cheb2ord(wp/pi,ws/pi,rp,rs); [b,a]=cheby2(N,rp,wn); freqz(b,a);

46

Page 47: Trinity Dsp Lab Manual

FIGURE:-

SAMPLE INPUT:-

Enter the pass band attenuation:2 Enter the stop band attenuation:20 Enter the pass band frequency:[0.3*pi,0.4*pi] Enter the stop band frequency:[0.1*pi,0.5*pi]

(iv) CHEBYSHEV (TYPE-2) BAND STOP FILTER

MATLAB CODE:-

clc; clear all; close all; rp=input('Enter the pass band attenuation:'); rs=input('Enter the stop band attenuation:'); wp=input('Enter the pass band frequency:'); ws=input('Enter the stop band frequency:'); [N,wn]=cheb2ord (wp/pi,ws/pi,rp,rs); [b,a]=cheby2(N,rp,wn,'stop'); freqz(b,a);

FIGURE:-

47

Page 48: Trinity Dsp Lab Manual

SAMPLE INPUT:- Enter the pass band attenuation:2 Enter the stop band attenuation:20 Enter the pass band frequency:[0.1*pi,0.5*pi] Enter the stop band frequency:[0.3*pi,0.4*pi]

RESULTS:- Thus the Amplitude response and phase response of chebyshev type 2 filters were verified.

GENERATION OF FIR FILTER USING WINDOWS. (RECTANGULAR, BARTLET

48

Page 49: Trinity Dsp Lab Manual

BLACKMANN, KAISER, HANNING AND HAMMINGB WINDOW)

Experiment No: - 14

AIM: - TO write a MATLAB program to plot magnitude response and phase response of digital FIR filter using windows,

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Get the order of the filter Get the cut off frequency Use ‘fir1 ’& corresponding window functions to compute the filter coefficient Draw the magnitude and phase response

MATLAB CODE:-

clc;clear all;close all;rp=input('enter passband ripple');rs=input('enter the stopband ripple');fp=input('enter passband freq');fs=input('enter stopband freq');f=input('enter sampling freq ');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;endc=input('enter your choice of window function 1. rectangular 2. bartlet 3.kaiser 4.blackman 5.hanning 6.hamming: \n ');if(c==1)y=rectwin(n1);disp('Rectangular window filter response');

49

Page 50: Trinity Dsp Lab Manual

endif (c==2)y=bartlett(n1);disp('bartlett window filter response');endif(c==3)y=kaiser(n1);disp('kaiser window filter response');endif(c==4)y=blackman(n1);disp('blackmann window filter response');endif(c==5)y=hanning(n1);disp('hanning window filter response');endif(c==6)y=hamming(n1);disp('hamming window filter response');end %LPFb=fir1(n,wp,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,1);plot(o/pi,m);title('LPF');ylabel('Gain in dB-->');xlabel('(a) Normalized frequency-->'); %HPFb=fir1(n,wp,'high',y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,2);plot(o/pi,m);title('HPF');ylabel('Gain in dB-->');xlabel('(b) Normalized frequency-->'); %BPFwn=[wp,ws];b=fir1(n,wn,y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,3);plot(o/pi,m);title('BPF');ylabel('Gain in dB-->');xlabel('(b) Normalized frequency-->'); %BSFwn=[wp,ws];b=fir1(n,wn,'stop',y);[h,o]=freqz(b,1,256);m=20*log10(abs(h));subplot(2,2,4);plot(o/pi,m);title('BSF');ylabel('Gain in dB-->');

50

Page 51: Trinity Dsp Lab Manual

xlabel('(b) Normalized frequency-->');

FIGURES:-

1) USING RECTANGULAR WINDOW

2) USING BARTLET WINDOW

3) USING BLACKMANN WINDOW

51

Page 52: Trinity Dsp Lab Manual

4) USING KAISER WINDOW

5) USING HANNING WINDOW

52

Page 53: Trinity Dsp Lab Manual

6) USING HAMMING WINDOW

53

Page 54: Trinity Dsp Lab Manual

SAMPLE INPUTS:-

Enter the value of pass band ripple:0.05 Enter the value of stop band ripple:0.04Enter the value of pass band frequency:1500Enter the value of stop band frequency:2000Enter the value of sampling frequency:9000

RESULTS: - Thus the magnitude response of FIR filter using all types of windows was verified.

GENERATION OF EQUIRIPPLE FILTER

54

Page 55: Trinity Dsp Lab Manual

Experiment No: -15

AIM: - To write a MATLAB program to plot magnitude response of Equi-Ripple filter.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Get the order of the filter Get the cut off frequency Use corresponding filter functions to compute the filter coefficient. Draw the magnitude.

1) LOWPASS EQUI RIPPLE FILTER

MATLAB CODE:-

clc;close all;clear all;Fs=1000;Fp=input('Input the pass band frequency Fp= ');Fst=input('Input the stop band frequency Fst= ');Ap=input('Input the pass band attenuation Ap= ');Ast=input('Input the stop band attenuation Ast= ');d = fdesign.lowpass('Fp,Fst,Ap,Ast',0.2, 0.22, 1, 60);Hd=design(d,'equiripple'); fvtool(Hd);

55

Page 56: Trinity Dsp Lab Manual

FIGURE:-

2) HIGH PASS EQUI RIPPLE FILTER

MATLAB CODE:-

%equiripple FIR filterclc;close all;clear all;Fs=1000;Fp=input('Input the pass band frequency Fp= ');Fst=input('Input the stop band frequency Fst= ');Ap=input('Input the pass band attenuation Ap= ');Ast=input('Input the stop band attenuation Ast= ');d=fdesign.highpass('Fst,Fp,Ast,Ap',1600,2000,80,1,8000);Hd=design(d,'equiripple');fvtool(Hd);

FIGURE:-

56

Page 57: Trinity Dsp Lab Manual

3) BAND PASS EQUI RIPPLE FILTER

MATLAB CODE:-

%equiripple FIR filterclc;close all;clear all;Fs=1000;Fp=input('Input the pass band frequency Fp= ');Fst=input('Input the stop band frequency Fst= ');Ap=input('Input the pass band attenuation Ap= ');Ast=input('Input the stop band attenuation Ast= ');D = fdesign.bandpass('Fst1,Fp1,Fp2,Fst2,Ast1,Ap,Ast2',... 1600,2000,2400,2800,60,1,80,8000);Hd = design(D,'equiripple'); fvtool(Hd);

FIGURE:

57

Page 58: Trinity Dsp Lab Manual

4) BAND STOP EQUI RIPPLE FILTER

MATLAB CODE:-

%equiripple FIR filterclc;close all;clear all;Fs=1000;Fp=input('Input the pass band frequency Fp= ');Fst=input('Input the stop band frequency Fst= ');Ap=input('Input the pass band attenuation Ap= ');Ast=input('Input the stop band attenuation Ast= ');D = fdesign.bandstop('Fp1,Fst1,Fst2,Fp2,Ap1,Ast,Ap2',.4,.5,.6,.7,1,80,.5);Hd = design(D,'equiripple');fvtool(Hd);

FIGURE:

58

Page 59: Trinity Dsp Lab Manual

SAMPLE INPUTS:-

Enter the pass band frequency Fp= 1200Enter the stop band frequency Fst= 2000Enter the pass band attenuation Ap= .05Enter the stop band attenuation Ast= .04

RESULTS: - Thus the magnitude response of Equi-Ripple FIR filters were verified.

GENERATION OF LINEAR CONVOLUTION USING DFT (OVERLAP ADD AND OVERLAP SAVE METHOD)

59

Page 60: Trinity Dsp Lab Manual

Experiment No: - 16

AIM: - TO write a MATLAB program to find the linear convolution of two sequence using OVERLAP ADD

AND OVERLAP SAVE METHOD

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Find the length of first sequence x[n] Find the length of second sequence h[n] Estimate the number of samples in the result of linear convolution Plot input and output sequences

1) OVERLAP ADD METHOD

MATLAB CODE:-

clc;clear all;x = input('Enter the sequence x(n) = ');h = input('Enter the sequence h(n) = ');n1 = length(x);n2 = length(h);N = n1+n2-1;y = zeros(1,N);h1 = [h zeros(1,n2-1)];n3 = length(h1);y = zeros(1,N+n3-n2);H = fft(h1);for i = 1:n2:n1if i<=(n1+n2-1)x1 = [x(i:i+n3-n2) zeros(1,n3-n2)];elsex1 = [x(i:n1) zeros(1,n3-n2)];endx2 = fft(x1);x3 = x2.*H;

x4 = round(ifft(x3));

60

Page 61: Trinity Dsp Lab Manual

if (i==1) y(1:n3) = x4(1:n3);elsey(i:i+n3-1) = y(i:i+n3-1)+x4(1:n3);endendsubplot(3,1,1);stem(x(1:n1));grid on;title('Input Sequence x(n)');xlabel('Time --->');ylabel('Amplitude --->');subplot(3,1,2);stem(h(1:n2));grid on;title('Input Sequence h(n)');xlabel('Time --->');ylabel('Amplitude --->');subplot(3,1,3);disp('Block Convolution Using Overlap Add Method = ');disp(y(1:N));stem(y(1:N));grid on;title('Block Convolution Using Overlap Add Method');xlabel('Time --->');ylabel('Amplitude --->');

FIGURE:

SAMPLE INPUTS:-

61

Page 62: Trinity Dsp Lab Manual

Enter the sequence x(n) = [1 2 3 4 5 6 7 8 9]Enter the sequence h(n) = [1 1 1]Block Convolution Using Overlap Add Method = 1 3 6 9 12 15 18 21 24 17 9

1) OVERLAP SAVE METHOD

MATLAB CODE:-

clc;clear all;x = input('Enter the sequence x(n) = ');h = input('Enter the sequence h(n) = ');n1 = length(x);n2 = length(h);N = n1+n2-1;h1 = [h zeros(1,N-n1)];n3 = length(h1);y = zeros(1,N);x1 = [zeros(1,n3-n2) x zeros(1,n3)];H = fft(h1);for i = 1:n2:Ny1 = x1(i:i+(2*(n3-n2)));y2 = fft(y1);y3 = y2.*H;y4 = round(ifft(y3));y(i:(i+n3-n2)) = y4(n2:n3);endsubplot(3,1,1);stem(x(1:n1));grid on;title('Input Sequence x(n)');xlabel('Time --->');ylabel('Amplitude --->');subplot(3,1,2);stem(h(1:n2));grid on;title('Input Sequence h(n)');xlabel('Time --->');ylabel('Amplitude --->');subplot(3,1,3);disp('Block Convolution Using Overlap Save Method = ');disp(y(1:N));stem(y(1:N));grid on;title('Block Convolution Using Overlap Save Method');xlabel('Time --->');ylabel('Amplitude --->');

FIGURE:

62

Page 63: Trinity Dsp Lab Manual

SAMPLE INPUTS:-

Enter the sequence x(n) = [1 2 3 4 5 6 7 8 9]Enter the sequence h(n) = [1 1 1]

Block Convolution Using Overlap save Method = 1 3 6 9 12 15 18 21 24 17 9

RESULTS: - Thus the program for linear convolution using is written using OVERLAP ADD AND OVERLAP SAVE METHOD is written using MATLAB and verified.

GENERATION OF FIR FILTER DESIGN USING FREQUENCY SAMPLING METHOD

63

Page 64: Trinity Dsp Lab Manual

Experiment No: -17

AIM: - TO write a MATLAB program to plot magnitude response and phase response of digital FIR filter using frequency sampling method.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program For the output see command window\ Figure window

ALGORITHM:-

Get the order of the filter Get the cut off frequency use ‘fir2 ’& corresponding functions to compute the filter coefficient Draw the magnitude and phase response

MATLAB CODE:-

clc;clear all;f = [0 0.15 0.15 0.55 0.55 0.7 0.7 1]; A = [0.04 1 1 1 1 0.04 0.04 0.04]; b = fir2(32,f,A); a = 1; subplot(1,2,1) impz(b,a) subplot(1,2,2) freqz(b,a)

FIGURE:

64

Page 65: Trinity Dsp Lab Manual

RESULTS: - Thus the program for FIR filter using frequency sampling method is written using MATLAB and verified.

GENERATION OF Z-TRANSFORM AND INVERSE Z- TRANSFORM

65

Page 66: Trinity Dsp Lab Manual

Experiment No: - 18

AIM: - To write a MATLAB program to plot Z-TRANSFORM AND INVERSE Z- TRANSFORM of given sequences.

PROCEDURE:-

Open MATLAB Open new M-file Type the program Save in current directory Compile and Run the program for the output see command window\ Figure window

ALGORITHM:-

Get the numerator and denominator. Use tf2zp; zp2sos functions to compute. Draw response.

Z-TRANSFORM

MATLAB CODE:-

clc; clear all; num = input('Type in the numerator coefficients ='); den = input('Type in the denominator coefficients ='); [z,p,k]=tf2zp (num,den); m = abs(p); % to find distance from origin of poles disp('Zeros are at'); disp(z); disp('poles are at'); disp(p); disp('gain constant'); disp(k); disp('Radius of poles'); disp(m); sos= zp2sos(z,p,k); disp('Second order sections'); disp(real(sos)); zplane(num,den);

66

Page 67: Trinity Dsp Lab Manual

FIGURE:

Zeros are at -1.6506 -0.1747 + 1.5469i -0.1747 - 1.5469i

poles are at -1.0000 -0.0000 + 1.0000i -0.0000 - 1.0000i

gain constant 1

Radius of poles 1.0000 1.0000 1.0000

Second order sections 1.0000 1.6506 0 1.0000 1.0000 0 1.0000 0.3494 2.4233 1.0000 0.0000 1.0000

SAMPLE INPUTS:-

67

Page 68: Trinity Dsp Lab Manual

Enter the numerator coefficients = [1 2 3 4]Enter the denominator coefficients = [1 1 1 1]

INVERSE Z-TRANSFORM

MATLAB CODE:-

clc;clear all;close all;L=input('length of output vector=');num=input('numerator coefficient');den=input('denominator coefficient');[y,t]=impz(num,den,L);disp(y);stem(y,t);

FIGURE:

SAMPLE INPUTS:

Length of output vector = 11Numerator coefficient = [1 2]Denominator coefficient = [1 .4 -.12]

RESULTS: - Thus the program for Z TRANSFORM and INVERSE Z TRANSFORM are written using MATLAB and verified.

68

Page 69: Trinity Dsp Lab Manual

INTRODUCTION TO THE TMS 320C6713

69

Page 70: Trinity Dsp Lab Manual

70

Page 71: Trinity Dsp Lab Manual

FUNCTIONAL OVERVIEW OF THE TMS 320C6713 DSK

71

Page 72: Trinity Dsp Lab Manual

CODE COMPOSER STUDIO

The Code Composer Studio (CCS) provides an integrated development environment (IDE) to incorporate the software tools. CCS includes tools for code generation, such as a C compiler, an assembler, and a linker. It has graphical capabilities and supports real-time debugging. It provides an easy-to-use software tool to build and debug programs.

The C compiler compiles a C source program with extension .c to produce an assembly source file with extension.asm. The assembler assembles an.asm source file to produce a machine language object file with extension.obj. The linker combines object files and object libraries as input to produce an executable file with extension.out. This executable file represents a linked common object file format (COFF), popular in Unix-based systems and adopted by several makers of digital signal processors. This executable file can be loaded and run directly on the C6713 processor.

To create an application project, one can “add” the appropriate files to the project. Compiler/linker options can readily be specified. A number of debugging features are available, including setting breakpoints and watching variables, viewing memory, registers, and mixed C and assembly code, graphing results, and monitoring execution time. One can step through a program in different ways (step into, or over, or out).

Real-time analysis can be performed using real-time data exchange (RTDX) associated with DSP/BIOS .RTDX allows for data exchange between the host and the target and analysis in real time without stopping the target. Key statistics and performance can be monitored in real time. Through the Joint Team Action Group (JTAG), communication with on-chip emulation support occurs to control and monitor program execution. The C6713 DSK board includes a JTAG emulator interface.

72

Page 73: Trinity Dsp Lab Manual

73

Page 74: Trinity Dsp Lab Manual

74

Page 75: Trinity Dsp Lab Manual

75

Page 76: Trinity Dsp Lab Manual

76

Page 77: Trinity Dsp Lab Manual

77

Page 78: Trinity Dsp Lab Manual

78

Page 79: Trinity Dsp Lab Manual

79

Page 80: Trinity Dsp Lab Manual

80

Page 81: Trinity Dsp Lab Manual

81

Page 82: Trinity Dsp Lab Manual

82

Page 83: Trinity Dsp Lab Manual

83

Page 84: Trinity Dsp Lab Manual

84

Page 85: Trinity Dsp Lab Manual

85

Page 86: Trinity Dsp Lab Manual

86

Page 87: Trinity Dsp Lab Manual

87

Page 88: Trinity Dsp Lab Manual

88

Page 89: Trinity Dsp Lab Manual

References

[Abr72] M. Abramowitz and I.A. Stegun, editors. Handbook of Mathematical Functions.Dover Publications, New York NY, 1972.

[Bag98] S. Bagchi and S.K. Mitra. Nonuniform Discrete Fourier Transform and Its SignalProcessing Applications. Kluwer, Boston MA, 1998.

[Bat80] M.R. Bateman and B. Liu. An approach to programmable CTD filters usingcoefficients 0, +1, and −1. IEEE Trans. on Circuits and Systems, CAS-27:451-456, June 1980.

[Cio91] J. Cioffi. A Multicarrier Primer. ANSI T1E1.4 Committee Contribution, BocaRaton FL, November 1991.

[Con70] A.C. Constantinides. Spectral transformations for digital filters. Proc. IEE(London), 117:1585–1590, August 1970.

[Cro75] R.E. Crochiere and A.V. Oppenheim. Analysis of linear digital networks. Proc.IEEE, 62:581–595, April 1975.

[Gas85] L. Gaszi. Explicit formulas for lattice wave digital filters. IEEE Trans. onCircuits & Systems, CAS-32:68–88, January 1985.

[Gra73] A.H. Gray, Jr. and J. D. Markel. Digital lattice and ladder filter synthesis. IEEETrans. on Audio and Electroacoustics, AU-21:491–500, December 1973.

[Her73] O. Herrmann, L.R. Rabiner, and D.S.K. Chan. Practical design rules for optimumfinite impulse response lowpass digital filters. Bell System Tech. J., 52:769-799,1973.

[Jac70] L.B. Jackson. On the interaction of roundoff noise and dynamic range in digitalfilters. Bell System Technical Journal, 49:159–184, February 1970.

[Jac96] L.B. Jackson. Digital Filters and Signal Processing. Kluwer, Boston MA, thirdedition, 1996.

[Jar88] P. Jarske, Y. Neuvo, and S.K. Mitra. A simple approach to the design of FIRfilters with variable characteristics. Signal Processing, 14:313–326, 1988.

89

Page 90: Trinity Dsp Lab Manual

[Kai74] J.F. Kaiser. Nonrecursive digital filter design using the I0-sinh window function.Proc. 1974 IEEE International Symposium on Circuits and Systems, pages 20-23,San Francisco CA, April 1974.

[Kra94] T.P. Krauss, L. Shure, and J.N. Little. Signal Processing TOOLBOX for use withMATLAB. The Mathworks, Inc., Natick MA, 1994.

[Abr72] M. Abramowitz and I.A. Stegun, editors. Handbook of Mathematical Functions.Dover Publications, New York NY, 1972.

[Bag98] S. Bagchi and S.K. Mitra. Nonuniform Discrete Fourier Transform and Its SignalProcessing Applications. Kluwer, Boston MA, 1998.

[Bat80] M.R. Bateman and B. Liu. An approach to programmable CTD filters usingcoefficients 0, +1, and −1. IEEE Trans. on Circuits and Systems, CAS-27:451-456, June 1980.

[Cio91] J. Cioffi. A Multicarrier Primer. ANSI T1E1.4 Committee Contribution, BocaRaton FL, November 1991.

[Con70] A.C. Constantinides. Spectral transformations for digital filters. Proc. IEE(London), 117:1585–1590, August 1970.

[Cro75] R.E. Crochiere and A.V. Oppenheim. Analysis of linear digital networks. Proc.IEEE, 62:581–595, April 1975.

[Gas85] L. Gaszi. Explicit formulas for lattice wave digital filters. IEEE Trans. onCircuits & Systems, CAS-32:68–88, January 1985.

[Gra73] A.H. Gray, Jr. and J. D. Markel. Digital lattice and ladder filter synthesis. IEEETrans. on Audio and Electroacoustics, AU-21:491–500, December 1973.

[Her73] O. Herrmann, L.R. Rabiner, and D.S.K. Chan. Practical design rules for optimumfinite impulse response lowpass digital filters. Bell System Tech. J., 52:769-799,1973.

[Jac70] L.B. Jackson. On the interaction of roundoff noise and dynamic range in digitalfilters. Bell System Technical Journal, 49:159–184, February 1970.

[Jac96] L.B. Jackson. Digital Filters and Signal Processing. Kluwer, Boston MA, thirdedition, 1996.

90

Page 91: Trinity Dsp Lab Manual

[Jar88] P. Jarske, Y. Neuvo, and S.K. Mitra. A simple approach to the design of FIRfilters with variable characteristics. Signal Processing, 14:313–326, 1988.

[Kai74] J.F. Kaiser. Nonrecursive digital filter design using the I0-sinh window function.Proc. 1974 IEEE International Symposium on Circuits and Systems, pages 20-23,San Francisco CA, April 1974.

[Kra94] T.P. Krauss, L. Shure, and J.N. Little. Signal Processing TOOLBOX for use withMATLAB. The Mathworks, Inc., Natick MA, 1994.

91


Recommended