You are on page 1of 6

2.14/2.

140 Analysis and Design of Feedback Control Systems, Spring 2009


Lab Hardware and Software Quick Guide
February 8, 2009 (Rev. 3)

The 2.14/2.140 laboratory is located in the Mechatronics Teaching Lab, room 1-004. The purpose
of this document is to give you a quick start on using the core lab equipment and software with
some basic examples. Please refer to the user manuals of individual equipment for more details,
which can be found on the course Stellar site.

1 Computer Access

There are 12 workstations located on benches throughout the lab and a network printer for you to
use. You may log in to any computer by using your Mechanical Engineering Departmental username
and password, since all the computers in the lab are on the ME domain. If you are not sure whether
you can access ME domain computers, please stop by the Mechanical Engineering Undergraduate
Office in Room 1-110 and verify your account. Upon a successful login, your personal Z: drive on
the ME server will be automatically mapped to your workstation - a link to it will be placed on
the desktop. Note that any data that is not saved to your Z: drive will be deleted when
you log out.

2 Starting MATLAB

A shortcut to MATLAB can be found in the Start Menu, as can be seen in Fig. 1.

Figure 1: Start Menu shortcut to MATLAB.

When it is loading, you will be prompted to select which real time interface (RTI) that you wish
to use. As indicated in Fig. 2, select RTI1104.

Shortly thereafter, you will be presented with a second dialog, seen in Fig. 3, indicating that some
Configuration Preferences need to be modified. As the figure suggests, select Set Preferences
automatically.

Once MATLAB is finished loading, launch Simulink by clicking on the icon located in the

1
Figure 2: Select RTI1104 when prompted.

Figure 3: Select to set the preferences automatically when prompted.

2
shortcuts toolbar or by typing simulink at the command prompt.

3 Running Simulink and dSPACE

This next section will guide you on how to construct a Simulink model that can be executed on
the dSPACE DS1104 R&D Controller Board.

1. After Simulink has finished loading (see 2), the rtiib1104 Library window should appear (see
Fig. 4). This window contains all of the building blocks that are at your disposal. Double-
click on the Simulink block to bring out the Simulink Library Browser window. Do the same
on the MASTER PPC block to bring out the 1104 Master PPC window. Form there you can
then drag each block you need to your model workspace.

Figure 4: Simulink and dSPACE screen.

2. Create a new model by selecting File New Model from the menu bar. A new (empty)
window will appear - a blank canvas upon which you will design your model using blocks
from the Library Browser.
Each block in the Simulink model acts as a block in a block diagram. Signals sent through
the block diagram via virtual wires may be manipulated by blocks to perform various math-
ematical operations (e.g., addition, subtraction, integration, etc...).

3
3. Before we construct our model, let us first adjust the models settings. In the new models
window select Simulation Configuration Parameters... from the menu bar. A new
window should appear with a list of pages on the left and the page contents on the right.
Please verify that your model is configured with the settings in Table 1.

Page Parameter Value


Solver Stop Time inf
Solver Type Fixed-step
Fixed Step Size 1e-4
Solver Type ode1
Optimization Block Reduction Off

Table 1: Desired configuration parameters.

4. With the models settings configured, we may proceed to building the model. Here is a
simple model that reads in an analog signal on ADC Channel 5 of the DS1104 DSP board
and outputs an analog signal through DAC Channel 1.

(a) Drag the blocks you need from the Library Browser into your model.
(b) Connect the output of the ADC block to the input of the DAC block by clicking on the
ADC output port, holding down the mouse button while you drag the cursor over the DAC
input port and then releasing the button. At this point, your model should resemble
Fig. 5.

Figure 5: Simulink model.

5. Save your model being sure to change the target directory from one on the C: drive to a
directory in your Z: drive.

6. To compile and upload your model to the DS1104, by selecting Tools Real-Time Workshop
Build Model from the model windows menu bar or by clicking on the Incremental
Build button in the toolbar. Alternatively you can use the hotkey combination Ctrl-B
to build the model. Once the build process is complete, your model will automatically begin
to run on the DS1104 hardware.

4
4 Signal Generator and Scope

In this section you will learn how to create a signal using the signal generator, send it through your
dSPACE model, and measure the resulting output on the oscilloscope.

1. Turn on both the signal generator and oscilloscope (scope). Connect the MAIN output from
the function generator to ADC Channel 5 on the DS1104 using a BNC cable. Use a second
BNC cable to connect the output from DAC Channel 1 on the DS1104 to the Channel 1 input
on the scope.

2. Set the signal generator to output a sine wave with a frequency of roughly 1 kHz.

3. On the scope, display only the channel 1 signal using the CH 1 and CH 2 buttons in conjunction
with the WAVEFORM OFF button. Adjust the horizontal (time) scale to 500 s and the vertical
(voltage) scale to 1 V.

4. Back on the signal generator, adjust the amplitude so that the peak-to-peak signal voltage is
4 V. If necessary, tweak the frequency knob so that the frequency is exactly 1 kHz.

5. Use the Trigger Menu to set the trigger to operate on either Ch 1 or the Auxiliary (Rear
Panel) signal. The auxiliary trigger option uses a square sync pulse of the same frequency
as the actual signal which runs from the function generators SYNC output to an input at the
rear of the scope. In the Horizontal menu set the Trigger Position to 50% and exit the
menu using the CLEAR MENU button near the bottom right of the scopes display.

6. Use the Cursor menu functions to manually measure the signal period and amplitude.

7. Now, use the Measure menu functions to measure the signal period and amplitude.

5 Saving and Plotting Scope Traces

1. To save scope data, insert a formatted (3.5) floppy disk into the oscilloscopes floppy drive.

2. With the waveform that you plan to record on the scopes display, press the Save/Recall
Waveform button on the scope to bring up the Waveform save menu.

3. Press the button corresponding to Save Format, and then choose MathCad from the submenu
to save save data in the MathCad or ASCII format.

4. Press the Save Wfm Ch1/2 button on the main menu to save the file to disk.

5. To read the data into MATLAB, copy the data file from the floppy disk to your working
directory.

6. Assuming that your data was saved with the filename lab1.dat, go to your working directory
in MATLAB and at the prompt type:

5
>> load lab1.dat
>> TimeStep = lab(2);
>> NumberOfPoints = lab(1);
>> x = [0:TimeStep :(NumberOfPoints -1)*TimeStep ];
>> y = data(5:end);
>> plot(x,y);
>> title(Title of the plot);
>> xlabel(Time (sec)), ylabel(Amplitude (V)), grid;

Note that the first four rows of data are header data detailing the record length, sampling
time, etc. The actual data begins at the fifth row of the data vector. The code above shows
you how to generate a time vector for the x-axis.

You might also like