Dsp Lab Manual

Share Embed Donate


Short Description

Download Dsp Lab Manual...

Description

DIGITAL SIGNAL PROCESSING LAB MANUAL

ECE: V SEMESTER

LIST OF EXPERIMENTS MATLAB: INTRODUCTION TO MATLAB.  GENERATION OF SIGNALS.  LINEAR AND CIRCULAR CONVOLUTION OF TWO SEQUENCES.  SAMPLING AND EFFECT OF ALIASING.  DESIGN OF FIR FILTERS.  CALCULATION OF FFT OF A SIGNAL.  DESIGN OF IIR FILTERS.

PROCESSOR:-

 STUDY OF TMS320C50 PROCESSOR.  16 BIT ARITHMETIC OPERATION USING TMS320C50.  STUDY OF VARIOUS ADDRESSING MODES OF DSP USING SIMPLE PROGRAMMING EXAMPLES.  SAMPLING OF INPUT SIGNAL AND DISPLAY.  IMPLEMENTATION OF FIR FILTER.  CALCULATION OF FFT.

1. STUDY OF MATLAB AIM: To study the MATLAB and its operations. APPARATUS REQUIRED: PC with software MATLAB THEORY: MATLAB is a high performance language for technical computing. It integrates computing, visualization and programming in an easy way to be used by the environment where problems and solutions are expressed in familiar mathematical notation. Typical uses include 1. Math and Computation 2. Algorithm development 3. Data acquisition 4. Modeling, simulation and proto-typing 5. Scientific and engineering graphics 6. Application development including graphical user interface building 7. Data analysis, exploration, visualization. MATLAB SYSTEM: The MATLAB consists of three main parts 1. Desktop and Development Environment This is the set of tools and facilities that help you use MATLAB function and files. Many of these tools are graphical user interfaces. It includes the MATLAB desktop and command window, command history and editor and debugger, a code analyzer and other reports, and browser for viewing help, the workspace, files and the search path. 2. The MATLAB Mathematical Function Library This is a vast collection of computational algorithm ranging from elementary function like sum, sine, cosine and complex arithmetic to more sophisticated functions like matrix inverse, matrix Eigen values, Bessel functions and fast Fourier transform.

3. The MATLAB Language This is a high level matrix/array language with control flow statements, functions, data structures, input and output and object oriented programming features. It allows both programming in the small to rapidly create quick and dirty throw –away program and programming in the large to create large and complex application programmer. 4. Graphics MATLB has extensive facilities for displaying vectors and matrices as graphs as well as annotating and printing these graphs. It includes high-level functions for two and three dimensional data visualization, image processing animation and presentation graphics. 5. MATLAB External Interfaces This is a library that allows you to write a C program and function FORTRAN programmer that interacts with MATLAB. It includes facilities for calling routines from MATLAB (dynamic range), calling MATLAB as a computational engine, and for reading and writing MATLAB files. EXAMPLES: 1. Mathematics-Mathematical operation functions and data analysis. 2. Programming-Programming features and techniques.

RESULT: Thus the functions and operations of MATLAB was studied.

2.GENERATION OF SIGNALS AIM: To draw the waveform for unit step, unit ramp, unit impulse, exponential, sine and cosine wave using MATLAB program. APPARATUS REQUIRED: PC with MATLAB ALGORITHM: STEP1: Clear output screen by using clc command in editor window. STEP2: Divide output screen into number of portions by using sub-plot command. STEP3: Then the function for unit step, ramp, impulse and exponential, sine and cosine waves are declared. STEP4: Give the title for each output. STEP5: End the program. PROCEDURE: 1. Click MATLAB icon and open a new file. 2. Type the program and save the project. 3. Run the program by clicking on debug. 4. Note the output and plot the graph for the output.

PROGRAM: clc; clear all; figure(1); subplot(3,2,1); a=5; t=-a ; a; i =[zeros(1,a),1,ones(1,a)]; stem (t, i); x label (‘time’); y label (‘amplitude’); title (‘unit step’); subplot (3,2,2); figure (1); a=5; t=-a;a; x=t.i; stem(t,x); x label (‘time’); y label (‘amplitude’); title (‘unit ramp’); subplot (3,2,3); figure (1); a=5; t=-a:a; j=[zeros(1,a),1,zeros(1,a)]; stem (t,j); x label (‘time’);

