Main Content

Propagate Variant Conditions from Variant Source Blocks to Conditionally Executed Subsystems

Aconditionally executed subsystemis a nonvirtual subsystem that allows you to control its execution with an external signal. Enabled, Triggered, and Function-Call Subsystems are examples of conditional subsystems. The external signal that controls a conditional subsystem is called thecontrol signaland the port through which the signal enters the block is called thecontrol port。For more information on conditional subsystems, seeConditionally Executed Subsystems Overview

You can use a single-input/single-output or a multi-inputVariant Sourceblock to control the execution of conditional subsystems based on the active variant conditions at the inports of theVariant Sourceblock.

Use Variant Source Block to Control Execution of Conditional Subsystem Blocks

This example shows how to use a single-input/single-output Variant Source block to control the execution of a conditional subsystem block.

Explore the Model

Open the modelslexVariantControlPorts

The model contains a single-input/single-output Variant Source block,变体Source1, with variant condition set asV==1。The output from变体Source1block is connected to the control port of the Enabled SubsystemSubsystem

TheAllow zero active variant controlsparameter on the变体Source1block is set toon。When this option is selected and there is no active variant choice, Simulink® disables all the blocks connected to the input and output stream of the Variant Source block.

When you simulate the model after settingV=1,conditionV==1propagates to the outport of变体Source1and then to the control port ofSubsystem。The condition assigned to the subsystem block then propagates to the blocks namedSine2andOut1connected to its input and output ports. If you setVto a value other than1, Simulink disables all the blocks connected to the inport and outport of变体Source1

Propagate Variant Conditions to Function-Call Subsystems

A Function-Call Subsystem block is a subsystem that another block can invoke directly during simulation. The Function-Call Subsystem block is analogous to a function in procedural programming language. For more information, seeUsing Function-Call Subsystems

You can use a Variant Source block to make the Function-Call Subsystem block conditional.

The Variant Source block has conditionV==1, whereVis aSimulink.Parameter

TheOutput function callparameter on the Variant Source block is set toon。这使得块输出函数call signals.

TheAllow zero active variant controlsparameter on the Variant Source block is set toon

When you simulate this model, the variant condition from the Variant Source block propagates to the control port of theSubAsubsystem block and further propagates to the blocks connected to its inports and outports.

  • WhenV=1,SubAblock is active and the variant condition propagates backward and forward to the blocks connected to the input (三机一体) and output (Out1) ports.

  • WhenV~=1(for example,V=0),SubAbecomes inactive, which makesOut1inactive.In2remains active because it is connected toSubB, which is active.

  • IfIn2is not connected toSubB,In2变得不活跃的时候V~=1

Note: If the Function-Call Subsystem is placed inside a virtual grouped subsystem, the variant condition triggering the Function-Call Subsystem must match the corresponding condition on the input of the higher level subsystem block.

Related Topics