Docsity

Digital Signal Processing Lab: Experiments and MATLAB/DSP Implementation, Study notes of Digital Signal Processing

Partial preview of the text

Download Digital Signal Processing Lab: Experiments and MATLAB/DSP Implementation and more Study notes Digital Signal Processing in PDF only on Docsity!

LAB MANUAL

EC8562-DIGITAL SIGNAL PROCESSING LABORATORY

ST. ANNE’S

COLLEGE OF ENGINEERING AND TECHNOLOGY (Approved by AICTE, New Delhi. Affiliated to Anna University, Chennai) (An ISO 9001: 2015 Certified Institution) ANGUCHETTYPALAYAM, PANRUTI – 607 106

Regulation : 2017

Branch : B.E. – ECE

Year & Semester : III Year / V Semester

ANNA UNIVERSITY CHENNAI Regulation 2017 EC8562-DIGITAL SIGNAL PROCESSING LABORATORY LIST OF EXPERIMENTS: MATLAB / EQUIVALENT SOFTWARE PACKAGE

  1. Generation of elementary Discrete-Time sequences
  2. Linear and Circular convolutions
  3. Auto correlation and Cross Correlation
  4. Frequency Analysis using DFT
  5. Design of FIR filters (LPF/HPF/BPF/BSF) and demonstrates the filtering operation
    1. Design of Butterworth and Chebyshev IIR filters (LPF/HPF/BPF/BSF) and demonstrate the filtering operations DSP PROCESSOR BASED IMPLEMENTATION
  6. Study of architecture of Digital Signal Processor
  7. Perform MAC operation using various addressing modes
  8. Generation of various signals and random noise
  9. Design and demonstration of FIR Filter for Low pass, High pass, Band pass and Band stop filtering
  10. Design and demonstration of Butter worth and Chebyshev IIR Filters for Low pass, High pass, Band pass and Band stop filtering
    1. Implement an Up-sampling and Down-sampling operation in DSP Processor TOTAL: 60 PERIODS

INTRODUCTION MATLAB is a software package for high performance numerical computation and visualization provides an interactive environment with hundreds of a built in functions for technical computation, graphics and animation. The MATLAB name stands for Matrix laboratory. At its core, MATLAB is essentially a set (a “toolbox”) of routines (called “m files” or “mex files”) that sit on your computer and a window that allows you to create new variables with names (e.g. voltage and time) and process those variables with any of those routines (e.g. plot voltage against time, find the largest voltage, etc). It also allows you to put a list of your processing requests together in a file and save that combined list with a name so that you can run all of those commands in the same order at some later time. Furthermore, it allows you to run such lists of commands such that you pass in data. and/or get data back out (i.e. the list of commands is like a function in most programming languages). Once you save a function, it becomes part of your toolbox. For those with computer programming backgrounds: Note that MATLAB runs as an interpretive language (like the old BASIC). That is, it does not need to be compiled. It simply reads through each line of the function, executes it, and then goes on to the next line.

DSP Development System

  • Testing the software and hardware tools with Code Composer Studio
  • Use of the TMS320C6713 DSK
  • Programming examples to test the tools Digital signal processors such as the TMS320C6x (C6x) family of processors are like fast special-purpose microprocessors with a specialized type of architecture and an instruction set appropriate for signal processing. The C6x notation is used to designate a member of Texas Instruments’ (TI) TMS320C6000 family of digital signal processors. The architecture of the C6x digital signal processor is very well suited for numerically intensive calculations. Based on a very-long-instruction-word (VLIW) architecture, the C6x is considered to be TI’s most powerful processor. Digital signal processors are used for a wide range of applications, from communications and controls to speech and image processing. The general-purpose digital signal processor is dominated by applications in communications (cellular). Applications embedded digital signal processors are dominated by consumer products. They are found in cellular phones, fax/modems, disk drives, radio, printers, hearing aids, MP3 players, high-definition television (HDTV), digital cameras, and so on. These processors have become the products of choice for a number of consumer applications, since they have become very cost-effective. They can handle different tasks, since they can be reprogrammed readily for a different application. DSP techniques have been very successful because of the development of low-cost software and hardware support. For example, modems and speech recognition can be less expensive using DSP techniques.DSP processors are concerned primarily with real-time signal processing. Real-time processing requires the processing to keep pace with some external event, whereas non-real-time processing has no such timing constraint. The external event to keep pace with is usually the analog input. Whereas analog-based systems with discrete electronic components such as resistors can be more sensitive to temperature changes, DSP-based systems are less affected by environmental conditions. DSP processors enjoy the advantages of microprocessors. They are easy to use, flexible, and economical. A number of books and articles address the importance of digital signal processors for a number of applications .Various technologies have been used for real- time processing, from fiber optics for very high frequency to DSPs very suitable for the audio- frequency range. Common applications using these processors have been for frequencies from 0 to 96kHz. Speech can be sampled at 8 kHz (the rate at which samples are acquired), which implies that each value sampled is acquired at a rate of 1/(8 kHz) or 0.125ms. A commonly used sample rate of a compact disk is 44.1 kHz. Analog/digital (A/D)- based boards in the megahertz sampling rate range are currently available.

