xPC Target | ![]() ![]() |
Entering the Simulation Parameters
The simulation and real-time run parameters are entered in the Simulink Parameters dialog box. They give information to Real-Time Workshop for how to build the target application from your Simulink model.
After you load a Simulink model and boot the target PC, you can enter the simulation parameters. This procedure uses the Simulink model xpcosc.mdl
as an example and assumes you have already loaded that model.
Simulink displays the Solver page. This page defines the initial stop and sample time for your target applcation.
tg.Stoptime
.0.00025
seconds (250
microseconds). You can change this value after creating the target application.If you find that 0.000250
seconds results in overloading the CPU on the
target PC, try a larger Fixed step size such as 0.002
seconds.
If your model contains discrete states, which would lead to a hybrid model,
the sample times of the discrete states can only be multiples of the Fixed
step size. If your model does not contain any continuous states, enter
'auto'
, and the sample time is taken from the model.
The Solver page should look similar to the figure shown below.
The Workspace I/O page opens. This page defines which model signals are logged during the simulation of your model or the real-time run of your target application.
To save (log) data from signals other than the state values, you need to add outport blocks to your Simulink model and connect the signals to the outport blocks.
Note When running your target application in real-time, data is not saved
to the variables tout
and yout
. Instead, data is saved to the target object
properties TimeLog, StateLog, and OutLog. However, you must still select
the Time, States, and Output check boxes for data to be logged into the
target object properties.
The Workspace I/O page should look similar to the figure shown below.
Normally all the check boxes are activated, except maybe in the following cases:
The System target file xpctarget.tlc
, the Template makefile
xpc_default_tmf
, and the Make command make_rtw
are automatically
entered into the page. The Real-Time Workshop page should now look like
the figure shown below.
tg.TETlog
. Selecting the Enable Signal Acquisition (Scope) Engine check box allows you to add scopes to the target PC. For example, the model xpcosc.mdl
has 6
signals (1 time, 2 states, 2
outputs, and 1 TET). If you enter a buffer size of 100000
, then the target
object property tg. MaxLogSample
is calculated as 100000 / 6 = 1666. After
saving 1666 sample points the buffer wraps to collect the next 1666 samples.
If you select a logging buffer size larger then the RAM on the target PC, the target PC displays a message, ERROR: allocation of logging memory failed, after downloading and initializing the target application. In this case you need to install more RAM or reduce the buffer size for logging. In any case the target PC has to be rebotted.
tg
.Your next task is to create (build) the target application. See Building and Downloading the Target Application.
![]() | Troubleshooting the Boot Process | Building and Downloading the Target Application | ![]() |