2.737 Mechatronics Introduction to the Real-Time Interface

advertisement
2.737 Mechatronics
Introduction to the Real-Time Interface
February 2, 2000
This quick tutorial is intended to get you started with the hardware and real-time interface. In particular we walk you through simulating a second-order lter with the dSpace
board. The input signal comes from the signal generator, and the output is observed on
the oscilloscope. The lter is constructed using the real-time interface to Simulink. We also
introduce the TRACE tool which can be thought of as a software oscilloscope. Finally, we
introduce COCKPIT which allows you to vary parameters in real time.
The Dreaded Manuals
Although it is rare to nd someone who enjoys reading manuals, it is essential to develop the
skill. Half of the work is just overcoming your fear of the \manual" and opening it up. They
often aren't so bad. (Occasionally they are.) At least skim through the contents so you know
what information is available should you need it later. You rarely need to read more than
small portions of a manual at a time. And after you have gone to the trouble to understand
a ne point that has been bothering you, share your new wisdom with those around you.
Manuals for the Oscilloscope, Signal Generator, and the dSpace systems are available for use
in the lab.
To get you started on this pursuit, read the ten manual pages from dSpace listed in the
next section. They go by quickly and are quite informative.
Reading
This tutorial document is loosely based on some of the material listed below in the RealTimer Interface to Simulink. If you are not yet comfortable with Matlab and Simulink, you
need to get up to speed on these as well.
Chapters 1, 3, 4.1{4.1.2 in Real-Time Interface to Simulink in dSpace User Guide
packets in lab
(optional) Chapters 1{5 in text Mastering Simulink 2
Tutorial
This tutorial will get you started. Please experiment along the way. Consult the manuals as
you go to better understand what you are doing or if you need more help in a certain area.
Creating an input signal on the Signal Generator & Measuring it on the Scope
Turn on the signal generator and scope. Attach the MAIN output on the signal generator to Ch. 1 on the scope with a BNC cable from your lab kit.
Set the signal generator to a square wave with a frequency of approximately 1 kHz.
On the scope display only the channel 1 by using the channel 1 and 2 buttons and the
WAVEFORM OFF. Adjust the timescale to 500 s and the vertical scale to 1 V.
On the signal generator adjust the amplitude so that the signal is 4 V peak-to-peak.
Adjust the frequency so that it is 1 kHz exactly.
Use the Trigger menu to trigger o either Ch. 1 or the Auxiliary (Rear Panel). The
Auxiliary Signal is a square sync pulse of the same frequency as the actual signal. Try
combinations of the two triggers, while switching between square, triangle, and sine
waves, and adjusting the trigger level. Can you explain what you observe? In the
Horizontal menu set Trigger Position to 50% and return to the square wave.
1
Use the Cursor menu to measure the period and amplitude of the signal. Use the
Measure menu to do the same thing.
Play around with some of the other settings on the scope. Refer to the scope manuals
as needed.
For the next section we will want to use an input signal that is a 4 V peak-to-peak
square wave with a period of 16 ms. Create this signal with the wave generator and
display it with the scope. Set the horizontal scale to 2 ms and the vertical scale to 1 V
for both channels.
Real-Time Interface
Login with your username and password.
Start up Matlab and type rtilib at the Matlab prompt.
Type cd z:. Type mkdir introex. Type cd introex. We will store all the example
les here.
Double-click DEMOS and then PT2 with I/O. Double-click the Second order lag and
note the bandwidth of the lter and its damping ratio. Save the model in the folder we
just created. Save it again. (This xes a bug. See Using the Laboratory Computers)
Build the model. This downloads it to the DSP board.
Connect the Wave generator to the scope and your lab kit using a \T" connector at the
scope. Use two wires to bring the signal and ground over to ADC1 and AGND on the
green printed circuit board. Use another two wires to bring DAC1 and DGND over to
a BNC terminal, and connect this to the scope channel 2. This is the same connection
as the one shown in the handout, PreLab 1 (Part B) except for the addition of the \T."
You should see the input and a ltered signal on the scope.
Double-click the TRACE icon on the desktop. Load the trace le pt2 io.trc. Click
on Model Root and select, B:DS1102ADC ADC #1. In the Trace Plots window hit
START. You should see the square wave input. Then hit the multicolored button to
the left of the \i" button. Click on Model Root and this time select B:Slider Gain Out1.
Choose a dierent color for this signal. Then hit OK. Click START. You should see
both signals just as you do on the scope! There is much more to learn about TRACE.
Refer to the TRACE manual for more info.
Double-click on the COCKPIT icon on the desktop. Load the trace le pt2 io.trc.
Select the Control menu and choose Input/Output Controls, and then Slider. Draw the
rectangle for the slider on the window. Double-click the slider. Select \Slider Gain"
and then choose P:Slider Gain.Gain. Then click OK & OK. Click Start. See what
happens as you change the slider gain in real time. You can observe the eects on both
the scope and the TRACE plot. Refer to the COCKPIT manual for more info.
2
Download