y label (‘amplitude’); title (‘unit impulse’); subplot (3,2,4); figure (1); a=5; t=-a:a; x=exp(t); stem (t,x); x label (‘time’); y label (‘amplitude’); title (‘unit exponential’); subplot (3,2,5); t=0:.01:2; x=sin(2*pi*t); plot (t,x); line ([0,2],[0,0]); x label (‘time’); y label (‘amplitude’); title (‘sine wave’); subplot (3,2,6); t=0:.01:2; x=cos(2*pi*t); plot(t,x); line([0,2],[0,0]); x label (‘time’); y label (‘amplitude’); title(‘cosine wave’);

RESULT: Thus the waveform for unit step, unit ramp, unit impulse, unit exponential, and sine and cosine wave obtained using MATLAB program.

3. LINEAR AND CIRCULAR CONVOLUTION OF TWO SEQUENCES AIM: To perform linear and Circular convolution. APPARATUS REQUIRED: PC with MATLAB ALGORITHM: STEP1: Get the input sequence. STEP2: Plot them using subplots in figure window. STEP3: Calculate output using convolution command. STEP4: Plot sequences using subplot command. STEP5: Stop the program. THEORY: LINEAR CONVOLUTION: Any linear system is implemented by means of linear convolution defined as, Y (n) =∑x (k) h (n-k) If the two inputs are each of length n1 and n2 the output is of length n1+n2-1.the linear convolution between the two inputs is equivalent to flipping one input and running it through the other like a train.

CIRCULAR CONVOLUTION: We know that linear convolution of two finite length data sequence is done by assuming that the data is zero outside the length in which it is defined[recall that linear convolution runs from –α to α].this need not be the only valid assumption. For e.g. one can assume that the data is periodic outside the sequence length in which it is defined. This is consistent with the definition of DFT.DFT is equivalent to discrete time Fourier series and that all Fourier series assume periodicity. So this definition of convolution would be more practical use since it implies with DFT definition. Therefore circular Convolution is defined n-1 X (n) +y (n) =∑ x (m) y [(n-m) mod n)] m=0

PROCEDURE: 1. Click on MATLAB icon and open new file. 2. Type program and save it. 3. Run program by clicking on debug. 4. Note output and plots the graph.

PROGRAM: %linear convolution clear all; clc; close all; a=input(‘enter the value of a’); b= input(‘enter the value of b’); subplot (3,1,1); stem (a); subplot (3,1,2); stem(b); c=conv(a,b); subplot (3,1,3); stem (c);

%circular convolution clear all; clc; close all; x= input(‘enter the value of x’); y= input(‘enter the value of y’); a=length(x); b=length(y);

n=a+b/2 %zero padding if a~=b if a fs/2 so that aliasing takes place. STEP7: End the program. THEORY: According to sampling theorem a band limited signal with highest frequency component of Wm must be sampled (i.e.) Ws=2Wm is not satisfied, and then the signal will be aliased to another signal of linear frequency this is known as aliasing. PROCEDURE: 1. Click on MATLAB icon and open a new file. 2. Type the program & save the project. 3. Run the program by clicking on debug. 4. Note the output and plot the graph for the output.

PROGRAM: %SAMPLING AND EFFECT OF ALIASING clc; clear all; close all; disp(‘aliasing’); fc1=50; fc2=10; t=0:(1/10)e2:0.1; x1=sin(2*pi*fc1*t); x2= sin(2*pi*fc2*t); subplot (2,3,1); plot(x1); line ([0,200],[0,0]); x label (‘time’); y label (‘amplitude’); title (‘sinusoidal signal f=50 hz’); subplot (2,3,4); plot (x2); line([0,100],[0,0]); x label (‘time’); y label (‘amplitude’); title (‘sinusoidal signal f=50 hz’); fs=40; n=0:1:15; x3=sin(2*pi*fc1*n/fs); x4=sin(2*pi*fc2*n/fs); subplot (2,3,2);

stem(x3); line ([0,15],[0,0]); x label (‘time’); y label (‘amplitude’); title (‘sampled signal (alias fs=40hz)’); subplot (2,3,5); stem (x4); line ([0,15],[0,0]); x label (‘time’); y label (‘amplitude’); title(‘sampled signal fs=40 hz’); fs1=150 n=0:1:10 x5=sin (2*pi*fc1*n/fs1); x6=sin(2*pi*fc2*n/fs1); subplot (2,3,3); stem (x5); line([0,10],[0,0]); x label (‘time’); y label (‘amplitude’); title(‘sampled signal fs1=150hz’); subplot(2,3,6); stem (x6); line ([0,10],[0,0]); x label (‘time’); y label (‘amplitude’); title(‘sampled signal fs1=150hz’); g text(‘sampling and aliasing’);

RESULT: Thus a sine wave is sampled and the effects of aliasing are studied.

5. DESIGN OF FIR FILTERS AIM: To write a MATLAB program for FIR filter using different window techniques for the given order and sampling frequency. APPARATUS REQUIRED: PC with MATLAB ALGORITHM: STEP1: Clear the screen. STEP2: Sampling frequency & cut off frequency are specified. STEP3: FIR filter coefficient is determined by using FIR 1 command. STEP4: Input to the FIR filter is given as a sequence square wave & the output is computed using filter command. STEP5: Frequency response of the filter with various windows functions calculated using frequency. STEP6: From the frequency response various functions are studied. THEORY: FIR is the non-recursive filter that has the impulse response for finite number of n, n1 ≤ n≤ n2 with n1 and n2 being finite. This filter is also known as convolution filter b0 and is all non-zero system. In general, the unit sample response is of finite duration and must be truncated at some point to yield FIR filter of finite length. This method is called as WINDOWING. Thus multiplying a window function in time domain results in the convolution of Fourier transform of window with that of unit sample response, which will be a sine function .In most of times, two criteria that has satisfied by the window functions are(i) The width of the main lobe should be small for the ripples to be small. (ii) The height of the side lobe should be small for the ripples to be small. Thus we will study various windows based on the above criteria. PROCEDURE: 1. Click on MATLAB icon and open a new file. 2. Type the program & save the project. 3. Run the program by clicking on debug. 4. Note the output and plot the graph for the output.

PROGRAM: % KAISER WINDOW clc; clear all; close all; n=input (‘enter the order of the filter’);

%order of the filter

wc=input (‘enter cut off frequency’); % cut off frequency beta=input(‘enter the beta value’); % kaiser window parameter w=kaiser(n+1,beta); %fir filter using Kaiser window fn b=fir1(n,wc,w); % fir filter coefficient [h,omega]=freqz(b,1,256); %frequency response m=20*log(abs(h)); %magnitude response ph=angle(h*(180/pi)); %phase response subplot (2,2,1); plot (b); title (‘filter response’); subplot (2,2,2); plot (omega/pi,h); title (‘frequency response’); subplot (2,2,3); plot(m); title(‘magnitude response’); subplot(2,2,4); plot(ph); title(‘phase response’); %RECTANGULAR WINDOW

clc; clear all; close all; n=input(‘enter the value’) wc=input(‘enter the cut-off frequency’) w=boxcar(n+1); b=fir1(n,wc,w); [h,omega]=freqz(b,1,256); m=20*log(abs(h)); ph=angle(h*180/pi)); subplot(2,2,1); plot(b); title(‘filter response’); subplot(2,2,2); plot(omega/pi,h); title(‘frequency response’); subplot(2,2,3); plot(m); title(‘magnitude response’); subplot(2,2,4); plot(ph); title(‘phase response’); %BARLETT WINDOW clc; clear all; close all; n=input(‘enter the value’); wc=input(‘enter cut off frequency’);

w=barlett(n+1); b=fir1(n,wc,w); [h,omega]=freqz(b,1,256); m=20*log(abs(h)); ph=angle(h*(180/pi)); subplot(2,2,1); plot(b); title(‘h(n)’); subplot(2,2,2); plot(omega/pi,h); title(‘frequency response’); subplot(2,2,3); plot(m); title(‘magnitude response’); subplot(2,2,4); plot(ph); title(‘phase response’); %BLACKMAN WINDOW clc; clear all; close all; n=input(‘enter the value’); wc=input(‘enter the cut off frequency’); w=blackman(n+1); b=fir1(n,wc,w); [h,omega]=freqz(b,1,256); m=20*log(abs(n)); ph=angle(h*(180/pi));

