Main Content

TriggerConfiguration

Trigger measurements properties for scope

    Description

    Use the TriggerConfiguration object to define a trigger event to identify the simulation time of specified input signal characteristics. You can use trigger events to stabilize periodic signals such as a sine wave or capture nonperiodic signals such as a pulse that occurs intermittently.

    You can enable the trigger events either from the toolstrip or from the command line. To enable a trigger event from the scope interface, open the Trigger tab and click Enable Trigger in the Controls section.

    Triangle cursors highlighted - two on each side of the sine wave. One on top and one at the bottom.

    Creation

    Description

    example

    trigger = TriggerConfiguration() creates a trigger configuration object trigger.

    Properties

    expand all

    All properties are tunable.

    For more information on these triggers and the associated parameters, see Source/Type and Levels/Timing Panes (Simulink).

    Display update mode, specified as one of these:

    • "auto" –– Display data from the last trigger event. If no event occurs after one time span, display the last available data.

    • "normal" –– Display data from the last trigger event. If no event occurs, the display remains blank.

    • "once" –– Display data from the last trigger event and freeze the display. If no event occurs, the display remains blank. Click the Rearm button (Rearm button) to look for the next trigger event.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Setup section, set Mode to one of the available options.

    Data Types: char | string

    Type of trigger, specified as one of the following:

    • "edge" –– Trigger when the signal crosses a threshold.

    • "pulse-width" –– Trigger when the signal crosses a low threshold and a high threshold twice within a specified time.

    • "transition" –– Trigger on the rising or falling edge of a signal that crosses the high and low levels within a specified time range.

    • "runt" –– Trigger when a signal crosses a low threshold or a high threshold twice within a specified time.

    • "window" –– Trigger when a signal stays within or outside a region defined by the high and low thresholds for a specified time.

    • "timeout" –– Trigger when a signal stays above or below a threshold longer than a specified time.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Setup section, set Type to one of the available options.

    Data Types: char | string

    Trigger polarity, specified as one of the following:

    • "rising", "falling", or "either" –– When Type is set to "edge" or "timeout".

    • "positive", "negative", or "either" –– When Type is set to "pulse-width" or "runt".

    • "rise-time", "fall-time", or "either" –– When Type is set to "transition".

    • "inside", "outside", or "either" –– When Type is set to "window".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Setup section, set Polarity to one of the available options.

    Data Types: char | string

    Automatic thresholding of edge-triggered signal, specified as true or false. When you set this property to false, specify the threshold manually using the Level property.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, select the Auto Level check box.

    Data Types: logical

    Horizontal position of the trigger on the screen, specified as a positive scalar in the range (0 100].

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, set Position (%) as a positive scalar less than or equal to 100.

    Data Types: double

    Threshold of an edge-triggered signal, specified as a finite real scalar.

    Dependency

    To enable this property, set AutoLevel to false and Type to "edge" or "timeout".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Level as a real scalar.

    To enable this property, clear the Auto Level check box and set Type to Edge or Timeout.

    Data Types: double

    Noise reject value, specified as a finite real scalar. For more information on hysteresis, see Hysteresis of Trigger Signals (Simulink).

    Dependency

    To enable this property, set AutoLevel to false and Type to "edge" or "timeout".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Hysteresis as a real scalar.

    To enable this property, clear the Auto Level check box and set Type to Edge or Timeout.

    Data Types: double

    Lower trigger level of window-triggered signal, specified as a finite real scalar.

    Dependency

    To enable this property, set AutoLevel to false and Type to "pulse-width", "transition", "runt", or "window".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Low as a real scalar.

    To enable this property, clear the Auto Level check box and set Type to Pulse Width, Transition, Runt, or Window.

    Data Types: double

    Higher trigger level of window-triggered signal, specified as a finite real scalar.

    Dependency

    To enable this property, set AutoLevel to false and Type to "pulse-width", "transition", "runt", or "window".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the High as a real scalar.

    To enable this property, clear the Auto Level check box and set Type to Pulse Width, Transition, Runt, or Window.

    Data Types: double

    Minimum pulse width for a pulse or runt-triggered signal, specified as a nonnegative scalar.

    Dependency

    To enable this property, set Type to "pulse-width" or "runt".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Min Width (s) as a nonnegative scalar.

    To enable this property, set Type to Pulse Width or Runt.

    Data Types: double

    Maximum pulse width for a pulse or runt-triggered signal, specified as a nonnegative scalar.

    Dependency

    To enable this property, set Type to "pulse-width" or "runt".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Max Width (s) as a nonnegative scalar.

    To enable this property, set Type to Pulse Width or Runt.

    Data Types: double

    Minimum duration for a transition or window-triggered signal, specified as a nonnegative scalar.

    Dependency

    To enable this property, set Type to "transition" or "window".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Min Time (s) as a nonnegative scalar.

    To enable this property, set Type to Transition or Window.

    Data Types: double

    Maximum time duration for a transition or window-triggered signal, specified as a nonnegative scalar.

    Dependency

    To enable this property, set Type to "transition" or "window".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Max Time (s) as a nonnegative scalar.

    To enable this property, set Type to Transition or Window.

    Data Types: double

    Timeout duration for a timeout-triggered signal, specified as a nonnegative scalar.

    Dependency

    To enable this property, set Type to "timeout".

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Timeout (s) as a nonnegative scalar.

    To enable this property, set Type to Timeout.

    Data Types: double

    Trigger offset in seconds, specified as a finite real scalar.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Delay (s) as a real scalar.

    Data Types: double

    Minimum time between trigger events, specified as a finite nonnegative scalar.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. In the Properties section, specify the Holdoff (s) as a nonnegative scalar.

    Data Types: double

    Trigger channel, specified as a positive integer.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip. Select a channel from the Channel drop down.

    Data Types: double

    Enable trigger, specified as true or false. Set this property to true to enable trigger.

    Scope Window Use

    Click the Trigger tab on the Time Scope toolstrip, and the click Enable Trigger in the Controls section.

    Data Types: logical

    Examples

    collapse all

    View a sine wave in the Time Scope. This sine wave is streaming constantly in the display and cannot be captured without stabilization. To stabilize the sine wave, enable a trigger event programmatically on the scope display using the Enabled property of the TriggerConfiguration object. Alternatively, you can enable the trigger by clicking the Enable Trigger button on the Trigger tab of the toolstrip.

    Create Sine Wave

    Create the input sine wave using the sin function. Create a timescope MATLAB® object to display the signal. Set the TimeSpan property to 1 second.

    f = 100;
    fs = 1000;
    swv = sin(2.*pi.*f.*(0:1/fs:1-1/fs)).';
    scopeNoTrigger = timescope(SampleRate=fs,...
        TimeSpanSource="property", ...
        TimeSpan=1);

    Display the sine wave in the scope. You can see that the signal in the scope is constantly moving.

    while(1) 
        scopeNoTrigger(swv)
    end
    release(scopeNoTrigger)
    

    Snapshot of the scope window showing sine wave. Trigger tab is expanded. Enable Trigger button is not selected.

    Enable Trigger

    Now enable a trigger event to stabilize the signal.

    You can either enable the trigger event in the scope during simulation or enable the trigger event programmatically when creating the object.

    To use the programmatic approach, create another timescope object and enable the trigger event programmatically while creating the object.

    scope = timescope(SampleRate=fs,...
        TimeSpanSource="property",...
        TimeSpan=1);
    scope.Trigger.Enabled = true;
    scope.Trigger.Type = "transition";
    scope.Trigger
    TriggerConfiguration with properties:
    
               Mode: 'auto'
               Type: 'transition'
           Polarity: 'rise-time'
          AutoLevel: 1
           Position: 50
           LowLevel: 0.2000
          HighLevel: 2.3000
        MinDuration: 0
        MaxDuration: Inf
              Delay: 0
            Holdoff: 0
            Channel: 1
            Enabled: 1

    Stream in the sine wave signal again.

    while(1) 
        scope(swv)
    end
    release(scope)
    

    The display freezes as you have enabled the trigger.

    Enable Trigger button is selected on the UI. Triangle markers appear at the 50% position.

    The triangle markers show the trigger positions and levels. For more information on the trigger, hover over the triangle.

    Cursors highlighted - two on each side of the sine wave. One on top and one at the bottom.

    Version History

    Introduced in R2022a