Add trigger or function port to subsystem or model
Simulink / Ports & Subsystems
HDL Coder / Ports & Subsystems
The Trigger block adds 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 control signal changes in a way that you specify.
Multiple times during a time step, when the control signal is a function-call event from a Stateflow® chart, Function-Call Generator block, or S-Function block.
Port_1
— Value that describes control signalValue that identifies a control signal, returned as a scalar or vector. For each element of the input signal, the value at a given time step is:
1
for a signal that causes a rising
trigger
-1
for a signal that causes a falling
trigger
2
for a function-call event
0
in all other cases
To enable this port, select Show output port.
Data Types: double
| int8
Trigger type
— Select the type control signalrising
(default) | falling
| either
| function-call
Select the type of control signal that executes a subsystem or model.
rising
Trigger execution of subsystem or model when the control 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 control 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 control signal is either rising or falling.
function-call
Execute subsystem or model when the control signal receives a function-call event from a Stateflow chart, Function-Call Generator block, S-Function block, or Hit Crossing block.
Block Parameter:
TriggerType |
Type: character vector |
Values:
'rising' | 'falling' |
'either' |
'function-call' |
Default:
'rising' |
Treat as Simulink function
— Create Simulink Function blockSelect this parameter to create a Simulink Function block by configuring a Subsystem block that is callable with arguments from a function caller. 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.
Clear this parameter to remove the configuration.
To display and enable this parameter, select
function-call
from the
Trigger type list.
Block Parameter:
IsSimulinkFunction |
Type: character vector |
Values:
'off' | 'on' |
Default:
'off' |
Function name
— Specify function name for Simulink Function blockf
(default) | function nameSpecify 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 that displays on the face of a Simulink Function block.
To display and enable this parameter, select
function-call
from the Trigger type list and select the
Treat as a Simulink Function
check box.
Block Parameter:
FunctionName |
Type: character vector |
Values:
'f' | '<function
name>' |
Default:
'f' |
Enable variant condition
— Controls activating the variant control (condition)Control activating the variant control (condition) defined with the Variant Control parameter.
Select this parameter to activate variant control of the subsystem. Selecting this parameter:
Enables the Variant control parameter.
Displays a variant badge on the face of the block
indicating that variant conditions are enabled.
Clear this parameter to deactivate variant control of the subsystem.
To display and enable this parameter, select
function-call
from the
Trigger type list and select the
Treat as Simulink function check
box.
Block Parameter:
Variant |
Type: character vector |
Values:
'off' | 'on' |
Default:
'on' |
Variant control
— Specify variant control (condition) expression(inherit)
(default) | <logical expression>
Specify variant control (condition) expression that executes a variant
Simulink Function block when the expression evaluates
to true
.
(inherit)
Default 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.
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.
To display and enable this parameter, select
function-call
from the Trigger type list, select the Treat as a Simulink Function check box,
then select the Enable variant condition check
box.
Block Parameter:
VariantControl |
Type: character vector |
Values:
'(inherit)' |<logical
expression> | Simulink.Variant
object |
Default:
'(inherit)' |
Generate preprocessor conditionals
— Control enclosing variant choicesControl enclosing variant choices within C preprocessor conditional statements.
Select this parameter to enclose variant choices within C preprocessor conditional statements (#if) when generating code for an ERT target.
To display and enable this parameter, select the Enable variant condition check box.
Block Parameter:
GeneratePreprocessorConditionals |
Type: character vector |
Values:
'off' | 'on' |
Default:
'off' |
Function visibility
— Select scope visibility of functionscoped
(default) | global
Select scope of Simulink Function block within subsystem or model.
scoped
Limit accessibility of function to:
Hierarchic level containing the Simulink Function block and levels below.
One hierarchical level above with qualification.
global
Function accessible from any part of the model hierarchy.
To display and enable this parameter, select
function-call
from the Trigger type list, then select the
Treat as a Simulink Function
check box..
Block Parameter:
FunctionVisibility |
Type: character vector |
Values:
'scoped' |
'global' |
Default:
'scoped' |
States when enabling
— Select how to set block state valuesheld
(default) | reset
| inherit
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
.
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 by Using bind Actions (Stateflow).
The function-call initiator is an S-function that
explicitly enables and disables the function-call
subsystem. See ssEnableSystemWithTid
for an
example.
Block Parameter:
StatesWhenEnabling |
Type: character vector |
Values:
'held' | 'reset' |
'inherit' |
Default:
'held' |
Propagate sizes of variable-size signals
— Select when to propagate variable-size signalsDuring execution
(default) | Only when enabling
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.
To display and enable this parameter for a Trigger
port block, select Function-call
from the
Trigger type list.
Block Parameter:
PropagateVarSize |
Type: character vector |
Values:
'During execution' | 'Only when
enabling' |
Default:
'During execution' |
Show output port
— Control display of output portControl display of an output port for a signal that identifies the trigger signal or function-call event signal.
Select this parameter to display the output port and determine which signal caused the trigger signal or function-call event. The width of the output port signal is the width of the control 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 event
0
in all other cases
Clear this parameter to remove the output port.
Block Parameter:
ShowOutputPort |
Type: character vector |
Values:
'off' | 'on' |
Default:
'off' |
Output data type
— Select output port data typeauto
(default) | double
| int8
Select the output port data type for the signal that identifies the trigger signal or function-call event signal.
auto
Data type is the same as the port connected to the output.
double
Double value.
int8
Integer value
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.
Block Parameter:
OutputDataType |
Type: character vector |
Values:
'auto' | 'double' |
'int8' |
Default:
'auto' |
Sample time type
— Select calling ratetriggered
(default) | periodic
Select the calling rate for a subsystem or model.
triggered
Apply to applications that do not have a periodic function-call frequency. A function-call initiator can execute a triggered (aperiodic) function-call subsystem one or more times per time step and can provide a series of aperiodic function-call events.
periodic
A function-call initiator can execute a periodic function-call system only once per time step and must provide a series of periodic function-call events.. A Stateflow chart is an example of a function-call initiator.
To enable this parameter, select
Function-call
from the
Trigger type list.
Block Parameter:
SampleTimeType |
Type: character vector |
Values:
'triggered' |
'periodic' |
Default:
'triggered' |
Sample time
— Specify time interval-1
(default) | Ts
| [Ts, To]
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 control 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.
To enable this parameter, select
function-call
from the Trigger type list and
periodic
from the Sample time type list.
Block Parameter:
SampleTime |
Type: character vector |
Values:
'-1' | 'Ts' |
'[Ts, To]' |
Default:
'-1' |
Enable zero-crossing detection
— Control zero-crossing detectionSelect this parameter to detect zero crossings.
To enable this parameter, select
rising
,
falling
, or
either
from the Trigger
type list.
Block Parameter:
ZeroCross |
Type: character vector |
Values:
'on' | 'off' |
Default:
'on' |
Initial trigger signal state
— Select the initial state of the trigger signalcompatibility (no trigger on first
evaluation)
(default) | zero
| positive
| negative
Select the initial state of the trigger control 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.
To display and activate this parameter, select
rising
,
falling
, or
either
from the Trigger
type list.
Block Parameter:
InitialTriggerSignalState |
Type: character vector |
Values:
'compatibility (no trigger on first
evaluation)' | 'zero' |
'positive' |
'negative' |
Default:
'compatibility (no trigger on first
evaluation)' |
Port dimensions
— Specify dimensions for the trigger signal1
(default) | [n]
| [m n]
Specify dimensions for the trigger signal attached externally a 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.
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.
Block Parameter:
PortDimensions |
Type: character vector |
Values:
'1' | '[n]' |
'[m n]' |
Default:
'1' |
Trigger signal sample time
— Specify time interval-1
(default) | Ts
| [Ts, To]
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.
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.
Block Parameter:
TriggerSignalSampleTime |
Type: character vector |
Values:
'-1' | 'Ts' |
'[Ts, To]' |
Default:
'-1' |
Minimum
— Specify minimum output value for the trigger signal[]
(default) | real scalarSpecify 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:
Simulation range checking. See Specify Signal Ranges.
Automatic scaling of fixed-point data types.
Optimization of generated code. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. See Optimize using the specified minimum and maximum values (Embedded Coder).
[]
Unspecified minimum value.
Real scalar value.
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.
Block Parameter:
OutMin |
Type: character vector |
Values:
'[]' | '<real
scalar>' |
Default:
'[]' |
Maximum
— Specify maximum output value for the trigger signal[]
(default) | real scalarSpecify 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:
Simulation range checking. See Specify Signal Ranges.
Automatic scaling of fixed-point data types.
Optimization of generated code. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. See Optimize using the specified minimum and maximum values (Embedded Coder).
[]
Unspecified maximum value.
Real scalar value.
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.
Block Parameter:
OutMax |
Type: character vector |
Values:
'[]' | '<real
scalar>' |
Default:
'[]' |
Data type
— Select output data type for the trigger signaldouble
(default) | single
| int8
| uint8
| int16
| uint16
| int32
| uint32
| int64
| uint64
| boolean
| fixdt(1,16)
| fixdt(1,16,0)
| fixdt(1,16,2^,0)
| <data type expression>
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.
int64
Signed 64-bit integer.
uint64
Unsigned 64-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
. You cannot
enter the name of a Simulink.Bus
object as a data type
expression.
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.
Block Parameter:
OutDataTypeStr |
Type: character vector |
Values:
'double' | 'single' |
'int8' | 'uint8' |
'int16' | 'uint16' |
'int32' | 'uint32' |
'int64' | 'uint64' |
'boolean' |
'fixdt(1,16)' |
'fixdt(1,16,0)' |
'fixdt(1,16,2^0,0)' | '<data
type expression>' |
Default:
'double' |
Mode
— Select data type categoryBuilt in
(default) | Fixed point
| Expression
Select data type category and display drop-down lists to help you define the data type.
Built 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.
To enable this parameter, select the Show data type assistant
button .
No equivalent command-line parameter.
Interpolate data
— Control how missing workspace data is estimatedControl how missing workspace data is estimated when loading data from the MATLAB® workspace.
Select this parameter to linearly interpolate output at time steps for which no corresponding workspace data exists.
Clear this parameter to set the output at such time steps equal to the output at the most recent time step for which data exists.
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.
Block Parameter:
Interpolate |
Type: character vector |
Values:
'on' | 'off' |
Default:
'on' |
Data Types |
|
Direct Feedthrough |
|
Multidimensional Signals |
|
Variable-Size Signals |
|
Zero-Crossing Detection |
|
HDL Coder™ provides additional configuration options that affect HDL implementation and synthesized logic. See also HDL Code Generation.
This block has a single, default HDL architecture.