subplot(2,2,1); plot(b); title(‘h(n)’); subplot(2,2,2); plot(omega/pi,h); title(‘frequency response’); subplot(2,2,3); plot(m); title(‘magnitude response’); subplot(2,2,4); plot(ph); title(‘phase response’);

RESULT: Thus the FIR filter was designed using window technique using MATLAB program for the given order and cut –off frequency.

6. CALCULATION OF FFT OF A SIGNAL AIM: To perform fast Fourier transforms using DFT using MATLAB program. APPARATUS REQUIRED: PC with MATLAB ALGORITHM: STEP1: Get the input sequence. STEP2: Plot them using subplots in the figure window. STEP3: Find the result using FFT commands. STEP4: Plot the sequences using subplot command. STEP5: Stop the program. THEORY: The FFT is the faster version of the discrete Fourier transform (FFT).The FFT utilizes same algorithm to do the same thing as DFT, but in much less time. The DFT is extremely imp in the area of frequency analytic because it takes a discrete signal in time domain and transform that signal into it discrete frequency domain representation. Without the discrete time, to discrete time freq transform, we could not be able to compute FFT in DFT based system. It is the speed and discrete nature of the FFT that allows us to analyze the signal spectrum with MATLAB.

PROCEDURE: 1. Click on MATLAB icon and open a new file 2. Type the program and save the project 3. Run the program by clicking debug. 4. Note the output and plot the graph.

PROGRAM: %N POINT FFT USING DFT: clc; clear all; close all; x=input(‘enter the sequence’); N=length(x); z= fft(x,n); display(‘input’);x display(‘output’);z n=1:N; subplot(3,2,1); stem(n,x); xlabel(‘sequence number’); ylabel(‘amplitude’); title(‘input sequence’); subplot(3,2,2); stem(n,abs(z)); xlabel(‘sequence number’); ylabel(‘amplitude’); title(‘output amplitude’); subplot(3,2,3); stem(b,real(z)); xlabel(‘sequence number’); ylabel(‘real’); title(‘output real part’); subplot(3,2,4); stem(n,imag(z));

xlabel(‘sequence number’); ylabel(‘imaginary’); title(‘output imaginary part’); subplot(3,2,5); stem(n,(z)); xlabel(‘sequence number’); ylabel(‘phase’); title(‘output phase’);

%N-POINT INVERSE FFT USING IDFT: clc; clear all; close all; x=input(‘enter the number’); N=length(x); z= ifft(x,n); display(‘input’);x display(‘output’);z n=1:N; subplot(2,2,1); stem(n,x); xlabel(‘sequence number’); ylabel(‘amplitude’); title(‘input sequence’); subplot(2,2,2); stem(n,z); xlabel(‘sequence number’); ylabel(‘amplitude’);

title(‘output sequence’); subplot(2,2,3); stem(n,floor(real(acos(z)))); xlabel(‘sequence number’); ylabel(‘amp’); title(‘output sequence’); gtext(‘mnmjec’);

RESULT: Thus the program to perform linear combination and circular convolution using FFT has been processed and verified successfully.

7. DESIGN OF IIR FILTERS AIM: To write MATLAB program for IIR filter for the given order and cut off frequency and stop band frequency. APPARATUS REQUIRED: PC with MATLAB ALGORITHM: STEP1: Get the required filter parameters. STEP2: Calculate filter co-efficient. STEP3: Butterworth filter can be designed using butter command [b a]=butter (n, w0), n=order of filter and w0=normalized cut off frequency. STEP4: Chebyshev filter can be designed using cheby1 and cheby2 command. [b a]=cheby1(n,r,w0) n=order of filter, r=pass band ripple and w0=normalized cut off frequency. STEP5: plot the frequency, magnitude and phase response. STEP6: End the program. THEORY: BUTTERWORTH FILTER: Butterworth filter approximation concentrates on w=0 (i.e.) maximally flat response at origin. Hn(w)=wn |π(jw)|2 =1/(1+c2w2n) As the order of filter is increased the sharpness of cut off increase. The attenuation in pass band is xp(w) =10log (1+c2).butter worth filter gives a fairly linear response. As order of chebyshev response becomes higher, phase response become non-linear. CHEBYSHEV FILTER:

Concentrates over range 0
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF