MATLAB: What is causing missed ticks in the Simulink Desktop Real-Time simulation, and how can I reduce them

I have a model that is running in Normal Mode in Simulink Desktop Real-Time and I am using it to interface with external I/O hardware. I added a Real-Time Sync block to my model to measure the missed ticks.
However, I am getting random spikes in missed ticks (model overrun or lag) while executing my model at random points during execution. This is causing my data input/output to be interrupted. This seems to occur regardless of the sample time I chose. Is there a way to reduce these missed ticks?

Best Answer

Possible reasons for missed ticks are:
1) Temporary events in the OS (Windows or macOS), such as mouse movements or opening a document, may cause sporadic missed ticks.
2) The model is too big or complex to run in the desired sample time. This means the computations of the model are above what the computer can do in the allotted sample time, and therefore you see missed ticks, and these will tend to increase until the model stops. This is a situation where running in Accelerator mode may help.
If not even Accelerator mode can help achieve the required performance, External mode may make more sense for your application. In External mode the model runs on the real-time kernel and is synchronized with the real-time clock. However in Normal or Accelerator mode, the model runs in the Simulink process and it is not synchronized with a real-time clock.
In general, External mode is recommended for operating with real-time I/O hardware. You can read more here: