Sei sulla pagina 1di 79

ELECTRONICS & COMMUNICATION ENGINEERING

DIGITAL SIGNAL PROCESSING LAB MANUAL

IV YEAR I-SEMESTER (ECE)

DIGITAL SIGNAL PROCESSING LAB MANUAL IV YEAR I-SEMESTER (ECE) PRRM ENGINEERING COLLEGE Shabad, R.R.District, AP.

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

[USING TMS320C6713 DSP PROCESSOR].

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

1. STUDY OF DSP PROCESSORS ARCHITECTURE-

TMS320C54XX/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

Fixed- Point Operations

Floating- Point Operations

.L unit (.L1, .L2)

32/40- bit arithmetic and compare

Arithmetic operations

Operations Leftmost 1 or 0 bit

conversion operations:

counting for 32 bits Normalization

DP → SP, INT→ DP,

count for 32 and 40 bits 32- bit

INT→ SP

logical operations.

.S unit (.S1, .S2)

32- bit arithmetic operations 32/40-

Compare reciprocal and

Bit shifts and 32- bit bit- field

reciprocal square- root

Operations 32- bit logical operations

operations Absolute value

Branches Constant generation

operations SP to DP

Register transfer to/from the control

Conversion operations.

Register file (.S2 only)

.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

Load double word with a

Circular address calculation

5- bit constant offset

Loads and stores with a 5- bit

Constant offset Loads and stores with

a 15- bit constant offset(.D2 only)

C67x instruction set:

.L Unit

.M Unit

 

.S Unit

.D Unit

ABS

MPY

ADD

SET

ADD

STB (15- bit offset)

ADD

MPYU

ADDK

SHL

ADDAB

STH (15- bit offset)

ADDU

MPYUS

ADD2

SHR

ADDAH

STW (15- bit offset)

AND

MPYSU

AND

SHRU

ADDAW

SUB

CMPEQ

MPYH

B

disp

SSHL

LDB

SUBAB

CMPGT

MPYHU

B

IRP+

SUB

LDBU

SUBAH

CMPGTU

MPYHUS

B

NRP+

SUBU

LDH

SUBAW

CMPLT

MPYHSU

B

reg

SUB2

LDHU

ZERO

CMPLTU

MPYHL

CLR

XOR

LDW

LMBD

MPYHLU

EXT

ZERO

LDB (15- bit offset)

MV

MPYHULS

EXTU

LDBU (15- bit offset)

NEG

MPYHSLU

MV

LDH (15- bit offset)

NORM

MPYLH

MVC+

LDHU (15- bit offset)

NOT

MPYLHU

MVK

LDW (15- bit offset)

OR

MPYLUHS

MVKH

MV

SADD

MPYLSHU

MVKLH

STB

SAT

SMPY

NEG

STH

SSUB

SMPYHL

NOT

STW

SUB

SMPYLH

OR

SUBU

SMPYH

 

SUBC

XOR

ZERO

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.

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

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

u(n) =

ALGORITHM:

1, n >= 0

0, n < 0

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.

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

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

r(n) =

ALGORITHM:

nt, n ≥ 0

0, n < 0

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.

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

2- D. GENERATION OF EXPONENTIAL FUNCTION.

AIM:

To generate an exponential function using MATLAB.

THEORY:

It is mathematically written as

g(n) =

α n , n≥0

0, n<0 Where α is constant;

if

exponential

exponential signal.

signal,

and

if

it

is

α

is

positive

real number, it

then

it

gives increasing

a decreasing

negative value,

produces

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 :’);

% positive Value for increasing exponential. % Negative value for decreasing Exponential.

y= exp (a*t); stem (t ,y); Ylabel(‘Amplitude ----->); Xlabel(‘Time ----->’); title(‘exponential sequence’);

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.

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

enter the "n" value: 20

enter the "a" value:

-0.25

% a is Negative Value.

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

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

signal. Rather it would be formed in the shape of a random signal.

are added the resultant signal will no longer be a sinusoidal

),

ALGORITHM:

1. Enter the range t=0 to 2*pi with an interval of 0.5.

2. Take the function Sin(t) and assign this to variable x.

3. Plot the graph t Vs x.

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

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.

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) =

ALGORITHM:

x(k)h(n-k)

k= -∞

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 the sequence in variable h.

3. Use the inbuilt function conv() to find the convolution of the given sequences.

4. Plot all the three waveforms using subplot().

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

the convolved sequence. Enter the input sequence: [1 2 3 4] Enter the impulse response: [2

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

AIM:

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);

end

k=k-1;

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

sequence. Enter the input sequence:[1 2 3 4] Enter the impulse response:[2 1 2 1] Convolution

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) =

Mathematically, circular convolution is defined as y(n) = And generally it is represented as N It

And generally it is represented as

is defined as y(n) = And generally it is represented as N It can also be

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);

for(i=1:n3);

j=n-i+1;

if(j<=0)

y(n)=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

the input sequence: [2 1 2 1] Enter the impulse response: [1 2 3 4] circ

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

target. The auto correlation sequence of X(n) is given by Note: ALGORITHM: (n)=E x the energy

Note:

The auto correlation sequence of X(n) is given by Note: ALGORITHM: (n)=E x the energy of

ALGORITHM:

(n)=E x

the energy of the signal x(n).

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

enter the sequence:[1 2 3 4] Auto correlation of the sequence is 4.0000 11.0000 20.0000 30.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

ALGORITHM:

r xy (l)=

of X(n), Y(n) is given by ALGORITHM: r x y (l ) = 1. Ask the

1. Ask the user to enter the first sequence.

l=0, ±1, ±2, ±3,…

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 1 st sequence’); h= input(‘enter the 2 nd sequence’); n1= length (x); n2 = length (h); n = max(n1,n2);

subplot(3,1,1);

m=0:n1-1;

stem(m,x); title(‘1 st sequence’); xlabel(‘time-->’); ylabel(‘amplitude-->’);

subplot(3,1,2);

m=0:n2-1;

stem(m,h); title(‘2 nd 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

the 2nd sequence:[1 2 3 4] cross correlation of given sequence is 8.0000, 10.0000 15.0000 14.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)=

THEORY: DFT of a finite sequence x(n) is defined as X(k)= Where U = N=No. of

Where U=

of a finite sequence x(n) is defined as X(k)= Where U = N=No. of samples in

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.

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

using FFT algorithm. THEORY: The DFT Equation X(k)=1/N where = TWIDDLE FACTOR: [TWIDDLE FACTOR] In the

where

=
=

TWIDDLE FACTOR:

[TWIDDLE FACTOR]

In the definition of the DFT, there is a factor called the Twiddle Factor

=
=

where N= number of samples.

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 e.g.
Note that
1.
It is periodic (i.e. it goes round and round the circle).
2.
That the vectors are symmetric.
FAST FOURIER TRANSFORM: 2-Point 4-Point 2-Point 8-Point 2-Point 4-Point 2-Point
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;

//#of points for FFT

//twiddle constants stored in w

//input sample array, # of points

//temporary storage variables

//loop counter variables

// index of upper/lower butterfly leg

// difference between upper/ lower leg

//number of FFT stages (iterations)

int index, step;

// index/step through twiddle constant

i=1;

// log (base2) of N-points= # of stages

do

{

num_stages+ =1;

i=i*2;

}

while(i!=N);

leg_diff= N/2;

// difference between & lower legs

step= (PTS*2)/N;

// step between values in twiddle.h

for (i=0; i<num_stages; i++)

{

index= 0;

for(j=0; j<leg_diff; j++)

{

// 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]).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

IDFT of a finite sequence X(n) is defined as. X(k)=1/N w h e r e =

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

1

2

3

4

4 DFT of xn is 10.0000, -2.0000 + 2.0000i, -2.0000, -2.0000 - 2.0000i. IDFT of XK

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. Digital filters

2. 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)= -

(a) Linear difference equation, which is given by Y(n)= - y(n-k)+ (n-k) (b) Transfer function, which

y(n-k)+

difference equation, which is given by Y(n)= - y(n-k)+ (n-k) (b) Transfer function, which is given

(n-k)

(b) Transfer function, which is given by

- y(n-k)+ (n-k) (b) Transfer function, which is given by ALGORITHM: 1. Get the cut off

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:

Hence the MATLAB program for IIR-Filter was written and obtained the

result.

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

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 frequency- based 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.

ALGORITHM:

S(w) =FT(R( ))=

of the auto correlation. ALGORITHM: S(w) =FT(R( ))= R( ) = (S(w)) = dw 1. Select

R( ) =

(S(w)) =

correlation. ALGORITHM: S(w) =FT(R( ))= R( ) = (S(w)) = dw 1. Select no. of points

dw

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

Points of FFT(eg.64)) using math library

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.

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];

//FFT prototype

//as Input and output buffer

//intermeadiate buffer

short i;

short buffercount = 0;

//general purpose index variable

//number of new samples in io buffer

float y[128];

COMPLEX w[PTS];

COMPLEX samples[PTS];

main ()

