Contents

Trigger

Add trigger port to model or subsystem

Library

Ports & Subsystems

Description

Adding a Trigger block to a model allows an external signal to trigger its execution. You can add a trigger port to a root-level model or to a subsystem.

Configure the Trigger block to execute the model either:

  • Once on each integration step, when the value of the external signal changes in a way that you specify.

  • Multiple times during a time step, when the external signal is a function-call from a Function-Call Generator block or S-function.

Include only one Trigger block in a model or a subsystem.

Specify the properties that the trigger port enforces for any incoming signal, using the Signal Attributes tab.

The Trigger block supports signal label propagation.

For more information, see:

Data Type Support

The Trigger block accepts signals of supported Simulink® numeric data types, including fixed-point data types. For more information, see Data Types Supported by Simulink in the Simulink documentation.

Parameters and Dialog Box

The Main tab of the Trigger block dialog box appears as follows:

The Signal Attributes tab of the Trigger block dialog box appears as follows:

Trigger type

Select the type of event that triggers execution of the subsystem.

Settings

Default: rising

rising

Triggers execution of the model or subsystem when the control signal rises from a negative or zero value to a positive value. If the initial value is negative, rising to zero triggers execution.

falling

Triggers execution of the model or subsystem when the control signal falls from a positive or a zero value to a negative value. If the initial value is positive, falling to zero triggers execution.

either

Triggers execution of the model or subsystem when the signal is either rising or falling.

function-call

Allows a Function-Call Generator or S-function to control execution of the subsystem or model.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Treat as Simulink Function

Configure the Function-call subsystem to be a Simulink Function callable with arguments.

Settings

Default: Off

When you select the check box, a function prototype appears on the subsystem block icon, which you can edit to configure input and output arguments to the Simulink Function.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Dependency

This parameter appears only when you select function-call as the Trigger type parameter.

Function name

Specify the function name of Simulink Function.

Settings

Default: f

This parameter provides the function name in the function prototype of the Simulink Function.

Dependency

Setting Trigger type to function-call and selecting theTreat as a Simulink Function check box enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

States when enabling

Specify the state values when triggered by a function-call.

Settings

Default: held

held

Leaves the states at their current values.

reset

Resets the states.

inherit

Uses the held/reset setting from the parent subsystem initiating the function-call. If the parent of the initiator is the model root, the inherited setting is held. If the trigger has multiple initiators, set the parents of all initiators to either held or reset.

Dependencies

To enable this parameter, select function-call from the Trigger Type list.

The parameter setting applies only if the model explicitly enables and disables the function-call subsystem. For example:

  • The function-call subsystem resides in an enabled subsystem. In this case, the model enables and disables the function-call subsystem along with the parent subsystem.

  • The function-call initiator that controls the function-call subsystem resides in an enabled subsystem. In this case, the model enables and disables the function-call subsystem along with the enabled subsystem containing the function-call initiator.

  • The function-call initiator is a Stateflow® event bound to a particular state. See Control Function-Call Subsystems Using Bind Actions in the Stateflow documentation.

  • The function-call initiator is an S-function that explicitly enables and disables the function-call subsystem. See ssEnableSystemWithTid for an example.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Propagate sizes of variable-size signals

Specify when to propagate a variable-size signal.

Settings

Default: During execution

Only when enabling

Propagates variable-size signals only when enabling the model or subsystem containing the Trigger block.

During execution

Propagates variable-size signals at each time step.

Dependency

Select Function-call from the Trigger type list to enable this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Show output port

Select this check box to output the trigger signal.

Settings

Default: On

On

Shows the Trigger block output port and outputs the trigger signal. This action allows the system to determine which signal caused the trigger. The width of the signal is the width of the triggering signal. The signal value is:

  • 1 for a signal that causes a rising trigger

  • -1 for a signal that causes a falling trigger

  • 2 for a function-call trigger

  • 0 otherwise

Off

