Documentation

Trigger

Add trigger port to subsystem or model

  • Library:
  • Ports & Subsystems

Description

The Trigger block allows an external signal to control the execution of a subsystem or a model. To enable this functionality, add this block to a Subsystem block or at the root level of a model that is referenced in a Model block.

Then, configure the Trigger block to execute a subsystem or model:

  • Once at each time step, when the value of the trigger signal changes in a way that you specify.

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

Ports

Output

expand all

Trigger signal attached externally to the outside of an Subsystem block or a Model block that is passed to the inside of the block. To enable this port, select Show output port.

Data Types: single | double | int8 | int16 | int32 | uint8 | uint16 | uint32 | Boolean | fixed point | expression

Parameters

expand all

Main

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

rising

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

falling

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

either

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

function-call

Trigger execution of subsystem or model when the trigger signal is a function-call event from a Stateflow chart, Function-Call Generator block, or an S-function block.

Programmatic Use

Block parameter: TriggerType
Type: character vector
Value: 'rising' | 'falling' | 'either' | 'function-call'
Default: 'rising'

Create a Simulink Function block by configuring a Subsystem block that is callable with arguments from a function caller.

off

Remove configuration.

on

Configure a Subsystem block as a Simulink Function block. The Trigger block must reside within the subsystem.

You can edit the function prototype that displays on the block face to specify input and output arguments for the block.

Dependency

To display and enable this parameter, select function-call from the Trigger type list.

Programmatic Use

Block parameter: IsSimulinkFunction
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Specify the function name for a Simulink Function block. Alternatively, you can specify the name by editing the function prototype on the face of the block.

f

Default name for a Simulink Function block.

function name

Function name that displays on the face of a Simulink Function block.

Dependency

To display and enable this parameter, select function-call from the Trigger type list and select the Treat as a Simulink Function check box.

Programmatic Use

Block parameter: FunctionName
Type: character vector
Value: 'f' | '<function name>'
Default: 'f'

Control activating the variant control (condition) defined with the Variant Control parameter.

off

Deactivate variant control of subsystem.

on

Activate variant control of subsystem. Selecting this parameter:

  • Enables the Variant control parameter.

  • Displays a variant badge on the face of the block indicating variant conditions are enabled.

Dependency

To display and enable this parameter, select function-call from the Trigger type list and select the Treat as a Simulink Function check box..

Programmatic Use

Block parameter: Variant
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Specify variant control (condition) expression that executes a variant Simulink Function block when the expression evaluates to true.

(inherit)

Defualt value for variant control. Inherits the variant condition from the corresponding Function Caller blocks in the model. When Variant Control is set as (inherit) the value for Generate preprocessor conditionals is inherited automatically from the Function Caller block in the model.

logical expression

A logical (Boolean) expression or a Simulink.Variant object representing a logical expression.

The function is activated when the expression evaluates to true.

If you want to generate code for your model, define the variables in the expression as Simulink.Parameter objects.

Dependency

To display and enable this parameter, select function-call from the Trigger type list, select the Treat as a Simulink Function check box and then select the Enable variant condition check box.

Programmatic Use

Block parameter: VariantControl
Type: character vector
Value: '(inherit)'|<logical expression> | Simulink.Variant object
Default: '(inherit)'

Control enclosing variant choices within C preprocessor conditional statements.

off

Do not enclose variant choices within C preprocessor conditional statements.

on

