Documentation

Scope

Real-time Scope block

  • Library:
  • Displays and Logging

Description

The real-time Scope block acquires data in chunks of size Number of samples from the real-time application that is executing on the target computer.

You can configure real-time scope blocks for three types: Target, Host, and File. The target scope displays data on the target computer screen. The host scope transmits data to the development computer for processing and display. The file scope writes data to a file on the target computer.

The block dialog box changes depending on the setting for parameter Scope type. By default, the block dialog box displays the parameters for Target scopes.

In some situations, an output signal of a block is not observable by the Scope block. You can make the signal observable by adding test points, by adding unit Gain blocks, or by turning off the Signal storage reuse or Block reduction configuration parameters. For more information, see Signals Not Accessible by Name.

The real-time application can generate data faster than the kernel can process it. Previous data can be overwritten, causing gaps. If gaps occur in the data, consider increasing the value of the Decimation property of the scope.

Ports

Input

expand all

Time-varying numeric value, which can be of any type that Simulink® Real-Time™ supports.

Time-varying numeric value, which can be of any type that Simulink Real-Time supports.

Dependency

This input becomes visible when you set Trigger mode to Signal triggering and set the Add signal port to connect a signal trigger source parameter.

Parameters

expand all

Common and Host Scope Parameters

Host scopes require only the common scope parameters.

Contains a unique number to identify the scope that is displayed. This number is incremented each time you add a Simulink Real-Time Scope block.

This number identifies the Simulink Real-Time Scope block and the scope display on the development or target computer.

  • Target — Output appears on the target computer screen

  • Host — Output goes to the development computer. Usually, you display it with a host scope display in Simulink Real-Time Explorer.

  • File — Output goes to a file on the target computer. You can download the file to the development computer for display or postprocessing.

Select this check box to start a scope when you download and start the real-time application. After it starts, the scope waits for a trigger. With a target scope, the scope window opens automatically. With a host scope, you can open a host scope viewer window from Simulink Real-Time Explorer.

Enter the number of values to be acquired in a data package. The minimum number is 3 samples.

Specify a value less than 0 to save this number of samples before a trigger event. Specify a value greater than 0 to skip this number of samples after the trigger event before data acquisition begins.

Enter a value to collect data at each sample time (1) or to collect data at less than every sample time (2 or greater).

When a real-time scope is triggered, it acquires up to Number of samples of data from the real-time application that is executing on the target computer.

  • FreeRun — The scope acquires data continuously without waiting for a trigger.

  • Software triggering — The scope triggers in response to a user action, such as clicking the Trigger button () in Simulink Real-Time Explorer.

  • Signal triggering — The scope triggers in response to a signal level crossing.

    • In the Trigger signal box, enter the index of a signal previously added to the scope.

      (Alternatively) Click the Add signal port to connect a signal trigger source check box, then connect an arbitrary trigger signal to the port Trigger signal. If the Add signal port to connect a signal trigger source check box is selected, parameter Trigger signal does not apply.

    • In the Trigger level box, enter a value for the signal to cross before triggering.

    • From the Trigger slope list, select one of Either, Rising, or Falling.

  • Scope triggering — The scope triggers in response to the triggering of another scope.

    • In the Trigger scope number box, enter the scope number of a Scope block. If you use this trigger mode, you must also add a second Scope block to your Simulink model.

    • If you want the scope to trigger on a specific sample of the other scope, enter a value in the text box Sample to trigger on (-1 for end of acquisition). The default value of 0 indicates that the triggering scope starts at the same time as the triggered (current) scope.

Dependency

  • Signal triggering — The scope block adds the Trigger signal, Add signal port to connect signal trigger source, Trigger level, and Trigger slope parameters.

  • Scope triggering — The scope block adds the Trigger scope number and Sample to trigger on (-1 for end of acquisition) parameters.

Enter the signal index. To find the index number for a signal, in the Command Window, type:

tg.ShowSignals = 'on'
.

Dependency

This parameter does not apply if the Add signal port to connect a signal trigger source check box is selected.

This parameter becomes visible when you set Trigger mode to Signal triggering.

Adds a port to the block to which you can connect a trigger signal. If you do not select this parameter, the Signal port is the trigger port.

Dependency

This parameter becomes visible when you set Trigger mode to Signal triggering.

When you select the Add signal port to connect a signal trigger source parameter, output Trigger signal becomes visible.

The scope triggers when the value on the trigger signal passes through value Trigger level in the direction given by Trigger slope.

Dependency

This parameter becomes visible when you set Trigger mode to Signal triggering.

The scope triggers when the value on the trigger signal passes through value Trigger level in the direction given by Trigger slope.

Dependency

This parameter becomes visible when you set Trigger mode to Signal triggering.

Enter the scope ID. To find the ID number for a scope, double-click the scope block or, in the Command Window, type:

tg.Scopes

Dependency

This parameter becomes visible when you set Trigger mode to Scope triggering.

Number of samples into the trigger scope acquisition on which to trigger this scope. If the value is -1, trigger at the end of acquisition.

Dependency

This parameter becomes visible when you set Trigger mode to Scope triggering.

Target Scope Parameters

