IntroLab

advertisement
EE422G Signals and Systems Laboratory
Introductory Exercises (Matlab, Simulink, and LabVIEW)
Kevin D. Donohue
September 8, 2010
The following exercises are designed to introduce you to the 3 software packages used in the laboratory
assignments for this course. You will learn how to access the help files and design simple programs
through the Getting Started tutorials for each package. There is no grade for this lab exercise, but take
advantage of this time enhance your skills and knowledge with each package to save time and
frustration on future lab assignments. I recommend taking turns at the keyboard and mouse, unless
someone is already very familiar with these packages. In that case you should allow someone else to
access the software package and help them out. Along the way it is good to try things not in the tutorial
(i.e. “what if” questions) to see if the programs behave in accordance with your predictions.
1.
LabVIEW from National Instruments
This package has dominated data acquisition applications in industry. In recent years it has
developed some very sophisticated programming options as well.
For this exercise, launch the LabVIEW program and follow the instructions for the “Getting
started with LabVIEW Virtual Instruments.” You will create a function generator, adding
controls and indicators to the user interface on the CONTROL PANNEL and functionality to the
simulations of the waveforms through programming g-codes on the BLOCK DIAGRAM.
Once you have completed the function generator (2 SAW waves at different scalings)
demonstrate it works to the TA.
2. Matlab from Mathworks
This package has dominated engineering and scientific program applications for prototyping
algorithms, simulation, and scientific computing. In recent years it has developed powerful data
acquisition interfaces and code translators to port the code to various hardware platforms.
For this exercise, go to the help window on Matlab and then click on the Demo Tab. Expand the
Matlab folder (if necessary).
A) View the 5 minute video on Writing a Matlab Program (3rd video). Make sure the sound is
on, since verbal instructions are given.
B) Run the demo for using the FFT in Matlab
C) Run the demo for FFT for spectral analysis (important since your programming exercise will
be like this script).
D) Run the demo for Graphs and Matrices
E) Run the demo for 2D Plots
F) Run the demo for 3D Plots
G) Run the demo for Lines plots (GUI)
H) Run the demo for Visualizing Sound (GUI)
I) Run the demo for Images and Matrices
1
J) Run the demo for Square Wave from Sine Waves
K) Do not run the Minesweeper and Sliding Puzzle demo, they will lower your IQ.
Your programming assignment:
Down load the mat file from http://www.engr.uky.edu/~donohue/ee422/Data/ee422sig.mat
to your current directory. Then load into your work space with the “>> load ee422sig.mat”
command, 3 variables will be loaded in your workspace (type “whos” to see):
Name
Size
Bytes Class
Attributes
fs
1x1
8 double
sig
1x2000
16000 double
t
1x2000
16000 double
SIG is a sampled sound wave consisting for 2 sinusoids in noise, and T is the corresponding time
axis. The signal was sampled at FS (FS is the sampling rate). The time waveform can be plotted
with >>plot(t,sig).
You need to write a script that will take the FFT of SIG to determine the frequencies of the 2
sinusoids in the noisy signal. Show the TA your fft magnitude plot when finished, as well as
telling him the frequencies you detected.
3. Simulink
Simulink is a graphical programming language the runs on Matlab and is good for simulating
control, signal processing, and communications systems.
For this exercise go the “Getting Started” help for Simulink and build the model in the “creating
a simple model” section, through the CONTENTS tab in the help window. Once built, save it and
simulate it. The result is a sine wave generator. The default frequency is w=1 rad/sec, change it
to 10 rad/sec and show the TA it works.
2
Download