When generating code for an ERT target, enclose variant choices within C preprocessor conditional statements (#if).

Dependency

To display and enable this parameter, select the Enable variant condition check box.

Programmatic Use

Block parameter: GeneratePreprocessorConditionals
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Select scope of Simulink Function block within subsystem or model.

scoped

Limit accessability of function to:

  • Hierarchic level containing the Simulink Function block and levels below.

  • One hierarchical level above with qualification.

global

Function accessable from any part of the model hierarchy.

Dependency

To display and enable this parameter, select function-call from the Trigger type list and then select the Treat as a Simulink Function check box..

Programmatic Use

Block parameter: FunctionVisibility
Type: character vector
Value: 'scoped' | 'global'
Default: 'scoped'

Select how to set block state values when the subsystem or model is disabled.

held

Leave the block states at their current values.

reset

Reset the block state values.

inherit

Use the held or 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.

This 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 (Stateflow) 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.

Programmatic Use

Block parameter: StatesWhenEnabling
Type: character vector
Value: 'held' | 'reset'| 'inherit'
Default: 'held'

Select when to propagate variable-size signals.

During execution

Propagate variable-size signals at each time step.

Only when enabling

Propagate variable-size signals when executing a Subsystem block or Model block containing an Enable port, Trigger port with Trigger type set to function- call, or Action Port block. When you select this option, sample time must be periodic.

Dependencies

To display and enable this parameter for a Trigger port block, select Function-call from the Trigger type list.

Programmatic Use

Block parameter: PropagateVarSize
Type: character vector
Value:'During execution' | 'Only when enabling'
Default: 'During execution'

Control display of an output port for a signal that identifies the trigger signal.

off

Remove the output port.

on

Display the output port and determine which signal caused the trigger. The width of the output port 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 in all other cases

Programmatic Use

Block parameter: ShowOutputPort
Type: character vector
Value: 'off' | 'on'
Default: 'off'

Select output port data type for the signal that identifies the trigger signal.

auto

Data type is the same as the port connected to the output.

double

Double value.

int8

Integer value

Dependency

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

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

Programmatic Use

Block parameter: OutputDataType
Type: character vector
Value: 'auto' | 'double' | 'int8'
Default: 'auto'

Select the calling rate for a subsystem or model.

triggered

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

periodic

Apply 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

To enable this parameter, select Function-call from the Trigger type list.

Programmatic Use

Block parameter: SampleTimeType
Type: character vector
Value: 'triggered' | 'periodic'
Default: 'triggered'

Specify the time interval between function calls to a subsystem or model containing this Trigger port block. If the actual calling rate for the subsystem or model differs from the time interval this parameter specifies, Simulink® displays an error.

-1

Inherit time interval from the trigger signal.

Ts

Scalar where Ts is the time interval.

[Ts, To]

Vector where Ts is the time interval and To is the initial time offset.

Dependencies

To enable this parameter, select function-call from the Trigger type list and periodic from the Sample time type list.

Programmatic Use

Block parameter: SampleTime
Type: character vector
Value: '-1' | 'Ts'| '[Ts, To]'
Default: '-1'

Control .

on

Detect zero crossings.

off

Do not detect zero crossings.

Dependencies

To enable this parameter, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: ZeroCross
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Select the initial state of the trigger signal.

compatibility (no trigger on first evaluation)

No trigger at the first evaluation of trigger signal. If you choose this option and the Trigger block is in a subsystem where the states are reset, the block does not reset.

zero

Zero. Helps to evaluate a rising or falling trigger signal at the first time step.

positive

Positive value. Helps to evaluate a falling trigger signal at the first time step.

negative

Negative value. Helps to evaluate a rising trigger signal at the first time step.

Dependency

To display and activate this parameter, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: InitialTriggerSignalState
Type: character vector
Value: 'compatibility (no trigger on first evaluation)' | 'zero' | 'positive' | 'negative'
Default: 'compatibility (no trigger on first evaluation)'

Signal Attribute

Specify dimensions for the trigger signal attached externally to the Model block and passed to the inside of the block.

1

Scalar signal.

[n]

Vector signal of width n.

[m n]

Matrix signal having m rows and n columns.

Dependency

To display and enable this parameter for a Trigger port block at the root-level of a model, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: PortDimensions
Type: character vector
Value: '1' | '[n]' | '[m n]'
Default: '1'

Specify time interval between block method executions for the block driving the trigger signal.

-1

Inherit time interval.

Ts

Scalar where Ts is the time interval.

[Ts, To]

Vector where Ts is the time interval and To is the initial time offset.

Dependency

To display and enable this parameter for a Trigger port block at the root-level of a model, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: TriggerSignalSampleTime
Type: character vector
Value: '-1' | 'Ts'| '[Ts, To]'
Default: '-1'

Specify minimum value for the trigger signal attached externally to a Model block and passed to the inside of the block.

Simulink uses this value to perform:

[]

Unspecified minimum value.

real scalar

Real scalar value.

Dependency

To display and enable this parameter for a Trigger port block at the root-level of a model, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: OutMin
Type: character vector
Value: '[]' | '<real scalar>'
Default: '[]'

Specify maximum value for the trigger signal attached externally to a Model block and passed to the inside of the block.

Simulink uses this value to perform:

[]

Unspecified maximum value.

real scalar

Real scalar value.

Dependency

To display and enable this parameter for a Trigger port block at the root-level of a model, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: OutMax
Type: character vector
Value: '[]' | '<real scalar>'
Default: '[]'

Select data type for the trigger signal attached externally to a Model block and passed to the inside of the block.

double

Double-precision floating point.

single

Single-precision floating point.

int8

Signed 8-bit integer.

uint8

Unsigned 8-bit integer.

int16

Signed 16-bit integer.

uint16

Unsigned 16-bit integer.

int32

Signed 32-bit integer.

uint32

Unsigned 32-bit integer.

boolean

Boolean with a value of true or false.

fixdt(1,16)

Signed 16-bit fixed point number with binary point undefined.

fixdt(1,16,0)

Signed 16-bit fixed point number with binary point set to zero.

fixdt(1,16,2^,0)

Signed 16-bit fixed point number with slope set to 2^0 and bias set to 0.

<data type expression>

Data type object, for example Simulink.NumericType. Do not specify a bus object as the expression.

Dependency

To display and enable this parameter for a Trigger port block at the root-level of a model, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: OutDataTypeStr
Type: character vector
Value: 'double' | 'single' | 'int8' | 'uint8' | 'int16' | 'uint16' | 'int32' | 'uint32' | 'boolean' | 'fixdt(1,16)' | 'fixdt(1,16,0)' | 'fixdt(1,16,2^0,0)' | '<data type expression>'
Default: 'double'

Select data type category and display drop-down lists to help you define the data type.

Build in

Display drop-down lists for data type and Data type override.

Fixed point

Display drop-down lists for Signedness, Scaling, and Data type override.

Expression

Display text box for entering an expression.

Dependency

To enable this parameter, select the Show data type assistant button .

Programmatic Use

No equivalent command-line parameter.

Control how missing workspace data is estimated when loading data from the MATLAB® workspace.

on

Linearly interpolate output at time steps for which no corresponding workspace data exists.

off

Do not interpolate output at time steps. The current output equals the output at the most recent time step for which data exists.

Dependency

To display and enable this parameter for a Trigger port block at the root-level of a model, select rising, falling, or either from the Trigger type list.

Programmatic Use

Block parameter: Interpolate
Type: character vector
Value: 'on' | 'off'
Default: 'on'

Introduced before R2006a

Was this topic helpful?