Ec6511 Dsp Lab Manual

download Ec6511 Dsp Lab Manual

of 156

description

EC 6511 DSP LAB MAUAL FOR IIIRD YEAR VTH SEM ECE STUDENTS

Transcript of Ec6511 Dsp Lab Manual

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 0

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 1

    DEPARTMENT OF ELECTRONICS AND COMMUNICATION

    ENGINEERING

    EC 6511 Digital Signal Processing Lab

    LABORATORY MANUAL

    Regulation 2013

    V- Semester

    Name : ..

    Reg .No : ..

    Branch : ..

    Year & Section : ..

    Sri Muthukumaran Institute of Technology

    Chikkarayapuram, Near Mangadu, Chennai-600069

    AICTE Approved, NBA Accredited

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 2

    EC6511 DIGITAL SIGNAL PROCESSING LABORATORY L T P C

    0 0 3 2

    OBJECTIVES:

    The student should be made to:

    To implement Linear and Circular Convolution

    To implement FIR and IIR filters

    To study the architecture of DSP processor

    To demonstrate Finite word length effect LIST OF EXPERIMENTS:

    MATLAB / EQUIVALENT SOFTWARE PACKAGE

    1.Generation of sequences (functional & random) & correlation

    2.Linear and Circular Convolutions

    3.Spectrum Analysis using DFT

    4.FIR filter design

    5.IIR filter design

    6.Multirate Filters

    7.Equalization

    DSP PROCESSOR BASED IMPLEMENTATION 8. Study of architecture of Digital Signal Processor

    9. MAC operation using various addressing modes

    10. Linear Convolution

    11. Circular Convolution

    12. FFT Implementation

    13. Waveform generation

    14. IIR and FIR Implementation

    15. Finite Word Length Effect

    TOTAL: 45 PERIODS

    OUTCOMES: Students will be able to Carry out simulation of DSP systems

    Demonstrate their abilities towards DSP processor based implementation of DSP systems

    Analyze Finite word length effect on DSP systems

    Demonstrate the applications of FFT to DSP

    Implement adaptive filters for various applications of DSP

    LAB EQUIPMENT FOR A BATCH OF 30 STUDENTS (2 STUDENTS PER

    SYSTEM) PCs with Fixed / Floating point DSP Processors (Kit / Add-on Cards) 15 Units

    LIST OF SOFTWARE REQUIRED: MATLAB with Simulink and Signal Processing

    Tool Box or Equivalent Software in desktop systems -15 Nos Signal Generators (1MHz)

    15 Nos CRO (20MHz) -15 Nos

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 3

    INDEX

    S.No

    Date

    Name Of The Experiment

    Page

    No

    Staff

    Sign

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 4

    INDEX

    S.No

    Date

    Name Of The Experiment

    Page

    No

    Staff

    Sign

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 5

    INTRODUCTION TO DIGITAL SIGNAL PROCESSING (DSP)

    Why go digital?

    Digital signal processing techniques are now so powerful that sometimes it is extremely difficult, if

    not impossible, for analogue signal processing to achieve similar performance.

    Examples:

    FIR filter with linear phase.

    Adaptive filters.

    Analogue signal processing is achieved by using analogue components such as:

    Resistors.

    Capacitors.

    Inductors.

    The inherent tolerances associated with these components, temperature, voltage changes and

    mechanical vibrations can dramatically affect the effectiveness of the analogue circuitry.

    With DSP it is easy to:

    Change applications.

    Correct applications.

    Update applications.

    Additionally DSP reduces:

    Noise susceptibility.

    Chip count.

    Development time.

    Cost.

    Power consumption.

    Why NOT go digital?

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 6

    High frequency signals cannot be processed digitally because of two reasons:

    Analog to Digital Converters, ADC cannot work fast enough.

    The application can be too complex to be performed in real-time.

    Real-time processing

    DSP processors have to perform tasks in real-time, so how do we define real-time?

    The definition of real-time depends on the application.

    Example: a 100-tap FIR filter is performed in real-time if the DSP can perform and complete the following

    operation between two samples

    99

    0k

    knxkany

    Real-time processing

    We can say that we have a real-time application if:

    Waiting Time 0

    Why do we need DSP processors?

    Why not use a General Purpose Processor (GPP) such as a Pentium instead of a DSP processor?

    What is the power consumption of a Pentium and a DSP processor?

    What is the cost of a Pentium and a DSP processor?

    Why do we need DSP processors?

    Use a DSP processor when the following are required:

    Cost saving.

    Smaller size.

    Low power consumption.

    Processing of many high frequency signals in real-time.

    Use a GPP processor when the following are required:

    Large memory.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 7

    Advanced operating systems.

    What are the typical DSP algorithms?

    The Sum of Products (SOP) is the key element in most DSP algorithms:

    Algorithm Equation

    Finite Impulse Response Filter

    M

    k

    k knxany

    0

    )()(

    Infinite Impulse Response Filter

    N

    k

    k

    M

    k

    k knybknxany

    10

    )()()(

    Convolution

    N

    k

    knhkxny

    0

    )()()(

    Discrete Fourier Transform

    1

    0

    ])/2(exp[)()(

    N

    n

    nkNjnxkX

    Discrete Cosine Transform

    1

    0

    122

    cos).().(

    N

    x

    xuN

    xfucuF

    Hardware vs. Microcode multiplication

    DSP processors are optimised to perform multiplication and addition operations.

    Multiplication and addition are done in hardware and in one cycle.

    Example: 4-bit multiply (unsigned).

    Hardware Microcode

    General Purpose DSP vs. DSP in ASIC

    Application Specific Integrated Circuits (ASICs) are semiconductors designed for dedicated functions.

    The advantages and disadvantages of using ASICs are listed below:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 8

    Advantages

    High throughput Lower silicon area Lower power consumption Improved reliability Reduction in system noise Low overall system cost Disadvantages High investment cost Less flexibility Long time from design to market

    Useful Links

    Selection Guide: \Links\DSP Selection Guide.pdf

    Analog versus digital signal processing

    The signal processing operations involved in many applications like commu- nication systems, control systems, instrumentation, biomedical signal pro- cessing etc can be implemented in two di erent ways (1) Analog or continuous time method and (2) Digital or discrete time method. The analog approach to signal processing was dominant for many years. The analog signal processing uses analog circuit elements such as resistors, ca-pacitors, transistors, diodes etc. With the advent of digital computer and later microprocessor, the digital signal processing has become dominant now a days. The analog signal processing is based on natural ability of the analog system to solve di erential equations the describe a physical system. The solution are obtained in real time. In contrast digital signal processing relies on nu-merical calculations. The method may or may not give results in real time.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 9

    The digital approach has two main advantages over analog approach (1) Flexibility: Same hardware can be used to do various kind of signal processing operation,while in the core of analog signal processing one has to design a system for each kind of operation. (2) Repeatability: The same signal processing operation can be repeated again and again giving same results, while in analog systems there may be parameter variation due to change in temperature or supply voltage. The choice between analog or digital signal processing depends on application. One has to compare design time,size and cost of the implementation.

    The applications of the digital signal processing will include the following main applications.

    1. General Purpose applications

    waveform generation

    Convolution and correlation

    Digital filtering

    Adaptive filtering

    FFTs and fast cosine transform 2. Audio applications

    Audio watermarking

    Coding and decoding

    Effects generator

    Surround sound processing

    Three dimensional audio 3. Communications:

    Communication security

    Detection

    Encoding and Decoding

    Software radios

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 10

    Pioneer in signal Processing: Albert Michelson

    Albert Michelson (of Michelson-Morley fame) was an intense,practical

    man who developed ingenious physical instruments of extraordinary precision, mostly in the field of optics

    ,harmonic analyser, developed in 1898,could compute the first 80 co-efficients of the Fourier series of a

    signal x(t) specified by any graphical description.

    DO YOU KNOW?

    Examples of continuous time systems are electric networks composed of resistors, capacitors,and

    inductors that are driven by continuous time sources.

    S.No Name of DSP chip Manufacturer Chip Series

    1 Analog Devices ADSP-21XX series

    2 Texas instruments,USA TMS-320XXX series

    3 Motorola Corporation,USA M-56XXX series

    HISTORICAL SURVEY OF DIGITAL SIGNAL PROCESSING(DSP)

    S.No Technique of DSP Scientist Year

    1 Term Z-transform Jury 1964

    2 Term Fast Fourier Transform(FFT) Cooley-Tukey 1965

    3 Decimation in Time (DIT)FFT

    algorithms

    Cooley-Tukey 1965

    4 Decimation in Frequency (DIF)FFT

    algorithms

    Gentleman and sande 1966

    5 Term Digital filter Kuo and Kaiser 1967

    6 Term Digital signal Processing Gold and Rader 1968

    7 Hardware implementation of Digital filter Schubler and staff 1973

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 11

    8 First applications of DSP for

    implementations of data modems

    From 1975

    9 First 16x16-bit parallel multiplier,signal

    processor

    From 1980 till Today

    10 Digital processing of speech and audio

    signals,speech coding, speech

    identification Compact Disc (CD), Digital

    Video Disc( DVD), digital recording

    studios.

    Fully digital transmission standards:

    GSM,UMTS etc.,

    Dsp applications in nearly every field.

    For Reference:-

    http://www.vlab.co.in/

    Objectives of the Virtual Labs:

    To provide remote-access to Labs in various disciplines of Science and Engineering. These

    Virtual Labs would cater to students at the undergraduate level, post graduate level as well as to

    research scholars.

    To enthuse students to conduct experiments by arousing their curiosity. This would help them in

    learning basic and advanced concepts through remote experimentation.

    To provide a complete Learning Management System around the Virtual Labs where the students

    can avail the various tools for learning, including additional web-resources, video-lectures,

    animated demonstrations and self evaluation.

    To share costly equipment and resources, which are otherwise available to limited number of

    users due to constraints on time and geographical distances

    For Quick Link:- Please visit

    http://www.digital.iitkgp.ernet.in/dsp/

    The content of this website aims to provide a virtual laboratory platform for undergraduate

    Engineering students studying the course of Digital Signal Processing.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 12

    L-shaped membrane logo

    MATLAB R2013a running on 7

    Developer(s) MathWorks

    Initial release 1984; 30 years ago

    Stable release R2014a / March 6, 2014; 4 months ago

    Preview release None []

    Development status Active

    Written in C, C++, Java, MATLAB

    Operating system Cross-platform: Microsoft Windows,Linux,

    and Mac OS X

    Platform IA-32, x86-64

    Type Technical computing

    License Proprietary commercial software

    Website MATLAB product page

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 13

    EX:NO: 1 STUDY OF MATLAB R2013 a

    DATE:

    AIM:

    To study about MATLAB R2013a

    MATLAB:

    MATLAB is a high performance language for technical computing. It integrates computation,

    visualization and programming in an easy to use environment where problems and solutions are expressed

    in familiar mathematical notations.

    The name MATLAB stands for MATRIX LABORATORY. Today, MATLAB engines incorporate the

    LAPACK and BLAS Libraries, embedding the state of the art in software for matrix computation.

    USES:

    Typical uses include,

    Math and computation

    Algorithm development

    Data acquisition

    Modeling, simulation and prototyping

    Data analysis, exploration and visualization

    Scientific and engineering graphics

    Application development, including graphical user interface building.

    THE MATLAB SYSTEM :

    The MATLAB system consists of 5 main parts:

    DESKTOP TOOLS & DEVELOPMENT ENVIRONMENT:

    This is the set of tools and facilities that help you use MATLAB functions and files. Many of these

    tools are graphical user interface.

    THE MATLAB MATHEMATICAL FUNCTION LIBRARY:

    This is a vast collection of computational algorithms ranging from elementary functions like sum,

    sine, cosine & complex arithmetic to more sophisticated functions like matrix inverse, matrix reign values,

    Bessel functions and FFT.

    THE MATLAB LANGUAGE:

    This is a high level matrix / array language with control flow statement, functions, data structures, i/p, o/p

    and object oriented programming features.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 14

    GRAPHICS:

    MATLAB has extensive facilities for displaying vectors and matrices as groups as well as annotating and

    printing these graphs.

    THE MATLAB external interface / API :

    This is a library to write C & Fortran programs that interact with MATLAB. It includes facilities for

    calling routines from MATLAB.

    MATRICES AND ARRAYS :

    Matrices and Magic squares

    Expressions

    Controlling the command window

    EXPRESSIONS :

    The building blocks of expressions are

    Variables

    Numbers

    Operators

    Functions

    VARIABLES :

    MATLAB does not require any type of declarations or dimensions when it encounters a new variable

    name. It automatically creates the variable and allocates appropriate memory.

    Example : num_stud = 25

    NUMBERS :

    MATLAB uses conventional decimal notation, with an optional decimal point. It uses E to specify a

    power of ten. Imaginary nos used either i or j as a suffix.

    Example : 3, -99, 1i, 3e5i

    OPERATORS :

    + : add

    - : subtract

    * : multiply

    / : division

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 15

    \ : left division

    ^ : Power

    : complex conjugate transpose

    FUNCTIONS :

    MATLAB provides a large no.of standard functions including abs, sqrt, exp and stn.

    SYNTAX: abs : y = abs(x)

    b = sqrt(x)

    y = exp(x)

    c = sin(A)

    TOOL BOXES :

    There are a no.of tool boxes available in MATLAB some of them are:

    Communication toolbox

    Control system toolbox

    Data acquisition toolbox

    Data base toolbox

    Data Feed toolbox

    Filter design toolbox

    Fuzzy logic toolbox

    Signal processing toolbox

    Image processing toolbox

    OPC tool box

    Wavelet toolbox

    RF toolbox

    COMMUNICATION TOOLBOX:

    The communication toolbox extends the MATLAB technical computing environment with functions, plot

    as a graphical user interface.

    The toolbox helps you to create algorithms for commercial and defense wireless s/ms.

    FUNCTIONS :

    Signal Sources: Sources of random signals Performance evaluation : analysing and visualizing

    performances of a communication s/m.

    Source coding :quantization, companders and other kind of source coding.

    Error control coding : Block and convolution coding.

    Interleaving / De interleaving:Block and convolution interleaving.

    Special filters: raised cosine and Hilbert fitters

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 16

    GUI: Bit error rate analysis tool.

    FILTER DESIGN TOOLBOX:

    The filter design toolbox is a collection of tools that provides advanced techniques for designing simulation

    and analysing digital filters.

    SIGNAL PROCESSING TOOLBOX:

    The signal processing toolbox is a collection of tools built on the MATLAB numeric computing

    environment. The toolbox supports a wide range of signal processing operations from wave generation to

    filter design and implementation.

    COMMAND LINE FUNCTIONS:

    analog and digital filters analysis

    digital filter implementation

    FIR & IIR digital filter design

    Analog filter design

    cepstral analysis

    MATLAB COMMANDS:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 17

    IMAGE PROCESSING TOOLBOX:

    The image processing toolbox is a collection of functions that extend the capability of MATLAB numeric

    computing environment. The toolbox supports a wide range of image processing operations including.

    Spatial image transformations

    Morphological operations

    Transforms

    Deblurring

    Image registration

    SIMULINK :

    Simulink is a software package for modeling, simulating and analysing dynamic systems. It supports linear

    and non-linear s/ms, modeled in continuous time, sampled time, or a hybrid of the two systems may also

    have different parts that are sampled at different rates (multirated).

    RESULT:

    Thus the MATLAB and MATLAB tools were studied.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 18

    PROGRAM

    % program to generate unit step sequence

    n = -10:10;

    s = [zeros(1,10) 1 ones(1,10)];

    stem (n,s);

    title ('unit step sequence');

    xlabel ('time index n');

    ylabel ('amplitude');

    OUTPUT:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 19

    EX.NO: 2 GENERATION OF SIGNALS USING MATLAB

    DATE:

    AIM

    To write a MATLAB program to generate the following standard input signals and plot the response.

    1. Unit step,

    2. Unit impulse,

    3. Unit ramp,

    4. Exponential signal

    5. Sinusoidal signal,

    6. Cos signal

    7. Triangular wave,

    8. Saw tooth wave

    APPARATUS REQUIRED

    SOFTWARE : MATLAB 7.10 (OR) High version

    UNIT STEP SEQUENCE

    The unit step sequence is a signal that is zero everywhere except at n >= 0 where its value is unity.

    In otherwise integral of the impulse function is also a singularity function and is called the unit step

    function.

    MATHEMATICAL EQUATION

    u(n) = 1 for n >= 0

    = 0 for n < 0

    ALGORITHM

    1. Start the program

    2. Get the dimension of n

    3. Discrete output is obtained for n>= 0 and zeros for all other values.

    4. Output is generated in stem format

    5. Terminate the process

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 20

    PROGRAM

    UNIT IMPLULSE SEQUENCE

    %program to generate impulse sequence

    n = -20:20;

    s = [zeros(1,20) 1 zeros(1,20)];

    stem (n, s);

    title ('unit impulse sequence');

    xlabel ('time');

    ylabel ('amplitude');

    OUTPUT

    PROGRAM

    %program to generate unit ramp sequence

    n =0:10;

    s =n;

    stem (n,s);

    title ('unit ramp sequence');

    xlabel ('time index');

    ylabel ('amplitude');

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 21

    The unit impulse (sample) sequence is a signal that is zero everywhere except at n=0 where it is

    unity. This signal sometime is referred to as the unit impulse.

    MATHEMATICAL EQUATION

    (n) = 1 for n = 0

    = 0 for n 0

    ALGORITHM

    1. Start the program

    2. Get the dimension of n

    3. Discrete output is obtained for n = 0 and zeros for all other values.

    4. Output is generated in stem format

    5. Terminate the process.

    UNIT RAMP SEQUENCE

    This unit ramp sequence is signal that grows linearly when n>=0, otherwise it is zero.

    MATHEMATICAL EQUATION

    Ur (n) = n for n >= 0

    = 0 for n< 0

    ALGORITHM

    1. Start the program

    2. Get the dimension of n

    3. Discrete output is obtained for n>=0 and zeros for all other values

    4. Output is generated in stem format

    5. Terminate the process

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 22

    PROGRAM

    %program to generate exponential sequence

    clf;

    n=0:10;

    s=exp(0.3*n);

    figure(1);

    stem(n,s);

    grid;

    title('Exponential sequence');

    xlabel('time');

    ylabel('amplitude');

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 23

    EXPONENTIAL SEQUENCE

    When the values of a>1, the sequence grows exponentially and when the value is 0

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 24

    PROGRAM

    %program to generate sine sequence

    clear all;

    Fin = 1000;

    Fsamp = 900000;

    Tsamp = 1 / Fsamp;

    Nsamp = Fsamp/ Fin;

    N = 0:5 * Nsamp-1;

    x=sin(2*pi*Fin*Tsamp*N);

    plot(x);

    title ('Sine Wave');

    xlabel('Time -- >);

    ylabel('Amplitude-- >');

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 25

    ALGORITHM

    1. Initialize input Frequency and sampling frequency, these frequencies are very important to

    generate the sine waveform. Input frequency is declared as Fin (this is generating frequency

    range in Hertz), Sampling frequency is declared as Fsamp. Sampling frequency must be twice

    of the input frequency.

    2. Find Sampling Time using sampling Frequency (T = 1 / F), Tsamp = 1 / Fsamp

    3. Find No of cycle to generate the output, it depends on the Number of samples per cycle

    (Nsamp). It is calculated by using Fsamp & Fin, (Nsamp = Fsamp / Fin).

    4. Generate single cycle output, use N value from 0 to Nsamp 1. Then generate multiple output

    cycle using N values from 0 to no of cycle * Nsamp 1(no of cycle = 2, 3.etc)

    5. Apply the values into a general formula.

    6. Next , plot the output waveform into graph window, using plot function for continuous output

    and use stem function for discrete output. To plot more than one figure in single graph window

    subplot function is used. Syntax of subplot is

    i. subplot(a, b, c)

    Where, a = Row, b = Column, c = no of fig

    7. Use the title function to give the name to the waveform.

    8. Use xlabel and ylabel to find the unit for x and y axis.

    COSINE SEQUENCE

    The cosine function output is calculate by the following equation

    General equation Fn = cos(2 * pi * f * t)

    The modified cos wave equation is

    X(t) = cos (2 * pi * Fin * Tsamp * t)

    Where, Fin = Input Frequency in Hertz,

    Tsamp(Sampling Time) = 1 / Fsamp,

    Nsamp = Fsamp / Fin

    t = No of Samples vary from 0 to Nsamp-1(It is generate single wave. Increase wave means to multiply that

    no into Nsamp. Ex generate two cycles means multiply 2 into Nsamp.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 26

    PROGRAM

    %program to generate cosine sequence

    clear all;

    Fin = 1000;

    Fsamp = 900000;

    Tsamp = 1 / Fsamp;

    Nsamp = Fsamp/ Fin;

    N = 0:Nsamp-1;

    x=cos((2*pi*Fin*Tsamp)*N);

    plot(x);

    title('cosine Wave');

    xlabel('Time -- >);

    ylabel('Amplitude-- >');

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 27

    MATHEMATICAL EQUATION

    X(n) = A cos (2 * pi * f * t)

    Where f frequency in Hz, A - Amplitude

    ALGORITHM

    1. Initialize input Frequency and sampling frequency, these frequencies are very important to

    generate the cosine waveform. Input frequency is declared as Fin (this is generating frequency

    range in Hertz), Sampling frequency is declared as Fsamp. Sampling frequency must be twice

    that of the input frequency.

    2. Find Sampling time using sampling frequency (T = 1 / F), Tsamp = 1 / Fsamp

    3. Find number of cycles to generate the output, it depends on Number of sample per cycle

    (Nsamp) and is calculated by using Fsamp & Fin, (Nsamp = Fsamp / Fin).

    4. Generate single output cycle which uses N value from 0 to Nsamp 1. Then generate multiple

    output cycle which uses N value from 0 to no of cycle * Nsamp 1(no of cycle = 2, 3.etc)

    5. Apply the values into general formula.

    6. Plot the output waveform into graph window, use the plot function which uses continuous

    output for analog and use the stem function for discrete output. To plot more than one figure in

    single graph window subplot function is used. Syntax of subplot is

    i. subplot(a, b, c)

    Where, a = Row, b = Column, c = quadrant

    7. The title function used to give the name to the waveform.

    8. Then xlabel & ylabel is used to find the unit for x & y axis.

    TRIANGULAR WAVE

    The triangular function output is calculate by the following equation

    General equation Fn = sawtooth ((2 * pi * f * t),0.5)

    The modified Triangular wave equation is

    X(t) = sawtooth((2 * pi * Fin * Tsamp),0.5)

    Where, Fin = Input Frequency in Hertz,

    Tsamp(Sampling Time) = 1 / Fsamp,

    Nsamp = Fsamp / Fin

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 28

    PROGRAM

    % Triangular wave

    clear all;

    Fin = 1000;

    Fsamp = 900000;

    Nsamp = Fsamp / Fin;

    Tsamp = 1 / Fsamp;

    n = 0: 2* Nsamp-1;

    x=sawtooth(2 * pi * Fin * Tsamp * n,0.5);

    plot(x);

    title('Triangular Wave');

    xlabel('Time - >');

    ylabel('Amplitude- - >');

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 29

    t = No of Samples vary from 0 to Nsamp-1(It is generate single wave. Increase wave means to

    multiply that no into Nsamp. Ex generate two cycles means multiply 2 into Nsamp. The 0.5 value is

    used for triangular wave sapping value.

    ALGORITHM

    1. Initialize input Frequency and sampling frequency, these frequencies are very important to

    generate the Triangular waveform. Input frequency is declared as Fin (this is generating

    frequency range in Hertz), Sampling frequency is declared as Fsamp. Sampling frequency must

    be twice of the input frequency.

    2. Find Sampling time using sampling frequency (T = 1 / F), Tsamp = 1 / Fsamp

    3. Find number of cycles to generate the output, it depends on Number of sample per cycle

    (Nsamp) and calculated by using Fsamp & Fin, (Nsamp = Fsamp / Fin).

    4. Generate single output cycle which uses N value from 0 to Nsamp 1. Then generate multiple

    output cycle which uses N value from 0 to no of cycle * Nsamp 1(no of cycle = 2, 3.etc)

    5. Apply the values into general formula.

    6. Plot the output waveform into graph window, use the plot function which uses continuous

    output for analog and use the stem function for discrete output. To plot more than one figure in

    single graph window subplot function is used. Syntax of subplot is

    i. subplot(a, b, c)

    Where, a = Row, b = Column, c = quadrant

    7. The title function used to give the name to the waveform.

    8. Then xlabel & ylabel is used to find the unit for x & y axis.

    SAWTOOTH WAVE

    The sawtooth function output is calculate by the following equation

    General equation Fn = sawtooth (2 * pi * f * t)

    The modified sawtooth wave equation is

    X(t) = sawtooth (2 * pi * Fin * Tsamp)

    Where, Fin = Input Frequency in Hertz,

    Tsamp (Sampling Time) = 1 / Fsamp,

    Nsamp = Fsamp / Fin

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 30

    PROGRAM

    % sawtooth sequence

    clear all;

    Fin = 1000;

    Fsamp = 900000;

    Nsamp = Fsamp / Fin;

    Tsamp = 1 / Fsamp;

    n = 0: 3 * Nsamp-1;

    x=sawtooth(2 * pi * Fin * Tsamp * n);

    plot(x);

    title('SawTooth Wave');

    xlabel('Time- - >);

    ylabel('Amplitude- - >);

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 31

    t = No of Samples vary from 0 to Nsamp-1(It is generate single wave. Increase wave means to

    multiply that no into Nsamp. Ex generate two cycles means multiply 2 into Nsamp. The 0.5 value is

    used for triangular wave sapping value.

    ALGORITHM

    1. Initialize input Frequency and sampling frequency, these frequencies are very important to

    generate the sawtooth waveform. Input frequency is declared as Fin (this is generating

    frequency range in Hertz), Sampling frequency is declared as Fsamp. Sampling frequency

    must be twice that of the input frequency.

    2. Find Sampling time using sampling frequency (T = 1 / F), Tsamp = 1 / Fsamp

    3. Find number of cycles to generate the output, it depends on Number of sample per cycle

    (Nsamp) and is calculated by using Fsamp & Fin, (Nsamp = Fsamp / Fin).

    4. To generate single output cycle which use N value from 0 to Nsamp 1. Then generate

    multiple output cycle which use N value from 0 to no of cycle * Nsamp 1(no of cycle = 2,

    3.etc)

    5. Apply the values into general formula.

    6. Plot the output waveform into graph window, use the plot function which uses continuous

    output for analog and use the stem function for discrete output. To plot more than one figure

    in single graph window subplot function is used. Syntax of subplot is

    ii. subplot(a, b, c)

    Where, a = Row, b = Column, c = quadrant

    7. The title function used to give the name to the waveform.

    8. Then xlabel & ylabel is used to find the unit for x & y axis.

    RESULT

    Thus the MATLAB programs for unit step, unit impulse, unit ramp, sinusoidal signal sawtooth ,

    Triangular wave ,exponential signals were generated and their responses were plotted in discrete and

    continuous time domain successfully.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 32

    Viva voce:

    1. What is signal.

    2. Classify the signals.

    3. What is an Energy and power signal?

    4. What is the formula for energy and power?

    5. what is continuous time and discrete time signal.

    6. What is analog and digital signal?

    7. What is even and odd signal?

    8. What is multi channel and multidimensional signal?

    9. What is energy of unit sample function?

    10. what is unit step function.

    11. How unit step and impulse function are related?

    12. What is the condition for periodicity of DT signal?

    13. What is deterministic and random signal.

    14. what is causal and non causal signal.

    15. what is unit impulse and unit ramp signal.

    16. what is cos and sine signal.

    17. what is sinc and saw tooth function.

    18. what is Exponential signal.

    19. What is Elementary signal?

    20. What is BIBO stable system?

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 33

    EX.NO: 3 (a) GENERATION OF CONVOLUTION AND CORRELATION USING MATLAB

    DATE:

    Aim : To develop program for discrete convolution and correlation.

    Apparatus : PC having MATLAB software.

    Procedure

    1. OPEN MATLAB

    2. File New Script.

    a. Type the program in untitled window

    3. File Save type filename.m in matlab workspace path

    4. Debug Run. Wave will displayed at Figure dialog box.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 34

    Program :

    % program for discrete convolution

    % of x= [1 2] and h = [1 2 4]

    clc;clear all;close all;

    x = input('Enter the 1st sequence : '); %[1 2]

    h = input('Enter the 2nd sequence : '); %[1 2 4]

    y =conv(x,h);

    subplot(2,3,1);stem(x);

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

    xlabel('(a)n ------>');

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

    ylabel('(h) ------>');

    xlabel('(b)n ------>');

    title('Discrete Convolution');

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

    ylabel('(y) ------>');

    xlabel('(c)n ------>');

    disp(' The resultant Signal is :');y

    % program for discrete correlation

    % of h =[4 3 2 1]

    x1 = input('Enter the 1st sequence : '); %[1 2 3 4]

    h1 = input('Enter the 2nd sequence : '); %[4 3 2 1]

    y1 =xcorr(x1,h1);

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 35

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 36

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

    ylabel('(x1) ------>');

    xlabel('(d)n ------>');

    subplot(2,3,5);stem(h1);

    ylabel('(h1) ------>');

    xlabel('(e)n ------>');

    title('Discrete Correlation');

    subplot(2,3,6);stem(y1);

    ylabel('(y1) ------>');

    xlabel('(f)n ------>');

    disp(' The resultant Signal is :');y1

    Output :

    Convolution :

    Enter the 1st sequence : [1 2]

    Enter the 2nd sequence : [1 2 4]

    The resultant Signal is : y = 1 4 8 8

    Correlation :

    Enter the 1st sequence : [1 2 3 4]

    Enter the 2nd sequence : [4 3 2 1]

    The resultant Signal is : y1 = 1.0000 4.0000 10.0000 20.0000 25.0000 24.0000

    16.0000

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 37

    Graph:

    1 1.5 20

    0.5

    1

    1.5

    2(x

    ) ------>

    (a)n ------>

    1 2 30

    1

    2

    3

    4

    (h) ------>

    (b)n ------>

    Discrete Convolution

    0 2 40

    2

    4

    6

    8

    (y) ------>

    (c)n ------>

    0 2 40

    1

    2

    3

    4

    (x1)

    ------>

    (d)n ------>

    0 2 40

    1

    2

    3

    4(h

    1) ------>

    (e)n ------>

    Discrete Correlation

    0 5 100

    10

    20

    30

    (y1)

    ------>

    (f)n ------>

    RESULT

    Thus the MATLAB programs for discrete convolution and correlation were plotted in discrete time

    domain successfully.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 38

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 39

    EX.NO: 3(b) LINEAR & CIRCULAR CONVOLUTION

    DATE:

    AIM

    To write a MATLAB program to obtain the linear & circular convolution between two finite duration

    sequences x(n) and h(n).

    THEORY

    Convolution is a powerful way of characterizing the input-output relationship of time invariant linear

    systems. Convolution finds its application in processing signals especially analyzing the output of the

    system.

    The response or output y(n) of a LTI system for any arbitrary input is given by convolution of input and the

    impulse response h(n) of the system.

    y n x k h n kk

    ( ) [ ( ) ( ]

    (1)

    If the input has L samples and the impulse response h(n) has M samples then the output sequence y(n)

    will be a finite duration sequence consisting of L+ M-1 samples. The convolution results in a non-periodic

    sequence. Hence this convolution is also called a periodic convolution.

    The convolution relation of equation (1) can also be expressed as

    y(n) = x(n) *h(n) = h(n) * x(n)

    where the symbol * indicates convolution operation.

    ALGORITHM

    1. Initialize the two input sequences.

    2. Find the length of first and second input sequences use the following syntax

    length (x ).

    Where, x input sequence

    3. Find out the linear convolution output length using first sequence length and Second sequence

    length (N = x+h-1).

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 40

    PROGRAM

    %program to find linear convolution of two finite duration sequences

    clear all;

    Xn = [1,2,1,1];

    Hn = [1,1,1];

    x=length(Xn);

    h = length(Hn);

    N = x + h - 1;

    Yn = conv(Xn,Hn);

    subplot(2,2,1);

    stem(Xn);

    title('First Input Sequence');

    xlabel('Length of First Input Sequence');

    ylabel('Input Value');

    subplot(2,2,2);

    stem(Hn);

    title('Second Input Sequence');

    xlabel('Length of Second Input Sequence');

    ylabel('Input Value');

    subplot(2,2,3);

    stem(Yn);

    title('Linear Convolution Output Sequence');

    xlabel('Length of Output Sequence');

    ylabel('Output Value');

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 41

    4. Find Linear convolution of two input sequence using the conv(x,h) command. The conv

    perform linear convolution operation.

    Where, x First input sequence

    h Second input sequence

    5. Use the subplot & stem function to display the input & output in a single graph window. Else

    use figure( ) function to display the input &output in separate window.

    i. subplot(a, b, c)

    Where, a = Row, b = Column, c = quadrant

    6. The title function is used to give the name to the waveform.

    7. The xlabel & ylabel is used to find the unit for x & y axis.

    What is the need for convolution in digital signal processing?

    If we need to add two signals in time domain, we perform convolution. A better way, is to convert the

    two signals from time domain to frequency domain. This can be achieved by FAST FOURIER

    TRANFORM. Once both the signals have been converted to frequency domain, they can simply be

    multiplied. Since Convolution in time domain is similar to multiplying in Frequency domain. Once both

    the signals have been multiplied, they can be converted back to time domain by Inverse Fourier Transform

    method. Thus achieving accurate results.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 42

    INPUT & OUTPUT

    Enter the input sequence x(n) = [1,2,1,1]

    Enter the input sequence h(n) = [1,1,1]

    Convoluted output y(n) = 1, 3, 4, 4, 2, 1

    PROGRAM

    CIRCULAR CONVOLUTION

    clear all;

    Xn = [1,2,1,1];

    Hn = [1,1,1];

    x=length(Xn);

    h = length(Hn);

    N = max(x,h);

    Yn = cconv(Xn,Hn,N);

    subplot(2,2,1);

    stem(Xn);

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 43

    title('First Input Sequence');

    xlabel('Length of First Input Sequence');

    ALGORITHM

    1. Initialize the two input sequences.

    2. Find the length of first and second input sequences use the following syntax

    length (X ).

    Where, x input sequence

    3. Find out the circular convolution output length using First sequence length and Second

    sequence length (N = max(x,h)).

    4. Find circular convolution of two input sequence using the cconv function. The cconv

    perform circular convolution operation.

    5. Use the subplot & stem function to display the input & output in a single graph window. Else

    use figure( ) function to display the input &output in separate window.

    i. subplot(a, b, c)

    where, a = Row, b = Column, c = quadrant

    6. The title function is used to give the name to the waveform.

    7. The xlabel & ylabel is used to find the unit for x & y axis.

    Viva voce:

    1. What is meant by convolution?

    2. What are the types of convolution?

    3. What is linear convolution?

    4. What are the steps involved in the linear convolution.

    5. What are the methods to obtain in the linear convolution?

    6. What is need for linear convolution?

    7. What are the properties of convolution?

    8. What is circular convolution?

    9. What are the methods involved in the circular convolution?

    10. What is deconvolution?

    11. What is need for circular convolution?

    12. What is graphical method of linear convolution?

    13. Compare linear and circular convolution.

    14. What is the advantages & disadvantages of linear convolution?

    15. What is the advantages & disadvantages of circular convolution?

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 44

    subplot(2,2,2);

    stem(Hn);

    title('Second Input Sequence');

    xlabel('Length of Second Input Sequence');

    ylabel('Input Value');

    subplot(2,2,3);

    stem(Yn);

    title('Circular Convolution Output Sequence');

    xlabel('Length of Output Sequence');

    ylabel('Output Value');

    INPUT & OUTPUT

    Enter the input sequence x(n) = [1,2,1,1]

    Enter the input sequence h(n) = [1,1,1]

    Convoluted output y(n) = 3, 4, 4, 4

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 45

    RESULT

    Thus the MATLAB programs for linear and circular convolution signals were generated and their

    responses were plotted in discrete time domain successfully.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 46

    Program :

    DFT :

    %prog for computing discrete Fourier Transform

    clc;clear all;close all;

    x =input('Enter the sequence '); %x =[0 1 2 3 4 5 6 7]

    n = input('Enter the length of Fourier Transform ') %n =8 has to be same as

    %the length of sequence

    x =fft(x,n);

    stem(x);

    ylabel('imaginary axis------>');

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

    title('Exponential sequence');

    disp('DFT is');x

    IDFT :

    % prog for inverse discrete Fourier Transform (IDFT)

    clc;clear all;close all;

    x =input('Enter length of DFT '); % for best results in power of 2

    t = 0:pi/x:pi;

    num =[0.05 0.033 0.008];

    den =[0.06 4 1];

    trans = tf(num,den);

    [freq,w] =freqz(num,den,x); grid on;

    subplot(2,1,1);plot(abs(freq),'k');

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 47

    EX.NO: 4 DFT & IDFT

    DATE:

    Aim : To develop program for computing discrete Fourier Transform (DFT) and inverse discrete Fourier

    Transform (IDFT).

    Apparatus : PC having MATLAB software.

    Procedure

    1. OPEN MATLAB

    2. File New Script.

    a. Type the program in untitled window

    3. File Save type filename.m in matlab workspace path

    4. Debug Run. Wave will displayed at Figure dialog box.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 48

    disp(abs(freq));

    ylabel('Magnitude');

    xlabel('Frequency index');

    title('Magnitude Response');

    Output :

    DFT :

    Enter the sequence [0 1 2 3 4 5 6 7]

    Enter the length of Fourier Transform 8

    n = 8

    DFT is x = 28.0000 -4.0000 + 9.6569i -4.0000 + 4.0000i -4.0000 + 1.6569i

    -4.0000 -4.0000 - 1.6569i -4.0000 - 4.0000i -4.0000 - 9.6569i

    IDFT :

    Enter length of DFT 4 = 0.0180

    0.0166

    0.0130

    0.0093

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 49

    Graph:

    DFT :

    1 2 3 4 5 6 7 8-10

    -8

    -6

    -4

    -2

    0

    2

    4

    6

    8

    10

    Imag

    inar

    y ax

    is---

    --->

    Real axis------>

    Discrete Fourier Transform

    IDFT :

    1 1.5 2 2.5 3 3.5 40.005

    0.01

    0.015

    0.02

    Mag

    nitu

    de

    Frequency index

    Magnitude Response

    RESULT

    Thus the MATLAB programs for DFT/IDFT done successfully.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 50

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 51

    EX.NO: 5 SAMPLING & EFFECT OF ALIASING

    DATE:

    This experiment enables a student to learn

    How to view the real life analog signal with an oscilloscope.

    How to set the amplitude, frequency and phase of the signal source.

    How to set the sampling frequency of the source such that the signal is exactly reconstructed from

    its samples.

    The principal objective of this experiment is to understand the principle of sampling of continuous time

    analog signal.

    AIM

    To perform sampling operation and view the aliasing effect.

    THEORY

    A key step in any digital processing of real world analog signals is converting the analog signals into

    digital form. We sample continuous data and create a discrete signal. Unfortunately, sampling can

    introduce aliasing, a nonlinear process which shifts frequencies. Aliasing is an inevitable result of both

    sampling and sample rate conversion.

    The Nyquist sampling theorem defines the minimum sampling frequency to completely represent a

    continuous signal with a discrete one. If the sampling frequency is at least twice the highest frequency in

    the continuous baseband signal, the samples can be used to exactly reconstruct the continuous signal. A

    sine wave can be described by at least two samples per cycle (consider drawing two dots on a picture of a

    single cycle, then try and draw a single cycle of a different frequency that passes through the same two

    dots). Sampling at slightly less than two samples per cycle, however, is indistinguishable from sampling a

    sine wave close to but below the original frequency. This is aliasing - the transformation of high frequency

    information into false low frequencies that were not present in the original signal. The Nyquist frequency,

    also called the folding frequency, is equal to half the sampling frequency f, and is the demarcation between

    frequencies that are correctly sampled and those that will cause aliases. Aliases will be 'folded' from the

    Nyquist frequency back into the useful frequency range.

    ALGORITHM

    1. Initialize input Frequency, sampling frequency and number of sample values (Nsamp).

    Sampling frequency must be twice the input frequency.

    2. Then two different sinusoidal signals are sampled at the same sampling frequency.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 52

    PROGRAM

    % Sampling and effect of aliasing

    Fsamp = 10000;

    Fin = 1000;

    Nsamp = 100;

    N = 0 : (Nsamp - 1);

    k = 1;

    Xa = sin(2 * pi * (Fin / Fsamp) * N);

    Xb = sin(2 * pi * (Fin + (k * Fsamp))/ Fsamp * N);

    subplot(2, 1, 1);

    plot(N, Xa);

    subplot(2, 1, 2);

    plot(N, Xb);

    OUTPUT

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 53

    3.Sample the second signal at low sampling frequency. According to sampling theorem the

    sampling frequency value is twice the input frequency. So aliasing will occur in second signal.

    4. Due to aliasing effect two signals are plotted in same wave.

    5.The difference between these two sine wave signals is Aliasing Effect.

    6. Next plot the output waveform into graph window, use the plot function which uses the

    continuous function for analog output and use the stem function for discrete output.

    7.To plot more than one figure in single graph window subplot function is used. Syntax of subplot

    is

    subplot(a, b, c)

    Where, a = Row, b = Column, c = no of fig

    8. The title function is used to give name to the wave form.

    9. Then xlabel & ylabel are used to find unit of x & y axis.

    RESULT

    Thus the sampling operation and effect aliasing is performed.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 54

    Viva voce

    1. What is sampling theorem?

    2. What is aliasing?

    3. What is Nyquist rate and Nyquist interval?

    4. What is damped and undamped system?

    5. What is the condition for aliasing effect?

    6. What is the sampling frequency?

    7. What are the methods to obtain sampling theorem?

    8. What is the need of sampling theorem?

    9. What is the need of aliasing effect?

    10. What are the advantages & disadvantages of sampling theorem?

    11. Why CT signals are represented by samples?

    12. What is meant by sampling.

    13. What is meant by aliasing.

    14. . What are the effects aliasing.

    15. How the aliasing process is eliminated.

    16. . Define Nyquist rate.and Nyquist interval.

    17. . Define sampling of band pass sig

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 55

    EX.NO: 6 DESIGN OF FIR FILTER USING MATLAB

    DATE:

    The experiment enables students to understand:

    Basics of filter designs and different types of filter designing techniques.

    Different types of window functions.

    Designing of Lowpass and highpass FIR filters using these window functions

    Designing of bandpass and bandstop FIR filters using these window functions.

    AIM

    To write a MATLAB program for the design of FIR Filter for the given cutoff frequency using windowing

    technique. Also plot the magnitude and phase responses for the same.

    THEORY

    The filters designed by using finite number of samples of impulse response are called FIR filters. These

    finite number of samples are obtained from the infinite duration desired impulse response hd(n). Here

    hd(n)is the inverse Fourier transform of Hd(), where Hd() is the ideal (desired) frequency response. The

    various methods of designing FIR filters are (i). Fourier Series method, (ii). Window method, (iii).

    Frequency Sampling method, (iv) Optimal filter design method. Here we discuss about window method

    only.

    FILTER TYPES

    1. Low Pass Filter

    2. High Pass Filter

    3. Band Pass Filter

    4. Band Reject Filter

    1. LOW PASS FILTER

    The low pass filter equation is

    HdFc n

    W n n n n nn c( ) sin( ) / / /

    2 0

    2 2

    2. HIGH PASS FILTER The High pass filter equation is

    Hd nFc n

    W n n n n nc( )

    sin( ) / / /

    1 2 0

    2 2

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 56

    PROGRAM Hamming Window

    Low Pass Filter

    clear all;

    Fcut = 1000;

    Fsamp = 7500;

    N = 60; % Order of the filter

    d=fdesign.lowpass('N,fc',N,Fcut,Fsamp);

    Hd=window(d,'window',@hamming);

    fvtool(Hd);

    Simulation Output Window

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 57

    3. BAND PASS FILTER

    The band Pass filter equation is

    Hd nFc Fc n

    Wc n Wc n n n n n( )

    ( )

    sin( ) sin( ) / / /

    2 2 1 0

    2 1 2 2

    4. BAND REJECT FILTER

    The band reject filter equation is

    Hd nFc Fc n

    Wc n Wc n n n n n( )

    ( )

    sin( ) sin( ) / / /

    2 1 2 0

    1 2 2 2

    Where, Fc = Fcut / Fsamp

    Fc1 = Fps / Fsamp

    Fc2 = Fst / Fsamp

    Wc = 2Fc

    Wc1 =2Fc1 & Wc2 =2Fc2

    DESIGN OF FIR FILTERS USING WINDOWS

    The desired frequency response Hd(ej

    ) of a filter is periodic in frequency and can be expanded in a Fourier

    series. The resultant series is given by

    H e h n edjw

    d

    jwn

    n

    ( ) ( ) ]

    ..(1)

    Where

    h n H e e ddjw jwn( ) / ( )

    1 2

    (2)

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 58

    High Pass Filter

    clear all;

    Fcut = 1000;

    Fsamp = 7500;

    N = 60; % Order of the filter

    f= fdesign.highpass(N,fc,N,Fcut,Fsamp)

    Hd=window(d,'window',@hamming);

    fvtool(Hd);

    Simulation Output Window

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 59

    And known as Fourier coefficients having infinite length. One possible way of obtaining FIR filter is to

    truncate the infinite Fourier series at n= (N-1)/2, where N is the length of the desired sequence. But

    abrupt truncation of the Fourier series results in oscillation in the pass band and stop band. These

    oscillations are due to slow convergence of the Fourier series and this effect is known as the Gibbs

    phenomenon. To reduce these oscillations, the

    Fourier coefficients of the filter are modified by multiplying the infinite impulse response with a finite

    weighing sequence (n) called a window.

    Where

    (n) = (-n) 0 for |n| (N-1)/2

    = 0 for |n| > (N-1)/2

    After multiplying window sequence w(n) with Hed(n), we get a finite duration sequence h(n) that satisfies

    the desired magnitude response,

    h(n) = hd(n)(n) for all |n| (N-1)/2

    = 0 for |n| > (N-1)/2

    The frequency response H(ej

    ) of the filter can be obtained by convolution of Hd(ej

    )) and W(ej

    ) given

    by

    H e h n edjw

    d

    jwn

    n

    ( ) ( ) ]

    (1)

    H e H e e dj dj j w( ) / ( ) ( )

    1 2

    = H(ej

    ) * W(ej

    )

    (2)

    Because both Hd(ej

    ) and W(ej

    ) are periodic function, the operation often called as periodic convolution.

    WINDOW TYPES

    Rectangular window

    Rectangular window function can be found by the following equation

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 60

    Band Pass Filter

    Fpass = 1000;

    Fstop = 2000;

    N = 60;

    f = fdesign.bandpass('N,fc1,fc2', N,Fpass, Fstop, Fsamp);

    He = window(f,'window',@hamming);

    fvtool(He);

    Simulation Output Window

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 61

    rec nfor N n N

    Otherwise( )

    ( ) / ( ) /

    1 1 2 1 2

    0

    Hamming window

    Hamming window function is calculated by the given equation

    hm nn N for N n N

    Otherwise( )

    . . cos( ) / ( ) ( ) / ( ) /

    054 0 46 2 1 1 2 1 2

    0

    Hanning window

    Hanning window function is calculated by the given equation

    hn nn N for N n N

    Otherwise( )

    . . cos( ) / ( ) ( ) / ( ) /

    05 05 2 1 1 2 1 2

    0

    Blackman window

    Blackman window function is calculated by following equation

    b n

    n N n N

    for N n N

    Otherwise

    1

    0 42 05 2 1 0 08 4 1

    1 2 1 2

    0

    ( )

    . . cos( ) / ( ) . cos( ) / ( )

    ( ) / ( ) /

    Where N = order of the filter

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 62

    Band Stop Filter

    Fpass = 1000;

    Fstop = 2000;

    N = 60;

    f = fdesign.bandpass('N,fc1,fc2', N,Fpass, Fstop, Fsamp);

    He = window(f,'window',@hamming);

    fvtool(He);

    Simulation Output Window

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 63

    ALGORITHM

    1. Initialize the cutoff frequency, sampling frequency and Order of the filter for low pass and high

    pass filter. Then specify the Pass band and stop frequency for band pass & band stop filter.

    2. Declare the five filter types (low pass, high pass, Band pass, Band Reject), with the above

    specification.

    1. Low pass = fdesign.lowpass(N,fc,N,Fcut,Fsamp)

    2. High pass = fdesign.highpass(N,fc,N,Fcut,Fsamp)

    3. Band pass = fdesign.bandpass('N,fc1,fc2', N,Fpass, Fstop, Fsamp)

    4. Band stop = fdesign.bandstop('N,fc1,fc2', N,Fpass, Fstop, Fsamp)

    3. Specify the window type to do the window function .

    i. Bartlett window - @bartlett

    ii. Blackman window - @blackman

    iii. Hamming window - @hamming

    iv. Hanning window - @hann

    v. Kaiser window - @kaiser

    vi. Rectangular window - @rectwin

    vii. Triangular window - @triang

    4. Then use the fvtool for display the filter response outputs (fvtool filter visualization tool).

    RESULT

    Thus the FIR filters were designed using various windowing techniques in MATLAB and the output has

    been verified.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 64

    Viva voce:

    1. What is FIR filter?

    2. State properties of FIR filters?

    3. Why FIR filters are inherently stable?

    4. What are the advantages of all zero filters?

    5. How linear phase is achieved in FIR filters?

    6. Which are the different FIR filter design methods?.

    7. How FIR filters is designed using windows.

    8. What is Gibbs phenomenon?.

    9. Why does Gibbs phenomenon take place.

    10. How Gibbs phenomenon can be reduced or avoided?.

    11. Check whether following filter has linear phase?. H(n)={5 3 2 3 5}

    12. What is transition band?.

    14. Why transition band is provided?

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 65

    EX.NO:7 DESIGN OF IIR FILTER USING MATLAB

    DATE:

    The experiment enables students to understand:

    Basics of IIR filter designing and its implimentation.

    Filter designing techniques like Butterworth, Chebyshev 1, Chebyshev 2, Elliptic etc.

    AIM

    To write a MATLAB program to design Butterworth & Chebychev low pass, high pass, band pass and

    band stop digital IIR filter from the given specifications.

    THEORY

    The filters designed by considering all the infinite samples of impulse response are called IIR filters. IIR

    filters are of recursive type, whereby the present output sample depends on the present input, past input

    samples and output samples.

    ALGORITHM

    1. Initialize the pass band ripple, stop band attenuation and sampling frequency.

    2. Find the filter order, it depends on filter design type.

    1. Butterworth buttord

    2. Chebychev1 cheb1ord

    3. Chebychev2 cheb2ord

    3. Specify the filter type.

    1. Butterworth butter

    2. Chebychev1 cheby1

    3. Chebychev2 cheby2

    4. Declare the five filter types (low pass, high pass, Band pass, Band Reject), with the above

    specification. It is only for butterworth filter.

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

    2. [b, a] = butter(n, wn,high);

    3. [b, a] = butter(n, wn,'passband');

    4. [b, a] = butter(n, wn,'stop');

    5. The Chebychev filter type can be declare as

    1. [b, a] = cheby1(n,rp, wn,'low')

    2. [b, a] = cheby1(n,rp, wn, high)

    3. [b, a] = cheby1(n,rp, wn,'passband')

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 66

    PROGRAM

    %Design of Butterworth filter

    % Low Pass Filter

    rp = 3; % passband ripple

    rs = 60; % stopband attenuation

    fs = 20000; % sampling frequency

    wp = 4200 / 10000;

    ws = 5000 / 10000;

    [n, wn] = buttord(wp, ws, rp, rs);

    [b, a] = butter(n, wn,'low'); % Calculate filter coefficients

    fvtool(b, a);

    SIMULATION OUTPUT WINDOW

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 67

    4. [b, a] = cheby1(n,rp, wn,'stop')

    5. Then use fvtool for display the filter response outputs (fvtool filter

    visualization tool).

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 68

    % HIGH PASS FILTER

    rp = 3; % passband ripple

    rs = 60; % stopband attenuation

    fs = 20000; % sampling frequency

    wp = 4200 / 10000;

    ws = 5000 / 10000;

    [n, wn] = buttord(wp, ws, rp, rs);

    [b, a] = butter(n, wn, 'high'); % Calculate filter coefficients

    fvtool(b, a);

    SIMULATION OUTPUT WINDOW

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 69

    % BAND STOP FILTER

    rp = 3; % passband ripple

    rs = 60; % stopband attenuation

    fs = 20000; % sampling frequency

    [n, wn] = buttord(wp, ws, rp, rs);

    [b, a] = butter(n, wn,'stop'); % Calculate filter coefficients

    fvtool(b, a);

    SIMULATION OUTPUT WINDOW

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 70

    % BAND PASS FILTER

    rp = 3; % passband ripple

    rs = 60; % stopband attenuation

    fs = 20000; % sampling frequency

    wp = [2500 3500] / 10000;

    ws = [2000 4000] / 10000;

    [n, wn] = buttord(wp, ws, rp, rs);

    [b, a] = butter(n, wn,'bandpass'); % Calculate filter coefficients

    fvtool(b, a);

    SIMULATION OUTPUT WINDOW

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 71

    RESULT

    Thus the MATLAB programs for the design of Butterworth & Chebychev LPF, HPF, BPF and BSF were

    designed and also their magnitude responses has been plotted successfully.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 72

    Viva voce:

    1. Define IIR filter?.

    2. What are various methods to design IIR filters?

    3. What is the main problem of bilinear transformation?

    4. What is prewarping?

    5. State the frequency relationship in bilinear transformation.

    6. Where the j axis of s-plane is mapped in z-plane in bilinear transformation.

    7. Where left hand side and right-hand sides of s-plane are mapped in z-plane in bilinear transformation.

    8. What is the frequency response of butter worth filter?

    9.Which filter approximation has ripples in its response?

    10.Can IIR filter be designed without analog filters?

    11.What is the advantages of designing IIR filter using pole zero plot?.

    12.What do you mean by ideal low pass filter?

    13.Is it possible to design ideal low pass filter?

    14.What is the necessity of filter approximation?

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 73

    EX.NO: 8 (a) INTERPOLATION

    DATE:

    AIM: The objective of this program is To Perform upsampling on the Given Input Sequence.

    EQUIPMENT REQUIRED: P IV Computer

    Windows Xp SP2 MATLAB

    Procedure

    1. OPEN MATLAB

    2. File New Script.

    a. Type the program in untitled window

    3. File Save type filename.m in matlab workspace path

    4. Debug Run. Wave will displayed at Figure dialog box.

    THEORY:

    Up sampling on the Given Input Sequence and Interpolating the sequence.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 74

    PROGRAM:

    clc; clear all; close all; N=125; n=0:1:N-1; x=sin(2*pi*n/15); L=2; figure(1) stem(n,x); grid on; xlabel('No.of.Samples'); ylabel('Amplitude'); title('Original Sequence'); x1=[zeros(1,L*N)]; n1=1:1:L*N; j =1:L:L*N; x1(j)=x; figure(2) stem(n1-1,x1); grid on; xlabel('No.of.Samples'); ylabel('Amplitude'); title('Upsampled Sequence'); a=1; b=fir1(5,0.5,'Low'); y=filter(b,a,x1); figure(3) stem(n1-1,y); grid on; xlabel('No.of.Samples'); ylabel('Amplitude'); title('Interpolated Sequence');

    EXPECTED GRAPH:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 75

    Result:

    This MATLAB program has been written to perform interpolation on the Given Input sequence.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 76

    PROGRAM:

    clc; clear all;

    close all; N=250 ; n=0:1:N-1; x=sin(2*pi*n/15); M=2; figure(1) stem(n,x); grid on; xlabel('No.of.Samples'); ylabel('Amplitude'); title('Original Sequence'); a=1; b=fir1(5,0.5,'Low'); y=filter(b,a,x); figure(2) stem(n,y); grid on; xlabel('No.of.Samples'); ylabel('Amplitude'); title('Filtered Sequence'); x1=y(1:M:N); n1=1:1:N/M; figure(3) stem(n1-1,x1); grid on; xlabel('No.of.Samples'); ylabel('Amplitude'); title('Decimated Sequence');

    EXPECTED GRAPH:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 77

    EX.NO: 8 (b) DECIMATION

    DATE:

    AIM: The objective of this program is To Perform Decimation on the Given Input Sequence.

    EQUIPMENT REQUIRED: P IV Computer Windows Xp SP2 MATLAB

    Procedure

    1. OPEN MATLAB

    2. File New Script.

    a. Type the program in untitled window

    3. File Save type filename.m in matlab workspace path

    4. Debug Run. Wave will displayed at Figure dialog box.

    THEORY: Decimation on the Given Input Sequence by using filter with filter-coefficients a and b.

    Result:

    This MATLAB program has been written to perform Decimation on the Given Input Sequence.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 78

    PROGRAM clc; clear all; close all; M=3000; % number of data samples T=2000; % number of training symbols dB=25; % SNR in dB value L=20; % length for smoothing(L+1) ChL=5; % length of the channel(ChL+1) EqD=round((L+ChL)/2); %delay for equalization Ch=randn(1,ChL+1)+sqrt(-1)*randn(1,ChL+1); % complex channel Ch=Ch/norm(Ch); % scale the channel with norm TxS=round(rand(1,M))*2-1; % QPSK transmitted sequence TxS=TxS+sqrt(-1)*(round(rand(1,M))*2-1);

    x=filter(Ch,1,TxS); %channel distortion n=randn(1,M); %+sqrt(-1)*randn(1,M); %Additive white gaussian noise n=n/norm(n)*10^(-dB/20)*norm(x); % scale the noise power in accordance with SNR

    x=x+n; % received noisy signal

    K=M-L; %% Discarding several starting samples for avoiding 0's and negative X=zeros(L+1,K); % each vector column is a sample for i=1:K X(:,i)=x(i+L:-1:i).'; end %adaptive LMS Equalizer e=zeros(1,T-10); % initial error c=zeros(L+1,1); % initial condition mu=0.001; % step size for i=1:T-10

    e(i)=TxS(i+10+L-EqD)-c'*X(:,i+10); % instant error c=c+mu*conj(e(i))*X(:,i+10); % update filter or equalizer coefficient

    end sb=c'*X; % recieved symbol estimation %SER(decision part) sb1=sb/norm(c); % normalize the output sb1=sign(real(sb1))+sqrt(-1)*sign(imag(sb1)); %symbol detection start=7; sb2=sb1-TxS(start+1:start+length(sb1)); % error detection SER=length(find(sb2~=0))/length(sb2); % SER calculation disp(SER);

    % plot of transmitted symbols

    subplot(2,2,1), plot(TxS,'*'); grid,title('Input symbols'); xlabel('real part'),ylabel('imaginary part') axis([-2 2 -2 2])

    % plot of received symbols

    subplot(2,2,2), plot(x,'o'); grid, title('Received samples'); xlabel('real part'), ylabel('imaginary part')

    % plots of the equalized symbols

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 79

    EX.NO: 9 EQUALIZATION

    DATE:

    Aim : To develop program for equalization. Apparatus : PC having MATLAB software.

    Procedure:

    Equalizing a signal using Communications System Toolbox software involves these steps:

    1. Create an equalizer object that describes the equalizer class and the adaptive algorithm that you want to use. An equalizer object is a type of MATLAB variable that contains information about the equalizer, such as the name of the equalizer class, the name of the adaptive algorithm, and the values of the weights.

    2. Adjust properties of the equalizer object, if necessary, to tailor it to your needs. For example, you can change the number of weights or the values of the weights.

    3. Apply the equalizer object to the signal you want to equalize, using the equalize method of the equalizer object.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 80

    % subplot(2,2,3), plot(sb,'o'); grid, title('Equalized symbols'), xlabel('real part'), ylabel('imaginary part')

    % convergence

    subplot(2,2,4), plot(abs(e)); grid, title('Convergence'), xlabel('n'), ylabel('error signal')

    Expected graph:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 81

    RESULT:

    Thus the equalization program is designed and developed.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 82

    Figure 1 User interface of C-compiler, Code Composer Studio.

    Applications Digital imaging Medical ultrasound Portable ultrasound equipment CT scanners Magnetic resonance imaging

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 83

    EX.NO: 10 STUDY OF TMS 320VC5416 ARCHITECTURE

    DATE:

    AIM:

    To study architecture of TMS 320C5416

    THEORY:

    TM320C5416 consists of CPU containing various functional units such as ALU, MAC unit, EXP

    encoders, brrel registers, shifters, memory mapped registers, system control interface, program address

    generation logic and data address generation logic and eight 16 bit buses with interconnection.

    5AX BUSEs :

    The 5AX architecture in built around eight major 16 bit buses. The program bus arrives the

    instruction code and immediate operands from program memory. Three data buses interconnect to various

    elements such as CPU, DAGEN, on chip peripherals and the memory. The CB & DB carry operands that

    are read from data memory. The EB carrier data to be written in memory.

    INTERNAL MEMORY ORGANIZATION :

    1. ON CHIP ROM : This is part of program memory space and in some cases, part of data

    memory space. The amount of ON Chip on data devices varies.

    2. ON - CHIP DUAL ACCESS RAM : The DARAM is composed of several blocks can be accessed twice per machine cycle CPU can read from

    and write to a single block of DARAM in same cycle.

    3. ON CHIP SINGLE ACCESS RAM : The SARAM is composed of several blocks. Each block is accessible once per machine cycle. For either a

    read or write, the SARAM is always mapped in data space and primarily written to store data values.

    4. ON CHIP MEMORY SECURITY : The 5AX maskable memory security option protects contents of on chip memories, When this option is

    chosen, no externally originating instruction can access on chip

    5. MEMORY MAPPED REGISTE : The data memory space contains memory mapped registers for CPU and onchip peripherals. These

    registers are locked on data page sampling access to them.

    6. CENTRAL PROCESSING UNIT: The 5AX CPU is common to all its devices. The block diagram is given in 5AX CPU content.

    7. 40 BIT ALU : Two 40 bit accumulator register barred shift registers supporting A 16 to 31 shift range

    8. MULTIPLY OR ACCUMULATOR BLOCK : 9. 16 Bit temporary registers, TRM compare, select and store unit exponent encoders.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 84

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 85

    9.STATUS REGISTERS:

    STO & STI has status of various mode for 15x devices. STO has flag produced key arithimetic

    operation and bit manipulation in status of mode and instruction executed by processor.

    10.TRN REG: It set the transistor device divide on half to new matrix to perform the algorithm.

    RESULT:

    Thus the architecture of TMS320C5416 was studied.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 86

    PROGRAM:

    a) ADDITION

    .mmregs

    . global start

    start: ld # 1000h,a;

    .add # 00h,a:

    .end

    ii) SUBRACTION

    . mmregs

    . global start;

    start: ld # 1000h, a:

    sub # 0100h,a

    .end

    iii) MULTIPLICATION

    . mmregs

    . global start;

    start: ld # 1000h,a

    mpy # 0100h,a

    .end

    iv) DIVISION

    . mmregs

    . global start;

    start: ld # 1000h,a

    Div # 0100h,a

    .end

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 87

    EX.NO : 11 ARITHMETIC OPERATIONS USING TMS 320VC5416

    DATE :

    AIM:

    To write an assembly language program to perform aritmmetic operation using TMS320C5416.

    SOFTWARE USED:

    TMS software

    PROCEDURE:

    Step 1: Start the program.

    Step2: Get the data and check for the proper working.

    Step3: Condition of the processor using diagonistic tools.

    Step4: Create a new project & open a new source file and enter the source file and enter the

    source code in it.

    Step5: Add a source file command file and library file to the project created.

    Step6: Load the program and run it

    Step7: The required output is recorded

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 88

    OUTPUT:

    ADDITION:

    SUBTRACTION:

    Instruction After execution

    1. A= 1100h

    2. A= 1000h

    Addition Tabulation

    1. A=1000h

    2. A=2000h

    3. A=1FFFh

    4. A= 0002h

    5. A= 0020h

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 89

    RESULT:

    Thus the program is executed and output is verified.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 90

    PROGRAM:

    # include

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 91

    EX.NO : 12 GENERATION OF SINE WAVE USING TMS 320VC5416

    DATE:

    AIM:

    To write a program in C language to generate sine wave series using TMS 320C5416.

    SOFTWARE USED:

    TMS 320C5416

    PROCEDURE:

    i) Check the processor working conditions of the processor with the diagnostic loads.

    ii) Open a new project in that open a new source file and the program code.

    iii) To that source add a command file library file and a command file.

    iv) Now compile the source code.

    v) Now load the program and run it.

    vi) The required output is obtained.

    RESULT:

    Thus the program for generatig a sine wave is executed and the output is obtained.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 92

    PROGRAM:

    # include

    int y [10]

    main ( )

    {

    int m=4;

    int n=4;

    int I,j ;

    int x[7] = {1, 2, 3, 4,0, 0, 0 };

    int h[7] = {1, 2,3, 4, 0, 0, 0};

    for ( i=0; i< mm+n-1; i+ +)

    {

    y[i]= 0;

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

    y[ i]+ = x[j] * h[i-j];

    for (i=0; I < m+n-1; i++)

    printf ( % f \ n , y[i];

    }

    OUTPUT:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 93

    EX.NO : 13 LINEAR CONVOLUTION USING TMS 320VC5416

    DATE:

    AIM:

    To perform linear convolution using processor TMS 320 VC5416.

    APPARATUS REQUIRED:

    C5416 software processor.

    PROCEURE:

    i)Conect TMS v 5416 bit to pc

    ii) Open code and compare studio and ensure working conditions of the processor with the

    diagnostic loads.

    iii) Open a new project in that open a new source file and the program code.

    iv)To that source add a command file library file and a command file.

    v) Now compile the source code.

    vi) Now load the program and run it.

    vii)The required output is obtained.

    RESULT:

    Thus the program for generating a sine wave is executed and the output is obtained

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 94

    PROGRAM:

    .mmregs

    . global start

    Start: rsbx sxm

    stm #3h,bk

    stm #105eh,ar1

    ld #ar1+%,a,

    ld #ar1+%,a

    ld #ar1+%,a

    ld #ar1+%,a

    ld #ar1+%,a

    ld #ar1+%,a

    .end

    OUTPUT:

    Instructions

    Before execution

    After execution

    1 If the contents of memory are Sxm=0

    2 (0x105c)=0x0000 Bk=3

    3 (0x105c)=0x4413 (AC1)=0xBEEF

    (A)=105EH

    4 (A)=0x0000

    5 (A)=0x44C3

    6 (A)=0xBEEF

    7 (0x105E)=0xBEEF (A)=0x0000

    (A)=0x44C3

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 95

    EX.NO : 14 CIRCULAR CONVOLUTION USING TMS 320VC5416

    DATE :

    AIM:

    To perform linear convolution using processor TMS 320 VC5416.

    APPARATUS REQUIRED:

    C5416 software processor.

    PROCEDURE:

    i)Conect TMS v 5416 bit to pc

    ii) Open code and compare studio and ensure working conditions of the processor with the

    diagnostic loads.

    iii) Open a new project in that open a new source file and the program code.

    iv)To that source add a command file library file and a command file.

    v) Now compile the source code.

    vi) Now load the program and run it.

    vii)The required output is obtained.

    RESULT:

    Thus the program is executed and the output is obtained.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 96

    PROGRAM:

    Main( FFT 256 C )

    # include

    #define DTS 619 # of points for FFT

    # define P

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 97

    EX.NO : 15 FFT USING TMS 320VC5416

    DATE:

    AIM:

    To implement 64 point FFT using DIT algorithm in TMS 320 C 5416 DSP processor.

    APPARATUS REQUIRED:

    PC, TMS 320C5416 ,USB

    PROCEDURE:

    1. Open code composer studio and make sure bit is in proper working. 2. Start project and library file , command file and source file. 3. The compile program , build and loading is done. 4. Run program and output is received by graph.

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 98

    samples [ I ] .imag=0;

    for [ I =0;; i< pts;i++);

    {

    x1 [ I ] = sqrt ( samples [ I ] 0;

    }

    }

    FFT. C:

    # define PTS 64

    type def start { float, real , imag};

    void fft ( composer xy , intu)

    {

    complex turn p, turnp2;

    int upper = = log , lower leg;

    int num stages;

    int index- stages;

    I = 1;

    Do

    {

    num-stages + = 1;

    i= I * 2

    }

    while ( i/ n);

    leg diff = N/2;

    for ( i= 0; I < num stages ; I ++);

    {

    index = 0;

    for ( j =0; j , j < leg-difference ; j ++)

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 99

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 100

    {

    for ( upper leg= j ; upper- leg ( N) ; upper-leg+)

    = (2*leg diff)};

    lower leg = upper. Leg+ leg difference

    temp.real = [ y[ upper leg ]].real +[y9lower-leg]]

    temp.real = [y[ upper leg]] = imag+ (g(lower-leg))

    cy [ lower.leg].imag= temp2.real*w[index+imag+[ temp2 imag +index]real;

    }

    index + = step;

    }

    leg-differ leg-diff/2;

    step+=2

    }

    j= 0

    for ( i=1; i< N-1; i++)

    {

    j = j k;

    k= k/2;

    }

    k= k/2;

    }

    i = j- k;

    }

    I = j +k;

    {

    temp1.real = [ y( I ).real];

    temp2. imag = [y( j )imag];

    (y [ i]).real = [ y(I ). Imag];

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 101

    INPUT

    OUTPUT:

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 102

    ( y[ j ]).imag = [ y(i)]. Imag ];

    (y[I ] . real = temp1. real;

    ( y [j ]. Imag= temp1.imag;

    }

    }

    return;

    }

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 103

    RESULT:

    Thus program for 64 point FFT has been executed and output is obtained suddenly

  • EC6511 DIGITAL SIGNAL PROCESSING LABORATORY

    PREPARED BY Mr.R.RAMADOSS AP/ECE 2126-SMIT Page 104

    VIVA QUESTIONS

    1. What is the necessity of sectioned convolution in signal processing? 2. Define Correlation of the sequence. 3. State any two DFT properties 4. Differentiate IIR filters and FIR filters. 5. Write the characteristics features of Hanning window 6. Define pre-warping effect? Why it is employed? 7. Give any two properties of Butterworth filter. 8. When a FIR filter is said to be a linear phase FIR filter 9. Write the characteristics features of rectangular window. 10. Write the expression for Kaiser window function.. 11. What are the advantages and disadvantages of FIR filters? 12. Write the characteristics features of Hamming window 13. Why mapping is needed in the design of digital filters? 14. What are the effects of finite word