Configure Target Scopes with MATLAB Language

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 scopes.

  1. Start running your real-time application. Type:

    tg = slrt;
  2. 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 xpcosc are:

    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             
  3. Create a scope to be displayed on the target computer. For example, to create a scope with an identifier of 1 and a scope object name of sc1, type:

    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
  4. Add signals to the scope object. For example, to add Integrator1 and Signal Generator, type:

    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.

  5. Start the scope. For example, to start the scope sc1, type:


    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.

  6. 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'
  7. Stop the real-time application. In the Command Window, type:


Related Topics