Dspace 2
Dspace 2
Dspace 2
, Real-Time
Workshop
0
u + =
y C x d u + =
y
0 0
a
1
b
1
------
a
m
b
1
-------
x
a
1
b
1
------ u + =
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
226
N
d is only different from zero if the degree of the numerator polynomial
is equal to the degree of the denominator polynomial. In all other
cases, d equals zero.
E
Consider the following model:
Applying the conversion derived above will lead to the following
state-space representation of this system:
B always has the form given above and d equals 0 in this case.
The code-generating process of Real-Time Workshop introduces the
two vectors A and C (see TRC file), which can be accessed via
ControlDesk. In ControlDesk these parameters are referenced by
All the elements that are zero or one have been optimized out by
Real-Time Workshop.
s+2
3s +4s +5s +6s+7
4 3 2
Transfer Fcn
Step Scope
A
4 3 5 3 6 3 7 3
1 0 0 0
0 1 0 0
0 0 1 0
=
C
0 0 1 3 2 3
=
A 1 1 , [ ] 4 3 = C 1 1 , [ ] 0 =
A 2 1 , [ ] 5 3 = C 2 1 , [ ] 0 =
A 3 1 , [ ] 6 3 = C 3 1 , [ ] 1 3 =
A 4 1 , [ ] 7 3 = C 4 1 , [ ] 2 3 =
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004 227
I
How to Tune Transfer Function
Parameters via Manual
Conversion
The most obvious but least convenient method is to derive the new
values of the state-space matrices from the transfer function by
applying the conversion rules shown in MATLABs State-Space
Representation for a Transfer Function on page 225 or by using
MATLABs built-in tf2ss function, which directly calculates all matrix
positions.
To convert a transfer function to a state-space description
1 In the MATLAB Command Window, enter the following command:
[A,B,C,D] = tf2ss(NUM,DEN)
using your desired numerator and denominator.
Enter help tf2ss to get further information on the command and
its syntax.
2 Add the State-Space block from the Simulink library to your
model and open its Block Parameters dialog. Set the parameters
according to the results calculated via the tf2ss function.
The state-space matrices of the State-Space block (A, B, C and if it
exists, D) are available in the TRC file and can therefore be tuned via
ControlDesk.
Tuning Transfer Function Parameters via
External Simulation
A convenient way of parameter tuning in Transfer Fcn blocks is to
simulate the model in the external mode. In this simulation mode, you
can change parameters in Simulink and they are downloaded to the
real-time simulation. Refer to How to Run an External Simulation on
page 267.
x' = Ax+Bu
y = Cx+Du
State-Space
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
228
How to Tune Transfer Function
Parameters via Parameter
Inlining
It is possible to use parameter inlining for tuning transfer function
parameters like any other parameters. This technique allows you to
access the transfer function parameters directly via ControlDesk.
To use parameter inlining for Transfer Fcn blocks
1 Place the vectors of the polynomial coefficients in the MATLAB
workspace, for example,
myNum = [1 2]
myDenum = [3 4 5 6 7]
2 Specify the workspace parameters (for example, myNum and
myDenum) in the Block Parameters dialog of the Transfer Fcn block.
3 Select the Inline parameters checkbox on the Advanced page of
the Simulation Parameters dialog.
Open the Model Parameters Configuration dialog to specify
tunable parameters.
N
With RTI-MP the tunable parameters are not CPU-specific. Tunable
parameters declared in the overall model are used for all
submodels.
For details, refer to Model Parameters Configuration Dialog (for
RTI) and Model Parameters Configuration Dialog (for RTI-MP) in
the RTI and RTI-MP Implementation Reference.
4 In the Source list select the referenced workspace variables you
want to tune, for example, myNum and myDenum and add
them to the Global (tunable) parameters table.
myNum(s)
myDenum(s)
Transfer Fcn
Step Scope
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004 229
I
As a result, all the numerator and denominator coefficients in the
generated code are implemented as variables that can be changed
during real-time simulation.
N
Changing the highest-order coefficient of the denominator of a
transfer function to zero causes a change in the model structure,
which always requires that you rebuild the real-time code.
If you changed this coefficient to zero, a run-time error such as division
by zero could result. Changing zero coefficients to non-zero has no
effect on the real-time simulation because they are not implemented
in the real-time code.
How to Keep Zero Parameters of
State-Space Blocks
Real-Time Workshop tries to optimize out unnecessary parameters of
State-Space blocks. However, for parameter tuning you might want to
keep all parameters. There is a simple workaround for keeping the
parameters of the system matrices of a State-Space block.
To generate zero parameters of a State-Space block into the
real-time code
1 Enter nonzero values for all parameters of the State-Space block.
2 Set the Initial simulation state to STOP.
Refer to Real-Time Workshop Page (for RTI) and Main Page (for
RTI-MP) in the RTI and RTI-MP Implementation Reference.
3 Build and download the model.
4 Download the desired parameters and switch the simulation state
to run, for example, using ControlDesk.
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
230
Tuning Parameters of n-D Look-
Up Table Blocks
The parameters of multi-dimensional Look-Up Table (n-D), Direct Look-
Up Table (n-D), and Interpolation (n-D) using PreLook-Up blocks can
only be tuned via multiple 2-D slices. The handling of 1- and 2-
dimensional blocks also slightly differs from that of 1-D and 2-D Look-
Up Table blocks.
Parameter
representation by
Real-Time Workshop
Real-Time Workshop transforms the table parameters of the n-D table
blocks (Look-Up Table (n-D), Direct Look-Up Table (n-D), and
Interpolation (n-D) using PreLook-Up blocks) to arrays whose
dimensions typically have different dimensions from the corresponding
block parameters. This also applies if you configured the table as a 1-D
or 2-D table. As a result, up until dSPACE Release 4.0.x, ControlDesks
Table Editor instrument could not handle the parameters of n-D table
blocks.
Parameter
representation by RTI
Since dSPACE Release 4.1, RTI generates one or more
LookUpTableData entries into the variable description file. For 1- and 2-
dimensional tables, this corresponds to the table parameters of the
standard Look-Up Table and Look-Up Table (2-D) blocks. Therefore,
you can use ControlDesks Table Editor instrument as usual, connecting
it with the LookUpTableData entry of the table. The other table data
entry in the variable description file can be ignored.
E
Suppose you have a 3x4 Look-Up Table (n-D) block in your model. To
edit the table data via ControlDesk, connect the LookUpTableData
entry to a TableEditor instrument:
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004 231
I
Tables with more than 2
dimensions
ControlDesks Table Editor instrument cannot handle tables with more
than two dimensions. To let you access the parameters of such a table,
RTI subdivides it into several 2-dimensional table slices. This is
especially useful if you use the 3
rd
n
th
dimension to switch between
different 2-D tables.
E
Suppose you have a 3x4x2 Look-Up Table (n-D) block. In the variable
description file, this comes out as 2 LookUpTableData entries of the
dimensions 3x4, each of which you can connect to a separate
TableEditor instrument.
The variable description file for the Look-Up Table (n-D) block also
contains the different breakpoint sets bp01Data bpnData.
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
232
How to Migrate from
AlphaCombo to DS1005 or
DS1006
The AlphaCombo system is no longer supported. You can migrate
your AlphaCombo models either to a multiprocessor system or to a
single-processor system based on the DS1005 or DS1006.
Basics If you open the Multiprocessor Setup dialog or a Communication
Channel Setup dialog of an RTI-MP model for the AlphaCombo
system, RTI-MP prompts you to migrate the model to support the
multi-DS1005 or multi-DS1006 system. If you start the migration, the
AlphaCombo-specific options are removed and the model is migrated
to the platform support that is currently active.
You must specify the Gigalink topology via the Multiprocessor
Topology Setup dialog of the model. You can also adapt the CPU
names, if desired.
T
You are recommended to migrate your AlphaCombo models to a
single DS1005 or DS1006 board:
If your model contains a lot of I/O, consider migrating to the
DS1005 platform.
If your model contains a lot of arithmetics, consider migrating to
the DS1006 platform.
Migrating your application from an AlphaCombo system to a single-
processor system changes the path names for the simulation variables
in the variable description file (SDF, TRC). Thus, all data connections in
your experiment are lost.
For Details on the Experiment Connection Converter, refer to
Converting Experiments in the ControlDesk Experiment Guide.
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004 233
I
Restrictions When you migrate an application from AlphaCombo to single-DS1005
or single-DS1006, you might experience the following limitation:
Migration without RTI-MP license If you migrate your model
simultaneously from AlphaCombo to DS1005 or DS1006 and from
one dSPACE Release to another (e.g., from dSPACE Release 3.5 to
dSPACE Release 4.1) and you do not have an RTI-MP license for the
new dSPACE Release, you will not be able to open the RTI-MP-specific
dialogs of the model after it is migrated to the new dSPACE Release.
You should therefore make a note of the various options contained in
the Multiprocessor Setup dialog beforehand.
Then you can migrate the model to the new dSPACE Release, and
after that from AlphaCombo to DS1005 or DS1006.
Instructions To migrate a model from AlphaCombo to DS1005 or DS1006
1 Change to the MATLAB Command Window and enter rti1005 or
rti1006 to activate the corresponding platform.
The RTI library opens.
2 Change to the working folder of the multiprocessor model you
want to migrate and open the model.
3 Change to the MATLAB Command Window and enter set_rti to
set the new platform as the code generation target for the model.
RTI closes and reopens the model. The settings on the Real-Time
Workshop page of the Simulation Parameters dialog (Target
configuration category) are now valid for use with the new
platform.
4 Configure the options in the Simulation Parameters dialog
according to the settings provided in the Multiprocessor Setup
dialog and its subdialogs. The following table lists the options that
need to be changed to new values or cannot be used directly:
Specify the RTI Setting... New Value... According to RTI-MP Setting...
Solver page Main page
Solver Solver
1)
Fixed step size Basic step size
Mode Scheduler mode
2)
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
234
5 Close the Multiprocessor Setup dialog and delete the
Multiprocessor Setup block.
6 Replace all the IPC blocks with direct connection lines.
7 Replace all the IPI blocks with direct connections lines.
8 Delete all Default CPU blocks.
9 Build your real-time application. For details, refer to Building and
Downloading the Model on page 239.
When these steps have been carried out, the model is a valid DS1005
or DS1006 single-processor model.
Real-Time Workshop page
Category: RTI simulation options
CPUs pages and subdialogs
3)
Task Configuration Task Configuration
4)
Real-Time Workshop page
Category: RTI general build options
Compiler options <according to the requirements of your model>
Compiler optimization <according to the requirements of your model>
User-defined optimization <according to the requirements of your model>
Real-Time Workshop page
Category: RTI load options
Platform selection <according to your registered hardware> or
auto
Processor board name <according to your registered hardware>
Network client <required for a network connection>
1) If the different CPUs of the multiprocessor model had different solvers, you must now choose a solver that meets your
requirements best. If the multiprocessor model used a central integration algorithm (e.g. ode2-mp) you can choose the
standard solver (e.g. ode2).
2) With RTI-MP you can implement a multirate model by assigning the different step sizes to the different CPUs and operating the
CPUs in the single timer task mode. In RTI the same model might require the multiple timer task mode. Keep in mind that
Simulink does not accept direct connection lines between blocks with different sample times in the MultiTasking mode. For
details, refer to How to Achieve Data Consistency Between Timer Tasks on page 70. See also Example Applications Requiring
the Multiple Timer Task Mode on page 69.
3) If the different CPUs of the multiprocessor model had different local settings, for example, variable description file options, you
must now choose the setting that meets your requirements best.
4) You might need to redesign the task priorities of the single-processor model compared to the overall multiprocessor model to
get comparable behavior.
Specify the RTI Setting... New Value... According to RTI-MP Setting...
Multiprocessor
Setup
From: slave
to: master
on Channel: 1
IPC2
[ sync. sbuf ]
From: master
to: slave
on Channel: 0
IPC1
[ sync. sbuf ]
From:
to:
IPI Block
Default CPU:
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004 235
I
Next steps If you have a ControlDesk experiment for the real-time application of
the old multiprocessor model, you can now migrate it to match the
real-time application of the new single-processor model. For details,
refer to Migrating from AlphaCombo to DS1005 or DS1006 in the
ControlDesk Experiment Guide.
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
236
How to Use Simulinks Model
Verification Blocks
Since MATLAB R13, Simulink provides the Model Verification blocks.
These blocks can observe the signals of the Simulink simulation and
issue a warning or even stop the simulation if certain conditions occur.
For details on the Model Verification blocks, refer to the Simulink
documentation by The MathWorks.
RTI supports the Model Verification blocks for the real-time simulation.
To control the behavior of the Model Verification blocks in the real-
time simulation, use RTIs Assertion mode setting. Depending on this,
one of the following actions is carried out if a verified signal leaves the
desired range, meaning that the assertion occurs:
OFF: No reaction (default).
WARN: Issue a warning message in ControlDesks Log Viewer.
STOP: Issue an error message and stop the simulation, i.e. set
the simulation state to STOP.
N
In contrast to the Simulink simulation the behavior of the real-time
simulation does not depend on the Stop simulation when assertion
fails setting, which is available for each Model Verification block.
To verify a signal of the simulation
1 Place and connect the desired Model Verification block to your
model and specify the desired parameters.
2 Specify the initial assertion mode that is active after starting the
real-time simulation via the Model Verification block control
setting located on the Advanced page of the Simulation
Parameters dialog:
You can globally Enable all or Disable all Model
Verification blocks, overruling the local Enable assertion
settings of the individual Model Verification blocks.
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004 237
I
You can select the Use local settings entry (default), which
enables the Model Verification blocks whose Enable assertion
setting is selected.
3 Specify the desired behavior of the real-time simulation in the
event that an assertion occurs:
RTI Open the Real-Time Workshop page of the Simulation
Parameters dialog and select the RTI simulation options
category.
RTI-MP Open a CPUs page of the Multiprocessor Setup
dialog and open the CPU Options dialog on the Build Options
page.
Select the Assertion mode setting OFF, WARN or STOP.
If desired, you can change the Assertion mode setting while the
simulation is running:
To change the assertion mode from ControlDesk
Connect the rtiAssertionMode variable from the Main group of
the variable description file to a suitable instrument in your layout.
For example, you can use the RadioButton instrument. The
following values are valid:
N
With RTI-MP, the rtiAssertionMode variable is CPU-specific and
available from the Main group of each submodel.
If an assertion occurs during the real-time simulation, ControlDesks
Log Viewer will issue a message, pointing out the line concerned in
the real-time applications C source files. Via this information you can
find the involved block in the Simulink model. For details, refer to How
to Find the Simulink Block Related to an Exception on page 261.
Value Reaction to an Assertion Failure
0 No reaction
1 Issue a warning message in ControlDesks Log Viewer.
2 Issue an error message and stop the simulation, i.e. set
the simulation state to STOP.
Advanced Techniques
RTI and RTI-MP Implementation Guide March 2004
I
238
I
RTI and RTI-MP Implementation Guide March 2004 239
Building and
Downloading the
Model
When an RTI or RTI-MP model is complete, real-time code can be
generated and downloaded to the dSPACE system.
E
Consider the throttle control example (see page 20), and suppose you
want to build, download and run its real-time application with
different options, like solver type or execution mode. Or suppose you
have made minor changes to the S-function or User-Code of the
model, and you do not want to rebuild the entire model.
Basics Consider some basic information concerning the build and download.
Refer to Basics for the Build and Download on page 241.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
240
Building and
downloading
Follow these instructions to build and download a model:
Customize the build process by means of various options. Refer to
How to Specify Options for the Build Process on page 243.
Start the build and download procedure for your model. Refer to
How to Start the Build and Download on page 246.
If you want to automate the build and download procedure or if
you modified custom C code and want to quickly update the
real-time application without generating code for the model again,
refer to How to Automate the Build Procedure on page 248.
If you modified a USR.TRC file or a USR.SDF file, you might want to
update the real-time application. Refer to How to Update TRC and
SDF Files on page 251
If you have DS230<x> boards, you can download the
corresponding applications together with the real-time application.
Refer to How to Download DS230<x> Applications on page 252.
Debugging If you experience problems during the build and download or
simulation, you might want to debug your application. Refer to
Debugging an Application on page 254.
Virtual dSPACE systems You might want to create a model without having the dSPACE system
available and prepare it for later use on the actual hardware. Refer to
How to Create an Application for a Virtual dSPACE System on
page 263.
Related Topics
Registering platforms Before you can start the build and download procedure, you have to
ensure that your dSPACE hardware is registered correctly in
ControlDesk. Refer to Registering Platforms in the ControlDesk
Experiment Guide.
Simulation control The simulation state can be controlled from within ControlDesk and/or
the Simulink model itself as described in Simulation Control
(RUN/STOP Mechanism) on page 194.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 241
I
Basics for the Build and
Download
Here you will find some basic information relating to the build and
download.
Code format RTI and RTI-MP use Real-Time Workshops RealTime Code Format for
real-time applications. See Real-Time Workshop User's Guide by The
MathWorks.
File handling RTI and RTI-MP always generate a system description file (SDF), which
contains all the relevant information about the various object files and
TRC files. With ControlDesk you use this file to download the
application to your dSPACE system or to access the signals and
parameters of the simulation.
Several intermediate files are generated during or required by the build
process. These are located in the \<[sub]model>_<target>\ build
folder(s), where <target> is your active platform support. The current
working folder contains user-supplied files (for example,
<[sub]model>_usr.*) and the files that are needed for the real-time
application (such as the real-time object, variable description file, map
file, etc.).
Working board RTI By default, RTI downloads your real-time application to the first
local (bus) processor board ds1<xxx> if RTI1<xxx> is running.
If ControlDesks working board matches the current RTI, this overrides
RTIs default.
RTI-MP By default, RTI-MP downloads your real-time application to
the working board specified in ControlDesk provided that this board
matches the current RTI.
You can override ControlDesks working board using the Processor
board name (RTI) or Multiprocessor system name (RTI-MP) and
Network client options. For details, refer to Real-Time Workshop Page
(for RTI) and Advanced Page (for RTI-MP) in the RTI and RTI-MP
Implementation Reference.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
242
Overview of the build
process
When you initiate the build process, a number of utilities are invoked
sequentially to build the real-time program and download it to the
hardware. The build process can be divided into two separate phases:
the code generation phase and the compilation phase.
RTI-MP extracts the submodel for each CPU from the overall model
and carries out a similar build process for each submodel.
Code generation phase In this phase all the C code needed for
the real-time application is generated. The make_rti command is
started and performs the following steps sequentially:
Real-Time Workshop is called to generate an intermediate file,
<model>.rtw, from the Simulink model. This file is used as the basis
for code generation by the Target Language Compiler (see next
step).
The Target Language Compiler (TLC) is invoked. It reads the
<model>.rtw file as well as the TLC files provided by Real-Time
Workshop and RTI to generate the C code for the model and the
dSPACE I/O blocks used in the model.
A makefile called <model>.mk containing all application-specific
macros is created from the RTI template makefile and placed in the
current working folder. Following the makefile syntax, the
application-specific makefile holds all the commands necessary to
build the real-time program for the Simulink model and download
it to the hardware.
Compilation phase In this phase the C sources are translated into
the final application, which can be executed on the dSPACE real-time
hardware. The application-specific <model>.mk makefile is invoked by
the dsmake make utility. The utility calls:
The compiler/linker, which compiles the C sources of the model
and the dSPACE real-time simulation environment. It also links the
object files and libraries into an executable file.
The dSPACE loader program, which downloads the executable file
to the real-time processor, starts its execution and checks whether
it was started correctly.
With RTI-MP the application is not download automatically.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 243
I
How to Specify Options for the
Build Process
Simulink, Real-Time Workshop, RTI and RTI-MP provide options for:
Basic simulation settings
Task configuration and data typing
Code optimization options
Configuration of the variable description file
Non real-time simulation and processor board selection
Make process customization
Build and download options
For a complete list of options, see RTI Dialog Reference and RTI-MP
Dialog Reference in the RTI and RTI-MP Implementation Reference.
dSPACE single-processor systems You have to specify the
majority of real-time relevant settings in the Simulation Parameters
dialog (see Simulation Parameters Dialog in the RTI and RTI-MP
Implementation Reference). You can access this dialog via the
Simulation Parameters menu command.
dSPACE multiprocessor systems You have to specify the majority
of real-time relevant settings in the Multiprocessor Setup dialog (see
Multiprocessor Setup Dialog in the RTI and RTI-MP Implementation
Reference). You can access this dialog via the Multiprocessor Setup
block, which is located on the root level of your multiprocessor model.
To specify options for the build process
Set the options for the build process. The default values are
sufficient for most applications.
T
If you run a single-processor system, you can configure your model
with RTIs default settings via the set_rti command. Refer to How to
Specify RTI-Specific Settings for a Model on page 37.
Multiprocessor
Setup
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
244
E
Consider the throttle control example (see Throttle Control Example on
page 20), and suppose you want to build it for a MicroAutoBox
1401/1501 or a DS1005 multiprocessor system with solver type ode2,
a fixed-step size of 0.00065 sec, and using the single timer task mode.
MicroAutoBox 1401/1501 The following illustrations show the
corresponding settings for the Simulation Parameters dialog (for other
single board systems the settings are similar):
The Start time has to be
zero
Open end simulation via
inf
Fixed-step solver only
Desired step size for the
real-time simulation
Desired timer task mode
The various categories let
you configure options for
code generation and the
make process
The Build button starts the
build and download
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 245
I
DS1005 multiprocessor system The following illustrations show
the corresponding settings for the Multiprocessor Setup dialog:
Open end simulation via inf
Individual CPUs step sizes are
multiples of the Basic step size.
Starts the build for a single CPU
Starts the build for all CPUs
Starts the download. Enabled if
the build is complete for all CPUs.
Name of the submodel assigned to
the CPU
Desired solver for the CPU
Multiple times basic step size defines
the CPUs step size
Opens the dSPACE Task Configuration
dialog for the submodel of the CPU
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
246
How to Start the Build and
Download
Once you have specified the required options, you can start the build
and download procedure.
To start the build and download
1 If not already done, start ControlDesk, and register your hardware
via the Platform Manager. Ensure that the working board is
specified correctly. Refer to Registering Platforms in the
ControlDesk Experiment Guide.
2 Via MATLABs cd command, change to the desired working folder.
3 Open or activate the model you want to build and download.
4 If you run a multiprocessor system, you have to generate a new
<model>_tp.m file whenever you build a model for the first time.
The file must be regenerated if you changed or added any Gigalink
connection, or if you are building an application for a virtual
hardware system that is not connected to your PC.
The <model>_tp.m file contains the topology information of your
multiprocessor system. You can generate it via the Multiprocessor
Topology Setup dialog, which you can open via the MP network
topology button on the Advanced page of the Multiprocessor
Setup dialog.
For details on the Multiprocessor Topology Setup dialog, refer to
Multiprocessor Topology Setup Dialog in the RTI and RTI-MP
Implementation Reference.
5 Start the build process:
With RTI, select the Tools Real-Time Workshop Build
Model command from the menu bar of the model.
With RTI-MP, open the Multiprocessor Setup dialog, and
select the Main page.
To generate object files for all CPUs at once, click Build All.
To generate an object file for a single CPU, click Build for the
corresponding CPU.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 247
I
When an up-to-date object file for a CPU exists, the Build
button label reads Build OK. When all the object files are
available, the Download button is enabled, which lets you
download the real-time application.
N
Whenever you start a build and download, RTI and RTI-MP update
the corresponding system description file (<model>.sdf). Therefore,
you should not edit this file. If you want to customize the
download procedure, you can use the user system description file
(<model>_usr.sdf) instead. Refer to How to Download DS230<x>
Applications on page 252.
If you run a multiprocessor system and experience an overrun right
after the download, you might be able to avoid this via the
IGNORE_SECOND_SIM_STEP option. Refer to Build Options Page in
the RTI and RTI-MP Implementation Reference.
T
You can automate the build and download procedure via the
rti_build or rtimp_build command. Refer to How to Automate the
Build Procedure on page 248.
If you have just modified the custom C code of your model, you
can recompile and download the real-time application via the
rti_build or rtimp_build command. There is no need to regenerate
the model code. Refer to How to Automate the Build Procedure on
page 248.
With RTI-MP you can use the rtimpdiag diagnostic utility to get
information on the real-time program. Refer to How to Run the
RTI-MP Diagnostic Tool on page 254.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
248
How to Automate the Build
Procedure
You might want to automate the build process, especially when
working with models that are very large and need a rather long time
for building. Using the rti_build and rtimp_build commands, you
can run build processes virtually unattended or even create build
scripts that carry out several actions for you. In addition, the
commands provide the following customization options:
You can be prompted to check the task configuration or leave the
task configuration as it is to avoid interaction.
You can specify additional options for the make process.
You can log the messages of the build process to a file.
You can create a backup of all the run-time files directly after
successfully building a model. This lets you restore the last
successful build whenever the run-time files are deleted.
You can delete all the temporary files created during the build
process.
For RTI-MP models, some additional options are available:
If an error occurs while building one submodel, the build process
can be continued with the remaining submodels.
You can build either all submodels or just a subset of submodels.
For a detailed description of the commands and their options, refer to
rti_build and rtimp_build in the RTI and RTI-MP Implementation
Reference.
To start the automatic build procedure
1 Open the RTI or RTI-MP model you want to build.
2 Change to the MATLAB Command Window and enter the
rti_build or rtimp_build command with the desired build
command and options using the following syntax:
[errorFlag, errorMsg] = rti_build(mdlName,
'Command',<commands>[,<Parameter>,<Value>[,...]])
or:
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 249
I
[errorFlag, errorMsg] = rtimp_build(mdlName,
'Command',<commands>[,<Parameter>,<Value>[,...]])
where <commands> is one of:
'CodeGen' (or 'C' for short)
'Make' (or 'M' for short)
'Load' (or 'L' for short)
'CodeGen&Make' (or 'CM' for short)
'Make&Load' (or 'ML' for short)
'CodeGen&Make&Load' (or 'CML' for short)
See rti_build and rtimp_build in the RTI and RTI-MP
Implementation Reference.
Your model is built according to the options you specified.
To rebuild custom C code
If you modify the custom C code you can rebuild the real-time
application with the 'Make&Load' or 'CodeGen&Make&Load'
command:
Rebuild the entire model, especially if you changed the size
information of any S-function (sample time, number of inputs,
outputs, states, etc.) or the dimensions of data store memories
used for the data transfer between the model and the User-
Code:
Recompile the MEX DLL files of the modified S-functions. Then
use the 'CodeGen&Make&Load' command to rebuild the entire
model.
If it is sufficient to make and load the real-time application
without generating new code from the model, use the
'Make&Load' command.
To create a backup of the generated real-time application
1 Build the model as usual.
2 Create the <location> folder where you want to put the backup.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
250
3 Change to the MATLAB Command Window and enter the
following command:
[errorFlag, errorMsg] = rti_build(<mdlName>,
'Command','BackUp','BackUpFolder',<location>)
or:
[errorFlag, errorMsg] = rtimp_build(<mdlName>,
'Command','BackUp','BackUpFolder',<location>)
A backup copy of the generated real-time application files that are
necessary to load the application with ControlDesk is saved to the
specified folder.
N
Any existing files in the <location> folder are overwritten without
further notice.
To remove the temporary files of the build procedure
Change to the MATLAB Command Window, change to the
working folder of the model and enter the following command:
[errorFlag, errorMsg] = rti_build(<mdlName>,
'Command','CleanUp')
or:
[errorFlag, errorMsg] = rtimp_build(<mdlName>,
'Command','CleanUp',['ApplNames',{<appl1>,<appl2>,...}])
Via the 'ApplNames',{<appl1>,<appl2>,...} parameter-value pair
of the rtimp_build command, you can remove the temporary files
of specific applications.
The temporary files of the build procedure are removed.
T
If you replace the 'CleanUp' command with 'CleanUpAll', not only
the temporary files are deleted, but also the generated real-time
application(s). In this case, only the Simulink model and the user files
will remain.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 251
I
How to Update TRC and SDF
Files
If you modified or created a USR.TRC file or USR.SDF file of a model
that you already built real-time code for, you can update the TRC and
SDF files as described below. This is especially useful, for example, if
you started the build process before writing the files, or if you needed
to modify the files.
To update a TRC file
Change to the MATLAB Command Window and enter
rti_usrtrcmerge <model>.mdl
To update a system description file
Change to the MATLAB Command Window and enter
rti_sdfmerge <model>.mdl
In both cases, <model>.mdl denotes the model you want to update.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
252
How to Download DS230<x>
Applications
You might want to automatically download applications for DS230<x>
boards whenever you download an RTI or RTI-MP model.
Download via SDF file If you use one or more DS230<x> boards, you can download the
DS230<x> applications via the <model>_usr.sdf user system
description file of the model. RTI and RTI-MP incorporate the contents
of the user system description file in the generated system description
file (<model>.sdf) whenever you build the model.
To download DS230<x> applications via an SDF file
1 Start ControlDesk, and select Tools SDF File Editor from the
menu bar.
You can also open and modify an existing <model>_usr.sdf file.
2 Select the board type (DS230<x>) and add it. A dialog opens for
you to specify the desired object file(s) for the different channels.
3 Repeat the 2
nd
step for each DS230<x> board.
4 Save and exit the SDF file. If you did not modify an existing
<model>_usr.sdf file, you are prompted for a file name and folder.
Choose the working folder and the name for the Simulink model
according to the name of the model. You can also save a copy
under a new name.
See also Creating System Description Files in the ControlDesk
Experiment Guide.
Download via DDC file If you use only a single DS230<x> board, you can also generate a
C-coded project file (DDC file), which is downloaded automatically
whenever you download the application for the corresponding
processor board. This is the older method and has a few disadvantages
compared to the download via SDF file. Therefore, the download via
SDF file is recommended.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 253
I
N
DDC files are limited to a single DS230<x> board.
If you modify the DS230<x> application or the DDC file, you have
to rebuild the entire model. This might be more time consuming
than if you download the DS230<x> application via an SDF file.
To download DS230<x> applications via a DDC file
1 If not already done, create an SDF file for the DS230<x> board that
specifies the required object files. You can do so via ControlDesks
SDF File Editor.
2 Copy the desired DS230<x> application (meaning the OBJ file and
the SDF file) to the working folder of your model.
3 Create a DDC file by entering the following command at the
MATLAB prompt:
>> ! dds2c ds<xxxx> <ds230<x>_app>.sdf <model_name>
4 Start a build process for the model.
As a result, the DS230<x> applications are included in the object file of
the model and downloaded to the DS230<x> board whenever you
download the object file to your processor board.
T
If you use standard DS230<x> applications provided by the dSPACE
installation, you will find the corresponding SDF files in the folders of
the applications.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
254
Debugging an Application
If you experience problems during the build and download or
simulation, you might want to debug your application:
Analyzing RTI-MP
applications
If you run a multiprocessor system, you might want to use the
rtimpdiag diagnostic tool to analyze the application being executed.
Refer to How to Run the RTI-MP Diagnostic Tool on page 254.
Handling exceptions During real-time simulation you might experience exceptions that are
caused by illegal arithmetic or other invalid operations or system
states. For details, refer to Handling Exceptions on page 256.
How to Run the RTI-MP Diagnostic Tool
After you build and download a multiprocessor application, you might
want some information on its status; for example, whether it initialized
correctly. RTI-MP provides an easy-to-use MATLAB-based tool that can
provide you with such a basic set of information about your
multiprocessor application.
N
To work with the diagnostic tool rtimpdiag, your system requires
MLIB/MTRACE.
To start the RTI-MP diagnostic tool
At the MATLAB prompt, type rtimpdiag [<model>].
If there is only a single SDF file in the working folder, you do not
have to specify the SDF file name.
rtimpdiag provides detailed information on the running program,
possible error codes and initialization failures. In addition, the number
of simulation terminations and reinitializations, as well as the number
of background cycles, evaluations of the base rate, and idle cycles are
reported. Refer to Troubleshooting on page 281 if rtimpdiag reports
any problems.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 255
I
If you want rtimpdiag to provide profiling information for the
interprocessor communication that is operated with the synchronized
swinging buffer protocol, you have to specify the Profile
Synchronized Swinging Buffer Communication option for the
involved CPUs (this option is available on the CPUs page of the
Multiprocessor Setup dialog). As a result, rtimpdiag includes
information on how often data was read, the associated waiting times
and whether the waiting times caused an overrun situation.
E
rtimpdiag displays a table similar to the following one in the MATLAB
Command Window.
>> rtimpdiag
Current connection = 'BUS'.
CPU name : master slave
Board name : ds1005 ds1005_2
----------------------------------------------------------------------------
Program status : started started
Basic hardware initialization : ok ok
Initialization of I/O Boards : ok ok
Installation of interprocessor communication : ok ok
Registration of Simulink model : ok ok
----------------------------------------------------------------------------
Application successfully initialized : ok ok
Error code : 0 0
----------------------------------------------------------------------------
Simulation terminated : 1 x 1 x
Simulation re-initialized : 1 x 1 x
----------------------------------------------------------------------------
Number of cycles in background process : 2742740 3067065
Number of evaluations of the base sample rate : 215792 216537
Number of idle cycles : 41907 41907
The output lines from Basic hardware initialization up to
Application successfully initialized indicate which initialization
steps have been completed successfully by the application.
Errors during initialization are frequently caused by I/O boards that
have been used in the models but cannot be accessed on the
hardware.
rtimpdiag also displays how many times the simulation has been
stopped and restarted.
After a successful initialization, some diagnostic counters are
always incremented by RTI-MP. These counters are displayed in the
last three lines of the rtimpdiag table.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
256
The first counter displays the number of cycles that have been
performed in the background task. If this counter stops, the
real-time processor might have stopped or the application
might not respond.
The second counter is incremented each time one step of the
Simulink model is performed in the base rate service routine,
which corresponds to the fastest timer task.
If the model is in the STOP or PAUSE state, the idle counter is
incremented instead of the base rate cycle counter.
If you specified the Profile synchronized swinging buffer
communication option, an output similar to the following results:
CPU name: master
---------------------------------------------------------------------------------------------
IPC channel | input calls | wait time | max. wait time [usec] | overrun (caused by waiting)
1 41192 0.5 1.85 no
CPU name: slave
---------------------------------------------------------------------------------------------
IPC channel | input calls | wait time | max. wait time [usec] | overrun (caused by waiting)
0 41937 2.8 3.6 no
Handling Exceptions
The exception mechanism allows the processor to change to the
supervisor state as a result of external signals, errors or unusual
conditions arising in the execution of instructions. When exceptions
occur, information about the state of the processor is saved to certain
registers and the processor begins execution at an address predefined
for each exception. The exception message is reported by
ControlDesk. The application stops in most cases when an exception
occurs. With the help of RTLib functions, exceptions can be handled in
such a way that the system is set to a predefined state before
terminating.
Exception mechanism The CPU can generate exceptions if it is not able to complete a given
instruction. By default, arithmetic exceptions are disabled so that the
CPU continues the computation. However, the computation results are
unpredictable. It is not possible to make the processor correct
arithmetic exceptions.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 257
I
Localization of an error When an exception occurs (e.g. data access error, alignment error),
sometimes the error message includes the address that the last
operation was executed on. The location of the address may be a clue
as to which function provoked the error. However, this is not
necessarily the underlying cause of the run-time error, which may have
occurred in a previous function.
Information about the function associated with the address are
available from the MAP file, which is generated at each compilation.
However, it is not possible to find all the addresses, because the
functions are indicated by their start addresses only. To find an
exception that occurred within a function is very difficult, because the
functions are not sorted according to location, but alphabetically
(DS1005) or according to addresses (DS1006). Line numbers for
identifying the instruction in the source code are not displayed.
However, there is a way to get detailed information about the location
of the exception.
Debugging To debug an application, refer to How to Trace an Exception on
page 257.
Finding blocks Real-Time Workshop writes system/block identification tags in the
generated code. The tags are designed to help you identify the block
in your source model that generated a given line of code. Refer to
How to Find the Simulink Block Related to an Exception on page 261.
How to Trace an Exception
It is possible to identify the Simulink block that is responsible for a
particular exception. First you have to identify the relevant source code
in the way described below.
To find the relevant source code for an exception
1 Recompile your application using the -g option of the Microtec
PPC compiler (boards with PowerPC) or DS1006 compiler. This
option adds line number debug information to your generated PPC
file or X86 file.
See also How to Automate the Build Procedure on page 248.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
258
2 Download the application via ControlDesk. ControlDesk issues the
program address of the exception.
3 Invoke the GNU utility ppcobjdump located in %PPC_ROOT%\bin (for
boards with PowerPC processor) or x86-objdump located in
%X86_ROOT%\bin (for the DS1006) to disassemble the object file and
retrieve line number debug information from your application:
This command generates a debug.dmp file containing the following
information for each source code line of the application:
Line number
Function name
Module name
Source code
Assembler listing
Program addresses
N
The source code can be printed to the dump file only if the source
file and the PPC file (boards with PowerPC) or X86 file (DS1006)
are in the same folder.
For detailed information about ppcobjdump, refer to ppcobjdump in
the RTLib Reference of your PowerPC board.
For detailed information about x86-objdump, refer to x86-objdump
in the DS1006 RTLib Reference.
PowerPC: ppcobjdump -S -l -D applname.ppc>debug.dmp
DS1006: x86-objdump -S -l -D applname.x86>debug.dmp
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 259
I
4 For DS1006: Analyze the MAP files to find the function where the
exception occurred (via its absolute start address).
Calculate the offset of the exception to the functions absolute
start address via the formula:
Offset
Exception
= AbsoluteAddress
Exception
- AbsoluteAddress
Function
Search the debug.dmp file for the function name and retrieve the
relative start address of the function.
Calculate the relative address of the exception by adding its offset
to the relative start address of the function.
Finally search the debug.dmp file for the relative address of the
exception to find the corresponding source code line and the
source code itself.
For boards with PowerPC: Search the debug.dmp file for the
address where the exception occurred (see step 2). For this address
you will find the source code line and the source code itself
whenever possible.
E
The following lines are an excerpt from a possible output file for a
board with PowerPC (in this case a DS1005). For a DS1006, the
assembler commands are different and the addresses are relative.
0000481c <MdlOutputs>:
MdlOutputs():
smd_1005_sl.c:67
/* Compute block outputs */
void MdlOutputs(int_T tid)
{
481c: 7c 08 02 a6 mflr r0
4820: 94 21 ff d0 stwu r1,-48(r1)
4824: 93 61 00 1c stw r27,28(r1)
4828: 93 81 00 20 stw r28,32(r1)
482c: 93 a1 00 24 stw r29,36(r1)
4830: 93 c1 00 28 stw r30,40(r1)
4834: 93 e1 00 2c stw r31,44(r1)
4838: 90 01 00 34 stw r0,52(r1)
483c: 3f 80 00 05 lis r28,5
smd_1005_sl.c:69
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
260
if (ssIsContinuousTask(rtS, tid)) {
4840: 80 9c 99 48 lwz r4,-26296(r28)
4844: 37 e3 00 00 addic. r31,r3,0
4848: 40 82 00 90 bne 48d8 <MdlOutputs+0xbc>
484c: 3c 60 00 05 lis r3,5
smd_1005_sl.c:74
/* Integrator: '<Root>/Integrator 2' */
rtB.root_x = rtX.root_Integrator_2_CSTATE;
/* SignalGenerator: '<Root>/x disp' */
if (ssIsMajorTimeStep(rtS)) {
4850: 3f 60 00 05 lis r27,5
4854: c8 23 e4 58 lfd f1,-7080(r3)
4858: d8 3b e4 68 stfd f1,-7064(r27)
485c: 3f a0 00 05 lis r29,5
4860: 80 64 01 3c lwz r3,316(r4)
4864: 3f c0 00 05 lis r30,5
4868: 80 63 00 34 lwz r3,52(r3)
486c: 2c 03 00 01 cmpwi r3,1
4870: 40 82 00 58 bne 48c8 <MdlOutputs+0xac>
4874: 3c 60 00 05 lis r3,5
...
Here the MdlOutputs function is shown, and all machine operations
executed within it and all associated addresses. In the
smd_1005_sl.c file, you have to check the instruction given in line
74 if the error occurred at location 485c, for example.
5 Derive the respective source code line from the C source line close
above the disassembled code. Check whether these instructions
could have caused the exception.
6 If the specified function is associated with a Simulink block, you
can find the block in your model and change its parameters.
See also How to Find the Simulink Block Related to an Exception
on page 261.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 261
I
How to Find the Simulink Block Related to an
Exception
Real-Time Workshop writes system/block identification tags in the
generated code. The tags are designed to help you identify the block
in your source model that generated a given line of code. You should
use the hilite_system command to trace a tag back to the generating
block. For further information on identification tags and code tracing,
refer to the Real-Time Workshop Users Guide by The MathWorks.
To find the Simulink block related to an exception
1 Investigate the model source code (<model>.c) for the Simulink
block causing the problem: Real-Time Workshop begins the source
code for each Simulink block with a token that indicates the block
type and the actual block, for example,
/* Sum Block: <S1>/Sum */
rtB.s1_Sum = - rtB.s1_Product1 - rtB.s1_Product;
2 Make sure that the model is open, change to the MATLAB
Command Window and enter the hilite_system('token')
command. For the above-mentioned Sum block, this would read
hilite_system('<S1>/Sum')
E
Further information on the subsystem identifiers S1, S2, etc. is held at
the end of the <model>.h file, for example:
/*
* Comments are included throughout the generated code which
* allow you to trace directly back to the appropriate location
* in model. The basic format is <system>/block_name, where
* system is the system number (uniquely assigned by Simulink)
* and block_name is the name of the block.
* Use the MATLAB hilite_system command to trace the generated
* code back to the model. For example,
* hilite_system('<S3>') - opens system 3
* hilite_system('<S3>/Kp') - opens and selects block Kp
* which resides in S3
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
262
* Here is the system hierarchy for this model
*
* <Root> : smd_1005_sl
* <S1> : smd_1005_sl/Equation Block
* <S2> : smd_1005_sl/Model Parameters
* <S3> : smd_1005_sl/RTI Data
...
*/
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004 263
I
How to Create an Application
for a Virtual dSPACE System
Suppose you want to create a real-time application for a dSPACE
system that is not available at your developer PC and use another PC
to download it to your dSPACE system. Therefore, you have to use
fictional board names and block numbers.
To create an application for a virtual dSPACE system
1 Create your model as normal using the usual board numbers.
2 Create the related custom C code as normal using the usual board
names. For example, use DS5001_1_BASE to access the DS5001
board with the smallest PHS-bus address if you run a modular
dSPACE system.
3 If you use RTI, build the model with the Load application after
build option cleared (see Real-Time Workshop Page in the RTI and
RTI-MP Implementation Reference).
If you use RTI-MP, build the object files for all CPUs as normal, but
do not download it.
To download an application that was created for a virtual
dSPACE system
Download the real-time application to the dSPACE system using
ControlDesks Platform Manager.
The board numbers of the application are mapped to the PHS-bus
addresses of the I/O boards in ascending order (see PHS-Bus
Address and Board Number on page 43).
If the real-time application does not match the available dSPACE
system (for example, if the application references an I/O board that
is not present), you get an appropriate error message.
Building and Downloading the Model
RTI and RTI-MP Implementation Guide March 2004
I
264
I
RTI and RTI-MP Implementation Guide March 2004 265
External Simulation
The external mode is a simulation mode provided by Simulink,
Real-Time Workshop and RTI. This mode supports on-the-fly
parameter tuning in a real-time environment. External refers to the
fact that this mode involves two separate computing environments, a
host and a target.
The host is the computer that runs MATLAB and Simulink.
The target is the dSPACE real-time hardware that executes the
application you created with Real-Time Workshop/RTI.
Using external mode, you can modify the block parameters of the
real-time application without regenerating and recompiling code, and
without ControlDesk.
In external mode, parameter changes in the Simulink model are
automatically downloaded to the real-time application that is currently
running on your dSPACE hardware. The external mode of RTI and
RTI-MP supports parameter tuning (downloading of parameters). It
does not support data capture (uploading of the simulation results).
For real-time data capture use ControlDesk.
External Simulation
RTI and RTI-MP Implementation Guide March 2004
I
266
Running an external
simulation
Start and stop the external simulation and download parameters to
the real-time simulation. Refer to How to Run an External Simulation
on page 267.
Related Topics
Observing an external
simulation
To observe an external simulation, you can use ControlDesk. Refer to
the ControlDesk Experiment Guide.
Information provided
by The MathWorks
For further information on external simulation, see Real-Time
Workshop User's Guide by The MathWorks.
External Simulation
RTI and RTI-MP Implementation Guide March 2004 267
I
How to Run an External
Simulation
The following instructions describe how you can start the external
simulation after building and downloading the real-time application
and how you can change parameters of the real-time simulation via
the Simulink model.
N
If you run a multiprocessor system you cannot start the external
simulation for the entire model as a whole. Instead, you have to
start the external simulation individually for each CPU.
External simulation can be activated only for boards residing in the
connection that the current working board is in (bus/network). For
example, if the working board is in a bus connection, external
simulation cannot be performed on boards in a network
connection.
To start the external simulation
1 Build and download your model as usual so that it is running on
the dSPACE hardware.
2 If you run a multiprocessor system, open the submodel of the CPU
from the MATLAB prompt (the submodels of all the CPUs are
automatically generated during the build process). The name of a
submodel is the same as the name of the corresponding
application, which is listed in the 2
nd
column of the Application
Setup frame on the Main page of the Multiprocessor Setup dialog.
3 Select the Simulation External command.
4 Select the Simulation Connect to target command.
External Simulation
RTI and RTI-MP Implementation Guide March 2004
I
268
To download parameters via the external simulation
1 Change the parameters in the Simulink [sub]model according to
your requirements. By default, each parameter is downloaded
immediately.
2 If you want to batch the download of several parameters, you can
open the External Mode Control Panel dialog via the Tools
External Mode Control Panel command and select batch
download.
N
Selecting the batch download does not guarantee the data
consistency of the downloaded parameters. Since all
parameters are downloaded asynchronously to the execution
of the model, the real-time simulation might run with an
inconsistent parameter set for one or more sample steps.
The Arm trigger option should always be cleared, otherwise
you get a warning that no blocks have been selected for
uploading.
For information on the External Mode Control Panel, refer to External
Mode Control Panel in the RTI and RTI-MP Implementation Reference.
To stop the external simulation
1 Select the Simulation Disconnect from target command.
2 Before you can carry out a standard Simulink simulation for the
model after working in the external simulation mode, select the
Simulation Normal command.
I
RTI and RTI-MP Implementation Guide March 2004 269
Conventions and
Limitations
Even though RTI is designed to work seamlessly with Simulink and
Real-Time Workshop, there are a few technically related conventions
and limitations.
Toolboxes and blocksets In addition to MATLAB and Simulink, The MathWorks offers a wide
range of blocksets and toolboxes, which are extensions to the basic
MATLAB and Simulink software packages. Refer to Supported
Toolboxes and Blocksets from The MathWorks on page 270.
Data typing MATLAB, Simulink, Real-Time Workshop, RTI, and RTI-MP support
data typing. However, there are a few peculiarities. Refer to Data
Typing Restrictions on page 271.
Conventions There are a number of conventions for implementing models with RTI
and RTI-MP. Refer to Conventions on page 272.
Limitations Refer to Limitations on page 273.
Conventions and Limitations
RTI and RTI-MP Implementation Guide March 2004
I
270
Supported Toolboxes and
Blocksets from The MathWorks
In addition to MATLAB and Simulink, The MathWorks offers a wide
range of blocksets and toolboxes, which are extensions to the basic
MATLAB and Simulink software packages.
As blocksets provide additional Simulink blocks, you must always
know if these blocks can be used with Real-Time Workshop/RTI.
In most cases, toolboxes are simply extensions to MATLAB. This means
that they generally do not provide additional Simulink blocks and that
they have no impact on Real-Time Workshop/RTI compatibility.
However, some toolboxes also provide additional Simulink blocks and
you must know if these are supported by Real-Time Workshop/RTI too.
For blocksets and toolboxes from The MathWorks that provide
Simulink blocks, the RTI compatibility is tested with selected demo
models taken from the MATLAB installation and/or with test models
designed especially for this purpose. These tests naturally cannot cover
the complete functionality range of the blocksets. Although most
possibilities are taken into account, the complexity resulting from the
number of Simulink blocks and their possible parameterizations is far
too large to guarantee tests with a 100% coverage.
N
As a result, problems might occur even for a blockset or toolbox that is
stated to be supported by RTI. You can receive information about the
known problems from blockset- or toolbox-specific pages at
http://www.dspace.de/goto?Toolboxes or by contacting
mailto:info@dspace.de.
Conventions and Limitations
RTI and RTI-MP Implementation Guide March 2004 271
I
Data Typing Restrictions
MATLAB, Simulink, Real-Time Workshop, RTI, and RTI-MP support
data typing. However, there are a few peculiarities.
If you are uncertain whether an integer signal might fall outside
the valid signal range, you should select the Saturate on integer
overflow checkbox in the Block Parameters dialog of the
corresponding block. However, selecting this checkbox results in
code that is computationally more intensive. If you use this option
for a large number of integer blocks, the real-time code might
become slower than if you were not using data typing.
If you clear the Saturate on integer overflow checkbox for an
integer block, an overflow leads to an unexpected result that
depends on both the compiler and hardware.
ControlDesk displays the data types according to their
representation on the hardware; thus the data type displayed in
ControlDesks Variable Browser might differ from that defined in
Simulink. This is not an error.
The following data types are used:
All integer data types have the length specified in Simulink.
The Boolean data type is represented by the unsigned 8-bit
integer data type.
The single data type is a 32-bit floating-point variable.
The double data type is a 64-bit floating-point variable.
Conventions and Limitations
RTI and RTI-MP Implementation Guide March 2004
I
272
Conventions
There are a number of general conventions for implementing models
with RTI and RTI-MP.
Accessibility of parameters By default, ControlDesk can access
only basic parameters of Simulink blocks, not additional parameters
introduced in block masks. If you need to access mask or workspace
parameters, you have to use the Include mask and workspace
parameters option (see Real-Time Workshop Page (for RTI) and
Variable Description File Options Page (for RTI-MP) in the RTI and
RTI-MP Implementation Reference).
File names Ensure that you give your Simulink model a different
name from the files that were initially installed by dSPACE or MATLAB;
for example, do not use the name ds1103.mdl. As a rule of thumb, you
should not use file names that start with ds, rt or rti. This rule applies
even if the file name extensions are different.
File and path names must not contain any blanks.
Mask prompt names Do not use the " character (quotation mark)
in mask prompt names if you want to include the mask and workspace
parameters of the model in the variable description file. This character
leads to syntactically incorrect variable description files since it is used
as a string delimiter.
Naming of interrupt blocks Do not use identical names for
different interrupt blocks in your model. ControlDesk requires unique
names for all of the Task Infos subgroups.
Numerical integration For real-time simulation, use only
fixed-step integration methods.
Sampling time For discrete blocks located in a timer task, you have
to set the sample times to integer multiples of the base sample time.
Simulink block names Do not use the " (quotation mark) and
/ (slash) characters in Simulink block names. These characters lead to
unusable variable description files.
Conventions and Limitations
RTI and RTI-MP Implementation Guide March 2004 273
I
Limitations
General There are a number of general limitations for implementing models
with RTI and RTI-MP. Refer to General Limitations on page 273.
RTI-MP If you implement RTI-MP models, additional limitations apply. Refer to
Limitations with RTI-MP on page 277.
Stateflow If you include Stateflow