VI-Sem-SP Lab-ECE

Embed Size (px)

Citation preview

  • 7/30/2019 VI-Sem-SP Lab-ECE

    1/53

    SIGNAL PROCESSING LAB

    PREPARED BY

    Smt. B.Rajeswari Mr. M.K. Linga MurthyM.Tech M.Tech

    Assistant Professor. Assistant Professor.Dept., of ECE. Dept., of ECE.

    Department of Electronics and Communications Engineering,Lakireddy Bali Reddy College of Engineering

    (AUTONOMOUS),L.B.Reddy Nagar, MYLAVARAM 521230.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    2/53

    Lakireddy Bali Reddy College of Engineering (AUTONOMOUS)

    L.B.Reddy Nagar, MYLAVARAM 521230.Krishna Dist., (A.P.)

    Signal Processing Laboratory

    Name :

    Regd.No :

    Course : B.Tech (VI Semester). Branch :ECE

    Academic Year : 2012-2013

  • 7/30/2019 VI-Sem-SP Lab-ECE

    3/53

    P873 SIGNAL PROCESSING LAB

    Lecture : 3 Periods/week Internal Marks : 25

    External Marks : 75

    Credits : 2 External Examination : 3 Hrs--------------------------------------------------------------------------------------------------

    LIST OF EXPERIMENTS:

    USING TMS320C67X

    1 Generation of Signals

    2 Linear Convolution

    3 Implementation of a FIR filter

    4 Implementation of an IIR filter

    5 Calculation of FFT

    USING MATLAB

    1 Generation of Discrete time Signals

    2 Verification of Sampling Theorem

    3 FFT and IFFT

    4 Time & Frequency response of LTI systems

    5 Linear and Circular Convolution through FFT

    6 Design of FIR filters (window design)

    7 Design of IIR filters (Butterworth &Chebychev)

    ADDITIONAL EXPERIMENTS

    1 Verify decimation.

    2 Verify interpolation.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    4/53

    1. INTRODUCTION TO DSP PROCESSORS

    A signal can be defined as a function that conveys information, generally about

    the state or behavior of a physical system. There are two basic types of signals viz

    Analog (continuous time signals which are defined along a continuum of times) andDigital (discrete-time).

    Remarkably, under reasonable constraints, a continuous time signal can beadequately represented by samples, obtaining discrete time signals. Thus digital signal

    processing is an ideal choice for anyone who needs the performance advantage of digital

    manipulation along with todays analog reality.

    Hence a processor which is designed to perform the special operations(digital

    manipulations) on the digital signal within very less time can be called as a Digital signal

    processor. The difference between a DSP processor, conventional microprocessor and a

    microcontroller are listed below.

    Microprocessor or General Purpose Processor such as Intel xx86 or Motorola 680xx

    familyContains - only CPU

    No RAM

    No ROM

    No I/O ports

    No Timer

    Microcontroller such as 8051 family

    Contains - CPU

    RAM ROM

    I/O ports

    Timer &

    Interrupt circuitrySome Micro Controllers also contain A/D, D/A and Flash Memory

    DSP Processors such as Texas instruments and Analog Devices

    Contains - CPU

    RAM

    ROM I/O ports

    Timer

    Optimized for fast arithmetic- Extended precision- Dual operand fetch- Zero overhead loop- Circular buffering

  • 7/30/2019 VI-Sem-SP Lab-ECE

    5/53

    The basic features of a DSP Processor are

    Feature Use

    Fast-Multiply accumulate Most DSP algorithms, including

    filtering, transforms, etc. are

    multiplication- intensive

    Multiple access memory

    architecture

    Many data-intensive DSP operations

    require reading a program instruction

    and multiple data items during eachinstruction cycle for best performance

    Specialized addressing modes Efficient handling of data arrays andfirst-in, first-out buffers in memory

    Specialized program control Efficient control of loops for manyiterative DSP algorithms. Fast interrupt

    handling for frequent I/O operations.

    On-chip peripherals and I/O

    interfaces

    On-chip peripherals like A/D converters

    allow for small low cost system designs.Similarly I/O interfaces tailored forcommon peripherals allow clean

    interfaces to off-chip I/O devices.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    6/53

    2. ARCHITECTURE OF 6713 DSP PROCESSOR

    This chapter provides an overview of the architectural structure of theTMS320C67xx DSP, which comprises the central processing unit (CPU), memory, and

    on-chip peripherals. The C67xE DSPs use an advanced modified Harvard architecture

    that maximizes processing power with eight buses. Separate program and data spacesallow simultaneous access to program instructions and data, providing a high degree of

    parallelism. For example, three reads and one write can be performed in a single cycle.

    Instructions with parallel store and application-specific instructions fully utilize thisarchitecture. In addition, data can be transferred between data and program spaces. Such

    Parallelism supports a powerful set of arithmetic, logic, and bit-manipulation operations

    that can all be performed in a single machine cycle. Also, the C67xx DSP includes thecontrol mechanisms to manage interrupts, repeated operations, and function calling.

    Fig 2 1 BLOCK DIAGRAM OF TMS 320VC 6713

  • 7/30/2019 VI-Sem-SP Lab-ECE

    7/53

    Bus Structure

    The C67xx DSP architecture is built around eight major 16-bit buses (fourprogram/data buses and four address buses):

    The program bus (PB) carries the instruction code and immediate operands from

    program memory. Three data buses (CB, DB, and EB) interconnect to various elements, such as the

    CPU, data address generation logic, program address generation logic, on-chip

    peripherals, and data memory.

    The CB and DB carry the operands that are read from data memory.

    The EB carries the data to be written to memory.

    Four address buses (PAB, CAB, DAB, and EAB) carry the addresses needed forinstruction execution.

    The C67xx DSP can generate up to two data-memory addresses per cycle using thetwo auxiliary register arithmetic units (ARAU0 and ARAU1). The PB can carry data

    operands stored in program space (for instance, a coefficient table) to the multiplier andadder for multiply/accumulate operations or to a destination in data space for data moveinstructions (MVPD and READA). This capability, in conjunction with the feature of

    dual-operand read, supports the execution of single-cycle, 3-operand instructions such as

    the FIRS instruction. The C67xx DSP also has an on-chip bidirectional bus for accessing

    on-chip peripherals. This bus is connected to DB and EB through the bus exchanger inthe CPU interface. Accesses that use this bus can require two or more cycles for reads

    and writes, depending on the peripherals structure.

    Central Processing Unit (CPU)

    The CPU is common to all C67xE devices. The C67x CPU contains:

    40-bit arithmetic logic unit (ALU)

    Two 40-bit accumulators

    Barrel shifter

    17 17-bit multiplier

    40-bit adder

    Compare, select, and store unit (CSSU)

    Data address generation unit

    Program address generation unit

    Arithmetic Logic Unit (ALU)

    The C67x DSP performs 2s-complement arithmetic with a 40-bit arithmetic logicunit (ALU) and two 40-bit accumulators (accumulators A and B). The ALU can also

    perform Boolean operations. The ALU uses these inputs:

    16-bit immediate value

    16-bit word from data memory

    16-bit value in the temporary register, T

    Two 16-bit words from data memory

    32-bit word from data memory

  • 7/30/2019 VI-Sem-SP Lab-ECE

    8/53

    40-bit word from either accumulator

    The ALU can also function as two 16-bit ALUs and perform two 16-bit operations

    simultaneously.

    Fig 2 2 ALU UNITAccumulators

    Accumulators A and B store the output from the ALU or the multiplier/adder

    block. They can also provide a second input to the ALU; accumulator A can be an inputto the multiplier/adder. Each accumulator is divided into three parts:

    Guard bits (bits 3932)

    High-order word (bits 3116)

    Low-order word (bits 150)Instructions are provided for storing the guard bits, for storing the high- and the low-

    order accumulator words in data memory, and for transferring 32-bit accumulator words

    in or out of data memory. Also, either of the accumulators can be used as temporarystorage for the other.

    Barrel Shifter

    The C67x DSP barrel shifter has a 40-bit input connected to the accumulators or

    to data memory (using CB or DB), and a 40-bit output connected to the ALU or to data

    memory (using EB). The barrel shifter can produce a left shift of 0 to 31 bits and a rightshift of 0 to 16 bits on the input data. The shift requirements are defined in the shift count

    field of the instruction, the shift count field (ASM) of status register ST1, or in temporary

    register T (when it is designated as a shift count register).The barrel shifter and theexponent encoder normalize the values in an accumulator in a single cycle. The LSBs of

    the output are filled with 0s, and the MSBs can be either zero filled or sign extended,

    depending on the state of the sign-extension mode bit (SXM) in ST1. Additional shiftcapabilities enable the processor to perform numerical scaling, bit extraction, extended

    arithmetic, and overflow prevention operations.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    9/53

    Multiplier/Adder Unit

    The multiplier/adder unit performs 17 _ 17-bit 2s-complement multiplication witha 40-bit addition in a single instruction cycle. The multiplier/adder block consists of

    several elements: a multiplier, an adder, signed/unsigned input control logic, fractional

    control logic, a zero detector, a rounder (2s complement), overflow/saturation logic, and a

    16-bit temporary storage register (T). The multiplier has two inputs: one input is selectedfrom T, a data-memory operand, or accumulator A; the other is selected from program

    memory, data memory, accumulator A, or an immediate value. The fast, on-chipmultiplier allows the C54x DSP to perform operations efficiently such as convolution,

    correlation, and filtering. In addition, the multiplier and ALU together execute

    multiply/accumulate (MAC) computations and ALU operations in parallel in a single

    instruction cycle. This function is used in determining the Euclidian distance and inimplementing symmetrical and LMS filters, which are required for complex DSP

    algorithms. See section 4.5, Multiplier/Adder Unit, on page 4-19, for more details about

    the multiplier/adder unit.

    Fig 2 3 MULTIPLIER/ADDER UNIT

    These are the some of the important parts of the processor and you are instructed to go

    through the detailed architecture once which helps you in developing the optimized code

    for the required application.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    10/53

    INDEX

    CYCLE ----- I

    S.No Date Name of the Experiment Marks Signature

    1 Generation of Signals

    2 Linear Convolution

    3 Implementation of a FIR filter.

    4Implementation of an IIR filter.

    5 Calculation of FFT.

    CYCLE ----- II

    S.No Date Name of the Experiment Marks Signature

    1 Generation of discrete timeSignals

    2Verification of sampling

    theorem.

    3 FFT and IFFT

    4Time and Frequency response

    of LTI Systems

    5Linear and Circular

    Convolution through FFT.

    6Design of FIR filters

    (window design)

    7Design of IIR filters

    (Butterworth& Chebychev)

  • 7/30/2019 VI-Sem-SP Lab-ECE

    11/53

    CYCLE ------------I

  • 7/30/2019 VI-Sem-SP Lab-ECE

    12/53

    1. GENERATION OF DIFFERENT SIGNALS

    Aim: Generating different signals using C.

    Equipments: Operating System Windows XPConstructor - Simulator

    Software - CCStudio 2

    Theory:

    Procedure:

    1. Open CC Studio and Create a new project(projnew).

    2. Open source file and write the program and save the file with .C

    extension.(filenewsource file).

    3. Add source files to project (projadd files to projectfilename.c).

    4. Add library files to project (path: C:ti\C6000\Cgtools\lib\rts6700.lib).

    5. Add linker command files to project (path: C:ti\tutorial\dsk6711\hello1\hello.cmd).6. Compile and build the program (projcompile file, build).

    7. Load program (fileload program: Look in: proj. Out).

    8. Run the program and observe the result (debugrun).

  • 7/30/2019 VI-Sem-SP Lab-ECE

    13/53

    Program:

    #include

    #include

    #define pi 3.14159

    int t,L1,L2,N1;

    float x[1000],x1[1000],x2[1000];

    void main()

    {

    printf("Enter the Length of required wave");

    scanf("%d",&L1);

    printf("Enter the values for wave");

    for(t=0;t

  • 7/30/2019 VI-Sem-SP Lab-ECE

    14/53

    Output:

    Result:

    Precautions:

    1. Check out source file is with .c extension or not.

    2. Check out the files added were correct or not.3. Do not add more than one source file to the project at a time.

    4. If only building the project is having error check the processor setup.

    5. Dont delete any file or folder without informing the system administrator or

    lab in-charge.

    Viva-Voce Questions:

    1. Define signal and give examples of operations on signals.

    2. What are basic signals.3. Differentiate continuous and digital signals.

    4. What are the applications of signals.

    5. Define energy and power signals.

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    15/53

    2. LINEAR CONVOLUTION

    Aim:To compute the response of a discrete LTI system with input sequence x(n) and

    impulse response h(n) by using linear convolution.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - CCStudio 2

    Theory:

    Procedure:

    1. Open CC Studio and Create a new project(projnew).

    2. Open source file and write the program and save the file with .C extension.

    (file

    new

    source file).3. Add source files to project (projadd files to projectfilename.c).

    4. Add library files to project (path: C:ti\C6000\Cgtools\lib\rts6700.lib).

    5. Add linker command files to project(path: C:ti\tutorial\dsk6711\hello1\hello.cmd).

    6. Compile and build the program (projcompile file, build).

    7. Load program (fileload program: Look in: proj. Out).

    8. Run the program and observe the result (debugrun).

  • 7/30/2019 VI-Sem-SP Lab-ECE

    16/53

    Program:

    // Linear convolution program in c language using CCStudio

    #include

    int x[15],h[15],y[15];

    main()

    {

    int i,j,m,n;

    printf("\n enter value for m");

    scanf("%d",&m);

    printf("\n enter value for n");

    scanf("%d",&n);

    printf("Enter values for i/p x(n):\n");

    for(i=0;i

  • 7/30/2019 VI-Sem-SP Lab-ECE

    17/53

    OUTPUT:

    Result:

    Precautions:

    Check out source file is with .c extension or not.

    Check out the files added were correct or not.

    Do not add more than one source file to the project at a time.

    If only building the project is having error check the processor setup.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    VIVA -VOCE QUESTIONS:

    What is the need of convolution

    Why DFT does not support Linear Convolution.

    How to obtain the response of discrete LTI system from Linear Convolution

    What are different steps required to execute the DSP program in CCS.

    How to create project in CCS.

    What are different files to be added for project, to execute the program

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    18/53

    3. IMPLEMENTATION OF FIR FILTER

    Aim:To design FIR filters using c program & implement in CCS software

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - CCStudio 3

    Theory:

    Procedure:

    1. Open CC Studio and Create a new project (projnew).

    2. Open source file and write the program and save the file with .C

    extension.(filenewsource file).3. Add source files to project (projadd files to projectfilename.c).

    4. Add library files to project (path: C:ti\C6000\Cgtools\lib\rts6700.lib).5. Add linker command files to project (path: C:ti\tutorial\dsk6711\hello1\hello.cmd).

    6. Compile and build the program (projcompile file, build).

    7. Load program (fileload program: Look in: proj.Out).

    8. Run the program and observe the result (debugrun).

  • 7/30/2019 VI-Sem-SP Lab-ECE

    19/53

    Program:

    #include

    #include

    #define pi 3.1415

    int n,N,c;

    float wr[64],wt[64];

    void main()

    {

    printf("\n enter no. of samples,N= :");

    scanf("%d",&N);

    printf("\n enter choice of window function\n 1.rect \n 2. triang \n c= :");

    scanf("%d",&c);

    printf("\n elements of window function are:");

    switch(c)

    {

    case 1:

    for(n=0;n

  • 7/30/2019 VI-Sem-SP Lab-ECE

    20/53

    Output:

    Result:

    Precautions: Check out source file is with .c extension or not.

    Check out the files added were correct or not.

    Do not add more than one source file to the project at a time.

    If only building the project is having error check the processor setup.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    Viva -voce questions:

    What are the advantages of FIR filter?

    What is the need of usage of windows?

    What are different steps required to execute the DSP program in CCS.

    How to create project in CCS.

    What are different files to be added for project, to execute the program?

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    21/53

    4. IMPLEMENTATION OF IIR FILTERS

    Aim:To design and implement IIR (LPF/HPF) filters using c program & implement in CCS

    software.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - CCStudio 3

    Theory:

    Procedure:1. Open CC Studio and Create a new project (projnew).

    2. Open source file and write the program and save the file with .C

    extension.(filenewsource file).

    3. Add source files to project (projadd files to projectfilename.c).

    4. Add library files to project (path: C:ti\C6000\Cgtools\lib\rts6700.lib).5. Add linker command files to project (path:

    C:ti\tutorial\dsk6711\hello1\hello.cmd).

    6. Compile and build the program (projcompile file, build).

    7. Load program (fileload program: Look in: proj. Out).

    8. Run the program and observe the result (debugrun).

  • 7/30/2019 VI-Sem-SP Lab-ECE

    22/53

    Program:

    // iir filter implementation.

    #include

    #include

    int i,w,wc,c,N;

    float H[100];

    float mul(float, int);

    void main()

    {

    printf("\n enter order of filter ");

    scanf("%d",&N);

    printf("\n enter the cutoff freq ");

    scanf("%d",&wc);

    printf("\n enter the choice for IIR filter 1. LPF 2.HPF ");

    scanf("%d",&c);

    switch(c)

    {

    case 1:

    for(w=0;w

  • 7/30/2019 VI-Sem-SP Lab-ECE

    23/53

    a*=a;

    return(a);

    }

    OUTPUT:

    Result:

    PRECAUTIONS:

    Check out source file is with .c extension or not.

    Check out the files added were correct or not.

    Do not add more than one source file to the project at a time.

    If only building the project is having error check the processor setup.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    VIVA -VOCE QUESTIONS:

    What are advantages of IIR Filter over FIR Filter?

    What are different windows for IIR filter?

    What is the need of window.

    Which are raised cosine windows?

    What are characteristics of LPF and HPF?

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    24/53

    5. CALCULATION OF FAST FOURIER TRANSFORM

    Aim:To verify Fast Fourier Transform using c program & implement in CCS software.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - CCStudio 3

    Theory:

  • 7/30/2019 VI-Sem-SP Lab-ECE

    25/53

    Procedure:

    1. Open CC Studio and Create a new project (projnew).

    2. Open source file and write the program and save the file with .C extension.

    (filenewsource file).

    3. Add source files to project (projadd files to projectfilename.c).4. Add library files to project (path: C:ti\C6000\Cgtools\lib\rts6700.lib).

    5. Add linker command files to project (path: C:ti\tutorial\dsk6711\hello1\hello.cmd).

    6. Compile and build the program (projcompile file, build).

    7. Load program (fileload program: Look in: proj. Out).

    8. Run the program and observe the result (debugrun).

    Program:

    #include

    #include

    #define Pi 3.142857

    int x[20],N,n,k;

    float XReP[20],XImP[20],X[20],MSofX[20],PSofX[20];

    void main()

    {

    printf("Enter the length of discrete sequence x(n):N=");

    scanf("%d",&N);

    printf("Enter the discrete sequence x(n):\n");

    for(n=0;n

  • 7/30/2019 VI-Sem-SP Lab-ECE

    26/53

    XImP[k]=-XImP[k];

    PSofX[k]=atan(XImP[k]/XReP[k]);

    }

    printf("\nDiscrete sequence x(n)=");

    for(n=0;n

  • 7/30/2019 VI-Sem-SP Lab-ECE

    27/53

    Result:

    Precautions:

    Check out source file is with .c extension or not.

    Check out the files added were correct or not.

    Do not add more than one source file to the project at a time.

    If only building the project is having error check the processor setup.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    Viva-voce questions:

    What is Fast Fourier Transform

    How to obtain Fast Fourier Transform of a sequence x(n) What are different types of FFT algorithms

    Explain clearly how computational efficiency increases through FFT

    How to compute IDFT through FFT

    How to obtain response of the system from FFT.

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    28/53

    CYCLE ------- II

  • 7/30/2019 VI-Sem-SP Lab-ECE

    29/53

    1. GENERATION OF DISCRETE TIME SIGNALS.

    Aim:Generating different discrete time signals.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.1.0

    Theory:

    Procedure:

    1. Click on the Matlab icon and open Mfile(finenewM-file)

    2. Write the program and save it.3. Run the program .4. If any errors occurred in command window correct them and again run the

    program.

    5. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    30/53

    Program:

    clc;

    clear all;

    close all;

    x=-pi:0.01:pi;

    y=sin(x);z=cos(x);

    k=square(x,20);

    b=tripuls(x);

    i=sawtooth(x);

    c=rectpuls(x);

    figure(1);

    subplot(3,3,1)

    stem(y);

    subplot(3,3,2)

    stem(z);

    subplot(3,3,3)

    stem(k);

    subplot(3,3,4)

    stem(b);

    subplot(3,3,5)

    stem(i);

    subplot(3,3,6)

    stem(c);

    t=-10:0.1:10;

    a=impulse(sys,t);

    b=step(sys,t);

    c=exp(sys,t);

    figure(2)

    subplot(2,2,1)

    stem(a);

    subplot(2,2,2)

    stem(b);subplot(2,2,3)

    stem(c);

    Output:

  • 7/30/2019 VI-Sem-SP Lab-ECE

    31/53

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the two words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-charge.

    Viva-voce Questions:

    Define Discrete time signal.

    What are the different types of discrete time signals.

    What is the command used for plotting of discrete time signal.

    Compare discrete time and continuous time signal.

    Explain about Matlab briefly.

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    32/53

    2. VERIFICATION OF SAMPLING THEOREM

    Aim:To verify sampling theorem using MATLAB

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.1.0

    Theory:

    Procedure:

    1. Click on the Matlab icon and open Mfile(finenewM-file)

    2. Write the program and save it.

    3. Run the program .

    4. If any errors occurred in command window correct them and again run theprogram.

    5. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    33/53

    Program:

    clc;

    close all;

    clear all;

    t=-10:0.01:10;

    T=8;fm=1/T;

    x=sin(2*pi*fm*t);

    fs1=1.2*fm;

    fs2=2*fm;

    fs3=8*fm;

    n1=-4:1:4;

    xn1=cos(2*pi*n1*fm/fs1);

    subplot(221);

    plot(t,x);

    xlabel('time in seconds');

    ylabel('x(t)');

    title('continuous time signal');

    subplot(222);

    stem(n1,xn1);

    hold on;

    plot(n1,xn1);

    xlabel('n');

    ylabel('x(n)');

    title('discrete time signal with fs2fm');

    Output:

  • 7/30/2019 VI-Sem-SP Lab-ECE

    34/53

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the two words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-charge.

    Viva-voce Questions:

    Define Sampling theorem.

    What is the condition of sampling theorem.

    What is the disadvantage of the sampling theorem and what is the remedy for that.

    How we can find the sampling frequency.

    What are different toolboxes available in matlab.

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    35/53

    3. FFT AND IFFT

    Aim:To verify Fast Fourier Transform.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.0

    Theory:

    Procedure:

    1. Click on the Matlab icon and open Mfile(finenewM-file)

    2. Write the program and save it.

    3. Run the program .

    4. If any errors occurred in command window correct them and again run theprogram.

    5. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    36/53

    Program:

    %fast fourier transform

    clc;

    clear all;

    close all;n=input('enter the length of fft');

    x=input('enter the sequence');

    subplot(221);

    title('i/p signal');

    xlabel('n --->');

    ylabel('x(n) -->');

    grid;

    stem(x);

    %compute fft

    disp('fourier transformed signal');

    x1=abs(fft(x,n))

    subplot(2,2,2);stem(x1);

    xlabel('n --->');ylabel('x(n) -->');grid;

    title('fft of i/p x(n) is:');

    x2=fftshift(x1);

    subplot(223);stem(x2);grid;

    subplot(224);plot(x2);

    % x=fftshift(abs(fft([ones(1,8),zeros(1,100)])));

    % plot(x)

    xlabel('Real axis --->');

    ylabel('Imaginary axis -->');grid;

    x3=ifft(x,n);

    figure;

    stem(x2);

    xlabel('Real axis --->');

    ylabel('Imaginary axis -->');grid;

    Output:

  • 7/30/2019 VI-Sem-SP Lab-ECE

    37/53

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the two words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-charge.

    Viva-voce Questions:

    Define FFT.

    Define IFFT.

    What is the meaning of FFT and IFFT commands in Matlab.

    Explain about the Fast Fourier transform.

    Give the details of the commands used for finding FFT.

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    38/53

    4. TIME AND FREQUENCY RESPONSE OF LTI SYSTEMS

    Aim:

    To find time and frequency response of an LTI systems

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.1.0

    Theory:

    Procedure:

    1. Click on the Mat lab icon and open Mfile(finenewM-file)2. Write the program and save it.

    3. Run the program.4. If any errors occurred in command window correct them and again run the

    program.

    5. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    39/53

    Program:

    Output:

  • 7/30/2019 VI-Sem-SP Lab-ECE

    40/53

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    Viva-voce Questions:

    What is an LTI system?

    What are the characteristics of an LTI system?

    What is meant by Frequency Response of LTI system?

    What is meant by Time Response of the LTI system?

    What are the toolboxes available in mat lab?

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    41/53

    5. LINEAR AND CIRCULAR CONVOLUTION THROUGH FFT

    Aim:

    To implement Linear and Circular convolution through FFT.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.1.0

    Theory:

    Procedure:

    1. Click on the Mat lab icon and open Mfile (finenewM-file)2. Write the program and save it.

    3. Run the program.4. If any errors occurred in command window correct them and again run the

    program.

    5. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    42/53

    Program:% Program for circular convolution

    clc;

    clearall;

    x1=input('enter the first sequence');

    x2=input('enter the second sequence');

    n=input('enter the no of points of the dft');

    subplot(3,1,1);

    stem(x1,'filled');

    title('plot of first sequence');

    subplot(3,1,2);stem(x2,'filled');

    title('plot the second sequnce');

    y1=fft(x1,n);

    y2=fft(x2,n);

    y3=y1.*y2;

    y=ifft(y3,n);

    disp('the circular convolution result is ......');

    disp(y);

    subplot(3,1,3);

    stem(y,'filled');

    title('plot of circularly convoluted sequence');

    OR

    clc;

    clearall;

    x1=input(enter the first sequence);

    x2=input(enter the second sequence);

    n=input(enter the no of points of the dft);

    subplot(3,1,1);

    stem(x1,filled);

    title(plot of first sequence);

    subplot(3,1,2);

  • 7/30/2019 VI-Sem-SP Lab-ECE

    43/53

    stem(x2,filled);

    title(plot the second sequnce);

    n1 = length(x1);

    n2 = length(x2);

    m = n1+n2-1; % Length of linear convolution

    x = [x1 zeros(1,n2-1)]; % Padding of zeros to make it of

    % length m

    y = [x2 zeros(1,n1-1)];

    x_fft = fft(x,m);

    y_fft = fft(y,m);

    dft_xy = x_fft.*y_fft;

    y=ifft(dft_xy,m);

    disp(the circular convolution result is ......);

    disp(y);

    subplot(3,1,3);

    stem(y,filled);

    title(plot of circularly convoluted sequence);

    Output:

  • 7/30/2019 VI-Sem-SP Lab-ECE

    44/53

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-charge.

    Viva-voce Questions:

    What is meant by linear Convolution?

    What is meant by Circular Convolution?

    What is the difference between Linear and Circular Convolution?

    Commands used for Convolution using FFT.

    What are the toolboxes available in mat lab?

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    45/53

  • 7/30/2019 VI-Sem-SP Lab-ECE

    46/53

    6. DESIGN OF FIR FILTERS(WINDOW DESIGN)

    Aim:To Design and Implement FIR filters

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.1.0

    Theory:

    Procedure:

    1. Click on the Mat lab icon and open Mfile(finenewM-file)

    2. Write the program and save it.

    3. Run the program.

    4. If any errors occurred in command window correct them and again run theprogram.

    5. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    47/53

    Program:

    %fir filter design (window techniques)

    clc;

    clear all;

    close all;

    rp=input('enter passband ripple');

    rs=input('enter the stopband ripple');

    fp=input('enter passband freq');

    fs=input('enter stopband freq');

    f=input('enter sampling freq ');

    wp=2*fp/f;

    ws=2*fs/f;

    num=-20*log10(sqrt(rp*rs))-13;

    dem=14.6*(fs-fp)/f;

    n=ceil(num/dem);

    n1=n+1;

    if(rem(n,2)~=0)

    n1=n;

    n=n-1;

    end

    c=input('enter your choice of window function 1. rectangular 2. triangular 3.kaiser: \n ');

    if(c==1)

    y=rectwin(n1);

    disp('Rectangular window filter response');

    end

    if (c==2)

    y=triang(n1);

    disp('Triangular window filter response');

    end

    if(c==3)

    y=kaiser(n1);

    disp('kaiser window filter response');

    end

    %LPF

  • 7/30/2019 VI-Sem-SP Lab-ECE

    48/53

    b=fir1(n,wp,y);

    [h,o]=freqz(b,1,256);

    m=20*log10(abs(h));

    subplot(2,2,1);plot(o/pi,m);

    title('LPF');

    ylabel('Gain in dB-->');

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

    %HPF

    b=fir1(n,wp,'high',y);

    [h,o]=freqz(b,1,256);

    m=20*log10(abs(h));

    subplot(2,2,2);plot(o/pi,m);

    title('HPF');

    ylabel('Gain in dB-->');

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

    %BPF

    wn=[wp ws];

    b=fir1(n,wn,y);

    [h,o]=freqz(b,1,256);

    m=20*log10(abs(h));

    subplot(2,2,3);plot(o/pi,m);

    title('BPF');

    ylabel('Gain in dB-->');

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

    %BSF

    b=fir1(n,wn,'stop',y);

    [h,o]=freqz(b,1,256);

    m=20*log10(abs(h));

    subplot(2,2,4);plot(o/pi,m);

    title('BSF');

    ylabel('Gain in dB-->');

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

  • 7/30/2019 VI-Sem-SP Lab-ECE

    49/53

    Output:

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the two words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    Viva-voce Questions:

    What are advantages of FIR Filter?

    What are different windows for fir filter?

    What is the need of usage of windows?

    What are different steps required to execute the DSP program in Mat lab.

    What is the command used for FIR filter implementation.

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    50/53

    7. DESIGN OF IIR FILTERS (BUTTERWORTH&CHEBYCHEV)

    Aim:To design and implementation of IIR (Butterworth &Chebychev) filters.

    Equipments:

    Operating System Windows XP

    Constructor - Simulator

    Software - MATLAB 7.1.0

    Theory:

    Procedure:

    1. Click on the Mat lab icon and open Mfile(finenewM-file)2. Write the program and save it.

    3. Run the program .

    4. If any errors occurred in command window correct them and again run theprogram.

    6. Observe the result in command window and plots on figure window.

  • 7/30/2019 VI-Sem-SP Lab-ECE

    51/53

    Program:

    clc;

    clear all;

    close all;

    warning off;

    disp('enter the IIR filter design specifications');

    rp=input('enter the passband ripple');

    rs=input('enter the stopband ripple');

    wp=input('enter the passband freq');

    ws=input('enter the stopband freq');

    fs=input('enter the sampling freq');

    w1=2*wp/fs;w2=2*ws/fs;

    [n,wn]=buttord(w1,w2,rp,rs,'s');

    c=input('enter choice of filter 1. LPF 2. HPF \n ');

    if(c==1)

    disp('Frequency response of IIR LPF is:');

    [b,a]=butter(n,wn,'low','s');

    end

    if(c==2)

    disp('Frequency response of IIR HPF is:');

    [b,a]=butter(n,wn,'high','s');

    end

    w=0:.01:pi;

    [h,om]=freqs(b,a,w);

    m=20*log10(abs(h));

    an=angle(h);

    figure,subplot(2,1,1);plot(om/pi,m);

    title('magnitude response of IIR filter is:');

    xlabel('(a) Normalized freq. -->');

    ylabel('Gain in dB-->');

    subplot(2,1,2);plot(om/pi,an);

    title('phase response of IIR filter is:');

    xlabel('(b) Normalized freq. -->');

    ylabel('Phase in radians-->');

  • 7/30/2019 VI-Sem-SP Lab-ECE

    52/53

    Output:

    Result:

    Precautions:

    Files should not save with the numbers as starting.

    Dont save the files with the two words separated by space.

    Dont open any other folders or files.

    Dont delete any file or folder without informing the system administrator or lab in-

    charge.

    Viva-voce Questions:

    What are advantages of IIR Filter over FIR Filters?

    What is the difference between Butterworth and Chebychev?

    What is the Command used for Butterworth filter.

    Explain about Mat lab.

    What are the advantages of this Mat lab..

    Lab In-charge

  • 7/30/2019 VI-Sem-SP Lab-ECE

    53/53

    Additional Experiments