You are on page 1of 79

ELECTRONICS & COMMUNICATION ENGINEERING

DIGITAL SIGNAL PROCESSING LAB MANUAL

IV YEAR I-SEMESTER (ECE)

PRRM ENGINEERING COLLEGE Shabad, R.R.District, AP.

DIGITAL SIGNAL PROCESSING LAB (IV-I SEM) INDEX


1. STUDY OF DSP PROCESSORS ARCHITECTURE- TMS320C54XX/6713 2. A). GENERATION OF UNIT IMPULSE FUNCTION 2. B).GENERATION OF UNIT STEP FUNCTION 2. C).GENERATION OF RAMP FUNCTION 2. D). GENERATION OF EXPONENTIAL FUNCTION 3. SUM OF SINUSOIDAL SIGNALS 4. LINEAR CONVOLUTION (USING BUILT-IN FUNCTION) 5. LINEAR CONVOLUTION (WITH-OUT USING BUILT-IN FUNCTION 6. CIRCULAR CONVOLUTION 7. A) AUTO CORRELATION 7. B) CROSS CORRELATION 8. DISCRETE FOURIER TRANSFORM 9. N-POINT FAST FOURIER TRANSFORM (FFT) ALGORITHM 10. INVERSE DISCRETE FOURIER TRANSFORM 11. FREQUENCY RESPONSE OF ANALOG LP/HP FILTERS 12. POWER DENSITY SPECTRUMOF A SEQUENCE 13. IMPLEMENTATION OF IIR FILTER (LP/HP) ON DSP PROCESSORS 14. A). FIR LOW PASS FILTER USING RECTANGULAR WINDOW 14. B). FIR LOW PASS FILTER USING TRIANGULAR WINDOW 14. C). FIR LOW PASS FILTER USING KAISER WINDOW 14. D). FIR LOW PASS FILTER USING HAMMING WINDOW 14. E). FIR LOW PASS FILTER USING HANNING WINDOW 15. A). IIR LOW PASS FILTER USING BUTTERWORTH APPROXIMATION 15. B). IIR LOW PASS FILTER USING CHEBYSHEY TYPE-1 APPROXIMATION 15. C). IIR-LOW PASS FILTER USING CHEBYSHEY TYPE-2 APPROXIMATION

[USING TMS320C6713 DSP PROCESSOR].

1. STUDY OF DSP PROCESSORS ARCHITECTURETMS320C54XX/6713


Architecture and instruction set of DSP Processor- TMS320C54XX/6713 FEATURES OF HIGHEST- PERFORMANCE FLOATING- POINT DIGITAL SIGNAL PROCESSOR TMS320C54XX/6713 Enhanced Harvard Architecture. VLIW parallel Architecture. Rich Addressing modes. Two general purpose Register files(A0- A15 & B0- B15) 32/64- Bit Data Word. Rich Instruction set. Eight 32- Bit Instructions/Cycle. 32/64- Bit Data Word. 4.4- , 6.7- ns Instruction Cycle Time. 1800 MIPS/1350 MFLOPS Rich Peripheral Set, Optimized for Audio. Highly Optimized C/C++ Complier.

INSTRUCTION SET FEATURES Single- and Double- Precision Instructions. Byte- Addressable (8-, 16-, 32- Bit Data) 8- Bit Overflow Protection Saturation; Bit- Field Extract, Set, Clear; Bit- Counting; Normalization

Functional units and operations performed Functional Unit .L unit (.L1, .L2) Fixed- Point Operations 32/40- bit arithmetic and compare Operations Leftmost 1 or 0 bit counting for 32 bits Normalization count for 32 and 40 bits 32- bit logical operations. .S unit (.S1, .S2) 32- bit arithmetic operations 32/40Bit shifts and 32- bit bit- field Operations 32- bit logical operations Branches Constant generation Register transfer to/from the control Register file (.S2 only) Compare reciprocal and reciprocal square- root operations Absolute value operations SP to DP Conversion operations. Floating- Point Operations Arithmetic operations conversion operations: DP SP, INT DP, INT SP

.M unit (.M1, .M2) 16 X 16 bit multiply operations

32 X 32 bit multiply Operations Floating Point multiply operations

D unit (.D1, .D2)

32- bit add, subtract, linear and Circular address calculation Loads and stores with a 5- bit Constant offset Loads and stores with a 15- bit constant offset(.D2 only)

Load double word with a 5- bit constant offset

C67x instruction set: .L Unit ABS ADD ADDU AND CMPEQ CMPGT .M Unit MPY MPYU MPYUS MPYSU MPYH MPYHU ADD ADDK ADD2 AND B disp B IRP+ B NRP+ B reg CLR EXT EXTU MV MVC+ MVK MVKH MVKLH NEG NOT OR .S Unit SET SHL SHR SHRU SSHL SUB SUBU SUB2 XOR ZERO ADD ADDAB ADDAH ADDAW LDB LDBU LDH LDHU LDW LDB (15- bit offset) LDBU (15- bit offset) LDH (15- bit offset) LDHU (15- bit offset) LDW (15- bit offset) MV STB STH STW .D Unit STB (15- bit offset) STH (15- bit offset) STW (15- bit offset) SUB SUBAB SUBAH SUBAW ZERO

CMPGTU MPYHUS CMPLT MPYHSU

CMPLTU MPYHL LMBD MV NEG NORM NOT OR SADD SAT SSUB SUB SUBU SUBC XOR ZERO MPYHLU MPYHULS MPYHSLU MPYLH MPYLHU MPYLUHS MPYLSHU SMPY SMPYHL SMPYLH SMPYH

2-A. GENERATION OF UNIT IMPULSE FUNCTION


AIM: To generate a unit impulse function using MATLAB. THEORY: The unit impulse function is defined as 1, n = 0 (n) = 0, n 0 The unit impulse function is very useful in continuous system analysis. It is used to generate system response providing fundamental information about the system characteristics. ALGORITHM: 1. Enter the range of n= -10 to 10. 2. Initialize the iteration count variable to 1 and increment it by 1 for every iteration until it reaches total number of samples. i.e., 21. 3. If a=11, then assign o to f(a). 4. Else assign 0 to f(a). 5. End else block. 6. End if block. 7. Plot the graph n Vs f(a). 8. Specify x label as time and y label as amplitude.

PROGRAM CODE: clc; close all; clear all; n=-10:10; for a=1:21 if a==11 f(a)=1; else f(a)=0; end end stem(n,f); ylabel ('Amplitude- - ->'); xlabel ('time- - ->'); title ('Unit impulse sequence');

