MATLAB: Input and output signals not visible in scope when simulating in external mode with Arduino Due

arduinodueexternalhardwareinsufficientmodesamplesscopesimulinktargetTarget Support Package

I'm trying to run a Simulink model on an Arduino Due, but I can't seem to run this in external mode and be able to read the scopes. I see no output in the scope that is connected to the output pins of the arduino. I receive an error (see attached screenshot) when I open the scope.

Best Answer

The 'External Mode' communication option in Simulink uses acknowledgement-based protocol, which takes approximately
30 milliseconds to upload data from the hardware back to Simulink. Therefore, when the sample rate is set to a value between 
1-100 microseconds, or if the 'Tasking mode for periodic sample times' parameter is set to Auto or Multitasking, you will see
missing data samples, as data is not available for every time step. 
The Multitasking scheduler on Arduino Due takes more than 1 microsecond to perform context switching. With this constraint,
setting the sample rate to 1 microsecond is not feasible.
Workarounds for this would be:
  • Decrease the sample time of the model, or
  • Set the 'Tasking mode for periodic sample times' to "Singletasking" mode.                                                                                                                                                                                                                 This can be done by going to Model configuration parameters --> Solver --> 'Tasking mode for periodic sample times' --> Set to "SingleTasking".
In the Simulink version for R2016b, the External mode performance has been improved by reducing the data upload time.
Therefore, we recommend trying the R2016b Simulink Arduino support package.