Package Modelica.​Blocks.​Logical
Library of components with Boolean input and output signals

Information

This package provides blocks with Boolean input and output signals to describe logical networks. A typical example for a logical network built with package Logical is shown in the next figure:

LogicalNetwork1.png

The actual value of Boolean input and/or output signals is displayed in the respective block icon as "circle", where "white" color means value false and "green" color means value true. These values are visualized in a diagram animation.

Extends from Modelica.​Icons.​Package (Icon for standard packages).

Package Contents

NameDescription
AndLogical 'and': y = u1 and u2
ChangeOutput y is true, if the input u has a rising or falling edge (y = change(u))
EdgeOutput y is true, if the input u has a rising edge (y = edge(u))
FallingEdgeOutput y is true, if the input u has a falling edge (y = edge(not u))
GreaterOutput y is true, if input u1 is greater than input u2
GreaterEqualOutput y is true, if input u1 is greater or equal than input u2
GreaterEqualThresholdOutput y is true, if input u is greater or equal than threshold
GreaterThresholdOutput y is true, if input u is greater than threshold
HysteresisTransform Real to Boolean signal with Hysteresis
LessOutput y is true, if input u1 is less than input u2
LessEqualOutput y is true, if input u1 is less or equal than input u2
LessEqualThresholdOutput y is true, if input u is less or equal than threshold
LessThresholdOutput y is true, if input u is less than threshold
LogicalSwitchLogical Switch
NandLogical 'nand': y = not (u1 and u2)
NorLogical 'nor': y = not (u1 or u2)
NotLogical 'not': y = not u
OnOffControllerOn-off controller
OrLogical 'or': y = u1 or u2
PreBreaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))
RSFlipFlopA basic RS Flip Flop
SwitchSwitch between two Real signals
TerminateSimulationTerminate simulation if condition is fulfilled
TimerTimer measuring the time from the time instant where the Boolean input became true
TriggeredTrapezoidTriggered trapezoid generator
XorLogical 'xor': y = u1 xor u2
ZeroCrossingTrigger zero crossing of input u

Block Modelica.​Blocks.​Logical.​And
Logical 'and': y = u1 and u2

Information

