Documentation

Real-Time Host Scope

Display time-domain data on development computer screen

Description

Controls and accesses properties of host scopes.

The kernel acquires a data package and sends it to the scope on the target computer. The scope waits for an upload command from the development computer, and then uploads the data. The development computer displays the data by using Simulink® Real-Time™ Explorer or other MATLAB® functions.

The following rules exist:

  • Function names are case sensitive. Type the entire name.

  • Property names are not case sensitive. You do not need to type the entire name, as long as the characters that you type are unique for the property.

You can invoke some of the scope object properties and functions from the target computer command line when you have loaded the real-time application.

Properties

expand all

Use scope object properties to select signals that you want to acquire, set triggering modes, and access signal information from the real-time application.

To get the value of a readable scope object property from a scope object:

scope_object = getscope(target_object, scope_number);
value = scope_object.scope_object_property

To get the Decimation of scope 3:

scope_object = getscope(tg, 3);
value = scope_object.Decimation

To set the value of a writable scope property from a scope object:

scope_object = getscope(target_object, scope_number);
scope_object.scope_object_property = new_value

To set the Decimation of scope 3:

scope_object = getscope(tg, 3);
scope_object.Decimation = 10

Not all properties are user-writable. For example, after you create the scope, property Type is not writable.

Host Scope Properties

Contains read-only output data for a single data package from a scope.

Contains read-only time data for a single data package from a scope.

Common Scope Properties

Read-only name of the real-time application associated with this scope object.

If 1, scope acquires every sample. If greater than 1, scope acquires every Decimationth sample.

Number of samples collected before or after a trigger event. Entering a negative value collects samples before the trigger event. Entering a positive value collects samples after the trigger event. If you set TriggerMode to 'FreeRun', this property has no effect on data acquisition.

Number of contiguous samples captured during the acquisition of a data package.

The scope writes data samples into a memory buffer of size NumSamples. If the scope stops before capturing this number of samples, the scope writes zeroes after the collected data to the end of the buffer. Know what type of data you are collecting, because it is possible that your data contains zeroes.

Read-only numeric index, unique for each scope.

List of signal indices from the target object to display on the scope.

Read-only state value:

  • 'Acquiring' — The scope is acquiring data.

  • 'Ready for being Triggered' — The scope is waiting for a trigger.

  • 'Interrupted' — The scope is not running (interrupted).

  • 'Finished' — The scope has finished acquiring data.

If TriggerMode is 'Signal', this parameter indicates the value that the signal has to cross to trigger the scope and start acquiring data. The trigger level can be crossed with either a rising or falling signal.

Trigger mode for a scope:

  • 'freerun' — The scope triggers on every sample time.

  • 'software' — The scope triggers from the Command Window.

  • 'signal' — The scope triggers when a designated signal changes state.

  • 'scope' — The scope triggers when a designated scope triggers.

If TriggerMode is 'Scope', then TriggerSample specifies on which sample of the triggering scope the current scope triggers.

For example, if TriggerSample is 0 (default), the current scope triggers on sample 0 (first sample acquired) of the triggering scope. In this case, the two scopes are synchronized with each other.

If TriggerSample is 1, the current scope triggers on sample 1 (second sample acquired) of the triggering scope. In this case, the two scopes have a one-sample offset.

Setting TriggerSample to -1 means that the current scope triggers at the end of the acquisition cycle of the triggering scope. In this case, the triggered scope acquires its first sample one sample after the last sample of the triggering scope.

If TriggerMode is 'Scope', this parameter identifies the scope to use for a trigger. To trigger a scope when another scope is triggered, set the slave scope property TriggerScope to the scope index of the master scope.

If TriggerMode is 'Signal', this parameter identifies the block output signal to use for triggering the scope. Identify the signal with a signal index from the target object property Signal.

If TriggerMode is 'Signal', TriggerSlope indicates the signal behavior that triggers the scope.

  • 'Either' — The signal triggers the scope when it crosses TriggerLevel in either the rising or falling directions.

  • 'Rising' — The signal triggers the scope when it crosses TriggerLevel in the rising direction.

  • 'Falling' — The signal triggers the scope when it crosses TriggerLevel in the falling direction.

Read-only property that determines how the scope collects and displays its data:

  • 'Host' — The scope collects data on the target computer and displays it on the development computer.

  • 'Target' — The scope collects data on the target computer and displays it on the target computer monitor.

  • 'File' — The scope collects and stores data on the target computer.

Object Functions

SimulinkRealTime.hostScope.addsignalAdd signals to host scope represented by scope object
SimulinkRealTime.hostScope.remsignalRemove signals from host scope represented by scope object
SimulinkRealTime.hostScope.startStart execution of host scope on target computer
SimulinkRealTime.hostScope.stopStop execution of host scope on target computer
SimulinkRealTime.hostScope.triggerSoftware-trigger start of data acquisition for host scope

Examples

expand all

Build and download xpcosc and execute the real-time application with a host scope.

Open, build, and download the real-time application.

ex_model = 'xpcosc';
open_system(ex_model);
rtwbuild(ex_model);
tg = SimulinkRealTime.target
Target: TargetPC1
   Connected            = Yes
   Application          = xpcosc
   Mode                 = Real-Time Single-Tasking
   Status               = stopped
   CPUOverload          = none

   ExecTime             = 0.0000
   SessionTime          = 7746.0916
   StopTime             = 0.200000
   SampleTime           = 0.000250
   AvgTET               = NaN
   MinTET               = Inf
   MaxTET               = 0.000000
   ViewMode             = 0

   TimeLog              = Vector(0) 
   StateLog             = Matrix (0 x 2)
   OutputLog            = Matrix (0 x 2)
   TETLog               = Vector(0) 
   MaxLogSamples        = 16666
   NumLogWraps          = 0
   LogMode              = Normal
   ProfilerStatus       = Ready

   Scopes               = No Scopes defined  
   NumSignals           = 7
   ShowSignals          = off

   NumParameters        = 7
   ShowParameters       = off

Add and configure host scope 1.

sc1 = addscope(tg, 'host', 1);
addsignal(sc1, 4);
addsignal(sc1, 5)
ans = 

Simulink Real-Time Scope
   Application          = xpcosc
   ScopeId              = 1
   Status               = Interrupted
   Type                 = Host
   NumSamples           = 250
   NumPrePostSamples    = 0
   Decimation           = 1
   TriggerMode          = FreeRun
   TriggerSignal        = 4  : Integrator1
   TriggerLevel         = 0.000000
   TriggerSlope         = Either
   TriggerScope         = 1
   TriggerSample        = 0
   StartTime            = -1.000000
   Data                 = Matrix (250 x 2)
   Time                 = Matrix (250 x 1)
   Signals              = 4  : Integrator1
                          5  : Signal Generator

Run the real-time application for 10 seconds.

tg.StopTime = 10;
start(sc1);
start(tg);
pause(10);
stop(tg);
stop(sc1);

Plot the result.

plot(sc1.Time,sc1.Data);

Unload the real-time application.

unload(tg)
Target: TargetPC1
   Connected            = Yes
   Application          = loader

Introduced in R2014a

Was this topic helpful?