The general workflow for using External Mode with Hardware Support Packages is as follows:
- With the Stop Time set to 'Inf', click "Monitor & Tune". This deploys an executable generated from the model onto the hardware and creates a connection between it and Simulink. This is often the only step needed.
- When the model is already deployed and running from step 1, select "Disconnect" from the "Step by Step Commands". This disconnects Simulink from the hardware, but the executable continues running.
- Now select "Connect" from the "Step by Step Commands". This reestablishes the connection between Simulink and the already running executable on the hardware. This can save time if you don't need to regenerate, compile, and deploy the code.
- The "Stop" option stops the executable from running and breaks the communication link. In order to run the model again, you need to go back to step 1.
Using the "Connect" option when there isn't currently an executable currently running on the target hardware may result in an error message such as this:
Error occurred while executing External Mode MEX-file 'ext_comm':
Failed to connect to the target. A time-out occurred while waiting for the connection response from the target. Possible reasons for the time-out:
a) The target is not switched on.
b) The target is not connected to your host machine.
c) The application for the model is not running on the target. You might have clicked the Stop button. If the Run button is not dimmed, click it. Otherwise, click the Build button, which downloads and runs your application on the target.