Real-Time Simulation
To evaluate the real-time behavior of your model, run the model, log data, tune parameters, and view signals from the Simulink® toolbar. Capture signals from the model and display them with standard Simulink Scope blocks. Run your model in Connected IO mode, accelerator mode, or Run in Kernel mode, depending upon the sample rate that you require.
If you require a moderate sample rate, up to 1 kHz, use Connected IO mode or accelerator mode. In these modes, you run the Simulink model within MATLAB®. Only the I/O module drivers run in the Simulink Desktop Real-Time™ kernel.
If you require a higher sample rate, up to 20 kHz, use Run in Kernel mode. In Run in Kernel mode, you use Simulink Coder™ to generate a real-time application from the model. The real-time application and the I/O module drivers run in the Simulink Desktop Real-Time kernel.
Functions
sldrtkernel | Install and remove Simulink Desktop Real-Time kernel |
rtwho | Display information about development computer status |
sldrtconfigset | Attach and activate default Simulink Desktop Real-Time configuration set |
SLDRT.run | Run model in real time by using Simulink Desktop Real-Time kernel (Since R2023b) |
createTimer | Create timer in real-time kernel (Since R2023b) |
loadExecutable | Load executable into real-time kernel (Since R2023b) |
loadDriver | Load driver instance into real-time kernel (Since R2023b) |
stop | Stops execution of current model simulation run and causes MATLAB to wait until execution stops (Since R2023b) |
wait | Wait for model execution to complete (Since R2023b) |
Objects
SLDRT.RunStatus | Get simulation run status and get data from scopes and logged signals (Since R2023b) |
RT.Kernel | Get real-time kernel property information and access child object for timers, executables, and drivers (Since R2023b) |
RT.Timer | Represent timer in real-time kernel (Since R2023b) |
RT.Executable | Represent executable in real-time kernel (Since R2023b) |
RT.Driver | Represent device driver in real-time kernel (Since R2023b) |
RT.DriverImage | Represent a binary image of device driver for real-time kernel (Since R2023b) |
Topics
Prerequisites
- Configure a Model for Simulink Desktop Real-Time
Configure a Simulink model to run as a real-time application.
Connected IO Mode (Normal Mode)
- Real-Time Execution in Connected IO Mode
Learn about the behavior of Simulink Desktop Real-Time in Connected IO mode.
Run in Kernel Mode (External Mode)
- Real-Time Execution in Run in Kernel Mode
Learn about the behavior of Simulink Desktop Real-Time in Run in Kernel mode.
- STEP 1: Set Run in Kernel Mode Code Generation Parameters
- STEP 2: Prepare Run in Kernel Mode Application
- STEP 3: Set Run in Kernel Mode (External Mode) Scope Parameters
- STEP 4: Execute Real-Time Application in Run in Kernel Mode by Using Run in Real Time
- STEP 5: Execute Real-Time Application in Run in Kernel Mode by Using Step by Step Commands
- STEP 6: Execute Real-Time Application with S-Functions in Run in Kernel Mode
Display
- Inspect Simulink Desktop Real-Time Signals with Simulation Data Inspector
Trace signals by using SDI in Run in Kernel mode. - Water Tank Model with Dashboard
Examine a real-time model of a water tank controlled by dashboard controls.