Removes the output port.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Output data type

Specify the trigger output data type.

Settings

Default: auto

auto

Specifies that the data type is the same as the port connected to output.

double

Sets the date type to double.

int8

Sets the data type to integer.

Dependencies

To enable this parameter, select the Show output port check box.

The Trigger block ignores the Data type override setting of the Fixed-Point Tool.

Sample time type

Specify the calling frequency of a subsystem.

Settings

Default: triggered

triggered

Applies to applications that do not have a periodic calling frequency.

periodic

Applies if the caller of the parent function-call subsystem calls the subsystem once per time step when the subsystem is active (enabled). A Stateflow chart is an example of a caller.

Dependency

Select Function-call from the Trigger type list to enable this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Sample time

Specify the calling rate for blocks.

Settings

Default: 1

Set this parameter to the sample time you expect for the calling rate of the function-call subsystem containing this Trigger block. If the actual calling rate for the subsystem differs from the rate that this parameter specifies, Simulink displays an error.

Dependency

Setting Trigger type to function-call and Sample time type to periodic enables this parameter.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Enable zero-crossing detection

Select to enable zero-crossing detection.

Settings

Default: On

On

Detects zero crossings.

Off

Does not detect zero crossings.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Port dimensions

Specify the dimensions of the input signal to the block.

Settings

Default: 1

Valid values are:

ValueDescription

n

Accepts vector signal of width n

[m n]

Accepts matrix signal having m rows and n columns

Command-Line Information

See Block-Specific Parameters for the command-line information.

Trigger signal sample time

Specify the rate at which the block driving the triggered signal is expected to run.

Settings

Default: -1

To inherit the sample time, set this parameter to -1.

See Specify Sample Time for more information.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Minimum

Specify the minimum value that the block should output.

Settings

Default: [] (unspecified)

This number must be a finite real double scalar value.

    Note:   If you specify a bus object as the data type for this block, do not set the minimum value for bus data on the block. Simulink ignores this setting. Instead, set the minimum values for bus elements of the bus object specified as the data type. For information on the Minimum property of a bus element, see Simulink.BusElement.

Simulink software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Command-Line Information

See Block-Specific Parameters for the command-line information.

Maximum

Specify the maximum value that the block should output.

Settings

Default: [] (unspecified)

This number must be a finite real double scalar value.

    Note:   If you specify a bus object as the data type for this block, do not set the maximum value for bus data on the block. Simulink ignores this setting. Instead, set the maximum values for bus elements of the bus object specified as the data type. For information on the Maximum property of a bus element, see Simulink.BusElement.

Simulink software uses this value to perform:

  • Simulation range checking (see Signal Ranges)

  • Automatic scaling of fixed-point data types

Command-Line Information

See Block-Specific Parameters for the command-line information.

Data type

Specify the expected data type of the signal feeding the trigger port.

Settings

Default: Inherit: auto

Inherit: auto

Data type is double

double

Data type is double.

single

Data type is single.

int8

Data type is int8.

uint8

Data type is uint8.

int16

Data type is int16.

uint16

Data type is uint16.

int32

Data type is int32.

uint32

Data type is uint32.

boolean

Data type is boolean.

fixdt(1,16,0)

Data type is fixed point, fixdt(1,16,0).

fixdt(1,16,2^0,0)

Data type is fixed point, fixdt(1,16,2^0,0).

Enum: <class name>

Data type is enumerated, for example, Enum: Basic Colors.

<data type expression>

The name of a data type object, for example, Simulink.NumericType.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Mode

Select the category of data to specify.

Settings

Default: Inherit

Inherit

Inheritance rule for data types. Selecting Inherit enables a second list.

Built in

Built-in data types. Selecting Built in enables a second list. Select one of the following choices:

  • double (default)

  • single

  • int8

  • uint8

  • int16

  • uint16

  • int32

  • uint32

  • boolean

Fixed point

