xPC Target | ![]() ![]() |
Entering Parameters for Outport Blocks
During a simulation, Simulink saves signal data to MATLAB variables using Outport blocks. The default MATLAB variables are tout
, xout
, and yout
. While running a real-time application, xPC Target uses these same variables to pass signal data to target object parameters. A target object is a structure in the MATLAB workspace that xPC Target uses to interact with a target application. The default target object is tg
, and the default parameters are tg.Time
, tg.States
, and tg.Output
.
After you add an Outport block to your Simulink model, you can enter parameters. This procedure uses the model xpc_osc1.mdl
with an outport block as an example. To add an Outport block, see Adding a Simulink Outport Block.
0
second. In the Stop time box, enter an initial stop time. For example, enter 20
seconds. To change this time after creating your target application, change the target object property tg.Stoptime
to the new time using the MATLAB command-line interface.
Fixed-step
. Real-Time Workshop does not support variable step solvers. From the algorithm list, select a solver. For example, select the general purpose solver ode4 (Runge-Kutta)
. In the Fixed step size box, enter the sample time for the target application. For example, enter 0.00025
second (250
microseconds). You can change this value after creating the target application.
0.000250
second 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 with both continuous and discrete states, 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 pane should look similar to the figure shown below.
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 pane should look similar to the figure shown below.
Normally you select all of the Save to workspace check boxes. However, you may want to consider clearing some or all of them off in the following cases:
Your next task is to add an xPC Target Scope block to your Simulink model. See Adding an xPC Target Scope Block.
![]() | Adding a Simulink Outport Block | Adding an xPC Target Scope Block | ![]() |