%Program for generation of unit ramp signal n1=input('enter the sample length of unit ramp sequence'); t=0:n1; subplot(2,2,3); stem(t,t); ylabel('amplitude'); xlabel('sequence'); title('unit ramp') %Program for generation of discrete exponential signal: n2=input('enter the length of the exponential sequence'); t=0:n2; a=input('enter the a value'); y2=exp(at); subplot(2,2,4); stem(t,y2); ylabel('amplitude'); xlabel('time period'); title('exponential sequence') %Program for generation of continuous exponential signal: n3=input('enter the length of the exponential sequence'); t=0:2:n3-1; a=input('enter the a value'); y3=exp(at); subplot(3,1,1); stem(t,y3); ylabel('amplitude'); xlabel('time period'); title('continuous exponential sequence') %Program for generation of sine wave t=0:0.01: pi; y=sin(2pit); subplot(3,1,2); stem(t,y); ylabel('amplitude'); xlabel('time period'); title('sine wave') %Program for generation of cosine wave t=0:0.01: pi; y=cos(2pit); subplot(3,1,3); stem(t,y); ylabel('amplitude'); xlabel('time period'); title('cosine wave')

OUTPUT: (DISCRETE SIGNALS)

Enter the sample length of unit step sequence 8 Enter the length of ramp sequence 6 Enter the length of the exponential sequence 8 Enter the a value 5 -4 -2 0 2 4 0

1 amplitude time period unit impulse 0 2 4 6 8 0

1 amplitude sequence unit step 0 2 4 6 0 2 4 6 amplitude sequence unit ramp 0 2 4 6 8 0 1 2 3 x 10 17 amplitude time period exponential sequence

Ex. No: 2 Date: AIM:

CORRELATION OF SEQUENCES

To write MATLAB programs for auto correlation and cross correlation. APPARATUS REQUIRED: HARDWARE : Personal Computer SOFTWARE : MATLAB R2014a PROCEDURE:

  1. Start the MATLAB program.
  2. Open new M-file
  3. Type the program
  4. Save in current directory
  5. Compile and Run the program
  6. If any error occurs in the program correct the error and run it again
  7. For the output see command window\ Figure window
  8. Stop the program.

PROGRAM: (Cross-Correlation of the Sequences) clc; clear all; close all; x=input('Enter the sequence 1: '); h=input('Enter the sequence 2: '); y=xcorr(x,h); figure; subplot(3,1,1); stem(x); xlabel('n->'); ylabel('Amplitude->'); title('Input sequence 1'); subplot(3,1,2); stem(fliplr(y)); stem(h); xlabel('n->'); ylabel('Amplitude->'); title('Input sequence 2'); subplot(3,1,3); stem(fliplr(y)); xlabel('n->'); ylabel('Amplitude->'); title('Output sequence'); disp('The resultant is'); fliplr(y); OUTPUT: (Cross-Correlation of the Sequences) Enter the sequence 1: [1 3 5 7] Enter the sequence 2: [2 4 6 8]

Ex. No: 3 Date: AIM:

LINEAR AND CIRCULAR CONVOLUTIONS

To write MATLAB programs to find out the linear convolution and Circular convolution of two sequences. APPARATUS REQUIRED: HARDWARE : Personal Computer SOFTWARE : MATLAB R2014a PROCEDURE:

  1. Start the MATLAB program.
  2. Open new M-file
  3. Type the program
  4. Save in current directory
  5. Compile and Run the program
  6. If any error occurs in the program correct the error and run it again
  7. For the output see command window\ Figure window
  8. Stop the program.

%Program for linear convolution %to get the input sequence n1=input('enter the length of input sequence'); n2=input('enter the length of impulse sequence'); x=input('enter the input sequence'); h=input('enter the impulse sequence'); %convolution operation y=conv(x,h); %to plot the signal subplot(3,1,1); stem(x); ylabel('amplitude'); xlabel('n1....>'); title('input sequence') subplot(3,1,2); stem(h); ylabel('amplitude'); xlabel('n2....>'); title('impulse signal') subplot(3,1,3); stem(y); ylabel('amplitude'); xlabel('n3'); disp('the resultant signal is');y

OUTPUT : LINEAR CONVOLUTION

Enter the length of input sequence 4 Enter the length of impulse sequence 4 Enter the input sequence [1 2 3 4] Enter the impulse sequence [4 3 2 1] The resultant signal is y= 4 11 20 30 20 11 4 1 1.5 2 2.5 3 3.5 4 0 2 4 amlitude n1....> input sequence 1 1.5 2 2.5 3 3.5 4 0 2 4 amlitude n2....> impulse signal 1 2 3 4 5 6 7 0 20 40 amlitude n

OUTPUT : CIRCULAR CONVOLUTION

Enter the input sequence [1 2 2 1] Enter the impulse sequence [4 3 2 1] The resultant signal is y= 15 17 15 13 1 1.5 2 2.5 3 3.5 4 0 1 2 amplitude n1..> input sequence 1 1.5 2 2.5 3 3.5 4 0 2 4 amplitude n impulse sequence 1 1.5 2 2.5 3 3.5 4 0 10 20 amplitude n RESULT: Thus the MATLAB (^) programs for linear convolution and circular convolution written and the results were plotted.

OUTPUT: (FFT)

Enter the input sequence [2 1 2 1 2 1 2 1] Enter the number of points in fft 8 The values …. Xk= 12 0 0 0 4 0 0 0 1 2 3 4 5 6 7 8 0 2 4 6 8 10 12 real axis imaginary axis fft

PROGRAM: (Spectrum Analysis Using DFT) N=input('type length of DFT= '); T=input('type sampling period= '); freq=input('type the sinusoidal freq= '); k=0:N-1; f=sin(2pifreq1/Tk); F=fft(f); stem(k,abs(F)); grid on; xlabel('k'); ylabel('X(k)'); INPUT: type length of DFT=32 type sampling period= type the sinusoidal freq= OUTPUT: (Spectrum Analysis Using DFT) RESULT: Thus the Spectrum Analysis of the signal using DFT is obtained using MATLAB.