You can use External mode to tune parameters in, and monitor data from, your model while it is running on the Arduino® Mega 2560,Arduino Mega ADK, and Arduino Due hardware. This capability is not available with Arduino Uno hardware.
External mode enables you to tune model parameters and evaluate the effects of different parameter values on the model results in real-time, in order to find the optimal values to achieve the desired performance. This process is called parameter tuning.
External mode accelerates parameter tuning because you do not have to re-run the model each time you change parameters. External mode also lets you 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.
The following list provides an overview of the parameter tuning process with External mode:
In the model on your host computer, you enable External Mode in the Simulation Mode drop down on the Simulink Editor.
In the model on your host computer, you configure Simulink® software to run your model on the target hardware.
You use the model on the host computer as a user interface for interacting with the model running on the target hardware:
When you open blocks and apply new parameter values on the host computer, External mode updates the corresponding values in the model running on the target hardware.
If your model contains blocks for viewing data, such as Scope or Display blocks, External mode sends the corresponding data from the target hardware to those blocks on the host computer.
You determine the optimal parameter settings by adjusting parameter values on the host computer and observing data/outputs from the target hardware.
When you have finished tuning a model, you can disable External mode and run the tuned model on your hardware.
Some limitations apply while you are using External mode:
Do not configure Serial Receive or Serial Transmit blocks in your model to use serial port 0 because the External mode uses serial port 0. However, you may use the Serial blocks with Wi-Fi or TCP/IP external mode.
Do not use the following Arduino® servo blocks: Standard Servo Read, Standard Servo Write, and Continuous Servo Write.
Connect your Arduino Mega 2560 or Arduino Due hardware to the host computer using a USB cable.
Create or open a Simulink model located on a local drive or a mapped network drive that has a drive letter assigned to it.
The software generates an error message if the location of the
model contains a UNC path. For example,
To prepare and run the model:
On the model toolbar, set Simulation mode to
Set the Simulation stop time parameter,
located to the left of Simulation mode on the
model toolbar. The default value is
To run the model for an indefinite period, enter
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\ realtime\realtime\+realtime\extModeAutoConnect.p> 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 a few seconds, Simulink starts running your model on the board.
While the model is running in External mode, you can change tunable parameter values in the model on your host computer and observe the corresponding changes in the model running on the hardware.
If your model contains blocks from the Simulink Sinks block library, the sink blocks in the model on your host computer display the values generated by the model running on the hardware.
If your model does not contain a sink block to which External mode can send data, the MATLAB Command Window displays a "No data has been selected for uploading" warning. You can disregard this warning, or you can add a sink block to the model and rerun your model.
When you have finished tuning and monitoring your model, you can disable External mode.
To deploy model to your hardware without using External mode. See Run Model on Arduino Hardware.
Note: External mode increases the processing burden of the model running on the hardware. If the software reports an overrun, you can apply the solutions described in Detect and Fix Task Overruns on Arduino Hardware.
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