Creating a scope object allows you to select and view signals using Simulink® Real-Time™ functions instead of the Simulink Real-Time user interface.
This procedure uses the Simulink model
xpcosc. To do this procedure, you must have already
built the real-time application for
xpcosc and downloaded it to the default
target computer. It describes how to
trace signals with target
Start running your real-time application. Type:
tg = slrt; start(tg)
To get a list of signals, type:
tg.ShowSignals = 'on'
The Command Window displays a list of the target object properties
for the available signals. For example, the signals for the model
Target: TargetPC1 Connected = Yes Application = xpcosc . . . Scopes = 1 NumSignals = 7 ShowSignals = on Signals = INDEX VALUE Type BLOCK NAME LABEL 0 0.000000 DOUBLE Gain 1 0.000000 DOUBLE Gain1 2 0.000000 DOUBLE Gain2 3 0.000000 DOUBLE Integrator 4 0.000000 DOUBLE Integrator1 5 0.000000 DOUBLE Signal Generator 6 0.000000 DOUBLE Sum . . .
Create a scope to be displayed on the
target computer. For example, to create a scope with an identifier
1 and a scope object name of
sc1 = addscope(tg, 'target', 1)
Simulink Real-Time Scope Application = xpcosc ScopeId = 1 Status = Interrupted Type = Target NumSamples = 250 NumPrePostSamples = 0 Decimation = 1 TriggerMode = FreeRun TriggerSignal = -1 TriggerLevel = 0.000000 TriggerSlope = Either TriggerScope = 1 TriggerSample = 0 DisplayMode = Redraw (Graphical) YLimit = Auto Grid = on Signals = no Signals defined
Add signals to the scope object. For
example, to add
Simulink Real-Time Scope Application = xpcosc ScopeId = 1 Status = Interrupted Type = Target . . . Grid = on Signals = 4 : Integrator1 5 : Signal Generator
The target computer displays the following messages:
Scope: 1, signal 4 added Scope: 1, signal 5 added
After you add signals to a scope object, the signal values are not shown on the target display until you start the scope.
Start the scope. For example, to start
The target display plots the signals after collecting each data package. During this time, you can observe the behavior of the signals while the scope is running.
Stop the scope. Type:
The signals shown on the target computer stop updating while the real-time application continues running. The target computer displays the following message:
Scope: 1, set to state 'interrupted'
Stop the real-time application. In the Command Window, type: