Set Configuration Parameters

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.

  1. In the MATLAB® window, type xpc_osc2.

    MATLAB loads the oscillator model and displays the Simulink block diagram.

  2. In the Simulink window, click Simulation > Model Configuration Parameters.

  3. In the Configuration Parameters dialog box, click the Solver node.

  4. In the Solver options section, from the Type list, select Fixed-step.

  5. From the Solver list, select a solver. For example, select the general-purpose solver ode4 (Runge-Kutta).

  6. Under Additional Options, in the Fixed-step size (fundamental sample time) box, enter the sample time for the real-time application. For example, enter 0.00025 seconds (250 microseconds). 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 0.0002 seconds.

    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.

  7. In the Configuration Parameters dialog box, click the Code Generation node.

    The code generation pane opens.

  8. To build a basic real-time application, in the Target selection section, click Browse at the System target file list. Click slrt.tlc, and then click OK.

    The system target file slrt.tlc, the template makefile xpc_default_tmf, and the make command make_rtw are automatically entered into the page. The Simulink Real-Time Options node appears in the left pane.

  1. 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 click OK.

    If you select slrtert.tlc without Embedded Coder installed, the build fails.

  2. 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.

  3. From the Execution mode list, select either Real-Time or Freerun.

    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, Freerun mode execution does not support variable-step solvers.

    In addition, multirate models cannot be executed in Freerun execution mode. On the Solver pane in the Configuration Parameters dialog box, set Tasking mode for periodic sample times to SingleTasking.

  4. From the Real-time interrupt source list, select a source. The default value is Timer.

  5. Select the Log Task Execution Time check box to log task execution times to the target object property tg.TETlog.

    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 (NaN).

  6. 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.

  7. 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 tg.

  8. Click OK.

  9. From the File menu, click Save as. Enter a file name. For example, enter xpc_osc3 and then click Save.

The next task is Start Target Computer.

Was this topic helpful?