Main Content

Run Model as Standalone Application

You can prepare, configure, and run a model on your target hardware. If you want to be able to tune parameters and observe application output, then see Signal Monitoring and Parameter Tuning.

Before starting this procedure:

  • Connect your board to the network and to a power supply.

    Note

    You must have an Internet connection from either the host connected to the target hardware or from the target hardware itself. This connection is necessary in case the software must update the firmware or drivers.

    If your target hardware is not connected to an Ethernet network, follow the instructions in the appropriate support package documentation:

  • Create or open a Simulink® model.

Running a new or updated model on the board:

  • Automatically stops a running model with the same name.

  • Does not stop running models that have other names.

Configure Model

  1. In your model, set simulation the stop time to inf to run the simulation until you explicitly pause or stop the model.

  2. Select Tools > Run on Target Hardware. Then, select either Prepare to Run or Options.

  3. In the Configuration Parameters dialog box, select the Hardware Implementation pane.

    select the Hardware Implementation pane from the configuration parameters dialog box and set the required parameters.

    1. Set Hardware board to Raspberry Pi or BeagleBone Black.

    2. Review the other parameters on this pane.

      • Raspberry Pi® hardware:

        • If you performed a firmware update, Board information is populated with the IP address, user name, and password of your Raspberry Pi hardware. Make sure that the IP address contains the correct address for your hardware. If it is not correct or not present, see Get IP Address of Raspberry Pi Hardware (Simulink).

        • Verify that the TCP/IP port parameter is set to the default value 17725. Simulink uses this TCP/IP port to communicate with Raspberry Pi hardware.

      • BeagleBone Black hardware:

        Under Target Hardware Resources, verify that Device Address, Username, and Password are correct for your board.

    3. To apply any changes and close the dialog box, click OK.

Build and Deploy Model

In the Simulink toolbar, click Deploy to Hardware .

The model is now running on the external hardware. A system command window opens that shows the messages coming from the model running on the target hardware.

Run and Stop Model on Target Hardware

The hardware support packages for Raspberry Pi and BeagleBone Black generate a Linux® executable for each Simulink model you run on the target hardware. To run and stop the model, you use the System object methods that run and stop execution on the target hardware.

  1. Create an object for the hardware.

    For Raspberry Pi hardware, enter:

    rpi = raspberrypi;

    For BeagleBone Black hardware, enter:

    bbone = beaglebone_black;

    The command generates an object for communicating with the hardware from the MATLAB® command line.

  2. To stop the model on the target hardware, at the MATLAB command line, call the object method that stops execution on the target hardware.

    For example, for Raspberry Pi hardware, enter:

    stop(rpi,'Name_of_model')

    For example, for BeagleBone Black hardware, enter:

    stopModel(bbone,'Name_of_model')

    The Name_of_model argument is the name of the model you deployed to the target hardware.

  3. To run a previously built Simulink model on your target hardware, at the MATLAB command line, call the object method that starts execution on the target hardware.

    For example, for Raspberry Pi hardware, enter:

    run(rpi,'Name_of_model')

    For example, for BeagleBone Black hardware, enter:

    runModel(bbone,'Name_of_model')

Related Topics