Switch (logic)
Outputs u1 while u2 is true, otherwise u3.
- signal
- Boolean
- Modelica Standard Library
- 4 ports
logicSwitchLibraryLogicDescription
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
Also in this example:ConstantSine waveClockANDRS flip-flopTimerBoolean constantBoolean stepTriggered samplerRising edge
Ports
Inputs 3
-
sel
u2Boolean selector.
-
true
u1Real input passed through while u2 is true.
-
false
u3Real 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.0
MSL documentation Modelica.Blocks.Logical.SwitchAssumptions 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.