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:
Configure Network Settings on Raspberry Pi Hardware (Simulink Support Package for Raspberry Pi Hardware)
Get the IP Address of a BeagleBone Black Board (Embedded Coder Support Package for BeagleBone Black Hardware)
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.
In your model, set simulation the stop time to inf
to
run the simulation until you explicitly pause or stop the model.
Select Tools > Run on Target Hardware. Then, select either Prepare to Run or Options.
In the Configuration Parameters dialog box, select the Hardware Implementation pane.
Set Hardware board to Raspberry
Pi
or BeagleBone Black
.
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 the Network Settings of the Raspberry Pi Hardware (Simulink Support Package for Raspberry Pi Hardware).
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.
To apply any changes and close the dialog box, click OK.
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.
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.
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.
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.
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')