The example model,
xpc_osc2, is a non-real-time
model of a damped oscillator. You enter the simulation and real-time
run parameters in the Configuration Parameters dialog box. These parameters
give information to Simulink® Coder™ on how to build the real-time
application from the Simulink model.
After you open a Simulink model and start the target computer, you can enter the simulation parameters.
In the MATLAB® window, type
MATLAB loads the oscillator model and displays the Simulink block diagram.
In the Simulink window, click Simulation > Model Configuration Parameters.
In the Configuration Parameters dialog box, click the Solver node.
In the Solver options section,
from the Type list, select
From the Solver list,
select a solver. For example, select the general-purpose solver
Under Additional Options,
in the Fixed-step size (fundamental sample time) box,
enter the sample time for the real-time application. For example,
0.00025 seconds (
You can change this value after creating the real-time application.
If you find that
0.000250 seconds results
in overloading the CPU on the target computer, try a larger Fixed-step
size value, such as
The sample times of the model blocks can only be multiples of Fixed-step
size. If you enter
'auto' in Fixed-step
size, the fundamental sample time is calculated from the
sample times of the model blocks.
In the Configuration Parameters dialog box, click the Code Generation node.
The code generation pane opens.
To build a basic real-time application,
in the Target selection section, click Browse at
the System target file list. Click
and then click OK.
The system target file
the template makefile
xpc_default_tmf, and the
make_rtw are automatically entered
into the page. The Simulink Real-Time Options node
appears in the left pane.
If you have Embedded Coder® software,
you can build an ERT real-time application. To build an ERT real-time
application, in the Target selection section,
click Browse at the System target
file list. Click
slrtert.tlc, and then
If you select
slrtert.tlc without Embedded Coder installed,
the build fails.
In the left pane, click the Simulink Real-Time Options node.
The associated pane is displayed. These are model-level configuration parameters that you can set for the model. For a description of the options on this node, see Configuration Parameters.
From the Execution mode list,
Freerun mode execution is similar
to a simulation, but uses the generated code. The target computer
runs the real-time application as fast as possible, which may be faster
than real-time execution. However,
execution does not support variable-step solvers.
In addition, multirate models cannot be executed in
mode. On the Solver pane in the Configuration
Parameters dialog box, set Tasking mode for periodic sample
From the Real-time interrupt source list,
select a source. The default value is
Select the Log Task Execution
Time check box to log task execution times to the target
The task execution time is the time in seconds to complete calculations
for the model equations and post outputs during each sample interval.
If you do not select this box, the average TET value appears as Not
a Number (
In the Signal logging buffer size in doubles box, enter the maximum number of sample points to save before wrapping, for example, 100000. This buffer includes the time, states, outputs, and task execution time logs.
In the Name of Simulink Real-Time object created
by build process box, enter the name of the target object
created by the build process. The default target object name is
From the File menu,
click Save as. Enter a file name. For example,
xpc_osc3 and then click Save.
The next task is Start Target Computer.