This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Tune and Monitor Models Running on Target Hardware

Overview of Using External Mode

You can use External mode to tune parameters and monitor a model running on your target hardware.

External mode enables you to tune model parameters and evaluate the effects of different parameter values on model results in real time. Doing so helps you find the optimal values to achieve desired performance. This process is called parameter tuning.

External mode accelerates parameter tuning because you do not have to rerun the model each time you change parameters. You can also use External mode to develop and validate your model using the actual data and hardware for which it is designed. This software-hardware interaction is not available solely by simulating a model.

This workflow lists the tasks usually required to tune parameters with External mode:

  1. In the model on your host computer, enable External mode.

  2. (Optional) Place one or more sink blocks in your model. For example, use Display or Scope blocks to visualize data, or use a To File block to log signal data.

  3. Give the Simulink® software command to run the model on the target hardware.

  4. (Optional) Observe the data External mode sends from the target hardware to sink blocks in the model on the host computer.

  5. Change and apply parameter values in the model on your host computer.

  6. Find the optimal parameter values by making adjustments and observing the results.

  7. Save the new parameter values, disable External mode, and save the model.

Run Your Simulink Model in External Mode

    Note:   If you have the Embedded Coder® or Simulink Coder™ software, you can use External mode with a model that contains Model blocks (uses the "Model reference").

  1. Connect the target hardware to your host computer.

    Different types of target hardware can use different types of connections. Check the External mode topic for your target hardware to determine which type of connection to use.

  2. On the model toolbar, set Simulation mode to External.

  3. Set the Simulation stop time parameter, located to the left of Simulation mode on the model toolbar. The default value is 10.0 seconds. To run the model for an indefinite period, enter inf.

  4. Click the Run button.

    If your model does not contain a sink block, the MATLAB® Command Window displays a warning message. For example:

    Warning: No data has been selected for uploading. 
    > In C:\Program Files (x86)\MATLAB\R2013a Student1\toolbox\
    extModeAutoConnect at 17
    In C:\Program Files (x86)\MATLAB\R2013a Student1\toolbox\
    realtime\realtime\sl_customization.p>myRunCallback at 149

    You can disregard this warning or add a sink block to the model.

    After several minutes, Simulink starts running your model on the board.

  5. Change parameter values in the model on your host computer.

    Observe the corresponding changes in the model running on the hardware.

    Any Simulink Sinks blocks in your model receive data from the hardware and display it on your host computer.

    Note:   External mode increases the processing burden of the model running on the board, and can cause overruns.

Stop External Mode

To stop the model running in External mode, click the black square Stop button located on the model toolbar, as shown here.

This action stops the process for the model running on the target hardware, and stops the model simulation running on your host computer.

If the Simulation stop time parameter is set to a specific number of seconds, External mode stops when that time elapses.

When you are finished using External mode, set Simulation mode back to Normal.

External Mode Control Panel

Using External Mode Control Panel provides additional control of External mode operations, including:

  • Connect or disconnect the model on the host computer to/from the model running on the target hardware.

  • Start and stop the model running on the target hardware.

  • Gather changes to parameter values in a batch before applying them concurrently to the model running on the target hardware.

To open the External Mode Control Panel dialog box, in the model window, select Code > External Mode Control Panel.

The Connect/Disconnect button connects or disconnects the model on your host computer to/from the model running on the target hardware. If the model is not running on the target hardware, clicking Connect automatically deploys and runs the model on the target hardware.

  • The Start Real-Time Code/Stop Real-Time Code button starts or stops the model running on the target hardware.

  • Batch download enables you to gather changes before using the Download button to simultaneously apply those changes to the model running on the hardware:

    • While Batch download is disabled, clicking OK or Apply in a block dialog box sends updated block parameter values from the block to the model running on the target hardware.

    • When you enable Batch download, clicking OK or Apply in a block dialog box stores updated block parameter values on the host computer. You can complete a set of changes before clicking Download to simultaneously send all of the updated values to the model running on the target hardware. This feature is useful for avoiding error conditions when a model contains blocks whose parameter values must be changed concurrently.

External Mode Control Panel displays Parameter changes pending... to the right of the Download button until the model running on the target hardware has applied the new parameter values.

See Also

Was this topic helpful?