After you build the real-time application, you can run your model in real time. In external mode, you execute your real-time application to observe the behavior of your model in real time with the generated code.
You cannot run a real-time application in Rapid Accelerator mode.
This procedure uses the model
(matlab: open_system(docpath(fullfile(docroot, 'toolbox', 'sldrt', 'examples', 'sldrtex_model')))). It shows how to use Run in Real Time to complete
these operations with one click:
Build — Create a real-time application from the model.
Connect — Establish a connection between the model and the kernel. This connection permits exchange of commands, parameters, and logged data.
Start — Start execution of the application in real time.
Open the model
In the Simulink® Editor, on the Desktop Real-Time tab, click Run in Real Time.
Simulink builds the real-time application, changes to external mode simulation, connects the model and kernel, and runs the simulation. You can accomplish these and other simulation operations as individual steps. For more information, see Execute Real-Time Application in External Mode by Using Step by Step Commands.
To stop the simulation before it ends, on the Desktop Real-Time tab, click the Stop.
In this example, the Scope window displays 1000 samples in 1 second, increases the time offset, and then displays the samples for the next 1 second.
Transfer of data is less critical than calculating the signal outputs at the selected sample interval. Therefore, data transfer runs at a lower priority in the CPU time that remains after real-time application computations are performed. As a result, data points can be omitted from the Scope block display.