CONTROL THEORY 1
Introduction to SIMULINK and the dSPACE System.
1 INTRODUCTION 2
1.1 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.2 Hardware Description . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2 LABORATORY PROCEDURE 2
A USING SIMULINK 3
A.1 Creating a New System Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
A.2 Simulink Menu Items . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
B Using dSPACE system and ControlDesk 7
B.1 Creating a dSPACE Block Diagram . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
B.1.1 Compiling and Downloading Simulink Block Diagram to the dSPACE board . . . . . . . . . . . . . . . . 7
B.2 The ControlDesk Package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
B.2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
B.2.2 Main Window . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
B.3 Procedure for a simple experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
B.3.1 Start ControlDesk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
B.3.2 Create a new experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
B.3.3 Adding variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
B.3.4 Adding Instrumentation Layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
B.3.5 Plotting the experiment data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
B.3.6 Adding Instrumentation Layout to Experiment . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
B.4 Using dSPACE to ﬁnd a step Response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
B.4.1 ControlDesk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
The objective of this laboratory is for students to become familiar with the use of the SIMULINK component of
Matlab and the dSPACE system in implementing given transfer functions. This knowledge will form the basis of later
laboratories in which dSPACE will be used to implement controllers or simulate control systems.
1.2 Hardware Description
The hardware used in this laboratory experiment consists of the following:
• Signal Generator
• IBM PC running Matlab and dSPACE ControlDesk software. This PC also contains a dSPACE DSP board.
2 LABORATORY PROCEDURE
1. Work through the example given in Appendix A on using simulink. Print out the step response and include it in
your pro-forma report.
2. (a) Choose new values for the gain blocks in your simulink block diagram and repeat item 1.
(b) Produce a print out of your block diagram and include it in your pro-forma report.
(c) What is the differential equation corresponding to your new block diagram?
3. Change the input of your system to a 1Hz sine wave (can be produced using a “signal generator” block in
simulink sources) and include the corresponding response in your pro-forma report.
4. Work through the example given in Appendix B on using DSPACE.
(a) Produce a plot of the response of the system to a 1Hz sine wave provided by the signal generator connected
to the dSPACE connector panel and print this plot using the screen capture method. Include this plot in
your ﬁnal report.
(b) Measure the turnaround time as described in the Appendix and note it on your report pro-forma.
(c) Use screen capture to print out your ﬁnal layout used to measure the response to the sinusoid input as well
as to measure the turn around time. Attach this diagram to your ﬁnal report.
(d) Measure the step response of the system using the method described in the Appendix. Use screen capture
to print out your ﬁnal layout used to measure the step response. Attach this diagram to your ﬁnal report.
(e) Use the matlab plot method described in Appendix B to print the step response of the system and attach
this plot to your ﬁnal report.
5. Choose new values for the gain blocks in the system considered in Part 4. Print out the new simulink block
diagram and include it in your report. Repeat Part 4 with your new system.
6. Modify your existing simulink block diagram to construct a simple simulink block diagram to enable dSPACE
to read in a signal with the ADC, multiply it by a gain factor of 0.5 and read out the signal with the DAC. Set
the dSPACE sample period to 0.001s and apply a 100Hz sine wave (20V pk-pk) from the signal generator to
this system. Print out your simulink block diagram and attach it to your report.
(a) Use dSPACE ControlDesk to capture and plot the output of the gain block corresponding to the sinusoid
input (You can use either the screen capture method or the matlab plot method). Attach a copy of the plot
to your report.
(b) Use the CRO to display the signal produced by the DAC. Comment on any differences between the signal
plotted using Control Desk and the signal displayed on the CRO.
A USING SIMULINK
Simulink is a package that runs within matlab. It is used to simulate mathematical models of physical systems. Models
can be graphically constructed in block diagram form. Simulink is rather like a digital computer emulation of an analog
computer. To use simulink, you must be running matlab on a PC.
The ﬁrst step in using SIMULINK involves logging on to the PC. You should use the username “student” and
the password “Eleceng1”. All of the ﬁles that you generate during the course of the laboratory should be stored in a
subfolder of the folder:
Note that the name of the Matlab root folder (i.e, matlabR11 in the above example) may be different as we up-
date the system as new versions of Matlab are released.
Matlab can be started by double clicking on the Matlab icon on the PC desktop. Matlab should startup with this as
the default directory. You can check this by typing the command:
If you are not in the right folder, you can give the command:
>> cd C:\matlabR11\work\student
(substitute a folder name reported by >> pwd instead of matlabR11). You can create a subfolder for you ﬁles for
this laboratory from within matlab by giving the following commands:
>> mkdir Lab1
>> cd Lab1
Here, the subfolder has been named “Lab1”. The remainder of this laboratory is written assuming that you are working
in this subdirectory.
To invoke simulink from matlab type the command
(Or click on the Simulink Library Browser icon in the Matlab toolbar.) This should produce the Simulink Library
Browser window as shown in Figure 1. Clicking on the + next to “simulink” and then the + next to “Continuous”
reveals all of the continuous time simulink blocks as shown in Figure 2.
Figure 1: Simulink Library Browser window. Figure 2: Simulink Library Browser window.
A.1 Creating a New System Model
To create a new system model, click on the “new model” symbol in the tool bar on the Simulink Library Browser
window. To illustrate this, we now construct a simple simulink model using blocks contained in the ’continuous,
’math’, ’sources’ and ’sinks’ libraries; see Figure 3.
Step Integrator Integrator1 Scope
Figure 3: Drag and drop blocks from the library to the model window
Note, the gain blocks were made slightly bigger by clicking on them and then dragging the corners out. Also,
they were ﬂipped by choosing the “ﬂip block” item in the format menu. The values of the gain blocks were set by
double clicking on the block and then typing in the required value. Similarly, the number of inputs and the signs on the
sum block were set by double clicking on the sum block. You can ﬁnd out more information on any block by double
clicking on that block and then choosing the help button. The step input block is set to have a step time of 0, an initial
value of 0 and a ﬁnal value of 1.
After the blocks have been copied across, they are linked together. This is done by drawing lines with the left
mouse button down. A line can be removed by clicking on it and then pressing the delete key. A line can be moved
using the left mouse button. A connection can be made to the middle of a line can be made with the right mouse
button. The following block diagram was obtained:
Step Integrator Integrator1 Scope
Figure 4: The ﬁnal block diagram
The block diagram in Figure 4 represents a second order differential equation driven by a step input. To see this
let us label the output of integrator1 (which is the signal to be plotted) x(t). Then the input to integrator1 must be
x(t). (Note that in using simulink to solve differential equations, we only use integrator blocks, never differentiators.).
Since this signal is also the output of the other integrator block, then the input to this integrator block must be x(t).
However, this signal x(t) is the output of a summing block. Looking at the inputs to this summing block we can write
down an equation for x(t):
x(t) = −x(t) − 2x(t) + u(t)
where u(t) is the unit step input signal. Thus, we are simulating the differential equation:
x(t) + x(t) + 2x(t) = u(t)
A.2 Simulink Menu Items
Most of the simulink menu items are self explanatory and you should experiment for yourself to see what they do. We
will now go through some of the main ones.
1. From the File menu, choose the Save menu item. In the resulting window, type the desired ﬁle name at the
end of the Selection window. In our case, we will type lab1.mdl. The name should always end in .mdl.
The window should now be called lab1. Throughout this laboratory, it will be most convenient if we keep the
same simulink block diagram name lab1.mdl and modify this one block diagram as we proceed through the
2. From the Simulation menu, choose the Parameters menu item. The solver window determines the
numerical method to be used in the simulation. The default value is ﬁxed-step ode1 which is quite OK for
simple problems. The Stop time is the length the simulation is to go. Choose some reasonable value such as
3. Double click on the scope block to produce the plot axis on which the simulation output will be plotted.
4. From the Simulation menu, choose the Start item. This will start the simulation and commence plotting.
A plot should appear in the window called Scope. The scale of this plot can be corrected by clicking on the
binoculars icon on the scope window. This should give the following plot:
0 1 2 3 4 5 6 7 8 9 10
Time offset: 0
Figure 5: A scope plot.
You can print your plot by clicking on the printer icon in the scope window. Also, you can print your block diagram
by clicking on the printer icon in the model window. Black-and-White laser printers cannot produce clear printing
tones corresponding to bright colours such as yellow, etc.. A much better quality graphs can be obtained by sending the
plot data to the MATLAB workspace, and then using MATLAB commands such as plot to produce plots. To send
the plot data to the MATLAB workspace, click the Parameters icon on the Scope window; see Figure 6. Next,
select the Data history panel on the pop-up Scope parameters window and check the Save data to
work space box. Specify a variable name in which the data will be stored; e.g., ScopeData. From the pull-down
menu Format: choose Structure with time. Then, click OK button.
After the data have been exported to the workspace, the plot can be generated from the MATLAB command line
using the command:
Figure 6: The Parameters icon and the Scope parameters properties.
B Using dSPACE system and ControlDesk
The dSPACE system is high performance digital control system based on the TI TMS320C31 DSP processor. It is
directly interfaced with MATLAB/SIMULINK running on a PC. A simulink block diagram is converted to real time
C code, cross compiled and downloaded to the DSP board. Software is also available for controlling the DSP from the
PC and plotting variables in real time in the DSP.
In this laboratory, you will familiarize yourself with some of the capabilities of the dSPACE system including the
implementation of transfer functions and the ability to provide step inputs and to plot the resulting step responses of
the systems under consideration. Each of the four IBM PCs in the control lab contains a dSPACE ds1102 DSP board.
This board can be connected to the outside world via a connector box.
B.1 Creating a dSPACE Block Diagram
We now present a case study of using the dSPACE system. In order to use the dSPACE system, you must construct
block diagrams on MATLAB/SIMULINK and run them on your dSPACE board. Create the following block diagram
in simulink which you wish to implement on dSPACE; see Figure 7.
ADC #1 1 1 DAC #1
ADC #2 s s
Figure 7: A simple simulink block diagram
Note that the ADC and DAC blocks included in this block diagram are speciﬁc to dSPACE and should be obtained
from the dSPACE RTI1102 folder of the simulink library browser. Also, ensure that you use the correct board which is
ds1102. As mentioned previously, it is most convenient if this block diagram retains the name ”lab1.mdl” throughout
The signal applied to a dSPACE ADC channel must be in the range -10 to 10 volts. A signal of +10 volts gives an
internal value of 1.00 within simulink. The dSPACE DAC converts give an output in the range of -10 to 10 volts. An
internal value of 1.00 gives +10 volts on the DAC.
B.1.1 Compiling and Downloading Simulink Block Diagram to the dSPACE board
In order to generate C code for your block diagram, go to the Tools menu and select Real-Time Workshop ->
Options; see Figure 8. This is necessary in order to conﬁgure simulink C code generation for use with dSPACE.
To generate the C code which can be used with dSPACE, SIMULINK must be conﬁgured as follows.
(a) Select the Solver tab and set the Fixed step size to a suitable value in seconds, (Say 0.001). This
determines the sample period used in the real time implementation of the system. Make sure the parameter Stop
time in the Simulation time box is set to inf (if this is not done, the system will stop working after the
speciﬁed time); see Figure 9.
(b) Select the Advanced tab and turn off the Block reduction option in the Optimizations; see Figure 9.
(c) Go to the Tools menu and select RTW Build Model. This will compile the block diagram and download it
to the dSPACE board; see Figure 10.
(d) From now on, if you change the block diagram and do not change the Solver settings, you can rebuild the block
diagram simply by going to the Tools menu and selecting Real-Time Workshop -> Build Model.
Figure 8: Selecting Real-Time Workshop -> Options from the Tools menu
Figure 9: Conﬁguration for the Solver and Advanced tabs.
Figure 10: To ﬁnish building the model and download it to the dSPACE board, select Build Model. The ﬁgure on
the right shows the compilation results. Check this output for errors.
B.2 The ControlDesk Package
This is a powerful dSPACE software package used to interact with the program you have running on the dSPACE DSP
board. In particular, it is used to change parameters in the model and to plot variables and signals in the DSP.
The following write up gives some basic instructions on the use of the ControlDesk package. However, in order to
use the package correctly you will need to use the online help. The online help package is called “dSPACE HelpDesk”.
To run this package choose the windows menu items as follows:
Start → Programs → dSPACE Tools → dSPACE HelpDesk
This online help system contains all the information about the ControlDesk package. In particular, if you can’t
do something in ControlDesk, DO NOT ASK THE DEMONSTRATOR HOW TO DO IT but rather look it up in
ControlDesk allows you to collect the various ﬁles you need for a particular model in an ”Experiment”. An experiment
can consist of
1. Hardware speciﬁcation: This speciﬁes which board the program runs on (In our case there is only one DSP
board to worry about).
2. Variables: The ControlDesk package requires a ".sdf" ﬁle corresponding to the simulink model which is
running on the DSP board. This ﬁle is automatically generated when the simulink block diagram is complied as
described in section B.1.1. This ﬁle is speciﬁed for the given experiment in the Variable Manager section.
3. Instrumentation layout: In control desk, the instrumentation layout is used to display signals from the DSP
and to adjust parameters in the DSP model. For each experiment, you must construct a layout to display the
required variables and adjust the required parameters.
B.2.2 Main Window
Figure 11: ControlDesk main window
A typical ControlDesk window is shown in Figure 11. As illustrated in the Figure, the main window contains a
number of elements:
• Menu Bar. These Menus allow for the various commands to be given to ControlDesk. The menus are dynamic
and depend on the view and element selected in the Navigator.
• Tool Bar. These provide quick ways of given ControlDesk commands rather than using the menus. The tool
bars can be turned on or off.
• Working Area. This is the area in which a ControlDesk instrument layout is constructed and used.
• Navigator. The Navigator panel provides access to the different parts of a real-time experiment. These are, the
Hardware View, the Experiment View and the Instrument View. The current view is controlled by the tabs at the
bottom of the Navigator panel.
• Tool Window. This window is used for various tools controlling the experiment depending on the view chosen
from the Navigator. Most commonly used is the variable manager which enables the selection variables from a
• Status Bar. This displays some information about the state of the ControlDesk system.
B.3 Procedure for a simple experiment
We now outline how to create a simple experiment which is based on the simulink block diagram shown in Figure 7.
The aim of this experiment is to display the output signals for this system using an oscilloscope type display.
B.3.1 Start ControlDesk
Double click on the dSPACE ControlDesk icon on the Windows desktop.
B.3.2 Create a new experiment
Go to the File menu and select New Experiment...; see the left picture in Figure12. In the window New
Experiment, specify Experiment name; e.g., Lab1 and specify the Working root folder as ”C:\MATLAB6p5\work\stude
see the right ﬁgure in Figure 12.
Figure 12: Creating a new experiment and specifying the experiment name
It is most convenient in this laboratory, if the experiment is named ”Lab1” which is the same name as the folder
previously created. Click on the green Platform tab (You may see only Pl...). The green triangle indicates that
a program is running on your ds1102 board. If not, you can drag and drop the corresponding .obj ﬁle (found in the
ﬁle selector window) onto the ds1102 icon to download this program. Then click on the pale blue Experiment tab.
You should now see the hardware icon included in the experiment.
B.3.3 Adding variables
You must specify a ﬁle which contains variables of your SIMULINK model. This ﬁle was created during building the
model and has extension .sdf. It is located in your work directory; in this example it is the directory Lab1. To add the
required .sdf ﬁle to your experiment use the following menu commands File -> Open Variable File and
choose the .sdf ﬁle corresponding to your simulink block diagram constructed above; see Figure 14.
Figure 13: The Platform and Experiment tabs showing a program running on the DS1102 board and the hard-
ware icon included in the experiment.
Figure 14: Selecting a variables ﬁle for the experiment.
Figure 15: The new Tool window and the variables window showing loaded variables.
Also, you may wish to add your simulink block diagram to the experiment. This ”.mdl” ﬁle is not used by
ControlDesk directly but it is useful to keep track of it.
To add this ﬁle, go to File -> Import Files... and locate the .mdl ﬁle for your block diagram. This
should lead to a new “External Files” section in the Navigator panel in the Experiment tab with your .mdl ﬁle
included; see Figure 16
Figure 16: Importing the Simulink model into the experiment. After the model is imported, the added .mdl ﬁle is
shown in the Experiment tab of the Navigator panel.
B.3.4 Adding Instrumentation Layout
To construct an instrumentation layout for the experiment, select from the menu File -> New, then scroll down
and select Layout. This should create a blank layout window in the Workspace area; Figure 11. Click on the
multi-coloured Instrumentation tab (In...). You should then see a virtual instrument panel; see Figure 17.
Figure 17: Creating a new instrumentation layout. The ﬁgure on the right shows the appearance of the
In this example, we wish to create a oscilloscope type display to plot the variable “Integrator1” which is the output
of our system. We will also include a gauge which displays the model “turnaround Time”. This is useful if we want to
know how short we can make the system sample time (It must be at least greater than the turnaround time.).
Click on Data Acquisition panel in the Virtual Instruments panel and then click on the Plotter
icon. Then move to the Layout panel and draw a rectangle which will determine the size of your plot. It should take
up about half the available area but can be adjusted later if desired. A set of axes should appear on your layout panel;
see Figure 18.
Figure 18: The Data Acquisition panel showing the plotter.
We now need to set up this plotter to plot the desired variable. First move to the Tool window and click on Model
Root. The variable panel should display a list of variables associated with your simulink block diagram. Click on the
variable denoted ”Integrator1”, the output signal ”Out1” and its changeable value ”InitialCondition” corresponding
to the simulink block labeled ”Integrator1” will appear in the window on the right. Now drag and drop ”Out1” to the
area just to the left of the plotter y-axis in the Layout panel. The y-axis now should be labeled Integrator1 Out1
and a red square appears indicating the color of the plot for this variable; see Figure 19.
Figure 19: Model Root with variables of the Simulink model, and the plotter instrument with the output of the Inte-
grator 1 added.
We can adjust the parameters of the plotter by right clicking on the plotter area and then choosing the Properties
menu item. Then click on the axes tab. At this stage, the only thing we will adjust will be the Y-min value to -0.05 and
the Y-Max value to 0.05.
The time and triggering of the plotter can be controlled by using a Capture Settings instrument. Select
the Capture Settings instrument icon on the virtual instruments panel and then draw a suitable rectangle in the
layout panel (About half of the available area).
Double click on the Settings button in the Capture Settings instrument. The window dSPACE CaptureSetting
Control Properties will appear. Click on the Capture tab. In the Capture window, click on the right dow-
narrow and choose the only option available DSP - lab - HostService. Also, set the length variable to 1sec.
Then click OK.
In this case, our trigger variable will be the same variable that we are going to plot. Hence, again click on Out1
in the Variable panel and drag and drop it in the trigger window in the capture instrument panel (this is just below
the words level and delay); see Figure 20. You can then adjust the plot interval and trigger level to suitable values
depending on the signal you are plotting. If the signal applied to the ﬁlter is a 1Hz sine wave with amplitude of 10V,
then a suitable length is 1sec. Turn the trigger on with AutoRepeat. The trigger level is usually set halfway between
expected peak values of the signal. That is, for a 1Hz sine wave, the trigger level can be left at 0.
Figure 20: The plotter properties window.
B.3.5 Plotting the experiment data
Connect the output of the function signal generator to "Vin1" of the dSPACE connector box. Set the signal generator
to produce a 1Hz since wave with 20 Volts to peak.
To start plotting (assuming that the signal generator has been connected to the DSP board connector panel), simply
give the following menu command Instrumentation -> Animation Mode. This should commence the in-
teraction between your instrumentation layout and the DSP board. To stop, choose the menu command Instrumentation
-> Edit Mode; see Figure 21. There are also corresponding buttons on the menu bar which can be used to start
and stop plotting. In Edit Mode, you can make further adjustments to your instrument panel.
Figure 21: Start or stop plotting by choosing Animation Mode or Edit Mode, respectively.
The ControlDesk program does not have a good way of printing plots. A simple way to print plots is to use screen
capture (press the Print Screen key). Then run the Paint program and paste the screen capture into the program.
The required plot can then be cut out and printed or saved.
If you wish to save your traced data to a ﬁle so that it can be later loaded into MATLAB and printed, make the fol-
lowing adjustment to the properties of the capture instrument: Click on the Setting button in the "CaptureSetting"
Figure 22: Saving the traced data. On the left, the Acquisition tab of the CaptureSettings panel. On the right, the
prompt to specify a ﬁlename.
instrument. Select Acquisition tab and check Autosave. Then when prompted specify a ﬁlename, in which the
data will be stored: e.g., ”output.mat”. Then run the animation again. It is best to tick off Autorepeat this time
since every time a trace is plotted, it will also overwrite this ﬁle.
After the capture is complete, you can open this ﬁle and plot it from your MATLAB command window as follows:
>> load output
This plot can then be labeled and printed if required (Before printing, be sure to choose matlab print setup and set the
paper type to A4).
Our ﬁnal step in this example will be to add a gauge to our layout which displays the program turnaround time.
With the layout in Edit mode, click on the Virtual instrument button in the Virtual instrument
panel and then click on the Gauge icon. Then draw a suitable size rectangle in the layout panel for the gauge. A
gauge should appear in the layout.
To get this gauge to display the turnaround time, click on the Timer Task 1 item in the Tool Window (click the
"+" in front of "Task Info" if necessary). The variable panel should then display various variables associated
with the program running on the DSP board. Drag and drop the “Turnaround Time” item onto the gauge instrument
in the layout panel. The gauge should now be labelled Turnaround Time; see Figure 23
Figure 23: Displaying the turnaround time.
Right click on the gauge instrument and adjust settings of the Gauge and Tics tabs as shown in Figure 24.
Restart animation. The gauge should now display the turnaround time in micro seconds.
Figure 24: Set turnaround time properties
B.3.6 Adding Instrumentation Layout to Experiment
This completes the layout for this experiment. The layout can be added to the experiment by right clicking on the
layout panel and then choosing Add layout to Experiment (This will also ask you to save the layout to disk
which you should do). A new Instrumentation element should appear in your experiment listing which contains the
corresponding layout ﬁle.
The ﬁnal ControlDesk window should look something like the following:
Figure 25: The ﬁnal ControlDesk window. The plotter shows a response to a sine wave input.
B.4 Using dSPACE to ﬁnd a step Response
The best way to use the dSPACE system to construct a step response is to add a "constant" block to your simulink
block diagram which will provide the step input. Then use the ControlDesk package to control the step and view the
resulting step response using a "plotter" instrument.
To provide the step input, we do NOT use the standard simulink step block. The step would be over before we
had time to set things up. Rather we add a “Constant” block whose value will be adjusted by ControlDesk to provide
the step input at the required time. Also, the ADC and DAC blocks can be removed. This leads to the following
simulink block diagram.
0 1 1
Constant s s
Figure 26: A Simulink block diagram for producing the step response.
Compile this system following instructions on building Simulink models and downloading them to the dSPACE
Return to ControlDesk and modify the existing layout as follows:
Figure 27: The instrument layout for capturing and plotting the step response.
1. In this layout, the plotted signal is the output of the system Integrator1. Also, plotted on the same graph
is the input to the system Constant. This is achieved by dragging corresponding signals of these variables to
the Y-axis of the plot.
The Capture instrument is set as shown in Figure 27. In this case, the trigger variable is the value parameter
variable P Value of the step input signal Constant. The time interval Length is 10 sec and a factor of
10 downsampling be used to ensure the DSP does not run out of memory with this long time interval. Triggering
is set up as described above. Also, the data can be saved to a ﬁle and loaded into matlab as explained above.
2. A step input will be applied by pushing an On/Off button which must be set to control the output of the block
“Constant” in the simulink block diagram. The RadioButton instrument provides a suitable On/Off button
as one of the options.
Add the RadioButton instrument to the layout; see Figure 28. To allow this instrument to control the constant
block of the simulink block diagram, click on the Constant variable in Tool window, then drag the value
parameter variable P Value to the RadioButton instrument in the layout. Also, the properties of this
instrument are set so that its On value is set to the size of the required step and the Off value is zero. To achieve
this, double click the RadioButton instrument and set the properties of this instrument as shown in Figure
29. Select Button-ID panel and change the Text properties of Button 00 to On, and set the Value to 1.
Change Button 01 to Off and its Value to 0.
3. The above layout also includes two Display instruments. One displays the value parameter " P Value" of
the input variable Constant and the other displays the output signal Out1 of the variable Integrator1.
These instruments can be added to the layout in the same fashion as other instruments, Select the Display
instrument in the "Virtual Instruments" panel, then draw a suitable rectangle in the Layout and drag
and drop the output signal "Out1" of the variable Integrator1 and the value parameter variable P
Value of the variable Constant to these rectangles. The display format is set as follows; see Figure 30.
Double click the instrument rectangle and select the Digits tab. Change DigitCount: to 3. Double click
Figure 28: The RadioButton instrument.
Figure 29: The RadioButton properties window.
the "Display Format..." button and in the window Display Format (shown on the right), change
Precision: to 2.
Figure 30: The properties window for the Digital Display instrument.
4. To use this ControlDesk experiment, the layout should be put in Animation mode and then the Constant value
set from Off to On. This should trigger the data capture and produce the resulting step response.
5. The above procedure can be used to plot the step response of any physical system connected to the dSPACE
board. Connect the input of the system to a DAC channel (Vout(1) in the connector box) and connect the output
of the physical system to an ADC channel (Vin(1) in the connector box).
6. Construct a simulink block diagram as shown below
0 DAC #1 ADC #1 1
Constant DAC #2 ADC #2 Output
DAC #3 ADC #3
DAC #4 ADC #4
Figure 31: A Simulink diagram for capturing and plotting the step response of a physical system.
7. Compile the system and obtain the step response using ControlDesk as above.