RESULT: Hence the MATLAB program for generation of unit impulse signal was written and verified the graph.

2-B.GENERATION OF UNIT STEP FUNCTION


AIM: To generate a unit step function using MATLAB. THEORY: The integral of the impulse function is called as the unit step function which has unit amplitude at n > = 0 and 0 elsewhere. Mathematically, it is represented as 1, n >= 0 u(n) = 0, n < 0 ALGORITHM: 1. Enter the range of n= - 10 to 10. 2. Initialize the iteration count variable to 1 and increment it by 1 for every iteration until it reaches total number of samples. i.e., 21. 3. If a 11, then assign 1 to f(a). 4. Else assign o to f(a). 5. End else block. 6. End if block. 7. Plot the graph n Vs f (a). 8. Specify Xlabel as time and y label as amplitude.

PROGRAM CODE: clc; close all ; clear all; n= -10:10; for a=1:21 if a >= 11 f(a) = 1; else f(a)=0; end end stem(n,f); Ylabel(Amplitude ----->); xlabel(time ----->); title(unit step sequence);

RESULT: Hence the MATLAB program for generation of unit step signal was written and verified the graph.

2-C.GENERATION OF RAMP FUNCTION


AIM: To generate a Ramp function using MATLAB. THEORY: The integral of unit step function is called as the unit ramp function. A ramp signal starts at n=0, and increases linearly with n. In discrete time domin the unit ramp signal is defined as nt, n 0 r(n) = 0, n < 0

ALGORITHM: 1. Enter the range of n= - 10 to 10. 2. Initialize the iteration count variable to 1 and increment it by 1 for every iteration until it reaches total number of samples. i.e., 21. 3. If a 11, then assign a-11 to f(a). 4. Else assign o to f(a). 5. End else block. 6. End if block. 7. Plot the graph n Vs f (a). 8. Specify Xlabel as time and y label as amplitude.

PROGRAM CODE: n= -10:10; for a=1:21 if a >= 11 f(a) = a-11; else f(a)= 0; end end stem(n,f) ; Ylabel('Amplitude ----->'); Xlabel('time ----->'); Title('unit ramp sequence');

RESULT: Hence the MATLAB program for the generation of ramp signal was written and verified the graph.

2- D. GENERATION OF EXPONENTIAL FUNCTION. AIM: To generate an exponential function using MATLAB. THEORY: It is mathematically written as

n, n0
g(n) = 0, n<0 Where is constant; if is positive real number, it gives increasing exponential signal, and if it is negative value, then it produces a decreasing exponential signal. ALGORITHM: 1. Enter the range n = - 10 to 10. 2. Initialize the iteration count variable to 1 and increment it by 1 for every iteration until it reaches total number of samples. i.e. , 21. 3. Ask the user to enter the value of . 4. If a > = 11, then assign ^ (a-11) to f(a). 5. Else assign 0 to f(a). 6. End else block. 7. End if block. 8. Plot the graph n Vs f(a). 9. Specify x label as time and y label as amplitude.

PROGRAM CODE: clc; close all ;clear all; n = input (enter the length of the exponential sequence :); t = 0 : n; a= input (enter the a value :); y= exp (a*t); stem (t ,y); Ylabel(Amplitude ----->); Xlabel(Time ----->); title(exponential sequence); % positive Value for increasing exponential. % Negative value for decreasing Exponential.

RESULT: Hence the MATLAB for generation of exponential signal was written and verified the graph. enter the "n" value: 20 enter the "a" value: 0.25 % a is Positive Value.

enter the "n" value: 20 enter the "a" value: -0.25 % a is Negative Value.

3. SUM OF SINUSOIDAL SIGNALS


AIM: To find sum of two sinusoidal signals using MATLAB. THEORY: A sine function is a continuous periodic signal which oscillates between +1 and -1. When two sinusoidal signals of different characteristics (like amplitudes, frequencies etc.....), are added the resultant signal will no longer be a sinusoidal signal. Rather it would be formed in the shape of a random signal. ALGORITHM: Enter the range t=0 to 2*pi with an interval of 0.5. Take the function Sin(t) and assign this to variable x. Plot the graph t Vs x. Take other variables y1, y2, y3 and so on in such a way that each of them are sum of different sinusoidal signals. 5. Plot the graphs for each of the variables (t Vs y1, t Vs y2 etc.). 6. Specify x label as time and y label as amplitude for each plot. 7. Observe the differences among all the variables. 1. 2. 3. 4.

PROGRAM CODE: clc;close all;clear all; t=0:.5:2*pi; x=sin(t); subplot(4,2,1); stem(x); xlabel(n----->); ylabel(amplitude); title(sin wave); subplot(4,2,2); plot(x); xlabel(n----->); ylabel(amplitude); title(sin wave); y1=sin(t)+5*sin(2*t); subplot(4,2,3); stem(y1); xlabel(n------>); ylabel(amplitude); title(sin wave with harmonic); subplot(4,2,4); plot(y1); xlabel(n----->); ylabel(amplitude); title(sin wave with harmonic); y2=sin(t)+5*sin(2*t)+10*sin(3*t); subplot(4,2,5);

stem(y2); xlabel(n----->); ylabel(amplitude); title(sin wave with two harmonics); subplot(4,2,6); plot(y2); xlabel(n----->); ylabel(amplitude); title(sin wave with two harmonics); y3=sin(t)+5*sin(2*t)+10*sin(3*t)+15*sin(4*t); subplot(4,2,7); stem(y3); xlabel(n----->); ylabel(amplitude); title( sin wave with three harmonics); subplot(4,2,8); plot(y3); xlabel(n----->); ylabel(amplitude); title( sin wave with three harmonics);

RESULT: Hence the MATLAB program for sum of sinusoidal signals was written and verified the graph.

4. LINEAR CONVOLUTION (USING BUILT-IN FUNCTION)


AIM: To find the linear convolution of given sequences using MATLAB THEORY: The convolution theorem says, roughly that convolving two sequences is the same as multiplying their Fourier Transforms. Applications of convolutions include Linear filtering of an image, finding the response of a system for an anonymous input, etc. Linear convolution of two sequences x(n), h(n) is given by, y(n) = x(k)h(n-k) k= - ALGORITHM: 1. 2. 3. 4. 5. Ask the user to enter the input sequence. Store this sequence in variable x. Ask the user to enter the impulse response. Store the sequence in variable h. Use the inbuilt function conv() to find the convolution of the given sequences. Plot all the three waveforms using subplot(). Also, display the resultant sequence in the command window using disp function.

