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:

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 Content

NameDescription
Modelica.Blocks.Logical.And And Logical 'and': y = u1 and u2
Modelica.Blocks.Logical.Or Or Logical 'or': y = u1 or u2
Modelica.Blocks.Logical.Xor Xor Logical 'xor': y = u1 xor u2
Modelica.Blocks.Logical.Nor Nor Logical 'nor': y = not (u1 or u2)
Modelica.Blocks.Logical.Nand Nand Logical 'nand': y = not (u1 and u2)
Modelica.Blocks.Logical.Not Not Logical 'not': y = not u
Modelica.Blocks.Logical.Pre Pre Breaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))
Modelica.Blocks.Logical.Edge Edge Output y is true, if the input u has a rising edge (y = edge(u))
Modelica.Blocks.Logical.FallingEdge FallingEdge Output y is true, if the input u has a falling edge (y = edge(not u))
Modelica.Blocks.Logical.Change Change Output y is true, if the input u has a rising or falling edge (y = change(u))
Modelica.Blocks.Logical.GreaterThreshold GreaterThreshold Output y is true, if input u is greater than threshold
Modelica.Blocks.Logical.GreaterEqualThreshold GreaterEqualThreshold Output y is true, if input u is greater or equal than threshold
Modelica.Blocks.Logical.LessThreshold LessThreshold Output y is true, if input u is less than threshold
Modelica.Blocks.Logical.LessEqualThreshold LessEqualThreshold Output y is true, if input u is less or equal than threshold
Modelica.Blocks.Logical.Greater Greater Output y is true, if input u1 is greater as input u2
Modelica.Blocks.Logical.GreaterEqual GreaterEqual Output y is true, if input u1 is greater or equal as input u2
Modelica.Blocks.Logical.Less Less Output y is true, if input u1 is less as input u2
Modelica.Blocks.Logical.LessEqual LessEqual Output y is true, if input u1 is less or equal as input u2
Modelica.Blocks.Logical.ZeroCrossing ZeroCrossing Trigger zero crossing of input u
Modelica.Blocks.Logical.LogicalSwitch LogicalSwitch Logical Switch
Modelica.Blocks.Logical.Switch Switch Switch between two Real signals
Modelica.Blocks.Logical.Hysteresis Hysteresis Transform Real to Boolean signal with Hysteresis
Modelica.Blocks.Logical.OnOffController OnOffController On-off controller
Modelica.Blocks.Logical.TriggeredTrapezoid TriggeredTrapezoid Triggered trapezoid generator
Modelica.Blocks.Logical.Timer Timer Timer measuring the time from the time instant where the Boolean input became true
Modelica.Blocks.Logical.TerminateSimulation TerminateSimulation Terminate simulation if condition is fullfilled


Modelica.Blocks.Logical.And Modelica.Blocks.Logical.And

Logical 'and': y = u1 and u2

Modelica.Blocks.Logical.And

Information


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

Extends from 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

Modelica definition

model And "Logical 'and': y = u1 and u2"
  extends Blocks.Interfaces.partialBooleanSI2SO;
equation 
  y = u1 and u2;
end And;

Modelica.Blocks.Logical.Or Modelica.Blocks.Logical.Or

Logical 'or': y = u1 or u2

Modelica.Blocks.Logical.Or

Information


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

Extends from 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

Modelica definition

model Or "Logical 'or': y = u1 or u2"
  extends Blocks.Interfaces.partialBooleanSI2SO;
equation 
  y = u1 or u2;
end Or;

Modelica.Blocks.Logical.Xor Modelica.Blocks.Logical.Xor

Logical 'xor': y = u1 xor u2

Modelica.Blocks.Logical.Xor

Information


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

Extends from 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

Modelica definition

model Xor "Logical 'xor': y = u1 xor u2"
  extends Blocks.Interfaces.partialBooleanSI2SO;
equation 
  y =not  ( (u1 and u2) or (not u1 and not u2));
end Xor;

Modelica.Blocks.Logical.Nor Modelica.Blocks.Logical.Nor

Logical 'nor': y = not (u1 or u2)

Modelica.Blocks.Logical.Nor

Information


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

Extends from 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

Modelica definition

model Nor "Logical 'nor': y = not (u1 or u2)"
  extends Blocks.Interfaces.partialBooleanSI2SO;
equation 
  y =not  ( u1 or u2);
end Nor;

Modelica.Blocks.Logical.Nand Modelica.Blocks.Logical.Nand

Logical 'nand': y = not (u1 and u2)

Modelica.Blocks.Logical.Nand

Information


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

Extends from 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

Modelica definition

model Nand "Logical 'nand': y = not (u1 and u2)"
  extends Blocks.Interfaces.partialBooleanSI2SO;
equation 
  y =not  ( u1 and u2);
end Nand;

