Switch (logic)

Outputs u1 while u2 is true, otherwise u3.

  • signal
  • Boolean
  • Modelica Standard Library
  • 4 ports
BlockSwitch (logic)KindlogicSwitchLibraryLogic

Description

Selects between two Real signals with a Boolean input: the output follows u1 while u2 is true, otherwise u3.

Example

Latch, timer, and sampler Start and stop buttons set and reset a flip-flop, which times the run, gates a signal, and samples the start time.

EnableStartStopEnabled startStart edgeStop edgeRunningRun timeSine 1 Hz0Gated sineClockStart time
In Gradara, select a Switch (logic) block and press F1, then choose Open example. It opens as a new model in My models, ready to run.

Also in this example:ConstantSine waveClockANDRS flip-flopTimerBoolean constantBoolean stepTriggered samplerRising edge

Ports

Inputs 3

  • selu2

    Boolean selector.

  • trueu1

    Real input passed through while u2 is true.

  • falseu3

    Real input passed through while u2 is false.

Outputs 1

  • y

    Selected signal.

Equations

Modelica
y = u1 if u2, otherwise u3

Implementation

Modelica Standard Library 4.1.0Modelica.Blocks.Logical.Switch
MSL documentation

Assumptions and limitations

  • The switchover is instantaneous, so y jumps when u1 and u3 differ.

Tips

  • To select by comparing a Real control signal with a threshold instead, use Switch.

See also

Select a block in Gradara and press F1 to open its page offline.