Fixed-point data types.

Enumerated

Enumerated data types. Selecting Enumerated enables a second text box, where you can enter the class name.

Expression

Expressions that evaluate to data types. Selecting Expression enables a second text box, where you can enter the expression.

Dependency

To enable this parameter, click Show data type assistant.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Data type override

Specify data type override mode for this signal.

Settings

Default: Inherit

Inherit

Inherits the data type override setting from its context, that is, from the block, Simulink.Signal object or Stateflow chart in Simulink that is using the signal.

Off

Ignores the data type override setting of its context and uses the fixed-point data type specified for the signal.

Tip

The ability to turn off data type override for an individual data type provides greater control over the data types in your model when you apply data type override. For example, you can use this option to ensure that data types meet the requirements of downstream blocks regardless of the data type override setting.

Dependency

This parameter appears only when the Mode is Built in or Fixed point.

Signedness

Specify whether you want the fixed-point data as signed or unsigned.

Settings

Default: Signed

Signed

Specify the fixed-point data as signed.

Unsigned

Specify the fixed-point data as unsigned.

Dependencies

Selecting Mode > Fixed point enables this parameter.

See Also

For more information, see Specifying a Fixed-Point Data Type.

Scaling

Specify the method for scaling your fixed-point data to avoid overflow conditions and minimize quantization errors.

Settings

Default: Best precision, Binary point, Integer

Binary point

Specify binary point location.

Slope and bias

Enter slope and bias.

Best precision

Specify best-precision values. This option appears for some blocks.

Integer

Specify integer. This setting has the same result as specifying a binary point location and setting fraction length to 0. This option appears for some blocks.

Dependencies

Selecting Mode > Fixed point enables this parameter.

Selecting Binary point enables:

  • Fraction length

  • Calculate Best-Precision Scaling

Selecting Slope and bias enables:

  • Slope

  • Bias

  • Calculate Best-Precision Scaling

Command-Line Information

See Block-Specific Parameters for the command-line information.

See Also

For more information, see Specifying a Fixed-Point Data Type.

Word length

Specify the bit size of the word that holds the quantized integer.

Settings

Default: 16

Minimum: 0

Maximum: 32

Dependencies

Selecting Mode > Fixed point enables this parameter.

See Also

For more information, see Specifying a Fixed-Point Data Type.

Fraction length

Specify fraction length for fixed-point data type.

Settings

Default: 0

Binary points can be positive or negative integers.

Dependencies

Selecting Scaling > Binary point enables this parameter.

See Also

For more information, see Specifying a Fixed-Point Data Type.

Slope

Specify slope for the fixed-point data type.

Settings

Default: 2^0

Specify any positive real number.

Dependencies

Selecting Scaling > Slope and bias enables this parameter.

See Also

For more information, see Specifying a Fixed-Point Data Type.

Bias

Specify bias for the fixed-point data type.

Settings

Default: 0

Specify any real number.

Dependencies

Selecting Scaling > Slope and bias enables this parameter.

See Also

For more information, see Specifying a Fixed-Point Data Type.

Interpolate data

Cause the block to interpolate or extrapolate output at time steps for which no corresponding workspace data exists when loading data from the workspace.

Settings

Default: On

On

Causes the block to interpolate or extrapolate output at time steps for which no corresponding workspace data exists when loading data from the workspace.

Off

Does not cause the block to interpolate or extrapolate output at time steps for which no corresponding workspace data exists when loading data from the workspace.

Command-Line Information

See Block-Specific Parameters for the command-line information.

Characteristics

Sample Time

Specified by the Sample time parameter if:

  • Trigger type is function-call

  • Sample time type is periodic

Otherwise, specified by the signal at the trigger port.

Dimensionalized

Yes

Virtual

Yes, when the output port is not present

For more information, see Virtual Blocks in the Simulink documentation.

Zero-Crossing Detection

Yes, if enabled

Was this topic helpful?