Run Model on EV3 Hardware
This example shows you how to configure and run a model on EV3 hardware.
Step 4 overwrites the Model Configuration Parameters. To preserve the configuration of an existing model, select File > Save As to create a working copy of the model that you can reconfigure.
Connect your host computer and EV3 hardware as described in Connect the EV3 Hardware to Host Computer.
Create a new Simulink® model or open an existing model.
In the Modeling tab of the toolstrip, select Model Settings.
In the Configuration Parameters dialog box, select the Hardware Implementation.
Set the Hardware board parameter to
LEGO MINDSTORMS EV3.
Select a value in Target Hardware Resources > Host to Target Connection > Connection type parameter. Make sure you select the same connection type as you have chosen for connecting your host computer and the EV3 brick.
The different connection types are:
USB - This is the default option.
Bluetooth® - Enter a value in the Device ID parameter.
Wi-Fi® - Enter values in the Device ID and the IP address parameters.
Ethernet - Enter values in the Device ID and the IP address parameters.
You can use the EV3 Brick Interface to get the Device ID and the IP address from the Brick Info screen.
(Optional- applicable for Wi-Fi and Ethernet connection type) Verify that the EV3 brick with the specified IP address is reachable on the network. For example, in the MATLAB® Command Window, enter:
ans = legoev3 with properties: ipAddress: '172.21.128.249'
If the EV3 brick is reachable on the network, the function displays the IP address of the brick. Otherwise, it returns a “failed to connect” error message.
In the Hardware tab, click Build, Deploy & Start.
Simulink software loads and runs the model on the EV3 hardware. You can see the successful build procedure message in the Diagnostic Viewer as shown.
To troubleshoot issues running models on EV3 hardware, see Viewing Build Failure Message in Diagnostic Viewer.
To stop a model running on the EV3 hardware, use either of the following methods:
stopModelin the MATLAB Command Window.
Press the Back button on the EV3 hardware and respond to any prompts on the EV3 display.
To troubleshoot issues stopping models on EV3 hardware, see Stopping the Model on EV3 Hardware.
To restart a model running on the EV3 hardware, use either of the following methods:
Using the EV3 Brick Interface, navigate to the File Navigation screen and open the
mwfolder. Then, select the model from the list of programs and press the Center button on the EV3 hardware.
runModelin the MATLAB Command Window.
To delete a model from the EV3 hardware, use the
Viewing Build Failure Message in Diagnostic Viewer
After clicking Deploy to Hardware, if your model is not successfully deployed on EV3 hardware, the following error is shown in the Diagnostic Viewer.
The possible causes for unsuccessful build are:
The EV3 is not switched on.
The host computer cannot connect to EV3 because:
EV3 is not properly connected to the host computer through USB.
A fault in Bluetooth pairing between EV3 and the host computer.
The Model Configuration Parameters contains the wrong IP address.
The Wi-Fi or Ethernet dongle are not connected to the EV3 hardware.
EV3 does not have a Wi-Fi connection to the network.
To fix this problem, complete the steps in Set Up the EV3 Hardware and Run Model on EV3 Hardware
Troubleshoot a Model not Running After Successful Deployment
If your model does not run after successful deployment, make sure that the ‘Brick Info’ screen is not displayed on the EV3 brick. If true, come out of the screen and retry.