PROGRAM CODE: clc; clear all; close all; x=input (enter the input sequence:); y= input (enter the impulse response:); subplot(3,1,1); stem(x); title(input sequence); xlabel(Time----->); ylabel(Amplitude------>); subplot(3,1,2);

stem(h); title(input sequence); xlabel(Time------>); ylabel(Amplitude------>); n=length(x)+lenth(h)-1; y=conv(x,h) m=0: n-1; subplot(3,1,3); stem(m,y); title(output sequence); xlabel(Time----->); ylabel(Amplitude----->);

RESULT: Hence the MATLAB program for Linear Convolution was written and obtained the convolved sequence. Enter the input sequence: [1 2 3 4] Enter the impulse response: [2 1 2 1] y= 2 5 10 16 12 11 4

AIM:

5. LINEAR CONVOLUTION (With-out using built-in function)


To find the linear convolution of given sequences using MATLAB.

ALGORITHM:
1. Ask the user to enter the input sequence. Store this sequence in variable x. 2. Ask the user to enter the impulse response. Store this sequence in variable h. 3. Find the lengths of the given sequence (using length ( ) command) and calculate the length of resultant sequence. (M+N-.1, where M, N are the lengths of resultant sequence respectively.) 4. Implement the formula for convolution using for loops and obtain the convolved sequence, Y. 5. Plot all the three sequences using subplot. 6. Also display the convolved sequence in the command window using disp() function.

PROGRAM CODE:
clc; clear all; close all; x=input('Enter the input sequence:'); h=input('Enter the impulse response:'); subplot(3,1,1); stem(x); title('input sequence'); xlabel('Time--->'); ylabel('Amplitude--->'); subplot(3,1,2); stem(h); title('impulse response'); xlabel('Time--->'); ylabel('Amplitude--->'); n=length(x)+length(h)-1; % length of output sequence

%-----------------------------Appending Zeros---------------------------------

x=[x,zeros(1,n-length(x))]; h=[h,zeros(1,n-length(h))]; %----------------Loop for calculation of convolution-------------------------for i=1:n k=i; y(i)=0; for j=1:i y(i)=y(i)+x(k)*h(j); k=k-1; end end %---------------------------------------------------------------------------------disp('Convolution output is...'); disp(y); m=0:n-1; subplot(3,1,3); stem(m,y); title('Output sequence'); xlabel('Time--->'); ylabel('Amplitude--->');

RESULTS: Hence the MATLAB program for linear convolution was written and obtained the convolved sequence. Enter the input sequence:[1 2 3 4] Enter the impulse response:[2 1 2 1] Convolution output is... 2 5 10 16 12 11 4

6. CIRCULAR CONVOLUTION
AIM: To find the circular convolution of given sequence using MATLAB. THEORY: Circular convolution is analogous to the linear convolution, but with a subtle difference. Linear convolution produces a sequence of length (M+N-1) with two sequences of lengths M, N respectively. Where as in circular convolution the resultant sequence would have Max(M,N) samples in it. It is achieved by circular time shifting and circular time reversal. Mathematically, circular convolution is defined as y(n) = And generally it is represented as N

It can also be computed by forming of the product of their N-point DFTs and the applying an N-point IDFT. ALGORITHM: 1. Ask the user to enter the input sequence. Store this sequence in variable x. 2. Ask the user to enter the impulse response. Store this sequence in variable h. 3. Find the lengths of the given sequence (using length ( ) command) and calculate the lengths of the resultant sequence (Max (M,N), where M, N are the lengths of given sequences respectively.) 4. Implement the formula for circular convolution using for loops and obtain the convolved sequence, y. 5. Plot all the three sequences using subplot. 6. Also display the convolved sequences in the command window using disp() function.

PROGRAM CODE: clc; clear all; close all; x=input('Enter the input sequence:'); h=input('Enter the impulse response:'); subplot(3,1,1); stem(x); title('input sequence:'); xlabel('Time--->'); ylabel('Amplitude--->'); subplot(3,1,2); stem(h); title('impulse response'); xlabel('Time--->'); ylabel('Amplitude--->'); n1=length(x); n2=length(h); n3=max(n1,n2); n4=n1-n2; %-----------------------------------------------------------------------------------------% Appending zeros if lengths of the sequences are not equal if(n4>0) h=[h,zeros(1,n4)]; else x=[x,zeros(1,-n4)]; end %---------------------------------- Loop for circular convolution---------------------for(n=1:n3); y(n)=0; for(i=1:n3); j=n-i+1; if(j<=0) j=j+n3; end y(n)=y(n)+x(i)*h(j); end end %---------------------------------------------------------------------------------------disp('circ convolution of given sequences is...'); disp(y); subplot(3,1,3); stem(y); title('Output sequence(Circular convolution)'); xlabel('n--->'); ylabel('Amplitude--->');

Result: Hence the MATLAB program for circular convolution was written and obtained the convolved sequence. Enter the input sequence: [2 1 2 1] Enter the impulse response: [1 2 3 4] circ convolution of given sequences is... 14 16 14 16

7(a): AUTO CORRELATION


AIM: To find the Auto Correlation of given sequence using MATLAB THEORY: There are applications where it is necessary to compare one reference signal with one or more signals to determine the similarity between the pair and to determine additional information based on the similarity. For example in digital communications, a set of data symbols are represented by a set of unique discrete time sequences. If one of these sequences is transmitted, the receiver has to determine which particular sequence has been received by comparing the received signal with every member of possible of sequences from the set. Similarly in RADAR and SONAR applications, the received signal reflected from the target is the delayed version of the transmitted signal and by measuring the delay, one can determine the location of the target. The auto correlation sequence of X(n) is given by

Note:

(n)=Ex

the energy of the signal x(n).

ALGORITHM: 1. Ask the user to enter the input sequence. 2. Find the auto correlation using the inbuilt function xcorr( ). 3. Display the output on command window. PROGRAM CODE: clc; clear all; close all; x = input(enter the sexuence); y = xcorr( x,x); disp(Auto correlation of the sequence is); disp(y); stem(y); title(Auto correlation); xlabel(samples - - >); ylabel(Amplitude - - >);

