Why does it take so long to stop a real-time application running on Speedgoat if my model contains many tunable parameters?
46 views (last 30 days)
MathWorks Support Team on 26 Sep 2022
When I try to stop the application running on my Speedgoat real-time target using "tg.stop", or the 'Stop' button in Simulink or SLRT Explorer, this can sometimes take up to 15 seconds or even more until MATLAB is no longer 'Busy' executing the Stop command.
Additionally, I sometimes get the following prompt indicating a time-out:
Error communicating with target 'TargetPC1':
Cannot stop application on target 'TargetPC1':
Timed-out waiting for application to stop.
MathWorks Support Team circa 15 ore ago
Edited: MathWorks Support Team circa 2 ore ago
When the application stops, an automatic parameter set file named "autoSaveOnStop" will be saved on the target. It contains the values of all tunable parameters at stop-time. This behavior is documented here: importParamSet
If your application contains many tunable parameters (in the order of several 100,000 doubles), this parameter autosave feature may be causing a longer delay when stopping the application. Our development team is working on addressing this performance issue for a future release of MATLAB.
(1) To avoid the delay, use the following code to disable the parameter autosave feature after your model has been built into a .mldatx file:
myApp = slrealtime.Application(mdlName);
This option was officially added in R2022b, but was also made available through R2022a Update 1 and R2021b Update 4.
The "updateAutoSaveParameterSetOnStop" option is documented here and shows a more complete code example to run the simulation from the MATLAB Command Line: updateAutoSaveParameterSetOnStop
To use the option with External Mode ("Run on Target" button), use the "Step by Step" commands and run the code above after the "Build Application" step: Execute Real-Time Application in Simulink External Mode by Using Step-by-Step Commands
(2) Another workaround would be to consider reducing the number of tunable parameters in your code by inlining them: Default parameter behavior
If the above doesn't help, see the following answer for other reasons why your real-time simulation may take a long time to stop: https://www.mathworks.com/matlabcentral/answers/1813565-why-does-it-take-so-long-to-stop-my-speedgoat-real-time-application
The "Timed-out waiting for application to stop" error message could also indicate that the target got in some kind of bad state or is hanging when the application stops. To further investigate this, check the Speedgoat status monitor using PuTTY to see if any message comes up when you try to stop the application: Target Computer Status Monitor
Contact MathWorks Technical Support with your findings.