Tune and Monitor Executable Running on BeagleBone Black Hardware

Using External Mode

You can use external mode to tune parameter values in, and receive data from, the executable while it is running on your hardware.

With external mode, you can tune model parameters and evaluate the effects of different parameter values on the executable while it is running on the hardware. This process is called parameter tuning.

External mode accelerates parameter tuning because you do not have to generate code, build, and run the executable each time you change the value of a parameter. You can also use External mode to develop and validate your application using the actual data and hardware for which the application is designed. This software-hardware interaction is not available by simulating a model.

This workflow lists the tasks to tune parameters with External mode.

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

  2. (Optional) Place one or more Sink (Simulink) 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. Click the Run button in the model. Embedded Coder:

    • Builds, loads, and runs an executable on the BeagleBone Black hardware.

    • Runs the model on the host computer in external mode.

    • Creates an external mode connection between the executable on BeagleBone Black hardware and the model on the host computer.

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

  5. (Optional) Change parameter values in the model on your host computer. External mode changes those values in the executable running on the hardware.

  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.

See also: Host-Target Communication with External Mode Simulation (Simulink Coder).

Run Your Simulink Model in External Mode

  1. Verify that you can run an executable on the BeagleBone Black hardware, as described in Build and Run Executable on BeagleBone Black Hardware.

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

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

  4. Optional: To observe data that external mode sends from the executable to the model on the host computer, place one or more sink (Simulink) blocks in your model. To visualize data, attach Display or Scope blocks to signals in the model. To log signal data, use a To File block. Also review the options under the Simulation Data Inspector button.

  5. Optional: To log signal data, enable MAT-file logging. See MAT-file logging (Simulink Coder).

  6. Click the Run button.

    External mode:

    • Runs the binary executable on the BeagleBone Black hardware.

    • Runs the model on the host computer in external mode.

    • Establishes external mode communication between the executable and the model.

  7. Change block parameter values in the model on your host computer. External mode applies the new parameters values to the executable running on the BeagleBone Black hardware. Observe the effects of those changes and optimize the parameter values.

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

Tip

When you finish tuning and monitoring your application, disable External mode by setting Simulation mode to Normal.

Stop External Mode

When a model stops simulating in external mode, the binary executable stops running on the hardware.

To stop the model simulating in external mode, click the Stop button.

If the Simulation stop time parameter is set to a numeric value such as 10 seconds, external mode stops when that period of time elapses.

Display Verbose External Mode

To help troubleshoot problems with external mode communications, you can configure a model to display verbose external mode messages in the Command Window.

  1. In the Simulink Editor, select Simulation > Model Configuration Parameters

  2. In the Configuration Parameter dialog box, click Hardware Implementation. From the Groups list, select the External Mode pane.

  3. Select the check box for the Verbose parameter. Click OK or Apply.

  4. When the model runs in external mode, review the External mode messages in the Command Window. For example:

    Got EXT_SETPARAM_RESPONSE from target with status OK.
    Got EXT_SELECT_SIGNALS_RESPONSE from target for upInfoIdx 0 with status OK.
    action: EXT_SELECT_TRIGGER
    Got EXT_CANCEL_LOGGING_RESPONSE from target for upInfoIdx 1 with status OK.
    Got EXT_MODEL_START_RESPONSE packet from target.
    Got EXT_SELECT_TRIGGER_RESPONSE from target for upInfoIdx 0 with status OK.
    action: EXT_ARM_TRIGGER
    Got EXT_ARM_TRIGGER_RESPONSE from target for upInfoIdx 0 with status OK.
    action: EXT_MODEL_STOP
    Got EXT_MODEL_SHUTDOWN packet from target.
    action: EXT_DISCONNECT_CONFIRMED

Related Topics