Run the real-time application with
generated code to observe the real-time behavior of the model. This procedure uses the
open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples',
'ex_slrt_rt_osc')))). You must have already carried out the steps in
Prepare Real-Time Application by Using MATLAB Language. In the model, select the output signal and mark the signal for data logging with the
Simulation Data Inspector.
In the MATLAB Command Window, type:
The real-time application starts running on the target computer. In the Command Window, the status of the target object changes from stopped to running.
Target: TargetPC1 Connected = Yes Application = ex_slrt_rt_osc Mode = Real-Time Single-Tasking Status = running
On the target computer screen, the Execution line changes from stopped to running. The AverageTET line is periodically updated with a new value.
In the Command Window, type:
The real-time application stops running.
You can change many properties and parameters without rebuilding the real-time
application. Two of these
Change the stop time. For example, to change the stop time to 1000 seconds, type:
tg.StopTime = 1000
Change the sample time. For example, to change the sample time to 0.01 seconds, type:
tg.SampleTime = 0.01
Some blocks produce incorrect results when you change their sample time at run time. If you include such blocks in your model, the software displays a warning message during model build. To avoid incorrect results, change the sample time in the original model, and then rebuild and download the model.
If you specify a sample time that is too small, a CPU overload can occur. If a CPU overload
occurs, the target object property
CPUOverload changes to
detected. In that case, change Fixed step
size to a larger value and rebuild the model.