Simulink Desktop Real-Time (SLDRT) provides a real-time kernel for executing Simulink models on a laptop or desktop running Windows or MacOS. It includes a library of I/O driver blocks that provide connections between physical I/O devices and your real-time model. You can run your model in Connected IO or Kernel mode, depending on the sample rate that you require:
1. Connected IO mode real-time simulation (before R2021b "Normal Mode"):
If you require a moderate sample rate up to 1 kHz, use Connected IO mode. In this mode, the model is run "normally" within Simulink. Only the I/O module drivers run in the real-time kernel.
This means that in Connected IO mode, SLDRT does not guarantee real-time performance. However, it is capable of reporting to the user when real-time performance cannot be achieved by using the Missed Ticks feature. On each sample hit, I/O is performed, while the rest of the algorithm runs in Simulink, and Simulink tries to synchronize to the real-time I/O. If Simulink makes it in time, there is no missed tick. If Simulink is late, it is indicated by the number of missed ticks Simulink lags behind. If your model contains no I/O blocks, you can add the Real-Time Sync block for the same purpose:
Setting "Maximum Missed Ticks" to some low number or even zero would error out when real-time cannot be met. Some higher number specifies how much tolerance you permit before erroring out, or you may use the missed ticks output port to do any custom action you want.
The advantages of SLDRT Connected IO mode are:
- No additional toolboxes are required.
- The possibility to use blocks that do not support code generation.
- The possibility to use any S-Function and call external binaries.
- The possibility to use variable-step solvers.
The limitations of SLDRT Connected IO mode are:
- No guarantee of real-time (only a detection if real-time constraints are met or not)
- Limited performance of up to 1 kHz.
If you see too many missed ticks while running your model in Connected IO Mode, this can mean that your model is too big or complex to run in the desired sample time. This is a situation where running in Accelerator mode may help, which is an extension of the Connected IO Mode and has the same advantages and limitations.
See this page for a detailed description of SLDRT Connected IO Mode:
2. Kernel mode real-time simulation (before R2021b "External mode"):
If you require a higher sample rate, use Kernel mode. In Kernel mode, the model, solver, and drivers are converted to C code, built into a real-time executable, and run in the real-time kernel. This means that the entire model is running in the real-time kernel and the executable is fully synchronized with the real-time clock. Depending on model complexity and number and type of I/O, it is usable for to up to a 20 kHz sample rate.
The advantages of SLDRT Kernel mode are:
- Guarantee of real-time.
- Good performance of up to 20 kHz.
- Recommend for operation with external real-time I/O hardware.
The limitations of SLDRT Kernel mode are:
- Simulink Coder toolbox is required.
- Models must only use blocks that support code generation
- Limited support for S-Functions and no support for external binaries
- Fixed-step solver is required.
See this page for a detailed description of SLDRT Kernel Mode: