A higher-performance alternative to real-time normal mode is real-time external mode. In this mode, you use Simulink® Coder™ to 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 development 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.
Use a fixed-step solver in external mode.
In external mode, the real-time application and the I/O drivers run in the kernel mode process. Using the I/O drivers to communicate with the hardware, the application 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 required sample interval. After model computations are finished, data transfer runs at a lower priority while the process waits 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
The data can also 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 pauses data collection until the entire buffer has been transferred. This pause can result in lost sample points between data buffers.