A higher-performance alternative to real-time normal mode is real-time external mode. In this mode, you use Simulink® Coder™ to dynamically link generated algorithm code with I/O driver code generated from the I/O blocks. The resulting executable runs in operating system kernel mode on the host computer and exchanges parameter data with Simulink via a shared memory interface.
Signal acquisition — You can capture and display
signals from your real-time application while it is running. Signal
data is retrieved from the real-time application and displayed in
the same Simulink
Scope blocks you used for
simulating your model.
Parameter tuning — You can change parameters in your Simulink block diagram and have the new parameters passed automatically to the real-time application. Simulink external mode changes parameters in your real-time application while it is running in real time.
The external mode executable is fully synchronized with the real-time clock. The main role of Simulink is to read and display simulation results returned from the executable.
Note: You must use a fixed-step solver in external mode.
In external mode, the real-time application runs in the kernel mode process. Using I/O drivers running in that process to communicate with the hardware, it stores contiguous response data in memory accessible to Simulink until a data buffer is filled. When the buffer is filled, the real-time application continues to run while Simulink transfers the data to the MATLAB® environment through Simulink external mode. Transfer of data is less critical than maintaining deterministic real-time updates at the selected sample interval. Therefore, data transfer runs at a lower priority in the remaining CPU time after model computations are performed while waiting for another interrupt to trigger the next model update.
Data captured within one buffer is contiguous. When a buffer
of data has been transferred, it is immediately plotted in a Simulink
or it can be saved directly to a MAT-file using the data archiving
feature of the Simulink external mode.
With data archiving, each buffer of data can be saved to its own MAT-file. The MAT-file names can be automatically incremented, allowing you to capture and automatically store many data buffers. Although points within a buffer are contiguous, the time required to transfer data back to Simulink forces an intermission for data collection until the entire buffer has been transferred and may result in lost sample points between data buffers.