Escolar Documentos
Profissional Documentos
Cultura Documentos
Semester/Term:
CONTEN TS
Lab. No. Dated Title of Experiments Page No
01-03
Remarks
Effects of Sampling in Discrete Time Signals. Effects of Quantization in Discrete Time Continuous Valued Signals.
04-06
Discrete-Time Convolution.
07-08
Discrete-Time Correlation.
09-10
11-12
13-14
7(a)
15-16
7(b)
17-18
19-21
9
10
Generation of sine waves and plotting with CSS using C-6713 DSK.
22-24
25-26
11
27-28
12
29-30
13
Appendices
31-35
Lab Session 01
Department of Electrical Engineering
THEORY:
This practical covers the topics of lectures 1-6, and are supported by sections 1.3 and 1.4 of your text book (DSP by Proakis, 4th Ed).
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and type the following code: clear all; close all; clc; F1 = 10; F2 = 110; Fs = 100; Ts = 1/Fs; t = [0 : 0.0005 : 0.2]; x1t = cos(2*pi*F1*t); x2t = cos(2*pi*F2*t); figure, plot(t,x1t,t,x2t, 'LineWidth',2); xlabel('cont time (sec)'); ylabel('Amp'); xlim([0 0.1]); grid on; legend('10Hz','110Hz'); title('Two CTCV sinusoids plotted'); 3. Save the file as P011.m in your current directory and run it, either using F5 key or writing the file name at the command window.
-1-
Lab Session 01
Department of Electrical Engineering
4. Check for the correctness of the time periods of both sinusoids. 5. Now add the following bit of code at the bottom of your P011.m file and save. nTs = [0 : Ts : 0.2]; n = [1 : length(nTs)-1 ]; x1n = cos(2*pi*F1*nTs); x2n = cos(2*pi*F2*nTs); figure, subplot(2,1,1), stem(nTs,x1n,'LineWidth',2); grid on; title('10Hz sampled'); xlabel('discrete time (sec)'); ylabel('Amp'); xlim([0 0.1]); subplot(2,1,2) stem(nTs,x2n,'LineWidth',2); grid on; title('110Hz sampled') xlabel('discrete time (sec)'); ylabel('Amp'); xlim([0 0.1]); 6. Before hitting the run, just try to understand what the code is doing and try to link it with what we have studied in classes regarding concepts of frequency for DT signals. 7. Now run the file and observe both plots. 8. To see what is really happening, type the following code at the bottom of your existing P011.m file and run again. figure, plot(t,x1t,t,x2t); hold stem(nTs,x1n,'r','LineWidth',2); xlabel('time (sec)'); ylabel('Amp'); xlim([0 0.05]); legend('10Hz','110Hz'); 9. Observe the plots.
-2-
Lab Session 01
Department of Electrical Engineering
RESULT:
Explain (write) in your own words the cause and effects of what you just saw.
EXERCISE:
This needs to be completed before your next practical and saved. Consider the following CT signal: x(t) = sin (2 pi F0 t). The sampled version will be: x(n) = sin (2 pi F0/Fs n), where n is a set of integers and sampling interval Ts=1/Fs. Plot the signal x(n) for n = 0 to 99 for Fs = 5 kHz and F1 = 0.5, 2, 3 and 4.5 kHz. Explain the similarities and differences among various plots.
-3-
Lab Session 02
Department of Electrical Engineering
LAB SESSION 02
THEORY:
In this session, we will generate DTCV sinusoids and quantize them. We shall measure the quantization noise signals and the quality of the quantization process. The error signal is given as: xe(n) = x(n) - xq(n). Where, xq(n) is the quantized signal. The resolution of the quantizer is given as:
quantization levels. The quality of the quantized signal is measured by the signal-to-quantization noise ratio
powers of the DTCV and quantized signal respectively, and may be written as:
Px
1 N
N 1 n 0
x(n) and. Pe
1 N
N 1
x ( n ) xq ( n )
n 0
This practical is supported by section 1.4.3 of your text book (4th Ed).
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and write the following code:
clear all; close all; clc; fd1 = 1/50; n = [0 : 499 ]; q=input('No. of Digits after decimal points to be retained (0-9): '); x1 = cos(2*pi*fd1*n); Px1 = sum(abs(x1).^2)/length(x1); x1q = round(x1*10^q)/10^q;
-4-
Lab Session 02
Department of Electrical Engineering
SQNR = 10*log10(Px1/Pe1); disp(['The Signal to Quantization Noise Ratio is: ' num2str(SQNR) ' dB.' ]); figure, subplot(2,1,1); plot(n,x1,n,x1q); xlabel('indices'); ylabel('Amp'); xlim([0 49]); ylim([-1.1 1.1]); legend('DTCV','DTDV'); subplot(2,1,2); plot(n,x1e); xlabel('indices'); ylabel('Error'); xlim([0 49]);
3. Save the file as P021.m in your current directory and run it. 4. Explore and take notes. 5. Now modify the above code as follows and save as another file P022.m.
clear all; close all; clc; fd1 = 1/50; n = [0 : 499 ]; q = [0 : 10]; % No. of Digits after decimal points to be retained for num = 1 : length(q) x1 = cos(2*pi*fd1*n); Px1 = sum(abs(x1).^2)/length(x1); x1q = round(x1*10^q(num))/10^q(num); x1e = x1 - x1q; Pe1 = sum(abs(x1e).^2)/length(x1e); SQNR(num) = 10*log10(Px1/Pe1); end figure, plot(q,SQNR); xlabel('Significant Digits'); ylabel('SQNR (dB)');
-5-
Lab Session 02
Department of Electrical Engineering
6. Before hitting the run, just try to understand what the code is doing and try to link it with the previous code. 7. Now run the file and observe the results.
RESULT:
Explain (write) in your own words the cause and effects of what you just saw.
EXERCISE:
Do Exercise 1.16 of Proakis (4th Ed) in MATLAB and bring it in your next lab.
-6-
Lab session 03
Department of Electrical Engineering
3. Modify the code such that h( n) = {3, 2,1, 2,1, 0, 4, 0,3} - (origin is shifted), and check
THEORY:
1. Convolution is given as: y ( n) = x(n) h(n) =
k =
one can compute the output y(n) to a certain input x(n) when impulse response h(n) of that system is known. Convolution holds commutative property. 2. The length of the resulting convolution sequence is N+M-1, where, N and M are the lengths of the two convolved signals respectively. 3. In Causal Systems, the output only depends on the past and/or present values of inputs and NOT on future values. This means that the impulse response h(n) of a causal system will always exist only for n 0. This practical is supported by section 2.3.3 of your text book (4th Ed).
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and write the following code:
clear all; close all; clc; h = [3 2 1 -2 1 0 -4 0 3]; % impulse response org_h = 1; % Sample number where origin exists nh = [0 : length(h)-1]- org_h + 1; x = [1 -2 3 -4 3 2 1]; % input sequence org_x = 1; % Sample number where origin exists nx = [0 : length(x)-1]- org_x + 1; y = conv(h,x);
-7-
Lab session 03
Department of Electrical Engineering
3. Save the file as P031.m in your current directory and run it. 4. Try to learn, explore the code and make notes. 5. Now modify the above code as mentioned in objectives above and check for causality.
RESULT:
EXERCISE:
1. What will happen if we input x( n) = {0, 0,1, 0, 0} into the above system.
2. Can you prove commutative property of the convolution? 3. Modify the code to prove Associative and Distributive properties of the convolution
-8-
Lab session 04
Department of Electrical Engineering
THEORY:
1. Correlation is given as: rxy (l ) =
n =
lag. This is called cross-correlation and it gives the magnitude and location of similarity between two signals. The correlation between y(n) and x(n) is not necessarily the same as the correlation between x(n) and y(n). It is given as:
ryx (l ) =
n =
2. Generally, rxy (l ) = ryx (l ) . These two are the same when x(n) and y(n) are the same signals or when x(n) and y(n) are even symmetric signals. 3. The length of the resulting correlation sequence is N+M-1, where, N and M are the lengths of the two signals 4. Correlation may also be computed using convolution algorithm with a modification that we need to fold one of the signals before applying the convolution. Mathematically, rxy (n) = x(n) y (n) .
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and write the following code:
clear all; close all; clc; n = [0:9]; ph1 = 0; ph2 = 0; x = sin(2*pi*0.1*n + ph1); org_x = 1; nx = [0 : length(x)-1]- org_x + 1;
-9-
Lab session 04
Department of Electrical Engineering
org_y = 1; ny = [0 : length(y)-1]- org_y + 1; rxy = xcorr(x,y); nr = [nx(1)-ny(end) : nx(end)-ny(1)]; [maxR indR] = max(rxy); disp(['The correlation at lag zero is: ' num2str(rxy(find(nr==0))) '.']); disp(['The maximum correlation is at lag ' num2str(nr(indR)) '.']); figure, subplot(3,1,1), stem(nx,x); xlabel('Time index n'); ylabel('Amplitude'); xlim([nx(1)-1 nx(end)+1]); title('Signal x(n)'); grid; subplot(3,1,2), stem(ny,y); xlabel('Time index n'); ylabel('Amplitude'); xlim([ny(1)-1 ny(end)+1]); title('Signal y(n)'); grid; subplot(3,1,3) stem(nr,rxy); xlabel('Time index n'); ylabel('Amplitude'); xlim([nr(1)-1 nr(end)+1]); title('Cross Correlation'); grid;
3. Save the file as P041.m in your current directory and run it. 4. Learn the specific logical bits of the code and make notes. 5. Now modify the phase of the second signal to pi/2 (it will make it cosine) and observe the correlation at lag zero. Modify the phase again to pi and observe. 6. Check for auto-correlation (ph1 = ph2) that the lag zero value gives the energy of the signal. 7. Observe that the commutative property does not hold.
RESULT:
EXERCISE:
Modify the code, such that the correlation is obtained using convolution command.
- 10 -
Lab session 05
Department of Electrical Engineering
LAB SESSION 05 Studying Time Frequency Characteristics using Continuous Time Fourier Series
OBJECTIVE:
1. Generate a square wave in time domain with certain time period and pulse width. 2. Apply CTFS equation to compute spectral coefficients. 3. Observe the plot to verify the properties mentioned above. 4. Modify time-periods and pulse widths to assess the corresponding change in frequency domain.
THEORY:
In this session, we will explore the relation between time domain properties of the signal (Time period and Pulse Width) and frequency domain properties (Spectral density and Lobe width) using CTFS equations. The Analysis equation for CTFS is given as: cK =
Fundamental Frequency and is the inverse of the Time period of the signal. 1. The spectral spacing of the spectrum is equal to the inverse of the time period of the signal. 2. The Lobe width of the spectrum is equal to the inverse of the pulse width of the signal.
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and write the following code:
clear all; clc; close all; Ts = 0.001; cont time t = [-10:Ts:9.999 ]; Tp = 1; tau = 0.5; %sampling period - so small to approximate % Time Vector - again approx. continuous % Time Period of the signal % Pulse Width - Duty Cycle % Generating Square wave
- 11 -
Lab session 05
Department of Electrical Engineering
% Extracting a portion of the signal equal to its period. I_period = find(round(t*1000)/1000 == -Tp/2) : find(round(t*1000)/1000 == Tp/2); xport = x( I_period ); figure, plot(t(I_period),xport); xlabel('secs') ylim([-1.2 1.2]) pause % Press any key % Computing CTFS Coefficients for k = 1:20 B = exp(-j*2*pi*(k-1)*Fo.*[-Tp/2:Ts:Tp/2]); C(k) = sum(xport.*B)/(length(xport)*Tp); end kFo = Fo*[0:k-1]; % Frequency Scale in Hz. figure, stem(kFo,abs(C)); title('CTFT Coefficients'); xlabel('Hz');
RESULT:
Explain (write) in your own words the cause and effects of what you just saw.
EXERCISE:
Now make the following modifications one by one and observe the effects. a. Change Tp to 2 secs and then to 0.5 secs. b. Change tau to 0.2. c. Change tau to 0.001 and see the spectra. d. Change tau to 1 and observe the spectra. Make notes about all observations and learn to play around with the code. Note: Do not change the sampling time, as this is an artificially made continuous-time signal. Also, do not increase Tp than 10 secs and reduce below 0.05 secs.
- 12 -
Lab session 06
Department of Electrical Engineering
1.
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Copy the audio file noisy.wav into your current directory. 3. Open M file editor and write the following code:
clear all; clc; close all; [y,Fs,bits] = wavread('noisy.wav'); Ts = 1/Fs; n = [0:length(y)-1]; t = n.*Ts; k = n; Df = Fs./length(y); F = k.*Df; Y = fft(y); magY = abs(Y); sound(y,Fs); figure, subplot(2,1,1); plot(F,magY); grid on; xlim([0 Fs/2]); xlabel('Frequency (Hz)'); ylabel('DFT Magnitude'); title('Discrete Fourier Transform'); subplot(2,1,2); plot(F,magY); grid on;
- 13 -
Lab session 06
Department of Electrical Engineering
4. Save the file as P081.m in your current directory and run it.
RESULT:
Explore and take notes.
EXERCISE
Try and remove the tone spikes from the spectra of the noisy signal. Take Inverse DFT (IFFT) of the modified spectra. Listen to this new time-domain signal and see if the tone noise is removed.
Note: This is actually a very crude of way of filtering which is covered later.
- 14 -
THEORY:
The Laplace Transform of a general continuous time signal x (t) is defined as;
X(S) =
x(t ) e
-st
dt.
Where the complex variable s= + j w, with and w the real and imaginary parts. CTFT is a subset of Laplace when =0. Since information is not present in CTFT, therefore information about stability can only be obtained from Laplace. If pole lies on L.H.S of splane, system is stable. If pole lies on R.H.S of s-plane, system is unstable. If pole lies on y(jw)-axis, system is marginally stable or oscillatory. If system has FIR, it is stable. If system is IIR, it can be stable or unstable.
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and write the following code:
clear all; close all; clc; Num = poly([(0-(i*(pi/2))),(0+(i*(pi/2)))]); Zeros=roots(Num) Den = poly([-1,-1]); poles=roots(Den) sys=tf(Num,Den) figure; subplot(3,1,1); pzmap(sys); xlim([-2 2]); ylim([-4 4]);
- 15 -
3. Save the file as P091.m in your current directory and run it.
RESULT:
1. Learn the specific logical bits of the code and make notes. 2. Observe the plots. 3. Now, explain (write) in your own words the cause and effects of what you just saw.
EXERCISE:
Change the location of poles from L.H.S of s-plane to y axis first, and then to R.H.S of splane and observe the effects.
- 16 -
THEORY:
The z - Transform of a general discrete time signal x(n) is defined as;
n=
X (z) =
Where the complex variable z=r w , with r the radius and w the angle. DTFT is a subset of z transform when r =1. Since r information is not present in DTFT, therefore information about stability in discrete time can only be obtained from z transform. If pole lies inside the unit circle, system is stable. If pole lies outside the unit circle, system is unstable. If pole lies at the unit circle, system is marginally stable or oscillatory. If system has FIR, it is stable. If system is IIR, it can be stable or unstable.
n =
x (n) z
-n
PROCEDURE:
1. Make a folder at desktop and name it as your current directory within MATLAB. 2. Open M-file editor and write the following code:
clear all; close all; clc; Num = poly([(0-(i*(pi/2))),(0+(i*(pi/2)))]); Den = poly([-1,-1]); Num1 = poly([j,-j]); Den1 = poly([exp(-1),exp(-1)]); sys1=tf(Num1,Den1,1) figure; subplot(3,1,1); pzmap(sys1); xlim([-2 2]); ylim([-4 4]); subplot(3,1,2); [mag phase w]=bode(sys1);
- 17 -
3. Save the file as P010.m in your current directory and run it.
RESULT:
1. Learn the specific logical bits of the code and make notes. 2. Observe the plots. 3. Now, explain (write) in your own words the cause and effects of what you just saw.
EXERCISE:
Change the location of poles from inside the unit circle to outside and at the unit circle and observe the effects.
- 18 -
Lab session 08
Department of Electrical Engineering
THEORY:
1. FIR filters are Finite Impulse Response filters with no feedback, whereas IIR contains feedback. 2. Transfer function of FIR filter does not contain any non-trivial poles. Their frequency response is solely dependent on zero locations. IIR filters contain poles as well as zeros. 3. As there are no poles, FIR filters cannot become unstable; however, IIR filters can become unstable if any pole lies outside the unit circle in z-plane. 4. More number of coefficients is needed to design the desired filter in FIR than IIR.
PROCEDURE:
1. Write the following code for FIR filters:
close all; clear all; clc; % Frequencies in Hz. F1 = 100; F2 = 150; % Sampling Frequency in samples/sec. Fs = 1000; t = [0 : 1/Fs : 1]; % Time Vector F = Fs*[0:length(t)-1]/length(t); % Frequency Vector x = exp(j*2*pi*F1*t)+2*exp(j*2*pi*F2*t); % Signal Vector bh = fir1( 64 , [125 175]/500); % filter coeffs. for bandpassing F1 bl = fir1( 64 , [75 125]/500); % filter coeffs. for bandpassing F2
- 19 -
Lab session 08
Department of Electrical Engineering
[hh,wh]=freqz(bh,1,length(t),'whole'); % Frequency response for filter 1 [hl,wl]=freqz(bl,1,length(t),'whole'); % Frequency response for filter 2 % Filter operation - see filtfilt in help to learn what it does yh = filtfilt(bh,1,x); yl = filtfilt(bl,1,x); % Plotting figure, subplot(5,1,1),plot(F,abs(fft(x)));xlim([0 Fs/2]); title('FFT of orgianl signal'); subplot(5,1,2),plot(F,abs(hh));xlim([0 Fs/2]); title('Frequency response of Filter One'); subplot(5,1,3),plot(F,abs(fft(yh)));xlim([0 Fs/2]); title('FFT of filtered signal from filter one'); subplot(5,1,4),plot(F,abs(hl));xlim([0 Fs/2]); title('Frequency response of Filter Two'); subplot(5,1,5),plot(F,abs(fft(yl)));xlim([0 Fs/2]); title('FFT of filtered signal from filter two'); xlabel('Hz.') % Pole Zero Constellations [bh,ah] = eqtflength(bh,1); [zh,ph,kh] = tf2zp(bh,ah); [bl,al] = eqtflength(bl,1); [zl,pl,kl] = tf2zp(bl,al); figure, subplot(1,2,1),zplane(bh,ah);xlim([-1.5 1.5]);ylim([-1.5 1.5]); title('Filter One'); subplot(1,2,2),zplane(bl,al);xlim([-1.5 1.5]);ylim([-1.5 1.5]); title('Filter Two');
2. Note the observations from frequency response and pole-zero constellation plots. 3. Now, write the code in another program for IIR filters:
close all; clear all; clc; % Frequencies in Hz. F1 = 100; F2 = 150; % Sampling Frequency in samples/sec. Fs = 1000; t = [0 : 1/Fs : 1]; % Time Vector F = Fs*[0:length(t)-1]/length(t); % Frequency Vector x = exp(j*2*pi*F1*t)+2*exp(j*2*pi*F2*t); % Signal Vector
- 20 -
Lab session 08
Department of Electrical Engineering
[bh,ah] = butter(6,[125 175]/500);% filter coeffs. for bandpassing F1 [bl,al] = butter(6,[75 125]/500);% filter coeffs. for bandpassing F2 [hh,wh]=freqz(bh,ah,length(t),'whole'); % Frequency response for filter 1 [hl,wl]=freqz(bl,al,length(t),'whole'); % Frequency response for filter 2 % Filter operation - see filtfilt in help to learn what it does yh = filtfilt(bh,ah,x); yl = filtfilt(bl,al,x); % Plotting figure, subplot(5,1,1),plot(F,abs(fft(x)));xlim([0 Fs/2]); title('FFT of orgianl signal'); subplot(5,1,2),plot(F,abs(hh));xlim([0 Fs/2]); title('Frequency response of Filter One'); subplot(5,1,3),plot(F,abs(fft(yh)));xlim([0 Fs/2]); title('FFT of filtered signal from filter one'); subplot(5,1,4),plot(F,abs(hl));xlim([0 Fs/2]); title('Frequency response of Filter Two'); subplot(5,1,5),plot(F,abs(fft(yl)));xlim([0 Fs/2]); title('FFT of filtered signal from filter two'); xlabel('Hz.') % Pole Zero Constellations [bh,ah] = eqtflength(bh,ah); [zh,ph,kh] = tf2zp(bh,ah); [bl,al] = eqtflength(bl,al); [zl,pl,kl] = tf2zp(bl,al); figure, subplot(1,2,1),zplane(bh,ah);xlim([-1.5 1.5]);ylim([-1.5 1.5]); title('Filter One'); subplot(1,2,2),zplane(bl,al);xlim([-1.5 1.5]);ylim([-1.5 1.5]); title('Filter Two');
4. Note the observations from frequency response, pole-zero constellation. 5. Compare plots across FIR and IIR.
- 21 -
Lab session 09
Department of Electrical Engineering
LAB SESSION 09 Generation of sine waves using lookup table using C-6713 DSK
OBJECTIVE:
To generate a sinusoid and plotting it with Code Composer Studio (sine8_buf).
REQUIREMENTS:
C6713 DSK(DSP Starter Kit) and its support tools Oscilloscope Head phones/ Speaker
THEORY:
This exercise generates a sinusoid with eight points. More important, it illustrates CCS capabilities for plotting in both time and frequency domains. The program used in this exercise creates a buffer to store the output data in memory.
Buffer:
Buffer is an array in which data to be written or to be read from the disk is placed. Putting the contents of a file in a buffer has certain advantages; we can perform various operations on the contents of buffer without having to access the file again. The size of the buffer is important for efficient operation. Depending on the operating system, buffers of certain sizes are handled more efficiently than others. In this program, an output buffer is created to capture a total of 256 sine data values.
Interrupt:
An interrupt can be issued internally or externally. An interrupt stops the current CPU process so that it can perform a required task initiated by the interrupt. The source of the interrupt can be an ADC, timer etc. On an interrupt; the conditions of the current process must be saved so that they can be restored after the interrupt task is performed.
PROCEDURE:
1. Connect DSK C6713 board to the USB port of PC and give +5V supply to the board. 2. Perform the diagnostic and quick tests of DSK (refer to Appendix A). 3. Connect the DSK by selecting Debug Connect, if it has not already been connected.
- 22 -
Lab session 09
Department of Electrical Engineering
4. Create New Project (refer to Appendix B).5.Add files to the project (refer to Appendix C). 6. Bulid the program (refer to Appendix D). 7. Select File Load Program in order to load sine_buf.out on the DSK. 8. Connect a speaker to the LINE OUT connector on the DSK 9. Select Debug Run.
OBSERVATION:
A tone of 1 kHz can be heard on speaker or can be viewed on an oscilloscope.
EXERCISE:
Plotting with Code Composer Studio (CCS):
To plot the current output data stored in the buffer using CCS, perform following steps: 1. Select View Graph Time/Frequency. Change the Graph Property Dialog so that the options in Figure 2.1 are selected for a time-domain plot. The other options can be left as default. Press OK and observe the wave pattern in time-domain within CCS. 2. Now change CCS Graph Property Dialog for a frequency-domain plot according to Figure 2.2. Press OK and observe the FFT magnitude plot. The spike at 1000Hz represents the frequency of the sinusoid generated.
Display Type Graph Title Start Address Acquisition Buffer Size Index Increment Display Data Size DSP Data Type Q-value Sampling Rate (Hz) Plot Data From Left-shifted Data Display Autoscale DC Value Axes Display Time Display Unit Status Bar Display
Single Time Graphical Display out_buffer 256 1 64 16-bit signed integer 0 8000 Left to Right Yes On 0 On S On
Figure 2.1
- 23 -
Lab session 09
Department of Electrical Engineering
Display Type Graph Title Signal Type Start Address Acquisition Buffer Size Index Increment FFT Frame Size FFT Order FFT Windowing Function Display Peak and Hold DSP Data Type Q-value Sampling Rate (Hz) Plot Data From Left-shifted Data Display Autoscale
FFT Magnitude Graphical Display Real out_buffer 256 1 256 8 Rectangle Off 16-bit signed integer 0 8000 Left to Right Yes On
Figure 2.2
- 24 -
Lab session 10
Department of Electrical Engineering
REQUIREMENTS:
C6713 DSK(DSP Starter Kit) and its support tools Oscilloscope Function Generator Head phones/ Speaker
THEORY:
This lab session illustrates input and output with the codec. This program example is very important since it can be used as a base program to build on. For example, to implement a digital filter, one would need to insert the appropriate algorithm between the input and output functions. An interrupt occurs every sample period Ts=1/Fs at which time an input sample value is read from the codecs ADC and then sent as output to the codecs DAC.
Interrupt:
An interrupt can be issued internally or externally. An interrupt stops the current CPU process so that it can perform a required task initiated by the interrupt. The source of the interrupt can be an ADC, timer etc. On an interrupt; the conditions of the current process must be saved so that they can be restored after the interrupt task is performed.
Loop:
We frequently need to perform an action over and over, often with variations in the details each time. The mechanism that meets this need is the loop. In programming, it is often the case that you want to do something a fixed number of times. The loop is ideally suited for such cases. There are three major loop structures in C: the for loop, the while loop and the do while loop. The program in this exercise uses while loop
PROCEDURE:
1. Connect DSK C6713 board to the USB port of PC and give +5V supply to the board. 2. Perform the diagnostic and quick tests of DSK (refer to Appendix A).
- 25 -
Lab session 10
Department of Electrical Engineering
3. Connect the DSK by selecting Debug Connect, if it has not already been connected. 4. Create New Project (refer to Appendix B). 5. Add files to the project (refer to Appendix C). 6. Build the program (refer to Appendix D). 7. Select File Load Program in order to load loop_intr.out on the DSK. 8. Input a sinusoidal waveform to the LINE IN connector on the DSK with an amplitude of approximately 2V p-p and a frequency between approximately 1and 3 kHz. 9. Select Debug Run.
OBSERVATION:
A tone of same input frequency, but attenuated to approximately 0.8V p-p, can be heard on speaker or can be viewed on an oscilloscope connected to the LINE OUT connector of the DSK.
EXERCISE:
Increase the amplitude of the input sinusoidal waveform beyond 6V p-p and observe that the output signal becomes distorted. This is because; the maximum level of the input signal to the codec is 6 Vp-p.
- 26 -
Lab session 11
Department of Electrical Engineering
REQUIREMENT:
1. C6713 DSK(DSP Starter Kit) and its support tools 2. Oscilloscope 3. Function Generator
THEORY:
The DFT converts a time - domain sequence into an equivalent frequency domain sequence. The inverse DFT performs the reverse operation and converts a frequency - domain sequence into an equivalent time - domain sequence. The FFT is a very efficient algorithm technique based on the DFT but with fewer computations required. The FFT is one of the most commonly used operations in digital signal processing to provide a frequency spectrum analysis.
PROCEDURE:
1. Connect DSK C6713 board to the USB port of PC and give +5V supply to the board.
2. Perform the diagnostic and quick tests of DSK (refer to Appendix A). 3. Connect the DSK by selecting Debug Connect, if it has not already been connected. 4. Create New Project (refer to Appendix B). 5. Add files to the project (refer to Appendix C). 6. Build this project as DFT (refer to Appendix D). The input x(n) is a cosine with N=8 data points. To test the results, load the program. 7. Select view, Watch Window and insert the two expressions j and out(right click on the Watch window). Click on +out to expand and view out[0] and out[1], which represent the real and imaginary components respectively. 8. Place a break point at the bracket } that follows the DFT function call.
- 27 -
Lab session 11
Department of Electrical Engineering
OBSERVATION:
1. Select Debug, Animate(Animation speed can be controlled through j=1 and at j=7, while small otherwise. Since x(n) is a one-cycle sequence, m=1. Since the number of points is N=8, a spike occurs at j=m=1 used to verify these results. 2. Note that the data values in the table are rounded (yielding a spike with a maximum value of 3996 in lieu of 4000). Since it is a cosine, the imaginary component out[1] is zero(small). In a real time implementation, with Fs=8KHz, the frequency generated would be at f=Fs(number of cycles)/N=1KHz.
EXERCISE:
Use the two-cycle sine data table (in the program) with 20 points as input x (n). Within the program, change N to 20, comment the table that corresponds to the cosine (first input), and instead use the sine table values. Rebuild and animate again. Verify a large negative value at j=N-m=18 (10,232). For a real time implementation, the magnitude of X (k), k=0,1,. can be found. With Fs=8 KHz, the frequency generated would corresponds to f=800 Hz.
- 28 -
Lab session 12
Department of Electrical Engineering
OBJECTIVE:
FIR Filter implementation: Bandstop centered at 2700Hz (FIR).
REQUIREMENTS:
1. C6713 DSK(DSP Starter Kit) and its support tools 2. Oscilloscope 3. Function Generator
THEORY:
A digital filter operates on discrete time signals ad can be implemented with a digital signal processor.. This involves the use of an ADC to capture an external input signal, processing the input samples, and sending the resulting output through a DAC. Digital filters are more reliable, accurate and less sensitive to temperature and aging. Stringent magnitude and phase characteristics can be achieved with a digital filter. Also filer characteristics such as centre frequency, bandwidth ad filter type can readily be modified can readily be modified transform is utilized for the analysis of discrete time signals, similar to the Laplace transform for continuous time signals.
PROCEDURE:
1. Connect DSK C6713 board to the USB port of PC and give +5V supply to the board. 2. Perform the diagnostic and quick tests of DSK (refer to Appendix A). 3. Connect the DSK by selecting Debug Connect, if it has not already been connected. 4. Create New Project (refer to Appendix B). 5. Add files to the project (refer to Appendix C). 6. Build the program (refer to Appendix D). 7. Select File Load Program in order to load FIR.out on the DSK 8. Input a sinusoidal signal and vary the input frequency slightly below and above 2700 Hz.
- 29 -
Lab session 12
Department of Electrical Engineering
OBSERVATION:
Verify that the output of bandstop filter is a minimum at 2700Hz.
EXERCISE:
Within CCS, edit the program FIR.c to include the coefficient file bp1750.cof in lieu of bs2700.cof. The file bp1750.cof represent an FIR bandpass filter centered at 1750 Hz. The coefficients can be obtained from FDA tool of MATLAB.
- 30 -
Appendices
Department of Electrical Engineering
APPENDICES
1. In debug options select connect. A message will appear that the target is now connected. 2. Creating new project.
To create the project file sine8_buff, select Project, New. Type sine8_buf for the project name, as shown in figure 2. This project file is saved in the folder sine8_buf (within C:\CCStudio_v3.1\MyProjects). In target field select TMS320C67XX. Click Finish.
- 31 -
Appendices
Department of Electrical Engineering
3. Adding files to the project. Go to Project, add files to project and do the following:
(a) Look in CCStudio_v3.1. Select folder C6000, change the file of type to All Files and add the following files:(i) Select cgtools, lib, rts6700 and click open.(ii)Select csl, lib, csl6713 and click open.(iii)Select dsk6713, lib, dsk6713bsl and click open.
- 32 -
Appendices
Department of Electrical Engineering
(i) Select folder Support and add the following files (i)C6713dsk (ii)C6713dskinit[Type C file not ASM or H file].(iii)Select Vectors_intr or Vectors_poll according to the requirement of the code. In our program its Vectors_intr. (ii) Select sine8_buf folder and then select sine8_buf type C file. 4. Building Program.
Building the program: (a) Go to project and then build options. (i) In compiler options Basic settings, remove the location from dollar sign to DEBUG and then in quotation marks write the location of sine8_buf i.e C:\CCStudio_v3.1\MyProjects\sine8_buf.
- 33 -
Appendices
Department of Electrical Engineering
(ii) (iii)
In Compiler option Advanced settings change the memory mmodel field to Far{-mem_model:data=far}. In Compiler option Preprocessor settings: (a) In Pre-Define Symbol {-d}, write CHIP_6713. (b) In Include Search Path{-i}, write C:\CCStudio_v3.1\C6000\dsk6713\include.
- 34 -
Appendices
Department of Electrical Engineering
(iv)
In linker Option delete top field from m to before -0. Delete w as well.
(b)Press OK at the end. (c)Press Build Clean in project. (d)Finally press Build to build the program. To open the code go to File, Open, Look in sine8_buf and open sine8_buf C type file.
- 35 -