If Action Subsystem
Subsystem whose execution is enabled by If block
- Library:
Simulink / Ports & Subsystems
Description
TheIf Action Subsystemblock is aSubsystemblock preconfigured as a starting point for creating a subsystem whose execution is controlled by anIfblock. TheIfblock evaluates a logical expression and then, depending on the result of the evaluation, outputs an action signal. Execution of the subsystem is controlled by anAction Portblock placed inside the subsystem.
金宝app®ignores a priority set on anIf Action Subsystemblock. Instead, set the priority on theIfblock that initiates execution of the subsystem.
Merge signals fromIf Action Subsystemblocks
This example shows how to merge signals controlled by anIfblock. TheIfblock selects the execution of anIf Action Subsystemblock from a set of subsystems. Regardless of which subsystem the If block selects, you can create a single signal with aMergeblock. To open the model, seeex_if_block
.
All blocks in anIf Action Subsystemblock must execute at the same rate as the drivingIfblock. You can satisfy this requirement by setting the sample time parameter for each block to either inherited (-1
) or the same value as theIfblock sample time.
Support for Fixed-Point Data Type
TheIfblock does not directly support fixed-point data types. However, you can use theCompare To Constantblock to work around this limitation.
Consider the following floating-point model without fixed-point data types. To open model, seeex_if_block_floating_point
.
In this model, theIf Action Subsystemblocks use their default configurations. The simulation parameters are set to their default values except for the parameters listed in the following table.
Configuration Parameter Pane |
Parameter |
Setting |
---|---|---|
Solver |
Start time |
|
停止时间 |
|
|
Type |
|
|
Solver |
|
|
Fixed-step size |
|
The block parameters are set to their default values except for the parameters listed in the following table.
Block |
Parameter |
Setting |
---|---|---|
Repeating Sequence Stair |
Vector of output values |
|
Repeating Sequence Stair1 |
Vector of output values |
|
If |
Number of inputs |
|
If expression |
|
|
Show else condition |
Selected |
|
Constant |
Constant value |
|
Constant1 |
Constant value |
|
Scope |
Number of axes |
|
Time range |
|
For this model, when inputu1
is greater than0
or inputu2
is greater than0.5
, the output is4
. Otherwise, the output is-4
. TheScopeblock displays the output from theMergeblock with inputsu1
, andu2
.
You can implement this block diagram as a model with fixed-point data types. To open model, seeex_if_block_fixed_point
.
TheRepeating Sequence Stairblocks output fixed-point data types.
TheCompare To Constantblocks implement two parts of theIf expressionthat is used in theIfblock in the floating-point version of the model,(u1 > 0)
and(u2 > 0.5)
. TheOR
operation,(u1|u2)
, can still be implemented inside theIfblock. For a fixed-point model, the expression must be partially implemented outside of theIf块,我s in this model.
The block and simulation parameters for the fixed-point model are the same as for the floating-point model with the following exceptions and additions:
Block |
Parameter |
Setting |
---|---|---|
Compare To Constant |
Operator |
|
Constant value |
|
|
出put data type mode |
|
|
Enable zero-crossing detection |
off |
|
Compare To Constant1 |
Operator |
|
Constant value |
|
|
出put data type mode |
|
|
Enable zero-crossing detection |
off |
|
If |
Number of inputs |
|
If expression |
|