Main Content

Real-Time Execution in Run in Priority Mode

The Priority mode is a higher-performance alternative to Real-Time Execution in Connected IO Mode. In Priority mode, you use Simulink® Coder™ to link generated algorithm code to I/O driver code generated from the I/O blocks. The resulting executable runs at the highest priority level provided by the operating system on the development computer.

Tip

Unlike Run in Kernel mode, Priority mode execution is scheduled by the operating system. This execution can use multiple CPU cores and use all the available physical memory. Use Priority mode to achieve maximum compatibility with the operating system, to use multiple CPU cores with multirate systems, to execute highly memory-intensive models, or to execute the model when Run in Kernel mode is not available on your platform.

In Priority mode, the executable exchanges parameter data with Simulink through 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 that 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. External mode changes parameters in your real-time application while it is running in real time.

The Priority 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.

Procedures related to real-time execution in run in priority mode include:

Note

Use a fixed-step solver for Priority mode execution.

In Priority mode, the real-time application and the I/O drivers run in the priority 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, the data is immediately plotted in a Simulink Scope block. You can save the data directly to a MAT-file by using data archiving in Simulink external mode.

With data archiving, you can save each buffer of data to its own MAT-file. The MAT-file names can be automatically incremented, enabling you to capture and 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.

See Also

Topics