Modelica.Blocks.Logical.Not Modelica.Blocks.Logical.Not

Logical 'not': y = not u

Modelica.Blocks.Logical.Not

Information


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

Extends from 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

Modelica definition

model Not "Logical 'not': y = not u"
  extends Blocks.Interfaces.partialBooleanSISO;

equation 
  y =not  u;
end Not;

Modelica.Blocks.Logical.Pre Modelica.Blocks.Logical.Pre

Breaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))

Modelica.Blocks.Logical.Pre

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 solveable.

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 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

Modelica definition

model Pre 
  "Breaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))"

  parameter Boolean pre_u_start = false "Start value of pre(u) at initial time";
  extends Blocks.Interfaces.partialBooleanSISO;

initial equation 
  pre(u) = pre_u_start;
equation 
  y = pre(u);
end Pre;

Modelica.Blocks.Logical.Edge Modelica.Blocks.Logical.Edge

Output y is true, if the input u has a rising edge (y = edge(u))

Modelica.Blocks.Logical.Edge

Information


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

Extends from 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

Modelica definition

model Edge 
  "Output y is true, if the input u has a rising edge (y = edge(u))"

  parameter Boolean pre_u_start = false "Start value of pre(u) at initial time";
  extends Blocks.Interfaces.partialBooleanSISO;

initial equation 
  pre(u) = pre_u_start;
equation 
  y = edge(u);
end Edge;

Modelica.Blocks.Logical.FallingEdge Modelica.Blocks.Logical.FallingEdge

Output y is true, if the input u has a falling edge (y = edge(not u))

Modelica.Blocks.Logical.FallingEdge

Information


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

Extends from 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

Modelica definition

model FallingEdge 
  "Output y is true, if the input u has a falling edge (y = edge(not u))"

  parameter Boolean pre_u_start = false "Start value of pre(u) at initial time";
  extends Blocks.Interfaces.partialBooleanSISO;

protected 
 Boolean not_u=not u;
initial equation 
  pre(not_u) =not  pre_u_start;
equation 
  y = edge(not_u);
end FallingEdge;

Modelica.Blocks.Logical.Change Modelica.Blocks.Logical.Change

Output y is true, if the input u has a rising or falling edge (y = change(u))

Modelica.Blocks.Logical.Change

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 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

Modelica definition

model Change 
  "Output y is true, if the input u has a rising or falling edge (y = change(u))"

  parameter Boolean pre_u_start = false "Start value of pre(u) at initial time";
  extends Blocks.Interfaces.partialBooleanSISO;

initial equation 
  pre(u) = pre_u_start;
equation 
  y = change(u);
end Change;

Modelica.Blocks.Logical.GreaterThreshold Modelica.Blocks.Logical.GreaterThreshold

Output y is true, if input u is greater than threshold

Modelica.Blocks.Logical.GreaterThreshold

Information


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

Extends from 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 Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block GreaterThreshold 
  "Output y is true, if input u is greater than threshold"
  extends Blocks.Interfaces.partialBooleanThresholdComparison;
equation 
  y = u > threshold;
end GreaterThreshold;

Modelica.Blocks.Logical.GreaterEqualThreshold Modelica.Blocks.Logical.GreaterEqualThreshold

Output y is true, if input u is greater or equal than threshold

Modelica.Blocks.Logical.GreaterEqualThreshold

Information


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

Extends from 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 Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block GreaterEqualThreshold 
  "Output y is true, if input u is greater or equal than threshold"

  extends Blocks.Interfaces.partialBooleanThresholdComparison;
equation 
  y = u >= threshold;
end GreaterEqualThreshold;

Modelica.Blocks.Logical.LessThreshold Modelica.Blocks.Logical.LessThreshold

Output y is true, if input u is less than threshold

Modelica.Blocks.Logical.LessThreshold

Information


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

Extends from 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 Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block LessThreshold 
  "Output y is true, if input u is less than threshold"

  extends Blocks.Interfaces.partialBooleanThresholdComparison;
equation 
  y = u < threshold;
end LessThreshold;

Modelica.Blocks.Logical.LessEqualThreshold Modelica.Blocks.Logical.LessEqualThreshold

Output y is true, if input u is less or equal than threshold

Modelica.Blocks.Logical.LessEqualThreshold

Information


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

Extends from 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 Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block LessEqualThreshold 
  "Output y is true, if input u is less or equal than threshold"
  extends Blocks.Interfaces.partialBooleanThresholdComparison;
equation 
  y = u <= threshold;
end LessEqualThreshold;

Modelica.Blocks.Logical.Greater Modelica.Blocks.Logical.Greater

Output y is true, if input u1 is greater as input u2

Modelica.Blocks.Logical.Greater

Information


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

Extends from 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 Boolean input signal
input RealInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block Greater "Output y is true, if input u1 is greater as input u2"
  extends Blocks.Interfaces.partialBooleanComparison;

