This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Configure Real-Time Target Scope Blocks

Simulink® Real-Time™ includes a specialized Scope block that you can configure to display signal and time data on the target computer monitor. Add a Scope block to the model, select Scope type Target, and configure the other parameters as described in the following procedure.

Do not confuse Simulink Real-Time Scope blocks with standard Simulink Scope blocks.

This procedure uses the example model ex_slrt_rt_osc (open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_rt_osc')))).

  1. In the Command Window, open ex_slrt_rt_osc.

  2. Double-click the block labeled Scope.

    The Scope block dialog box opens. By default, the target scope dialog box is displayed.

  3. In the Scope number box, a unique number is displayed that identifies the scope. 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 screen on the development or target computers.

  4. From the Scope type list, select Target if it is not already selected. The updated dialog box is displayed.

  5. To start the scope automatically when the real-time application executes, select the Start scope when application starts check box. The target scope opens automatically on the target computer monitor.

    In Stand Alone mode, this setting is mandatory, because the development computer is not available to issue a command to start scopes.

  6. From the Scope mode list, select Numerical, Graphical redraw, or Graphical rolling. (The Graphical sliding will be removed in a future release. It behaves like Graphical rolling.)

    If you have a scope type of Target and a scope mode of Numerical, the scope block dialog box adds a Numerical format box. You can define the display format for the data. If you do not complete the Numerical format box, the Simulink Real-Time software displays the signal using the default format of %15.6f. This format is a floating-point format without a label.

  7. If you select scope mode Numerical, in the Numerical format box, type a label and associated numerical format type in which to display signals. By default, the entry format is floating-point without a label, %15.6f. The Numerical format box takes entries of the format:

    '[LabelN] [%width.precision][type] [LabelX]'
    • LabelN is the label for the signal. You can use a different label for each signal or the same label for each signal. This argument is optional.

    • width is the minimum number of characters to offset from the left of the screen or label. This argument is optional.

    • precision is the maximum number of decimal places for the signal value. This argument is optional.

    • type is the data type for the signal format. You can use one or more of the following types.

      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 is a second label for the signal. You can use a different label for each signal or the same label for each signal. This argument is optional.

    Enclose the contents of the Numerical format text box in single quotation marks. For example:

    'Foo %15.2f end'

    For a whole integer signal value, enter 0 for the precision value. For example:

    'Foo1 %15.0f end'

    For a line with multiple entries, delimit each entry with a command and enclose the entire format character vector in single quotation marks. For example:

    'Foo2 %15.6f end,Foo3 %15.6f end2'

    You can have multiple Numerical format entries, separated by a comma. If you insert a single entry, that entry applies to each signal (scalar expansion). If you enter N label entries for N+Ksignals, the first N−1 entries apply to the first N−1 signals. The Nth entry is scalar expanded for the remaining K+1 signals. If you have two entries and one signal, the software ignores the second label entry and applies the first entry. You can enter as many format entries as you have signals for the scope. The format character vector has a maximum length of 100 characters, including spaces, for each signal.

  8. To display grid lines on the scope, select the Grid check box. This parameter is applicable only for target scopes with scope modes of type Graphical redraw or Graphical rolling.

  9. In the Y-Axis limits box, enter a row vector with two elements. 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, scaling is set to auto. This parameter is applicable only for target scopes with scope modes of type Graphical redraw or Graphical rolling.

  10. In the Number of samples box, enter the number of values to be acquired in a data package.

    • If you select a Scope mode of Graphical redraw, the display redraws the graph every Number of samples.

    • If you select a Scope mode of Numerical, the block updates the output every Number of samples.

    • If you select a Trigger mode other than FreeRun, this parameter can specify the Number of samples to be acquired before the next trigger event.

  11. In the Number of pre/post samples box, enter the number of samples to save or skip. To save N samples before a trigger event, specify the value −N. To skip N samples after a trigger event, specify the value N. The default is 0.

  12. In the Decimation box, enter a value to indicate when data is collected. The value 1 means that data is collected at each sample time. A value of 2 or greater means that data is collected at less than every sample time.

  13. From the Trigger mode list, select one of the following:

    • FreeRun or Software Triggering — No extra parameters.

    • Signal Triggering — enter additional parameters, as required:

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

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

      • (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.

      • 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 — enter additional parameters, as required:

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

      • To trigger one scope on a specific sample of another scope, enter a value in Sample to trigger on (-1 for end of acquisition). The default value, 0, indicates that the triggered scope starts on the same sample as the triggering scope.

    The target scope dialog box looks like this figure.

  14. Click OK.

  15. From the File menu, click Save As.

    Save the model as ex_slrt_target_osc (open_system(docpath(fullfile(docroot, 'toolbox', 'xpc', 'examples', 'ex_slrt_target_osc')))).

See Also

Related Topics