Real-Time Workshop User's Guide    

Part 3: Running the External Mode Target Program

The target executable, ext_example, is now in your working directory. In this section, you run the target program and establish communication between Simulink and the target.

The External Signal & Triggering dialog box displays a list of all the blocks in your model that support external mode signal monitoring and logging. The External Signal & Triggering dialog box also lets you configure which signals are viewed and how they are acquired and displayed. You can reconfigure the External Signal & Triggering dialog box while the target program runs.

In this exercise you will observe and use the default settings of the External Signal & Triggering dialog box.

  1. From the Tools menu, select External Mode Control Panel.
  2. In the External Mode Control Panel, click the Signal & triggering button.
  3. The External Signal & Triggering dialog box opens. The default configuration of the External Signal & Triggering dialog box is designed to ensure that all signals are selected for monitoring. The default configuration also ensures that signal monitoring will begin as soon as the host and target programs have connected. The figure below shows the default configuration for ext_example.

  4. Make sure that the External Signal and Triggering dialog box is set to the defaults as shown:

    Click Close and return to the External Mode Control Panel. Close the External Mode Control Panel.

  1. To run the target program, you must open an MS-DOS command prompt (on UNIX systems, an Xterm window). At the command prompt, type

    and the target program begins execution.

    The -tf switch overrides the stop time set for the model in Simulink. The inf value directs the model to run indefinitely. The model code will run until the target program receives a stop message from Simulink.

    The -w switch instructs the target program to enter a wait state until it receives a Start real-time code message from the host. This switch is required if you want to view data from time step 0 of the target program execution, or if you want to modify parameters before the target program begins execution of model code.

  1. Open Scope blocks A and B. At this point, no signals are visible on the scopes. When you connect Simulink to the target program and begin model execution, the signals generated by the target program will be visible on the scope displays.
  2. The model must be in external mode before communication between the model and the target program can begin. To enable external mode, select External from the simulation mode menu in the toolbar of the Simulink window. Alternatively, you can select External from the Simulation menu.
  3. Reopen the External Mode Control Panel and click Connect. This initiates a handshake between Simulink and the target program. When Simulink and the target are connected, the Start real-time code button becomes enabled, and the caption of the Connect button changes to Disconnect.
  4. Click the Start real-time code button.You should see the outputs of Gain blocks A and B on the two scopes in your model. With A=2 and B=3, the output looks like this.

Having established communication between Simulink and the running target program, you can tune block parameters in Simulink and observe the effects the parameter changes have on the target program. You will do this in the next section.


 Part 2: Building the Target Executable Part 4: Tuning Parameters