The output is true if all inputs are true, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSI2SO (Partial block with 2 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputu1Connector of first Boolean input signal
input BooleanInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Or
Logical 'or': y = u1 or u2

Information

The output is true if at least one input is true, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSI2SO (Partial block with 2 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputu1Connector of first Boolean input signal
input BooleanInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Xor
Logical 'xor': y = u1 xor u2

Information

The output is true if exactly one input is true, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSI2SO (Partial block with 2 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputu1Connector of first Boolean input signal
input BooleanInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Nor
Logical 'nor': y = not (u1 or u2)

Information

The output is true if none of the inputs is true, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSI2SO (Partial block with 2 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputu1Connector of first Boolean input signal
input BooleanInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Nand
Logical 'nand': y = not (u1 and u2)

Information

The output is true if at least one input is false, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSI2SO (Partial block with 2 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputu1Connector of first Boolean input signal
input BooleanInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Not
Logical 'not': y = not u

Information

The output is true if the input is false, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSISO (Partial block with 1 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Pre
Breaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))

Information

This block delays the Boolean input by an infinitesimal small time delay and therefore breaks algebraic loops. In a network of logical blocks, in every "closed connection loop" at least one logical block must have a delay, since algebraic systems of Boolean equations are not solvable.

The "Pre" block returns the value of the "input" signal from the last "event iteration". The "event iteration" stops, once both values are identical (u = pre(u)).

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSISO (Partial block with 1 input and 1 output Boolean signal).

Parameters

TypeNameDefaultDescription
Booleanpre_u_startfalseStart value of pre(u) at initial time

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Edge
Output y is true, if the input u has a rising edge (y = edge(u))

Information

The output is true if the Boolean input has a rising edge from false to true, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSISO (Partial block with 1 input and 1 output Boolean signal).

Parameters

TypeNameDefaultDescription
Booleanpre_u_startfalseStart value of pre(u) at initial time

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​FallingEdge
Output y is true, if the input u has a falling edge (y = edge(not u))

Information

The output is true if the Boolean input has a falling edge from true to false, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSISO (Partial block with 1 input and 1 output Boolean signal).

Parameters

TypeNameDefaultDescription
Booleanpre_u_startfalseStart value of pre(u) at initial time

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Change
Output y is true, if the input u has a rising or falling edge (y = change(u))

Information

The output is true if the Boolean input has either a rising edge from false to true or a falling edge from true to false, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSISO (Partial block with 1 input and 1 output Boolean signal).

Parameters

TypeNameDefaultDescription
Booleanpre_u_startfalseStart value of pre(u) at initial time

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​GreaterThreshold
Output y is true, if input u is greater than threshold

Information

The output is true if the Real input is greater than parameter threshold, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanThresholdComparison (Partial block to compare the Real input u with a threshold and provide the result as 1 Boolean output signal).

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​GreaterEqualThreshold
Output y is true, if input u is greater or equal than threshold

Information

The output is true if the Real input is greater than or equal to parameter threshold, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanThresholdComparison (Partial block to compare the Real input u with a threshold and provide the result as 1 Boolean output signal).

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​LessThreshold
Output y is true, if input u is less than threshold

Information

The output is true if the Real input is less than parameter threshold, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanThresholdComparison (Partial block to compare the Real input u with a threshold and provide the result as 1 Boolean output signal).

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​LessEqualThreshold
Output y is true, if input u is less or equal than threshold

Information

The output is true if the Real input is less than or equal to parameter threshold, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanThresholdComparison (Partial block to compare the Real input u with a threshold and provide the result as 1 Boolean output signal).

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Greater
Output y is true, if input u1 is greater than input u2

Information

The output is true if Real input u1 is greater than Real input u2, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanComparison (Partial block with 2 Real input and 1 Boolean output signal (the result of a comparison of the two Real inputs)).

Connectors

TypeNameDescription
input RealInputu1Connector of first Real input signal
input RealInputu2Connector of second Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​GreaterEqual
Output y is true, if input u1 is greater or equal than input u2

Information

The output is true if Real input u1 is greater than or equal to Real input u2, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanComparison (Partial block with 2 Real input and 1 Boolean output signal (the result of a comparison of the two Real inputs)).

Connectors

TypeNameDescription
input RealInputu1Connector of first Real input signal
input RealInputu2Connector of second Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Less
Output y is true, if input u1 is less than input u2

Information

The output is true if Real input u1 is less than Real input u2, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanComparison (Partial block with 2 Real input and 1 Boolean output signal (the result of a comparison of the two Real inputs)).

Connectors

TypeNameDescription
input RealInputu1Connector of first Real input signal
input RealInputu2Connector of second Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​LessEqual
Output y is true, if input u1 is less or equal than input u2

Information

The output is true if Real input u1 is less than or equal to Real input u2, otherwise the output is false.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanComparison (Partial block with 2 Real input and 1 Boolean output signal (the result of a comparison of the two Real inputs)).

Connectors

TypeNameDescription
input RealInputu1Connector of first Real input signal
input RealInputu2Connector of second Real input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​ZeroCrossing
Trigger zero crossing of input u

Information

The output "y" is true at the time instant when the input "u" becomes zero, provided the input "enable" is true. At all other time instants, the output "y" is false. If the input "u" is zero at a time instant when the "enable" input changes its value, then the output y is false.

Note, that in the plot window of a Modelica simulator, the output of this block is usually identically to false, because the output may only be true at an event instant, but not during continuous integration. In order to check that this component is actually working as expected, one should connect its output to, e.g., component Modelica.Blocks.Discrete.TriggeredSampler.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSO (Partial block with 1 output Boolean signal).

Connectors

TypeNameDescription
output BooleanOutputyConnector of Boolean output signal
input RealInputu 
input BooleanInputenableZero input crossing is triggered if the enable input signal is true

Block Modelica.​Blocks.​Logical.​LogicalSwitch
Logical Switch

Information

The LogicalSwitch switches, depending on the Boolean u2 connector (the middle connector), between the two possible input signals u1 (upper connector) and u3 (lower connector).

If u2 is true, connector y is set equal to u1, else it is set equal to u3.

Extends from Modelica.​Blocks.​Interfaces.​partialBooleanSI3SO (Partial block with 3 input and 1 output Boolean signal).

Connectors

TypeNameDescription
input BooleanInputu1Connector of first Boolean input signal
input BooleanInputu2Connector of second Boolean input signal
input BooleanInputu3Connector of third Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Block Modelica.​Blocks.​Logical.​Switch
Switch between two Real signals

Information

The Logical.Switch switches, depending on the logical connector u2 (the middle connector) between the two possible input signals u1 (upper connector) and u3 (lower connector).

If u2 is true, the output signal y is set equal to u1, else it is set equal to u3.

Extends from Modelica.​Blocks.​Icons.​PartialBooleanBlock (Basic graphical layout of logical block).

Connectors

TypeNameDescription
input RealInputu1Connector of first Real input signal
input BooleanInputu2Connector of Boolean input signal
input RealInputu3Connector of second Real input signal
output RealOutputyConnector of Real output signal

Block Modelica.​Blocks.​Logical.​Hysteresis
Transform Real to Boolean signal with Hysteresis

Information

This block transforms a Real input signal into a Boolean output signal:

The start value of the output is defined via parameter pre_y_start (= value of pre(y) at initial time). The default value of this parameter is false.

Extends from Modelica.​Blocks.​Icons.​PartialBooleanBlock (Basic graphical layout of logical block).

Parameters

TypeNameDefaultDescription
RealuLow if y=true and u<=uLow, switch to y=false
RealuHigh if y=false and u>=uHigh, switch to y=true
Booleanpre_y_startfalseValue of pre(y) at initial time

Connectors

TypeNameDescription
input RealInputu 
output BooleanOutputy 

Block Modelica.​Blocks.​Logical.​OnOffController
On-off controller

Information

The block OnOffController sets the output signal y to true when the input signal u falls below the reference signal minus half of the bandwidth and sets the output signal y to false when the input signal u exceeds the reference signal plus half of the bandwidth.

Extends from Modelica.​Blocks.​Icons.​PartialBooleanBlock (Basic graphical layout of logical block).

Parameters

TypeNameDefaultDescription
Realbandwidth Bandwidth around reference signal
Booleanpre_y_startfalseValue of pre(y) at initial time

Connectors

TypeNameDescription
input RealInputreferenceConnector of Real input signal used as reference signal
input RealInputuConnector of Real input signal used as measurement signal
output BooleanOutputyConnector of Real output signal used as actuator signal

Block Modelica.​Blocks.​Logical.​TriggeredTrapezoid
Triggered trapezoid generator

Information

The block TriggeredTrapezoid has a Boolean input and a real output signal and requires the parameters amplitude, rising, falling and offset. The output signal y represents a trapezoidal signal dependent on the input signal u.

The behaviour is as follows: Assume the initial input to be false. In this case, the output will be offset. After a rising edge (i.e., the input changes from false to true), the output is rising during rising to the sum of offset and amplitude. In contrast, after a falling edge (i.e., the input changes from true to false), the output is falling during falling to a value of offset.

Note, that the case of edges before expiration of rising or falling is handled properly.

Extends from Modelica.​Blocks.​Icons.​PartialBooleanBlock (Basic graphical layout of logical block).

Parameters

TypeNameDefaultDescription
Realamplitude1Amplitude of trapezoid
Timerising0Rising duration of trapezoid
TimefallingrisingFalling duration of trapezoid
Realoffset0Offset of output signal

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output RealOutputyConnector of Real output signal

Block Modelica.​Blocks.​Logical.​Timer
Timer measuring the time from the time instant where the Boolean input became true

Information

When the Boolean input "u" becomes true, the timer starts and the output "y" is the time that has elapsed since "u" became true. When the input becomes false, the timer stops and the output is reset to zero.

Extends from Modelica.​Blocks.​Icons.​PartialBooleanBlock (Basic graphical layout of logical block).

Connectors

TypeNameDescription
input BooleanInputuConnector of Boolean input signal
output RealOutputyConnector of Real output signal

Block Modelica.​Blocks.​Logical.​RSFlipFlop
A basic RS Flip Flop

Information

The output Q is set by the input S, is reset by the input R, and keeps its value in between. QI is the inverse of Q.

Extends from Modelica.​Blocks.​Icons.​PartialBooleanBlock (Basic graphical layout of logical block).

Parameters

TypeNameDefaultDescription
BooleanQinifalseStart value of Q at initial time

Connectors

TypeNameDescription
output BooleanOutputQ 
output BooleanOutputQI 
input BooleanInputS 
input BooleanInputR 

Block Modelica.​Blocks.​Logical.​TerminateSimulation
Terminate simulation if condition is fulfilled

Information

In the parameter menu, a time varying expression can be defined via variable condition, for example "condition = x < 0", where "x" is a variable that is declared in the model in which the "TerminateSimulation" block is present. If this expression becomes true, the simulation is (successfully) terminated. A termination message explaining the reason for the termination can be given via parameter "terminationText".

Parameters

TypeNameDefaultDescription
StringterminationText"... End condition reached"Text that will be displayed when simulation is terminated

Connectors

TypeNameDescription
output BooleanOutputconditionTerminate simulation when condition becomes true