Target scopes require the common scope parameters and also the following parameters.

  • Numerical — Displays the data numerically. The scope acquires Number of samples values before updating the output.

  • Graphical redraw — Displays a cycle of data continuously without scrolling (refreshing the entire plot). The scope acquires Number of samples values before redrawing the graph.

  • Graphical rolling — Displays running data continuously scrolling from left to right across the scope (similar behavior to oscilloscopes).

  • Graphical sliding — The legacy value 'sliding' will be removed in a future release. It behaves like value rolling.

Dependency

If the scope mode is Numerical, the scope block adds a Numerical format text box to the dialog box, set by default to %15.6f.

Use this box to define the display format for the data.

  • LabelN (optional) — Signal label. You can use a different label for each signal or the same label for each signal.

  • width (optional) — Minimum number of characters to offset from the left of the screen or label.

  • precision (optional) — Maximum number of decimal points for the signal value. For a whole integer signal value, enter 0 for the precision value.

  • type — Data type for the signal format, one of:

    Type

    Description

    %e or %E

    Exponential format using e or E

    %f

    Floating point

    %g

    Signed value printed in f or e format depending on which is smaller

    %G

    Signed value printed in f or E format depending on which is smaller

  • LabelX (optional) — Second label for the signal. You can use a different label for each signal or the same label for each signal.

You can have multiple Numerical format entries, separated by a comma. You can enter as many format entries as you have signals for the scope. The entries apply to the signals in order. If the format contains fewer label entries than signals, the default format ('%15.6f') applies to the remaining signals. If the format contains more entries than signals, the unmatched entries are ignored.

Delimit each entry with a comma and surround the entire character vector with a pair of quotes:

'Start1 %15.6f end1,Start2 %15.6f end2'

The default format is '%15.6f', a floating point format without a label.

Select this check box to display grid lines on the scope. This parameter is only applicable for target scopes and scope modes of type Graphical redraw and Graphical rolling.

Enter a row vector with two elements where the first element is the lower limit of the y-axis and the second element is the upper limit. If you enter 0 for both elements, then the scaling is set to auto. This parameter only applies to target scopes that were set to the scope modes Graphical redraw or Graphical rolling.

File Scope Parameters

File scopes require the common scope parameters and also the following parameters.

Enter a name for the file to contain the signal data. By default, the target computer writes the signal data to a file named C:\data.dat.

If you select the Dynamic file name enabled and AutoRestart check boxes, configure Filename to increment dynamically. Use a base file name, an underscore (_), and a < > specifier. Within the specifier, enter one to eight % symbols. Each symbol % represents a decimal location in the file name. The specifier can appear anywhere in the file name. For example, the following value for Filename, C:\work\file_<%%%>.dat creates file names with the following pattern:

file_001.dat
file_002.dat
file_003.dat

The last file name of this series is file_999.dat. If the function is still logging data when the last file name reaches its maximum size, the function overwrites the first file name in the series.

A fully qualified file name can have a maximum of 260 characters: The file part can have at most 12 characters: eight for the file name, one for the period, and at most three for the file extension. A file name longer than eight characters is truncated to six characters followed by '~1'.

Both Lazy and Commit mode open a file, write signal data to the file, then close that file at the end of the session. The difference is in when the block updates the file access table (FAT) entry for the file.

  • Lazy — The block updates the FAT entry only when the file is closed and not during each file write operation. This mode is faster than Commit mode. However, if the system crashes before the file is closed, the file system does not know the actual file size (the file contents, however, are intact).

  • Commit — The block updates the FAT entry for the file with each file write operation. This mode is slower than Lazy mode, but the file system maintains the actual file size.

You cannot read a file that was written during real-time execution until execution has completed.

This parameter specifies that a memory buffer, of length Number of samples, writes data to the file in WriteSize chunks. By default, this parameter is 512 bytes, which is the typical disk sector size. Using a block size that is the same as the disk sector size provides better performance.

The AutoRestart setting works with the Number of samples parameter.

  • Autorestart is on — When the scope triggers, the scope starts collecting data into a memory buffer. A background task examines the buffer and writes data to the disk continuously, appending new data to the end of the file. When the scope reaches the number of samples that you specified, it starts collecting data again, overwriting the memory buffer. If the background task cannot keep pace with data collection, data can be lost.

  • Autorestart is off — When the scope triggers, the scope starts collecting data into a memory buffer. It stops when it has collected the number of samples that you specified. A background task examines the buffer and writes data to the disk continuously, appending the new data to the end of the file.

Dependency

Selecting this parameter makes visible the Dynamic file name enabled and Max file size in bytes (multiple of WriteSize) parameters.

Select this check box to enable the ability dynamically to create multiple log files for file scopes.

To enable this parameter, select the AutoRestart check box. When you enable Dynamic file name enabled, configure Filename to create incrementally numbered file names for the multiple log files. Failure to do so causes an error when you try to start the scope.

You can enable the creation of up to 99999999 files (<%%%%%%%%>.dat). The length of a file name, including the specifier, cannot exceed eight characters.

Dependency

This parameter becomes visible when you select the AutoRestart parameter.

When the log file reaches Max file size in bytes (multiple of WriteSize) in size, the software creates the next numbered file name in the series. It continues logging data to that file, up until the highest log file number you have specified. If the software cannot create additional log files, it overwrites the first log file.

Dependency

This parameter becomes visible when you select the AutoRestart parameter.

Introduced in R2014a

Was this topic helpful?