Main Content

Variant Function-Call Signals on Variant Subsystem Outport

This example shows how the Variant Subsystem block allows function-call signals from its choice blocks to be merged on its outports.

NOTE: A Variant Subsystem block with more than one variant choice does not support function-call signals on its outports when the variant activation time is set tostartup.

Explore the Model

Open the modelslexVariantSubsystemFunctionCall.

open_system('slexVariantSubsystemFunctionCall.slx');

The model contains a Variant Subsystem block with two Chart blocks,Chart1andChart2, as variant choices. The variant control variableAis defined in thePreLoadFcnmodel callback. The variant conditions onChart1andChart2areA==1andA==2respectively. A Pulse Generator block is connected to the Variant Subsystem block and all its choices.Chart1andChart2are configured with port names that match the corresponding port names of the Variant Subsystem block.

open_system('slexVariantSubsystemFunctionCall/Variant Subsystem');

TheOutput function callparameter is selected on theSignal Attributestab of the Block Parameters dialog box of the Outport block namedactivate(). This allows the Outport block of the variant subsystem to emit function-call signals. To enable this option programmatically, use this command:

set_param('slexVariantSubsystemFunctionCall/Variant Subsystem/activate()','OutputFunctionCall','on');

Simulate the Model

To simulate the model, on theSimulationtab, clickRun. Variant condition propagation determines the active and inactive variant choices.

  • WhenA==1,Chart1is active.

  • WhenA==2,Chart2is active.

The outportactivate()gets function-call signal from the choicesChart1andChart2. When the Function-Call Subsystem block is triggered, there is a sine wave output atOut2.

sim卡('slexVariantSubsystemFunctionCall.slx');

More About