equation 
  y = u1 > u2;
end Greater;

Modelica.Blocks.Logical.GreaterEqual Modelica.Blocks.Logical.GreaterEqual

Output y is true, if input u1 is greater or equal as input u2

Modelica.Blocks.Logical.GreaterEqual

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 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 Boolean input signal
input RealInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block GreaterEqual 
  "Output y is true, if input u1 is greater or equal as input u2"
  extends Blocks.Interfaces.partialBooleanComparison;

equation 
  y = u1 >= u2;
end GreaterEqual;

Modelica.Blocks.Logical.Less Modelica.Blocks.Logical.Less

Output y is true, if input u1 is less as input u2

Modelica.Blocks.Logical.Less

Information


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

Extends from 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 Boolean input signal
input RealInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block Less "Output y is true, if input u1 is less as input u2"
  extends Blocks.Interfaces.partialBooleanComparison;

equation 
  y = u1 < u2;
end Less;

Modelica.Blocks.Logical.LessEqual Modelica.Blocks.Logical.LessEqual

Output y is true, if input u1 is less or equal as input u2

Modelica.Blocks.Logical.LessEqual

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 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 Boolean input signal
input RealInputu2Connector of second Boolean input signal
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block LessEqual 
  "Output y is true, if input u1 is less or equal as input u2"
  extends Blocks.Interfaces.partialBooleanComparison;

equation 
  y = u1 <= u2;
end LessEqual;

Modelica.Blocks.Logical.ZeroCrossing Modelica.Blocks.Logical.ZeroCrossing

Trigger zero crossing of input u

Modelica.Blocks.Logical.ZeroCrossing

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 ModelicaAdditions.Blocks.Discrete.TriggeredSampler.

Extends from 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

Modelica definition

block ZeroCrossing "Trigger zero crossing of input u"
  extends Blocks.Interfaces.partialBooleanSO;
  Blocks.Interfaces.RealInput u;
  Blocks.Interfaces.BooleanInput enable 
    "Zero input crossing is triggered if the enable input signal is true";

protected 
  Boolean disable=not   enable;
  Boolean u_pos;
initial equation 
  pre(u_pos)  = false;
  pre(enable) = false;
  pre(disable) =not  pre(enable);
equation 
  u_pos = enable and u >= 0;
  y = change(u_pos) and not edge(enable) and not edge(disable);
end ZeroCrossing;

Modelica.Blocks.Logical.LogicalSwitch Modelica.Blocks.Logical.LogicalSwitch

Logical Switch

Modelica.Blocks.Logical.LogicalSwitch

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 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

Modelica definition

block LogicalSwitch "Logical Switch"
  extends Blocks.Interfaces.partialBooleanSI3SO;

equation 
  y = if u2 then u1 else u3;
end LogicalSwitch;

Modelica.Blocks.Logical.Switch Modelica.Blocks.Logical.Switch

Switch between two Real signals