RESUTL: Hence the MATLAB program for auto correlation function was written and the result is obtained. enter the sequence:[1 2 3 4] Auto correlation of the sequence is... 4.0000 11.0000 20.0000 30.0000 20.0000 11.0000 4.0000

7(b). CROSS CORRELATION


AIM: To find the Auto correlation of given sequence using MATLAB.

THEORY: There are applications where it is necessary to compare one reference signal with one or more signals to determine the similarity between the pair and to determine additional information based on the similarity. For example in digital communications, a set of data symbols are represented by a set of unique discrete time sequences. If one of these sequences is transmitted, the receiver has to determine which particular sequence has been received by comparing the received signal with every member of possible of sequences from the set. Similarly in RADAR and SONAR applications, the received signal reflected from the target is the delayed version of the transmitted signal and by measuring the delay, one can determine the location of the target.
The cross correlation of two sequence of X(n), Y(n) is given by

rxy(l)=
ALGORITHM:

l=0, 1, 2, 3,..

1. Ask the user to enter the first sequence. 2. Ask the user to enter the second sequence. 3. Find the auto correlation using the inbuilt function xcorr( ). 4. Display the output on command window. PROGRAM CODE: clc; clear all; close all; x= input(enter the 1st sequence); h= input(enter the 2nd sequence); n1= length (x); n2 = length (h); n = max(n1,n2); subplot(3,1,1); m=0:n1-1; stem(m,x); title(1st sequence); xlabel(time-->); ylabel(amplitude-->); subplot(3,1,2); m=0:n2-1; stem(m,h); title(2nd ssequence); xlabel(time-->); ylabel(amplitude-->);

y=xcorr(x,h); disp(cross correlation of given sequence is .); disp(y); %disp(fliplr(y)); m= -(n-1):(n-1); subplot(3,1,3); stem(m,y); title(output sequence); xlabel(time-->); ylabel(amplitude-->);

Output: Hence the MATLAB program for cross correlation function was written and obtained the result. enter the 1st sequence:[2 1 2 1] enter the 2nd sequence:[1 2 3 4] cross correlation of given sequence is... 8.0000, 10.0000 15.0000 14.0000 8.0000 4.0000 1.0000

8. DISCRETE FOURIER TRANSFORM


AIM: To find the DFT of given sequence using MATLAB THEORY: DFT of a finite sequence x(n) is defined as

X(k)=
Where U= N=No. of samples in DFT

Working with the Fourier transform on a computer usually involves a form of the transform known as the discrete Fourier transform (DFT).There are two principal reasons for using this form: The input and output of the DFT are both discrete which makes it convenient for computer manipulations. There is a fast algorithm for computing the DFT known as the fast Fourier transform (FFT). ALGORITHM: 1. Ask the user to enter the sequence for which DFT is to be computed. 2. Ask the user to enter the number of samples in DFT. (number of samples in DFT must be greater than or equal to number of samples in the given sequence). 3. Compute the DFT using built-in function, fft(). 4. Display the result in the command window.

PROGRAM CODE: clc; clear all; close all; xn=input(Enter the sequence for which DFT is to be computed:); N=input(Enter the number of samples in the DFT;); L= length(xn); If(N<L) error(N must be >L); end Xk=fft(xn,N); disp(DFT of the given sequence is.....); disp(Xk); m=0:N-1; stem(m,Xk);

RESULT: Hence the MATLAB program for DFT was written and obtained the result. Enter the sequence for which DFT is to be computed: [2 5 8 9] Enter the number of samples in the DFT: 5 DFT of the given sequence is..... 24.0000, - 10.2082-4.1675i, 3.2082-3.8900i, 3.2082+3.8900i, -10.2082+4.1675i.

9. N-POINT FAST FOURIER TRANSFORM (FFT) ALGORITHM [USING TMS320C6713 DSP PROCESSOR].
AIM: To find the DFT of a sequence using FFT algorithm.

THEORY: The DFT Equation X(k)=1/N where TWIDDLE FACTOR: In the definition of the DFT, there is a factor called the Twiddle Factor = where N= number of samples. = [TWIDDLE FACTOR]

If we take an 8-bit sample sequence we can represent the twiddle factor as a vector in the unit. Circle e.g.

Note that 1. It is periodic (i.e. it goes round and round the circle). 2. That the vectors are symmetric. 3. The vectors are equally spaced around the circle.

FAST FOURIER TRANSFORM:


2-Point 4-Point 2-Point 8-Point 2-Point 4-Point 2-Point

ALGORITHM: 1. Select the no. of points for FFT. 2. Generate a sine wave of frequency f(eg:10Hz with a sampling rate = no.) 3. Take sampled data and apply FFT algorithm. 4. Use graph option to view the input and the output. 5. Repeat step-1 to 4 for different no. of points and frequencies.

PROGRAM CODE:
#define PTS 64 typedef struct {float real, imag;} COMPLEX ; extern COMPLEX w[PTS]; void FFT (COMPLEX *Y, int N) { COMPLEX temp1, temp2; output: int i,j,k; int upper_leg, lower_leg; input: int leg_diff; int num_steges=0; int index, step; i=1; do { num_stages+ =1; i=i*2; } while(i!=N); leg_diff= N/2; step= (PTS*2)/N; for (i=0; i<num_stages; i++) { index= 0; for(j=0; j<leg_diff; j++) { for(upper_leg= j; upper_leg<N; upper_leg +=(2*leg_diff)) { // difference between & lower legs // step between values in twiddle.h // for N-point FFT //temporary storage variables //loop counter variables // index of upper/lower butterfly leg // difference between upper/ lower leg //number of FFT stages (iterations) // index/step through twiddle constant // log (base2) of N-points= # of stages //twiddle constants stored in w //input sample array, # of points //#of points for FFT

lower_leg= upper_leg+leg_diff; temp1.real= (Y[upper_leg]).real+(Y[lower_leg]).real; temp1.imag= (Y[upper_leg]).imag+(Y[lower_leg]).imag; temp2.real= (Y[upper_leg]).real- (Y[lower_leg]).real; temp2.imag= (Y[upper_leg]).imag-(Y[lower_leg]).imag; (Y[lower_leg]).real= temp2.real*(w[index]).real-temp2.imag*(w[index]).imag; (Y[lower_leg]).imag= temp2.real*(w[index]).imag-temp2.imag*(w[index]).real; (Y[upper_leg]).real= temp1.real; (Y[upper_leg]).imag= temp1.imag; } index+= step; } leg_diff= leg_diff/2; step*=2; } j=0; for(i=1; i<(N-1); i++) { k= N/2; while (k<=j) { j= j-k; k=k/2; } j= j+k; if (i<j) { temp1.real= (Y[j]).real; // bit reversal for re-sequencing data

temp1.imag= (Y[j]).imag; (Y[j]).real=(Y[i]).real; (Y[j]).imag=(Y[i]).imag; (Y[i]).real=temp1.real; (Y[j]).imag=(Y[i]).imag; } } Return; }

