dSpace Tutorial
Overview
• This tutorial is aimed at giving an overview of
the basics for utilizing the dSPACE cards for
data acquisition and signal generation
• It ONLY covers the most basic operations
• If more complex operations are necessary,
there is plenty of information about MATLAB
Simulink and dSpace Control Desk in the web
Overview
• Basically, two elements compose the
configuration of a dSPACE measurement task:
– The SIMULINK model, which is loaded into the
dSPACE card as a real time application
– The dSPACE Control Desk GUI, which enables to
interact with the real time application and to store
data to the host computer hard disk
Overview
• This tutorial shows how to configure the
system for:
– Acquiring two analog signals using the dSPACE
input ports (labelled ADC XX in the card)
– Generating one analog voltage signal from one of
the dSPACE output ports (labelled DAC XX in the
card)
WARNING
• The dSPACE analog input ports (labelled ADC
XX) can measure VOLTAGE signals in the range
+10V and ‐10V
• To avoid damaging/destroying the card….
Before connecting any sensor to the card, one
MUST ensure that the signal voltage comply
with this limitation
Setting Up the Simulink Real Time
Application
Create a work
folder…for example
Desktop/dSpace
demo
Open MATLAB, and
make sure that it is
pointing to the work
folder
Go to New/ Simulink
Model
In the Simulink
Model Window, right
click on the
background, go to
”Model
Configuration
Parameters”
In the Solver tab, Set stop time to ”inf”,
Type to ”fixed step”, Solver to ”ode1” and
step size to the inverse of your desired
sampling frequency (in this case, 1000 Hz)
In the Code Generation tab, set System Target
File to ”rti1104.tlc” (if the Dspace card model is
CP1104). Press OK to apply the changes
Go to the Menu
”View/ Library
Browser”
In the Library
Browser tree, go to
dSPACE RTI1104/
Master PPC
Drag and Drop into
Simulink Workspace
these two items
Drag and Drop into
Simulink Workspace
this item
The ADC boxes read the input voltage
value in the dSPACE input ports
The DAC box sets the
voltage value to be
generated by the
dSPACE output port
From the SIMULINK
Library Browser, go to
Commonly Used Blocks,
Drag and Drop ”Gain”
The Gain Blocks for the ADC
ports must be set to 10, so that
the actual voltage value is
obtained
The Gain Blocks for the DAC
ports must be set to 0.1, so that
the correct voltage value is
generated
By double clicking the ADC/DAC
blocks, a dialog box enables to
select which channel is to be
acquired
From Library
Browser/Commonly Used
Blocks, Drag and Drop ”Out”
Block
Now, Out1 provides the value of
ADC5 in Volts, and Out2 the
value of ADC1 in Volts
Go to Library Browser/
Commonly Used Blocks , Drag
and Drop ”Constant” Block
Now, Constant Block controls
the voltage value to be
generated by the port DAC1
Save the Simulink Model in the
Work Folder
Press the ”Build Model” button
The SIMULINK application is now
loaded into the dSPACE card
In the Work Folder, together
with the Simulink Model, one
can see the files created by the
build process
The most important one is the
*.sdf file, which enables to link
the SIMULINK model with the
Control Desk GUI
Creating a GUI using dSPACE Control
Desk
Open dSPACE Control Desk 5.1
Click New Project + Experiment…
Set the Name of the Project and
the Work Folder
Set the name of the experiment
Check that the platform/device
is ”ds1104”
”Import from File” the sdf file
created when building the
SIMULINK real time application
In the Main Window, go to
”Measurement Configuration” Tab
Go the Triggers/Duration
Triggers/Duration Trigger 1, set
the value to XX seconds…the
value controls the amount of
data shown in the Data Plotters
Go the Recorders/ Recorder
1…then right click, go to
Properties
Enable ”Automatic Export”, set
the Data Folder, set Export
Format to .MAT and enable
”Automatic Save Dialog”
Go to Layouting / Insert
Instrument
A menu is displayed, with all the
displays/controllers that can be
included in the GUI
Drag and Drop two Plotter
windows into the Layout
Workspace
Drag and Drop a ”Display” Box
into the Workspace
Drag and Drop a ”Numeric
Input” Box into the Workspace
To relate the displays/controllers
to the application running in the
card, one uses the variables
tree, associated with .sdf loaded
at the beginning
Expand the tree ”Model
Root”…a reference to each
variable in the SIMULINK model
can be found here
If Out1 is selected, one can see
the associated variable on the
right side
By dragging and dropping this
variable into Plotter 1, one can
link this plotter to the variable
Out1…i.e. the voltage value
measured by ADC5
Similar procedure is followed
with Out2 (plotter 2), Out1
again (Display), Constant
(Numeric Input)
To start the measurement task,
go to Go Online, then Start
Measuring
Now, the indicators are
operating, and the numeric
input controls the voltage value
generated in DAC1
Every variable shown in a plotter
can be recorded in a data file…to
select/deselect them go to
Measurement Configuration
Tab, Recorder
By pressing F9 key, the data
recording starts…the elapsed
time is shown in the lower right
corner
Pressing F12 stops the data
recording…the save dialog
windows is displayed, with the
name file of the exported .mat
The recorded .mat file can be
open within MATLAB in the
usual way to postprocess the
measured data