Modelica.Blocks.Logical.Switch

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 Blocks.Interfaces.partialBooleanBlockIcon (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

Modelica definition

block Switch "Switch between two Real signals"
  extends Blocks.Interfaces.partialBooleanBlockIcon;
  Blocks.Interfaces.RealInput u1 "Connector of first Real input signal";
  Blocks.Interfaces.BooleanInput u2 "Connector of Boolean input signal";
  Blocks.Interfaces.RealInput u3 "Connector of second Real input signal";
  Blocks.Interfaces.RealOutput y "Connector of Real output signal";

equation 
  y = if u2 then u1 else u3;
end Switch;

Modelica.Blocks.Logical.Hysteresis Modelica.Blocks.Logical.Hysteresis

Transform Real to Boolean signal with Hysteresis

Modelica.Blocks.Logical.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 Blocks.Interfaces.partialBooleanBlockIcon (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 

Modelica definition

block Hysteresis "Transform Real to Boolean signal with Hysteresis"

  extends Blocks.Interfaces.partialBooleanBlockIcon;
  parameter Real uLow(start=0) "if y=true and u<=uLow, switch to y=false";
  parameter Real uHigh(start=1) "if y=false and u>=uHigh, switch to y=true";
  parameter Boolean pre_y_start = false "Value of pre(y) at initial time";

  Blocks.Interfaces.RealInput u;
  Blocks.Interfaces.BooleanOutput y;

initial equation 
  pre(y) = pre_y_start;
equation 
   y = u > uHigh or pre(y) and u >= uLow;
end Hysteresis;

Modelica.Blocks.Logical.OnOffController Modelica.Blocks.Logical.OnOffController

On-off controller

Modelica.Blocks.Logical.OnOffController

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 Interfaces.partialBooleanBlockIcon (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

Modelica definition

block OnOffController "On-off controller"
  extends Interfaces.partialBooleanBlockIcon;
  Blocks.Interfaces.RealInput reference 
    "Connector of Real input signal used as reference signal";
  Blocks.Interfaces.RealInput u 
    "Connector of Real input signal used as measurement signal";
  Blocks.Interfaces.BooleanOutput y 
    "Connector of Real output signal used as actuator signal";

  parameter Real bandwidth(start=0.1) "Bandwidth around reference signal";
  parameter Boolean pre_y_start = false "Value of pre(y) at initial time";

initial equation 
  pre(y) = pre_y_start;
equation 
  y = pre(y) and (u < reference + bandwidth/2) or (u < reference - bandwidth/2);
end OnOffController;

Modelica.Blocks.Logical.TriggeredTrapezoid Modelica.Blocks.Logical.TriggeredTrapezoid

Triggered trapezoid generator

Modelica.Blocks.Logical.TriggeredTrapezoid

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 Interfaces.partialBooleanBlockIcon (Basic graphical layout of logical block).

Parameters

TypeNameDefaultDescription
Realamplitude1Amplitude of trapezoid
Timerising0Rising duration of trapezoid [s]
TimefallingrisingFalling duration of trapezoid [s]
Realoffset0Offset of output signal

Connectors

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

Modelica definition

block TriggeredTrapezoid "Triggered trapezoid generator"
  extends Interfaces.partialBooleanBlockIcon;

  parameter Real amplitude=1 "Amplitude of trapezoid";
  parameter Modelica.SIunits.Time rising(final min=0)=0 
    "Rising duration of trapezoid";
  parameter Modelica.SIunits.Time falling(final min=0)=rising 
    "Falling duration of trapezoid";
  parameter Real offset=0 "Offset of output signal";

  Blocks.Interfaces.BooleanInput u "Connector of Boolean input signal";
  Blocks.Interfaces.RealOutput y "Connector of Real output signal";

protected 
  discrete Real endValue "Value of y at time of recent edge";
  discrete Real rate "Current rising/falling rate";
  discrete Modelica.SIunits.Time T "Predicted time of output reaching endValue";
initial equation 
  /* A start value of y is set, because pre(y) is present
     to avoid a warning message from the compiler. However,
     this setting does not have an effect, because y is initialized
     correctly, before pre(y) is used
  */
  pre(y) = 0;
equation 
    y = if time < T then endValue - (T - time)*rate else  endValue;

    when {initial(),u,not u} then
      endValue = if u then offset + amplitude else offset;
      rate = if u and (rising > 0) then amplitude/rising else 
        if not u and (falling > 0) then -amplitude/falling else 0;
      T = if u and not (rising > 0) or not u and not (falling
         > 0) or not abs(amplitude) > 0 or initial() then time else time
         + (endValue - pre(y))/rate;
    end when;
end TriggeredTrapezoid;

Modelica.Blocks.Logical.Timer Modelica.Blocks.Logical.Timer

Timer measuring the time from the time instant where the Boolean input became true

Modelica.Blocks.Logical.Timer

Information


When the Boolean input "u" becomes true, the timer is started and the output "y" is the time from the time instant where u became true. The timer is stopped and the output is reset to zero, once the input becomes false.

Extends from Interfaces.partialBooleanBlockIcon (Basic graphical layout of logical block).

Connectors

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

Modelica definition

block Timer 
  "Timer measuring the time from the time instant where the Boolean input became true"

  extends Interfaces.partialBooleanBlockIcon;
  Blocks.Interfaces.BooleanInput u "Connector of Boolean input signal";
  Blocks.Interfaces.RealOutput y "Connector of Real output signal";

protected 
  discrete Modelica.SIunits.Time entryTime "Time instant when u became true";
initial equation 
  pre(entryTime) = 0;
equation 
  when u then
    entryTime = time;
  end when;
  y = if u then time - entryTime else 0.0;
end Timer;

Modelica.Blocks.Logical.TerminateSimulation Modelica.Blocks.Logical.TerminateSimulation

Terminate simulation if condition is fullfilled

Modelica.Blocks.Logical.TerminateSimulation

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
BooleanOutputconditionfalseTerminate simulation when condition becomes true
StringterminationText"... End condition reached"Text that will be displayed when simulation is terminated

Connectors

TypeNameDescription
output BooleanOutputconditionTerminate simulation when condition becomes true

Modelica definition

block TerminateSimulation 
  "Terminate simulation if condition is fullfilled"

  Modelica.Blocks.Interfaces.BooleanOutput condition=false 
    "Terminate simulation when condition becomes true";
  parameter String terminationText = "... End condition reached" 
    "Text that will be displayed when simulation is terminated";

equation 
  when condition then
     terminate(terminationText);
  end when;
end TerminateSimulation;

Automatically generated Fri Nov 12 16:27:37 2010.