PROCEDURE:
Open code composer studio, make sure the DSP kit is turned on. Start a new project using project-new pull down menu, save it in a separate directory(c:\ti\myprojects) with name FFT.pjt. Add the source files FFT256.c and FFT.C in the project using project add files to project pull down menu. Add the linker to command file hello.cmd. Add the rts file rts6700.lib. Compile the program using the project-compile pull down menu or by clicking the short cut icon on the left side of program window. Load the program in program memory of DSP chip using the File-load program pull down menu. Run the program and observe output using graph utility.

RESULT:

Hence the MATLAB program for DFT was written and the result is obtained.

10.INVERSE DISCRETE FOURIER TRANSFORM


AIM: To find the IDFT of given sequence using MATLAB. THEORY:
IDFT of a finite sequence X(n) is defined as.

X(k)=1/N where =
N= no. of samples in DFT.

Working with the Fourier transform on a computer usually involve a form of the transform know as the discrete Fourier transform (DFT). There are two principle reasons for using this form. The input and output of the DFT are both discrete, which makes it convenient for computer manipulations. There is a fast algorithm for computing the DFT know as the fast Fourier transforms (FFT). ALGORITHM: Ask the user to enter the sequence for which IDFT is to be computed. 1. Ask the user to enter the no. of samples in DFT.(Number of samples in sequence) . 2. Compute the IDFT using built-in function, ifft(). 3. Display the result in the command window. PROGRAM CODE: clc; clear all; close all; xn= input ('Enter the sequence for which DFT is to be computed: ') ; N= input ('Enter the number of samples in the DFT: '); L= length (xn); if(N<L) error ('N must be > L'); end XK= fft (xn, N); disp ('DFT of xn is...'); disp (XK);

xn1= ifft (XK); disp ('IDFT of XK is... '); disp (xn1); m=0:N-1; subplot (3, 1, 1); stem (m, xn); title ('original sequence (xn)'); Xlabel ('Samples --->'); Ylabel ('Amplitude --->'); subplot (3, 1, 2); stem (m, XK); title('DFT of original sequence (XK)'); Xlabel ('Samples --->'); Ylabel ('Amplitude --->'); Subplot (3, 1, 3); Stem (m, xn1); title ('IDFT of XK (xn1, must be same as original sequence)'); Xlabel ('Samples --->'); Ylabel ('Amplitude --->');

RESULT: Hence the MATLAB program for IDFT was written and obtained the result.

Enter the sequence for which DFT is to be computed: [1 2 3 4 ] Enter the number of samples in the DFT: 4 DFT of xn is... 10.0000, -2.0000 + 2.0000i, -2.0000, -2.0000 - 2.0000i.

IDFT of XK is...

11. FREQUENCY RESPONSE OF ANALOG LP/HP FILTERS


AIM: To find the frequency response of analog LP/HP filters using butter worth approximation. THEORY: A filter may be defined as a device used to select a set of desired frequencies and reject all other frequencies. Filters can be classified into two types, based on the signals they accept. 1. 2. Digital filters Analog filters

Again, digital filters can be classified into two types 1. FIR Filters 2. IIR Filter In general, a filter may be characterized by its (a) Linear difference equation, which is given by

Y(n)= -

y(n-k)+

(n-k)

(b) Transfer function, which is given by

ALGORITHM: 1. Get the cut off frequency from the user. 2. Get the ripples from the user. 3. Get the sampling frequency and order of the filter from the user. 4. Use the built in functions to calculate the frequency response of the IIR filter. 5. Draw the response curve

PROGRAM CODE: clc; wp=input ('enter pass band cutoff frequency : '); ws= input ('enter stop band cutoff frequency : '); rp=input('enter pass band ripple in db : '); rs=input('enter stop band ripple in db : '); fs=input('enter the sampling frequence : '); 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:0.01:pi; [h,omega]=freqs(b,a,W); gain=20*log10(abs(h)); an=angle(h); xlabel('normalized frequency ---->'); ylabel('gain in db --->'); subplot(2,1,1); plot(omega/pi,gain); title('mag res of lpf'); xlabel('normalized frequency --->'); ylabel('phase in radians --->'); subplot(2,1,2); plot(omega/pi,an); title('phase res lpf');

RESULT: result. Hence the MATLAB program for IIR-Filter was written and obtained the

12. POWER DENSITY SPECTRUMOF A SEQUENCE


AIM: To find the PSD of sequence. THEORY: The total or the average power in a signal is often not of as great an interest. We are most often interested in the PSD or the power spectrum. We often want to see is how the input power has been redistributed by the channel and in this frequencybased redistribution of power is where most of the interesting information lies. The totalarea under the power spectrum or PSD is equal to the total avg. power of the signal. The PSD is an even function of frequency or in other words. TO COMPUTE PSD: The value of the auto-correlation function at zero-time equals the total power in the signal. To compute PSD we compute the auto-correlation of the signal and then take its FFT. The auto-correlation function and PSD are a Fourier transform pair. (Another estimation method called period gram uses sampled FFT to compute the PSD.).

Power spectral Density is a Fourier transform of the auto correlation. S(w) =FT(R( ))= R( ) = ALGORITHM: 1. Select no. of points for FFT (eg: 64). 2. Generate a sine wave of frequency f. (eg:10 Hz with sampling rate=No. of Points of FFT(eg.64)) using math library function. 3. Compute the auto correlation of sine wave. 4. Take output of auto correlation, apply FFT algorithm. 5. Use graph option to view the PSD. 6. Repeat the step-1 to 5 for different no. of points & frequency. (S(w)) = dw

PROGRAM CODE: PSD.c /********************************************************************/ * FILENAME * Non_real_time_PSD.c * DESCRIPTION * Program to compute Non real time PSD * using the TM320C6711 DSK. ********************************************************************/ *DESCRIPTION *Number of points for FFT (PTS) *x---> sine wave co-efficients * iobuffer-->out put of auto-correlation. * x1--> use in graph window to view PSD. /*==========================================================*/ #include<math.h> #define PTS 128 #define Pi=3.14159265358979 //# of points for FFT

