Real-Time Workshop User's Guide    

Part 2: Building the Target Executable

In this section, you set up the model and code generation parameters required for an external mode compatible target program. Then you generate code and build the target executable.

  1. Open the Simulation Parameters dialog box. On the Solver page, set the Solver options Type to Fixed-step, and the algorithm to discrete (no continuous states). Set Fixed-step Size to 0.01. Leave the other parameters at their default values.
  2. On the Workspace I/O page, deselect Time and Output. In this exercise, data will not be logged to the workspace or to a MAT-file.
  3. On the Real-Time Workshop page, select Target configuration from the Category menu.

    By default, the GRT target should be selected, as shown in this picture.

    If the GRT target is not selected, click the Browse button and select the GRT target from the System Target File Browser. Then click OK to close the browser. Return to the Real-Time Workshop page and click Apply.

  1. Select GRT code generation options from the Category menu and check the External mode option.This enables generation of external mode support code.

  2. Click Apply.
  3. On the Advanced page, make sure that the Inline parameters option is deselected. External mode does not currently support the Inline parameters option.

    The Advanced page should look like this picture.

  1. From the Tools menu, select External Mode Control Panel. The External Mode Control Panel, lets you configure host/target communications, signal monitoring, and data archiving. It also lets you connect to the target program and start and stop execution of the model code.

The top four buttons are for use after the target program has been launched. The three lower buttons open three separate dialog boxes:

  1. Click the Target interface button to open the External Target Interface dialog box. This dialog box configures the external mode interface options.

    The MEX-file for external interface field specifies the name of a MEX-file that supports host/target communications on the host side. The default is ext_comm, a MEX-file provided by the Real-Time Workshop. ext_comm supports communication via the TCP/IP communications protocol.

    The MEX-file arguments field lets you specify arguments, such as a TCP/IP server port number, to be passed to the external interface program. Note that these arguments are specific to the external interface file you are using. For information on these arguments, see "The External Interface MEX-File" on page 5-40.

    This exercise uses the default arguments. Leave the MEX-file arguments field blank.

    The External Target Interface dialog box should appear as shown below.

  1. Click OK to close the External Target Interface dialog box and return to the External Mode Control Panel.
  2. Close the External Mode Control Panel.
  3. Save the model.
  4. Return to the Real-Time Workshop page. Click Build to generate code and create the target program. The content of the succeeding messages depends on your compiler and operating system.The final message is

In the next section, you will run the ext_example executable and use Simulink as an interactive front end to the running target program.


 Part 1: Setting Up the Model Part 3: Running the External Mode Target Program