{

Float j,sum=0.0 ;

int n,k,l,a;

//twiddle constants stored in w

//primary working buffer

For(i=0;i<PTS;i++)

//set up twiddle constants in w

{

w[i].real =cos(2*Pi*i/(PTS*2.0));

/*Re component of twiddle constants*/

w[i].imag =-sin(2*Pi*i/(PTS*2.0));

}

/*Im component of twiddle constants*/

/**************************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;

}

//Signal x(Fs)=sin(2*pi*f**i/fs);

/***********************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)

}

iobuffer[n]=sum;

}

/************************* FFT of R(t) *******************************/

for (i=0;i<PTS;i++)

{

//swap buffers

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

/***************************** PSD ********************************/

for(i=0;i<PTS;i++0)

{

//compute the magnitude

x1[i]=sqrt(samples[i].real*samples[i].real+samples[i].image*samples[i].image);

}

}

// end of main

FFT.c:

#defined PTS128

//# of points for FFT

typedef struct{float real, imag;} COMPLEX;

extern COMPLEX w[PTS];

//twiddle constant stored in w

void FFT(COMPLEX*Y, int N);

{

COMPLEX temp1, temp2;

int i,j,k;

int upper_leg, lower_leg;

//input sample array,#of points

//temporary storage variables

//loop conter variables

//index of upper/lower butterfly leg

int leg_diff;

//difference between upper/lower leg

int num_stages=0;

int index; step;

do

{

i =1;

num_stages +=1;

//number of FFT stages(iterations)

//index/step through twiddele constant

//log(based2)of points=# of stages

i=i*2;

}

while (i!=N);

leg_diff=N/2;

//difference between upper & lower legs

step=(PTS*2)/N;

for(i=0;i<num_stages;i++)

{

index=0;

for(j=0;j<leg_diff;j++)

{

//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;

//bit reversal for resequencing data

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;

}

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

Program’pull 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.

PROGRAM CODE:

# include “filtercfg.h”

# include “dsk6713.h”

# include “dsk6713-aic23.h”

const signed int filter_coeff[ ]=

{

// (12730,-12730, 12730, 2767,-18324, 21137

/*HP2500*/

//312, 312, 312, 32767, -27943, 24367

/*cp800*/

//1455, 1455, 1455, 32767, -23140, 21735

/*LP2500*/

//9268,-9268, 9268, 32767, -7395, 18367

/*HP 4000*/

//7215, -7215, 7215, 32767, 5039, 6171

/*HP 7000*/

}

/*codec configuration settings*/

DSK6713 AIC23_config config = {

\ 0X0017,

/* 0 DSK6713 - AIC23 – LEFT INVOL Left line input channel volume*/

\0X0017,

/* 1 DSK 6713 - AIC23 – RIGHT INVOL Right line input channel Volume*/

\0X00d8,

/* 2 DSK 6713 – AIC23 – LEFT HPVOL Left channel head phone volume */

\0X00d8,

/* 3 DSK 6713 – AIC23 – RIGHT HPVOL Right channel head phone volume*/

\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);

static signed int Y [6] = {0, 0, 0, 0, 0, 0};

int temp = 0;

temp = (short int) x1;

/* X(n),X(n-1),X(n-2) must be static*/

/*Y(n),Y(n-1),Y(n-2) must be static*/

/* copy input to temp */

X[0] = (signed int) temp;

/*copy input to X [stages][0]*/

temp = ((int) h [0]*X[0]);

/* Bo *X(n) */

temp + = ((int) h [1]*X[1]);

/*B1/2*X(n-1)*/

temp + = ((int) h [1]*X[1]);

/*B1/2*X(n-1)*/

temp + = ((int) h [2]*X[2]);

/*B2*X(n-2)*/

temp _ = ((int) h [4]*Y[1]);

/*A1/2*Y(n-1)*/

temp _ = ((int) h [4]*Y[1]);

/*A1/2*Y(n-1)*/

temp _ =((int) h [5]*Y[2]);

/*A2*Y(n-2)*/

}

temp>>=15;

if (temp<32767).

{

temp =32767;

}

else if (temp<-32767).

{

temp =-32767;

}

Y[0] = temp;

Y[2] =Y[1];

Y[1] = Y[0];

X[2] = X[1];

X[1] = X[0];

return (temp<<2);

}

/*Divide temp by coefficients [A0]*/

/*shuffle values along one place for next time*/

/*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*/

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

WR (N) =

ALGORITHM:

1,

for │n│ ≤ (M-1) / 2

0, otherwise

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.

response curves. Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order

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

WT (n) =

ALGORITHM:

(1-│ n │), for │n│ ≤ (M-1)/2

0, otherwise

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

the response curves. Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the

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

Where:

Wn =

THEORY: The Kaiser Window function is given by Where: Wn = I 0 (α(√(1-((2n/M)-1) 2 )),

I 0 (α(√(1-((2n/M)-1) 2 )),

0

otherwise.

0 ≤ n ≤ M

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.

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

curves. Output: Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order

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(2πn/(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

curves. Output: Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order

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(2πn/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

curves. Output: Enter the cut off frequency: 300 Enter the sampling frequency: 1000 Enter the order

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

AIM:

To find response of the IIR- LPF using Butterworth Approximation.

ALGORITHM:

1. Get the cut off frequency from the user.

2. Get the sampling frequency and order of the filter from the user.

3. Use the built in function to calculate the frequency response of the IIR filter.

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

band edge frequency 500 Enter the sampling frequency 1200 Enter the pass band ripple 10 Enter

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. Get the cut off frequency from the user.

2. Get the sampling frequency and order of the filter from the user.

3. Use the built in function to calculate the frequency response of the IIR filter.

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

band edge frequency 500 Enter the sampling frequency 1200 Enter the pass band ripple 10 Enter

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. Get the cut off frequency from the user.

2. Get the sampling frequency and order of the filter from the user.

3. Use the built in function to calculate the frequency response of the IIR filter.

4. 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 type- 1 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

band edge frequency 500 Enter the sampling frequency 1200 Enter the pass band ripple 10 Enter