typedef struct {float real, imag;} COMPLEX;

void FFT(COMPLEX *Y, int n); float iobuffer[PTS]; float x1[PTS],x[PTS]; short i; short buffercount = 0; short flag = 0;

//FFT prototype //as Input and output buffer //intermeadiate buffer

//general purpose index variable //number of new samples in io buffer //set to 1 by ISR when iobuffer full

float y[128]; COMPLEX w[PTS]; COMPLEX samples[PTS]; main () { Float j,sum=0.0 ; int n,k,l,a; For(i=0;i<PTS;i++) { w[i].real =cos(2*Pi*i/(PTS*2.0)); w[i].imag =-sin(2*Pi*i/(PTS*2.0)); } /*Re component of twiddle constants*/ /*Im component of twiddle constants*/ //set up twiddle constants in w //twiddle constants stored in w //primary working buffer

/**************************Input Signal X(n)****************************/ For(i=0,j=0;i<PTS;i++) { x[i]=sin(2*Pi*5*i/PTS); samples[i].real=0.0; samples[i].imag=0.0; } /***********************Auto correlation of X(n)=R(t)*********************/ for(n=0;n<PTS;n++) { sum=0; for(k=0;k<PTS-n;k++) { sum=sum+(x[k]*x[n+k]); //Auto correlation R(t) //Signal x(Fs)=sin(2*pi*f**i/fs);

} iobuffer[n]=sum; } /************************* FFT of R(t) *******************************/ for (i=0;i<PTS;i++) { samples[i].real=iobuffer[i]; //buffer with new data } for (i=0;i<PTS;i++) samples[i].imag =0.0; FFT(sample,PTS); //imagcompenents = 0 //call functionFFT.c //swap buffers

/***************************** PSD ********************************/ for(i=0;i<PTS;i++0) { x1[i]=sqrt(samples[i].real*samples[i].real+samples[i].image*samples[i].image); } } FFT.c: #defined PTS128 //# of points for FFT // end of main //compute the magnitude

typedef struct{float real, imag;} COMPLEX; extern COMPLEX w[PTS]; void FFT(COMPLEX*Y, int N); { COMPLEX temp1, temp2; int i,j,k; int upper_leg, lower_leg; int leg_diff; //temporary storage variables //loop conter variables //index of upper/lower butterfly leg //difference between upper/lower leg //twiddle constant stored in w //input sample array,#of points

int num_stages=0; int index; step; i =1; do { num_stages +=1; i=i*2; } while (i!=N); leg_diff=N/2; step=(PTS*2)/N; for(i=0;i<num_stages;i++) { index=0; for(j=0;j<leg_diff;j++) {

//number of FFT stages(iterations) //index/step through twiddele constant //log(based2)of points=# of stages

//difference between upper & lower legs //step between values in twiddle.h//512 //for N-point FFT

for(upper_leg=j; upper_leg<N; upper_leg+=(2*leg_diff)) { lower_leg=upper_leg+leg_diff; temp1.real=(Y[upper_leg]).real + (Y[lower_leg]).real; temp1.imag=(Y[upper_leg]).imag + (Y[lower_leg]).image; temp2.real=(Y[upper_leg]).real - (Y[lower_leg]).real; temp2.imag=(Y[upper_leg]).imag + (Y[lower_leg]).image; (Y[lower_leg]).real=temp2.real*(w([index]).real - temp2.imag*(w[index]).imag; (Y[lower_leg]).imag=temp2.real*(w([index]).imag + temp2.imag*(w[index]).real (Y[upper_leg]).real=temp1.real;; (Y[upper_leg]).imag=temp1.imag;

} index +=step; } leg_diff=leg_diff/2; step*=2; } j=0; for(i=0;i<(N-1);i++) { k=N/2; while(k<=j) { j=j-k; k=k/2} j=j+k; if (i<j) { temp1.real=(Y[j].real; temp1.image=(Y[j].image; (Y[j].real=(Y[i].real; (Y[j].image=(Y[i].image; (Y[i].real=temp.real; (Y[i].image=temp.image; } } return; } //bit reversal for resequencing data

PROCEDURE: Open code composer studio, make sure the DSP kit is turned on. Start a new project using project-new pull down menu, save it in a separate rectory (c:\ti\my project) with name PSD.pjt. Add the source files PSD.c and FFT.c in the project using project add files to project pull down menu. Add the linker command file hello.cmd. Add the rts file rts6700.lib. Compile the program using the project-compile pull down menu or by clicking the shortcut icon on the left side of program window. Load the program in program memory of DSP chip using the file-load Programpull down menu. Run the program and observe output using graph utility.

RESULT: Hence the C program for PSD was written and obtained the result.

13. Implementation of IIR Filter (LP/HP) on DSP Processors


AIM: To design and implement a Digital IIR Filter and observe its frequency response. THEORY: In the design of frequency, selective filters, the desired filter characteristics are specified in the frequency domain in terms of the desired magnitude and phase response of the filter. In the filter design process, we determine the coefficients of a causal IIR filter that closely approximates the desired frequency response specifications. IMPLEMENTATION OF DISCRETE TIME SYSTEMS: Discrete time Linear Time Invariant (LTI) systems can be described completely by constant coefficient linear difference equations. Representing a system in terms of constant coefficient linear difference equation is its time domain characterization. In the design of simple frequency selective filter we would take help of some basic implementation methods for realizations of LTI systems described by linear constant coefficient difference equation. BACKGROUND CONCEPT: An Infinite impulse response (IIR) filter possesses an output response to an impulse which is of an infinite duration. The impulse response is infinite since there is feedback in the filter that is if you put in an impulse, then its out put must produced for infinite duration of time. ALGORITHM: 1. Initialize the MCBSP, the DSP board and the on board codec. 2. Initialize the discrete time system, that is, specify the initial conditions. Generally zero initial conditions are assumed. 3. Take sampled data from codec while input is fed to DSP kit from the signal generator. Since codec is stereo, take average of input data read from left and right channel. Store sampled data at a memory location. 4. Perform filter operation using above said difference equation and store filter output at a memory location 5. Output the value to codec (left channel & right channel) and view the output at oscilloscope. 6. Go to step 3.

PROGRAM CODE:
# include filtercfg.h # include dsk6713.h # include dsk6713-aic23.h const signed int filter_coeff[ ]= { // (12730,-12730, 12730, 2767,-18324, 21137 //312, 312, 312, 32767, -27943, 24367 //1455, 1455, 1455, 32767, -23140, 21735 //9268,-9268, 9268, 32767, -7395, 18367 //7215, -7215, 7215, 32767, 5039, 6171 } /*codec configuration settings*/ DSK6713 AIC23_config config = { \ 0X0017, \0X0017, \0X00d8, \0X00d8, /* 0 DSK6713 - AIC23 LEFT INVOL Left line input channel volume*/ /* 1 DSK 6713 - AIC23 RIGHT INVOL Right line input channel Volume*/ /* 2 DSK 6713 AIC23 LEFT HPVOL Left channel head phone volume */ /* 3 DSK 6713 AIC23 RIGHT HPVOL Right channel head phone volume*/ /*HP2500*/ /*cp800*/ /*LP2500*/ /*HP 4000*/ /*HP 7000*/

\0X00d11, /* 4 DSK6713 AIC23 ANAPATH Analog audio path control */ \ 0X0000, /* 5 DSK6713 AIC23 DIGPATH Digital audio path control */ \ 0X0000, /* 6 DSK6713 AIC23 POWERDOWN Power down control */

\ 0X0043, /* 7 DSK6713 AIC23 DIGIF Digital audio interface format */ \ 0X0081, /* 8 DSK6713 AIC23 SAMPLERATE Sample rate control */ \ 0X0001, /* 9 DSK6713 AIC23 DIGACT Digital interface activation */ \ } /* main ( ) - Main code routine, initializes BSL and generates tone*/ void main ( ) {

DSK6713_AIC23_CodecHandle hCodec; int l_input, r_input, l_output, r_output; /* Initialize the board support library, must be called first */ DSK6713 intit ( ); /* stat the codec */ hCodec = DSK6713 AIC23 Open codec (0, & config); DSK6713 AIC23 set Freq (hcodec, 3); While (1) { /* Read a sample to the left channel */ While (! DSK6713-AIc23-read (hcodec, & l -input); /*Read a sample to the right channel*/ While (! DSK 6713-AIc23-read (hcodec, &r-input)); l_output=IIR-FILTER (&filter-coeff, l-input); r_output=l-output; /*send a sample to the left channel */ While (! DSK6713-AIc23-write (hcodec, l output)); /*send a sample to the right channel */ While (! DSK6713-AIC23-write (hcodec, r-output)); } /* close the codec */ DSK6713_AIC23_close codec (hcodec); } signed int IIR_ FILTER (const_signed int *h, signed int x1) { static signed int X [6] = {0, 0, 0, 0, 0, 0); /* X(n),X(n-1),X(n-2) must be static*/ static signed int Y [6] = {0, 0, 0, 0, 0, 0}; /*Y(n),Y(n-1),Y(n-2) must be static*/ int temp = 0; temp = (short int) x1; /* copy input to temp */

X[0] = (signed int) temp; temp = ((int) h [0]*X[0]); temp + = ((int) h [1]*X[1]); temp + = ((int) h [1]*X[1]); temp + = ((int) h [2]*X[2]); temp _ = ((int) h [4]*Y[1]); temp _ = ((int) h [4]*Y[1]); temp _ =((int) h [5]*Y[2]);

/*copy input to X [stages][0]*/ /* Bo *X(n) */ /*B1/2*X(n-1)*/ /*B1/2*X(n-1)*/ /*B2*X(n-2)*/ /*A1/2*Y(n-1)*/ /*A1/2*Y(n-1)*/ /*A2*Y(n-2)*/ /*Divide temp by coefficients [A0]*/

} temp>>=15; if (temp<32767). { temp =32767; } else if (temp<-32767). { temp =-32767; } Y[0] = temp; /*shuffle values along one place for next time*/ Y[2] =Y[1]; Y[1] = Y[0]; X[2] = X[1]; X[1] = X[0]; /*Y(n-2)=Y(n-1)*/ /*Y(n-1)=Y(n)*/ /*X(n-2)=X(n-1)*/ /*X(n-1)=X(n) */ /*temp is used as input next time through*/ return (temp<<2); }

RESULT: Hence the C program for IIR filter was written and obtained the result.

14. (A). FIR LOW PASS FILTER USING RECTANGULAR WINDOW


AIM: To find response of an FIR LPF using rectangular window. THEORY: The rectangular window function is given by 1, for n (M-1) / 2 WR (N) = 0, otherwise

ALGORITHM: Get the cut off frequency from the user. 1. Get the sampling frequency and order of the filter from the user. 2. Use the built in functions to calculate the frequency response of the FIR filter. 3. Draw the response curve. PROGRTAM CODE: clc; clear all; close all; fc = input ('Enter the cut off frequency:'); fs = input ('Enter the sampling frequency:'); N = input ('Enter the order of the filter:'); if (rem(N,2)~=0) N=N+1; end wn=2*fc/fs; wr=boxcar(N+1); b=fir1(N, wn, wr); freqz(b,1);

RESULT: Hence the MATLAB program for the FIR Low pass filter using rectangular window is written and obtained the response curves.

Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order of the filter: 20.

14.(B). FIR LOW PASS FILTER USING TRIANGULAR WINDOW


AIM: To find response of an FIR LPF using Triangular window. THEORY: The triangular window function is given by

(1- n ), for n (M-1)/2 WT (n) = 0, otherwise ALGORITHM: Get the cut off frequency from the user. 1. Get the sampling frequency and order of the filter from the user. 2. Use the built in functions to calculate the frequency response of the FIR filter. 3. Draw the response curve. PROGRAM CODE: clc, clear all; close all; fc= input ('Enter the cut off frequency:'); fs= input ('Enter the sampling frequency:'); N= input ('Enter the order of the filter:'); if(rem (N, 2)~=0) N=N+1; end wn= 2*fc/fs; wr= triang(N+1); b= fir1(N, wn, wr); freqz(b,1);

RESULT: Hence the MATLAB program for the FIR Low Pass Filter triangular window is written and obtained the response curves. Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order of the filter: 20

14. (C). FIR LOW PASS FILTER USING KAISER WINDOW AIM: To find response of an FIR LPF using Kaiser window. THEORY: The Kaiser Window function is given by I0(((1-((2n/M)-1)2)), Wn = 0 Where: I0 is the Zeroth order modified Bessel function of the first kind. a is an arbitrary real number that determines the shape of the window. M is an integer, and the length of the sequence is N=M+1. When N is an odd number, the peak value of the window is WM/2=1, and When N is even, the peak values are WN/2-1= WN/2<1. ALGORITHM: Get the cut off frequency from the user. 1. Get the sampling frequency and order of the filter from the user. 2. Use the built in functions to calculate the frequency response of the FIR filter. 3. Draw the response curve. otherwise. 0nM

PROGRAM CODE: clc; clear all; close all; fc= input ('Enter the cut off frequency:'); fs= input ('Enter the sampling frequency :'); N= input ('Enter the order of the filter :'); B= 15; if (rem(N,2)~=0) N=N+1; end wn=2*fc/fs; wr= kaiser (N+1, B); B=fir1(N, wn, wr); freqz(B,1);

RESULT: Hence the MATLAB program for the FIR Low Pass Filter using Kaiser Window is written and obtained the response curves. Output: Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order of the filter: 20

14. (D). FIR LOW PASS FILTER USING HAMMING WINDOW

AIM: To find response of an FIR LPF using Hamming Window. THEORY: The Hamming Window function is given by W(n) = 0.53836-0.46164 cos(2n/(N-1)). ALGORITHM: Get the cut off frequency from the user. 1. Get the sampling frequency and order of the filter from the user. 2. Use the built in function to calculate the frequency response of the FIR filter. 3. Draw the response curve. PROGRAM CODE: clc; clear all; close all; fc= input ('Enter the cut off frequency: '); fs= input ('Enter the sampling frequency: '); N= input ('Enter the order of the filter: '); if(rem(N,2)~=0) N=N+1; end wn= 2*fc/fs; wr= Hamming (N+1); b= fir1(N, wn, wr); freqz(b, 1);

RESULT: Hence the MATLAB Program for the FIR Low Pass Filter Using Hamming Window is written and obtained the response curves. Output: Enter the cut off frequency: 300 Enter the sampling frequency: 1000
Enter the order of the filter: 20

14. (E). FIR LOW PASS FILTER USING HANNING WINDOW

AIM: To find response of an FIR-LPF using hanning window. THEORY: The Hanning window function is given by W(n) = 0.5(1- cos(2n/N-1))

ALGORITHM: Get the cut off frequency from the user. 1. Get the sampling frequency and order of the filter from the user. 2. Use the built in functions to calculate the frequency response of the FIR Filter. 3. Draw the response curve. PROGRAM CODE: clc; clear all; close all; fc= input ('Enter the cut off frequency: '); fs= input ('Enter the sampling frequency: '); N= input ('Enter the order of the filter: '); if(rem (N, 2)~=0) N=N+1; end wn= 2*fc/fs; wr= Hanning(N+1); b= fir1(N, wn, wr); freqz(b, 1);

RESULT: Hence the MATLAB program for the FIR Low Pass Filter using Hanning Window is written and obtained the response curves. Output: Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order of the filter: 20

15. (A). IIR LOW PASS FILTER USING BUTTERWORTH APPROXIMATION


AIM: To find response of the IIR- LPF using Butterworth Approximation. ALGORITHM: 1. 2. 3. 4. Get the cut off frequency from the user. Get the sampling frequency and order of the filter from the user. Use the built in function to calculate the frequency response of the IIR filter. Draw the response curve.

PROGRAM CODE: clc; clear all; close all; fp= input ('Enter the pass band edge frequency: '); fs= input ('Enter the stop band edge frequency: '); f= input ('Enter the sampling frequency: '); rp= input ('Enter the pass band ripple: '); rs= input ('Enter the stop band ripple: '); wp=2*fp/f; ws=2*fs/f; [n,wn]=buttord (wp, ws, rp, rs); [b,a]= butter(n, wn); freqz(b,a);

RESULT: Hence the MAYLAB program for the IIR Low Pass Filter using Butterworth approximation is written and obtained the response curves. Output: Enter the pass band edge frequency 200 Enter the stop band edge frequency 500 Enter the sampling frequency 1200 Enter the pass band ripple 10 Enter the stop band ripple 100

15. (B). IIR LOW PASS FILTER USING CHEBYSHEY TYPE-1 APPROXIMATION
AIM: To find response of an IIR LPF using Chebyshev type-1. ALGORITHM: 1. 2. 3. 4. Get the cut off frequency from the user. Get the sampling frequency and order of the filter from the user. Use the built in function to calculate the frequency response of the IIR filter. Draw the response curve.

PROGRAM CODE: clc; clear all; close all; fp= input ('Enter the pass band edge frequency: '); fs= input ('Enter the stop band edge frequency: '); f= input ('Enter the sampling frequency: '); rp= input ('Enter the pass band ripple: '); rs= input ('Enter the stop band ripple: '); wp= 2*fp/f; ws= 2*fs/f; [n,wn]=cheb1ord(wp,ws,rp,rs); [b,a]=cheby1(n,rp,wn); freqz(b,a);

RESULT: Hence the MATLAB program for the IIR Low Pass Filter using Chebyshev type-1 approximation is written and obtained the response curves. Enter the pass band edge frequency 200 Enter the stop band edge frequency 500 Enter the sampling frequency 1200 Enter the pass band ripple 10 Enter the stop band ripple 100

15. (C). IIR-LOW PASS FILTER USING CHEBYSHEY TYPE-2 APPROXIMATION


AIM: To find response of an IIR LPF using Chebyshev type-1. ALGORITHM: 1. 2. 3. 4. Get the cut off frequency from the user. Get the sampling frequency and order of the filter from the user. Use the built in function to calculate the frequency response of the IIR filter. Draw the response curve.

PROGRAM CODE:

clc; clear all; close all; fp= input ('Enter the pass band edge frequency: '); fs= input ('Enter the stop band edge frequency: '); f= input ('Enter the sampling frequency: '); rp= input ('Enter the pass band ripple: '); rs= input ('Enter the stop band ripple: '); wp= 2*fp/f; ws= 2*fs/f; [n, wn]=cheb2ord(wp,ws,rp,rs); [b, a]=cheby2(n,rs,wn); freqz(b,a);

RESULT:

Hence the MATLAB program for the IIR Low Pass Filter using Chebyshev type1 approximation is written and obtained the response curves. Output: Enter the pass band edge frequency 200 Enter the stop band edge frequency 500 Enter the sampling frequency 1200 Enter the pass band ripple 10 Enter the stop band ripple 100