This procedure shows how to trace signals with file scopes using
the Simulink® model
xpcosc. You must have already
built and downloaded the real-time application for this model. It
also assumes that you are using a serial link.
The signal data file can quickly increase in size. To gauge the growth rate of the file, examine the file size between runs. If the signal data file grows beyond the available space on the disk, the signal data is corrupted.
Create a target object
represents target computer
tg = SimulinkRealTime.target('TargetPC1')
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, these signals are part of
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 . . .
Start running your real-time application. Type:
Create a scope to be displayed on the
target computer. For example, to create a scope with an identifier
2 and a scope object name of
sc2 = addscope(tg, 'file', 2)
No name is initially assigned
FileName. After you start the scope,
a name for the file to acquire the signal data. This name typically
consists of the scope object name,
the beginning letters of the first signal added to the scope.
sc2 = Simulink Real-Time Scope Application = xpcosc ScopeId = 2 Status = Interrupted Type = File NumSamples = 250 NumPrePostSamples = 0 Decimation = 1 TriggerMode = FreeRun TriggerSignal = -1 TriggerLevel = 0.000000 TriggerSlope = Either TriggerScope = 2 TriggerSample = 0 FileName = unset WriteMode = Lazy WriteSize = 512 AutoRestart = off DynamicFileName = off MaxWriteFileSize = 536870912 Signals = no Signals defined
Add signals to the scope object. For
example, to add
sc2 = Simulink Real-Time Scope Application = xpcosc ScopeId = 2 Status = Interrupted Type = File . . . FileName = unset WriteMode = Lazy WriteSize = 512 AutoRestart = off DynamicFileName = off MaxWriteFileSize = 536870912 Signals = 4 : Integrator1 5 : Signal Generator
The target computer displays the following messages:
Scope: 2, signal 4 added Scope: 2, signal 5 added
After you add signals to a scope object, the file scope does not acquire signal values until you start the scope.
Before starting the scope, copy previously acquired data to the development computer. When the file scope starts, the software overwrites previously acquired data in files of the specified name or name pattern. A partially overwritten file or a file that is opened but left unwritten loses its original contents.
Start the scope. For example, to start scope
The Command Window displays a list of the scope object properties.
assigned a default file name to contain the signal data for the file
scope. This name typically consists of the scope object name,
and the beginning letters of the first signal added to the scope.
Application= xpcosc ScopeId = 2 Status = Pre-Acquiring Type = File . . . FileName = c:\sc2Integ.dat Mode = Lazy WriteSize = 512 AutoRestart= off DynamicFileName = off MaxWriteFileSize = 536870912 Signals = 4 : Integrator1 5 : Signal Generator
Stop the scope. Type:
Stop the real-time application. In the Command Window, type: