Documente Academic
Documente Profesional
Documente Cultură
Presented by:
Dep of ECE
BEC
L T/P/D C
0 -/3/- 2
Dep of ECE
BEC
Page No.
Introduction to MATLAB
11
17
19
21
23
25
29
33
36
39
41
43
46
48
converters
List of experiments using CC Studio
Introduction to DSP processors, TMS 320C6745 DSK
Introduction to CC STUDIO
55
63
2) Linear Convolution
68
72
order systems
Dep of ECE
BEC
INRODUCTION
MATLAB: MATLAB is a software package for high performance numerical computation and
Visualization provides an interactive environment with hundreds of 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 mfiles 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
Dep of ECE
BEC
MATLAB Windows:
MATLAB works with through three basic windows
Command Window: This is the main window .it is characterized by MATLAB command Prompt
>> when you launch the application program MATLAB puts you in this window all Commands
including those for user-written programs, are typed in this window at the MATLAB Prompt
Graphics window: the output of all graphics commands typed in the command window are Flushed
to the graphics or figure window, a separate gray window with white background color The user can
create as many windows as the system memory will allow
Edit window: This is where you write edit, create and save your own programs in files called M
files.
Input-output:
MATLAB supports interactive computation taking the input from the screen and flushing, the Output
to the screen. In addition it can read input files and write output files
Data Type: the fundamental data type in MATLAB is the array. It encompasses several distinct
data objects- integers, real numbers, matrices, character strings, structures and cells. There is no need
to declare variables as real or complex, MATLAB automatically sets the variable to be real.
Dimensioning: Dimensioning is automatic in MATLAB. No dimension statements are required for
vectors or arrays .we can find the dimensions of an existing matrix or a vector with the size and
length commands.
Dep of ECE
BEC
Typing quit in the command prompt>> quit, will close MATLAB Matlab Development
Environment.
For any clarification regarding plot etc, which are built in functions type help topic
i.e. help plot
Dep of ECE
BEC
t = [1 2 3 4]
This instruction will display a figure window which indicates the plot of x versus t
Dep of ECE
BEC
11. Subplot: This function divides the figure window into rows and columns.
Subplot (2 2 1) divides the figure window into 2 rows and 2 columns 1 represent number of
the figure
Subplot (3 1 2) divides the figure window into 3 rows and 1 column 2 represent number
of the figure
12. Conv
Syntax: w = conv(u,v)
Description: w = conv(u,v) convolves vectors u and v. Algebraically, convolution is the same
Operation as multiplying the polynomials whose coefficients are the elements of u and v.
13. Disp
Dep of ECE
BEC
BEC
Dep of ECE
10
BEC
1. GENERATION OF SIGNALS
Aim:- To generate the following signals using MAT LAB 2009
1. Unit impulse signal
2. Unit step signal
3. Unit ramp signal
4. Exponential growing signal
5. Exponential decaying signal
6. Sine signal
7. Cosine signal
Apparatus Required:- System with MAT LAB 2009
Algorithm:1. Get the number of samples.
2. Generate the unit impulse, unit step using ones, zeros matrix command.
3. Generate ramp, sine, cosine and exponential signals using corresponding general formula.
4. Plot the graph.
Program:
Dep of ECE
11
BEC
Dep of ECE
12
BEC
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('Unit Ramp Response');
Output:UNIT RA MP SIGNAL
Enter Number of Samples: 6
Enter Amplitude: 20
Dep of ECE
13
BEC
Dep of ECE
14
BEC
6. Cosine signal
clc;
clear all;
close all;
dis p('COSINE SIGNAL ');
N=input(' Enter Number of Samples : ');
n=0: 1: N;
x=cos(n);
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('Cosine Signal');
Output:COSINE SIGN AL
Enter Number of Samples : 16
Dep of ECE
15
BEC
7. Sine signal
clc;
clear all;
close all;
disp('SINE SIGNAL ');
N=input(' Enter Number of Samples : ');
n=0: 1: N;
x=sin (n);
stem(n, x);
xlabel('Time');
ylabel('Amplitude');
title('sine Signal');
Output:SINE SIGN AL
Enter Number of Samples: 16
Result:- Thus the MATLAB program for generation of all basic signals was performed and the
output was verified.
Dep of ECE
16
BEC
17
BEC
legend('y','y1','y2','y3','y4',' y5');
title ('generation of sum of sinusoidal signals');
grid on;
ylabel('---> Amplitude');
xlabel('---> t');
toc;
Output:Result: - Thus the MATLAB program for sum of sinusoidal signals was performed and the
output was Verified.
Dep of ECE
18
BEC
Dep of ECE
19
BEC
xlabel('time index');
ylabel('h[n]');
title('Impulse response');
figure(2);
zplane(b,a);
xlabel('Real part');
ylabel('Imaginary part');
title('Poles and Zeros of H[z] in Z-plane');
Output:Difference Equation of a digital system
Desired Impulse response length = 100
Coefficients of x[n] terms = 1
Coefficients of y[n] terms = [1 -1 0.9]
Result:-Thus the MATLAB program for Impulse Response of Difference Equation was
performed and the output was verified
Dep of ECE
20
BEC
21
BEC
grid on;
Output:Result: - Thus the MATLAB program for Frequency Response of Difference Equation was
performed and the output was verified.
Note: - If the transfer function is given instead of difference equation the n perform the inverse ZTransform and obtain the difference equation and then find the frequency response for the
difference equation using Matlab.
Dep of ECE
22
BEC
23
BEC
f = 1000*(0:256)/512;
figure,plot(f,Pyy(1:257));
title('Frequency content of y');
xlabel('frequency (Hz)');
Output:Result: - Thus the MATLAB program for Power Spectral Density was performed and the
output was verified.
Dep of ECE
24
BEC
25
BEC
26
BEC
end
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1,beta);
disp('kaiser window filter response');
end
%LPF
b=fir1(n,wp,y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
title('LPF');
ylabel('Gain in dB-->');
xlabel('(a) Normalized frequency-->');
Output:enter pass band ripple0.02
enter the stop band ripple0.01
enter pass band freq1000
enter stop band freq1500
enter sampling freq10000
enter beta value
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
Dep of ECE
27
BEC
1
Rectangular window filter response
enter your choice of window function 1. Rectangular 2. triangular 3.kaiser:
2
Triangular window filter response
enter beta value5
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
3
kaiser window filter response
Result:- Thus FIR LP Filter is designed for Rectangular/triangular/kaiser windowing techniques
using MATLAB.
Dep of ECE
28
BEC
29
BEC
30
BEC
if (c==2)
y=triang(n1);
disp('Triangular window filter response');
end
if(c==3)
y=kaiser(n1,beta);
disp('kaiser window filter response');
end
%HPF
b=fir1(n,wp,'high',y);
[h,o]=freqz(b,1,256);
m=20*log10(abs(h));
plot(o/pi,m);
title('HPF');
ylabel('Gain in dB-->');
xlabel('(b) Normalized frequency-->');
Output:enter pass band ripple0.02
enter the stop band ripple0.01
enter pass band freq1000
enter stop band freq1500
enter sampling freq10000
enter beta value
enter your choice of window function 1. rectangular 2. triangular 3.kaiser:
1
Dep of ECE
31
BEC
Dep of ECE
32
BEC
33
BEC
12) Give relevant names to x and y axes and gives an appropriate title for the plot.
13) Plot all the responses in a single figure window.[Make use of subplot]
Procedure:1) Open MATLAB
2) Open new M- file
3) Type the program
4) Save in current directory
5) Compile and Run the program
6) For the output see command window\ Figure window
Program:% IIR filters
clc;
clear all;
close all;
warning off;
disp('enter the IIR filter design specifications');
rp=input('enter the passband ripple');
rs=input('enter the stopband ripple');
wp=input('enter the passband freq');
ws=input('enter the stopband freq');
fs=input('enter the sampling freq');
w1=2*wp/fs;w2=2*ws/fs;
[n,wn]=buttord(w1,w2,rp,rs,'s');
disp('Frequency response of IIR HPF is:');
[b,a]=butter(n,wn,'low','s');
Dep of ECE
34
BEC
35
BEC
36
BEC
37
BEC
w=0:.01:pi;
[h,om]=freqs(b,a,w);
% Plot the frequency response
m=20*log10(abs(h));
subplot(2,1,1);
plot(om/pi,m);
title('magnitude response of IIR High Pass filter is:');
xlabel('(a) Normalized freq. -->');
ylabel('Gain in dB-->');
an=angle(h);
subplot(2,1,2);
plot(om/pi,an);
title('phase response of IIR High Pass filter is:');
xlabel('(b) Normalized freq. -->');
ylabel('Phase in radians-->');
Output:enter the IIR filter design specifications
enter the pass band ripple 0. 15
enter the stop band ripple 60
enter the pass band freq1500
enter the stop band freq3000
enter the sampling freq7000
Frequency response of IIR HPF is:
Result:- Thus IIR High Pass Filter is designed using MATLAB.
Dep of ECE
38
BEC
Dep of ECE
39
BEC
Dep of ECE
40
BEC
Dep of ECE
41
BEC
42
BEC
Digital Audio
Communications systems
Speech Processing
Antenna Systems
Radar Systems etc
Sampling rates may be changed upward or downward. Increasing the sampling rate is called
interpolation, and decreasing the sampling rate is called decimation. Reducing the sampling rate
by a factor of M is achieved by discarding every M-1 samples, or, equivalently keeping every
Mth sample. Increasing the sampling rate by a factor of L (interpolation by factor L) is achieved
by inserting L-1 zeros into the output stream after every sample from the input stream of
samples. This system can perform SRC for the following cases:
Decimation by a factor of M
Interpolation by a factor of L
SRC by a rational factor of L/M.
Decimator:
To reduce the sampling rate by an integer factor M, assume a new sampling period
The re-sampled signal is
The system for performing this operation, called down-sampler, is shown below:
Down-sampling generally results in aliasing. Therefore, in order to prevent aliasing, x(n)
should be filtered prior to down-sampling with a low-pass filter that has a cutoff frequency
The cascade of a low-pass filter with a down-sampler illustrated below and is called
decimator.
Dep of ECE
43
BEC
44
BEC
title('Output Sequence');
xlabel('Time index n');ylabel('Amplitude');
Output:enter Down-sampling factor : 3
enter number of samples :100
Result: - Thus Decimation Process is implemented using Mat lab.
Note: - Observe the Output Sequence for Different values of M.
Dep of ECE
45
BEC
46
BEC
Dep of ECE
47
BEC
Dep of ECE
48
BEC
Dep of ECE
49
BEC
CYCLE 2
Dep of ECE
50
BEC
Dep of ECE
51
BEC
Dep of ECE
52
BEC
Dep of ECE
53
BEC
Dep of ECE
54
BEC
TIs Code Composer Studio development tools are bundled with the 6713DSK providing the
user with an industrial-strength integrated development environment for C and assembly
Programming. Code Composer Studio communicates with the DSP using an on-board JTAG
emulator through a
USB interface.
The TMS320C6713 DSP is the heart of the system. It is a core member of Texas Instruments C64X
line of fixed point DSPs whose distinguishing features are an extremely high performance 225MHz
VLIW DSP core and 256Kbytes of internal memory. On-chip peripherals include a 32- bit external
memory interface (EMIF) with integrated SDRAM controller, 2 multi-channel buffered serial ports
(McBSPs), two on-board timers and an enhanced DMA controller (EDMA). The 6713 represents the
high end of TIs C6700 floating point DSP line both in terms of computational performance and onchip resources. The 6713 has a significant amount of internal memory so many applications will
have all code and data on-chip. External accesses are done through the EMIF which can connect to
both synchronous and asynchronous memories. The EMIF signals are also brought out to standard TI
expansion bus connectors so additional functionality can be added on daughter card modules. DSPs
are frequently used in audio processing applications so the DSK includes an on-board codec called
the AIC23. Codec stands for coder/decoder, the job of the AIC23 is to code analog input samples
into a digital format for the DSP to process, then decode data coming out of the DSP to generate the
processed analog output. Digital data is sent to and from the codec on McBSP1.
55
BEC
Dep of ECE
56
BEC
57
BEC
58
BEC
6. file.lib: library file, such as the run-time support library file rts6701.lib.
7. file.cmd: linker command file that maps sections to memory.
8. file.obj: object file created by the assembler.
9. file.out: executable file created by the linker to be loaded and run on the processor.
Procedure to work on code composer studio
1.Click on CCStudio 3.1 on the desktop
Now the target is not connected in order to connect Debugconnect
2. To create project, Project New
Digital Signal Processing Lab Manual
Page 65
59
BEC
Dep of ECE
60
BEC
61
BEC
Dep of ECE
62
BEC
Program
Sine Wave
#include <stdio.h>
#include <math.h>
float a[500];
void main()
{
int i=0;
for (i=0;i<500;i++)
{
a[i]=sin(2*3.14*10000*i);
}
}
Square wave
#include <stdio.h>
#include <math.h>
int a[1000];
void main()
{
int i,j=0;
int b=5;
for(i=0;i<10;i++)
Dep of ECE
63
BEC
Output:Sine wave
Square wave:Result: - The sine wave and square wave has been obtained.
2. Linear Convolution
Aim: -To verify Linear Convolution.
Equipments:
Procedure:1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using Project New pull down menu, save it in a separate directory
(C:\My projects) with file name linearconv.pjt
3. Create a new source file using File New Source file menu and save it in the project
folder (linearconv.c)
Dep of ECE
64
BEC
65
BEC
66
BEC
Power supply Procedure:1. Open Code Composer Setup and select C6713 simulator, click save and quit
2. Start a new project using ProjectNew pull down menu, save it in a separate directory
(C:\My projects) with file name impulseresponse.pjt
Dep of ECE
67
BEC
68
BEC
69
BEC
70
BEC
2.
In WorkSpace Launcher.
a.
BROWSE Select the project location and make one new folder, MAKE NEW FOLDER
Type the Workspace name, OK OK.
3.
a.
b.
c.
d.
e.
f.
g.
h.
i.
j.
4.
Dep of ECE
NEXT
NEXT NEXT.
FINISH
71
BEC
c.
FILE SAVE.
5.
a.
b.
c.
6.
Paste the Linker file in the project location.(linker file is available in cd)
a.
OK.
a.
IN C/C++ BUILD, INCLUDE OPTIONS (Add dir to #include search path(--include path,I)) select this add icon and add the following three path by individually
"${Diag}../../common/header"
"${XDAIS_CG_ROOT}/packages/ti/xdais"
"${C6000_CSL_CG_ROOT}/include"
8.
a.
b.
c.
Device: TMS320C6745. SAVE TARTGET CONFIGURATION C674X_0
BROWSE, browse the workspace location, open the gel folder and select the GEL file. OPEN
SAVE.
9.
10.
Connections :
a.
b.
11.
TARGET DEBUG ACTIVE PROJECT.(Then see out at corresponding place after run)
Dep of ECE
72
BEC
TARGET RUN.
15.
TARGET HALT.
0xC0001030 00000001....
AIM:
To generate the waveforms of Sine Wave signal
SOFTWARE USED:
CC Studio v4
HARDWARE USED:
void main()
Dep of ECE
73
BEC
sampt = 1/sampf;
nsamp = sampf/inpf;
for(count=0;count<nsamp;count++)
{
teta = (2 * PI * inpf * sampt * count);
printf("\nteta = %lf",teta);
value = sin(teta)*1024;
printf("\t sin %lf Value is : %d",teta,value);
Dep of ECE
74
BEC
Dep of ECE
75
BEC