Buildings.Controls.OBC.CDL.Logical

Package with logical blocks

Information

Package with blocks for elementary mathematical functions for boolean variables.

Package Content

Name Description
Buildings.Controls.OBC.CDL.Logical.And And Logical 'and': y = u1 and u2
Buildings.Controls.OBC.CDL.Logical.And3 And3 Logical 'and3': y = u1 and u2 and u3
Buildings.Controls.OBC.CDL.Logical.Change Change Output y is true, if the input u has a rising or falling edge (y = change(u))
Buildings.Controls.OBC.CDL.Logical.Edge Edge Output y is true, if the input u has a rising edge (y = edge(u))
Buildings.Controls.OBC.CDL.Logical.FallingEdge FallingEdge Output y is true, if the input u has a falling edge (y = edge(not u))
Buildings.Controls.OBC.CDL.Logical.IntegerSwitch IntegerSwitch Switch between two integer signals
Buildings.Controls.OBC.CDL.Logical.Latch Latch Maintains a true signal until change condition
Buildings.Controls.OBC.CDL.Logical.LogicalSwitch LogicalSwitch Switch between two boolean signals
Buildings.Controls.OBC.CDL.Logical.MultiAnd MultiAnd Logical MultiAnd, y = u[1] and u[2] and u[3] and ...
Buildings.Controls.OBC.CDL.Logical.MultiOr MultiOr Logical MultiOr, y = u[1] or u[2] or u[3] or ...
Buildings.Controls.OBC.CDL.Logical.Nand Nand Logical 'nand': y = not (u1 and u2)
Buildings.Controls.OBC.CDL.Logical.Nor Nor Logical 'nor': y = not (u1 or u2)
Buildings.Controls.OBC.CDL.Logical.Not Not Logical not
Buildings.Controls.OBC.CDL.Logical.OnOffController OnOffController On-off controller
Buildings.Controls.OBC.CDL.Logical.Or Or Logical 'or': y = u1 or u2
Buildings.Controls.OBC.CDL.Logical.Or3 Or3 Logical 'or': y = u1 or u2 or u3
Buildings.Controls.OBC.CDL.Logical.Pre Pre Breaks algebraic loops by an infinitesimal small time delay (y = pre(u): event iteration continues until u = pre(u))
Buildings.Controls.OBC.CDL.Logical.Switch Switch Switch between two Real signals
Buildings.Controls.OBC.CDL.Logical.Timer Timer Timer measuring the time from the time instant where the Boolean input became true
Buildings.Controls.OBC.CDL.Logical.Toggle Toggle Toggles output value whenever its input turns true
Buildings.Controls.OBC.CDL.Logical.TriggeredTrapezoid TriggeredTrapezoid Triggered trapezoid generator
Buildings.Controls.OBC.CDL.Logical.TrueDelay TrueDelay Delay a rising edge of the input, but do not delay a falling edge.
Buildings.Controls.OBC.CDL.Logical.TrueFalseHold TrueFalseHold Block that holds an output signal for at least a specified duration
Buildings.Controls.OBC.CDL.Logical.TrueHoldWithReset TrueHoldWithReset Block that holds a true signal for at least a requested duration
Buildings.Controls.OBC.CDL.Logical.Xor Xor Logical 'xor': y = u1 xor u2
Buildings.Controls.OBC.CDL.Logical.ZeroCrossing ZeroCrossing Trigger zero crossing of input u
Buildings.Controls.OBC.CDL.Logical.Sources Sources Package with blocks that generate source signals
Buildings.Controls.OBC.CDL.Logical.Validation Validation Collection of models that validate the logical blocks of the CDL

Buildings.Controls.OBC.CDL.Logical.And Buildings.Controls.OBC.CDL.Logical.And

Logical 'and': y = u1 and u2

Buildings.Controls.OBC.CDL.Logical.And

Information

Block that outputs true if all inputs are true. Otherwise the output is false.

Connectors

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

Modelica definition

block And "Logical 'and': y = u1 and u2" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 and u2; end And;

Buildings.Controls.OBC.CDL.Logical.And3 Buildings.Controls.OBC.CDL.Logical.And3

Logical 'and3': y = u1 and u2 and u3

Buildings.Controls.OBC.CDL.Logical.And3

Information

Block that outputs true if all inputs are true. Otherwise the output is false.

Connectors

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

Modelica definition

block And3 "Logical 'and3': y = u1 and u2 and u3" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanInput u3 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 and u2 and u3; end And3;

Buildings.Controls.OBC.CDL.Logical.Change Buildings.Controls.OBC.CDL.Logical.Change

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

Buildings.Controls.OBC.CDL.Logical.Change

Information

Block that outputs 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.

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

block 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"; Interfaces.BooleanInput u "Connector of Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; initial equation pre(u) = pre_u_start; equation y = change(u); end Change;

Buildings.Controls.OBC.CDL.Logical.Edge Buildings.Controls.OBC.CDL.Logical.Edge

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

Buildings.Controls.OBC.CDL.Logical.Edge

Information

Block that outputs true if the Boolean input has a rising edge from false to true. Otherwise the output is false.

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

block 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"; Interfaces.BooleanInput u "Connector of Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; initial equation pre(u) = pre_u_start; equation y = edge(u); end Edge;

Buildings.Controls.OBC.CDL.Logical.FallingEdge Buildings.Controls.OBC.CDL.Logical.FallingEdge

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

Buildings.Controls.OBC.CDL.Logical.FallingEdge

Information

Block that outputs true if the Boolean input has a falling edge from true to false. Otherwise the output is false.

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

block 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"; Interfaces.BooleanInput u "Connector of Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; protected Boolean not_u=not u "Boolean not of the input"; initial equation pre(not_u) = not pre_u_start; equation y = edge(not_u); end FallingEdge;

Buildings.Controls.OBC.CDL.Logical.IntegerSwitch Buildings.Controls.OBC.CDL.Logical.IntegerSwitch

Switch between two integer signals

Buildings.Controls.OBC.CDL.Logical.IntegerSwitch

Information

Block that outputs one of two integer input signals based on a boolean input signal.

If the input signal u2 is true, the block outputs y = u1. Otherwise, it outputs y = u3.

Connectors

TypeNameDescription
input IntegerInputu1Integer input signal
input BooleanInputu2Boolean switch input signal, if true, y=u1, else y=u3
input IntegerInputu3Integer input signal
output IntegerOutputyInteger output signal

Modelica definition

block IntegerSwitch "Switch between two integer signals" Interfaces.IntegerInput u1 "Integer input signal"; Interfaces.BooleanInput u2 "Boolean switch input signal, if true, y=u1, else y=u3"; Interfaces.IntegerInput u3 "Integer input signal"; Interfaces.IntegerOutput y "Integer output signal"; equation y = if u2 then u1 else u3; end IntegerSwitch;

Buildings.Controls.OBC.CDL.Logical.Latch Buildings.Controls.OBC.CDL.Logical.Latch

Maintains a true signal until change condition

Buildings.Controls.OBC.CDL.Logical.Latch

Information

Block that generates a true output when the latch input u rises from false to true, provided that the clear input clr is false or also became at the same time false. The output remains true until the clear input clr rises from false to true.

If the clear input clr is true, the output y switches to false (if it was true) and it remains false, regardless of the value of the latch input u.

At initial time, if clr = false, then the output will be y = pre_y_start. Otherwise it will be y=false (because the clear input clr is true).

Latch.png

Parameters

TypeNameDefaultDescription
Booleanpre_y_startfalseStart value of pre(y) if clr=false

Connectors

TypeNameDescription
input BooleanInputuLatch input
input BooleanInputclrClear input
output BooleanOutputyOutput signal

Modelica definition

block Latch "Maintains a true signal until change condition" parameter Boolean pre_y_start=false "Start value of pre(y) if clr=false"; Interfaces.BooleanInput u "Latch input"; Interfaces.BooleanInput clr "Clear input"; Interfaces.BooleanOutput y "Output signal"; initial equation pre(y) = pre_y_start; pre(u) = false; pre(clr) = false; equation when initial() then //scenario = 1; y = if clr then false else pre_y_start; elsewhen (not clr) and change(u) and (pre(u) == false) then //scenario = 2; y = not clr; elsewhen (not clr) and change(u) and (pre(u) == true) then //scenario = 3; y = if clr then false else pre(y); elsewhen change(clr) and (pre(clr) == true) and (not u) then //scenario = 4; y = false; elsewhen clr then //scenario = 5; y = false; end when; end Latch;

Buildings.Controls.OBC.CDL.Logical.LogicalSwitch Buildings.Controls.OBC.CDL.Logical.LogicalSwitch

Switch between two boolean signals

Buildings.Controls.OBC.CDL.Logical.LogicalSwitch

Information

Block that outputs one of two boolean input signals based on a boolean input signal.

If the input signal u2 is true, the block outputs y = u1. Otherwise, it outputs y = u3.

Connectors

TypeNameDescription
input BooleanInputu1Boolean input signal
input BooleanInputu2Boolean switch input signal, if true, y=u1, else y=u3
input BooleanInputu3Boolean input signal
output BooleanOutputyBooelan output signal

Modelica definition

block LogicalSwitch "Switch between two boolean signals" Interfaces.BooleanInput u1 "Boolean input signal"; Interfaces.BooleanInput u2 "Boolean switch input signal, if true, y=u1, else y=u3"; Interfaces.BooleanInput u3 "Boolean input signal"; Interfaces.BooleanOutput y "Booelan output signal"; equation y = if u2 then u1 else u3; end LogicalSwitch;

Buildings.Controls.OBC.CDL.Logical.MultiAnd Buildings.Controls.OBC.CDL.Logical.MultiAnd

Logical MultiAnd, y = u[1] and u[2] and u[3] and ...

Buildings.Controls.OBC.CDL.Logical.MultiAnd

Information

Block that outputs y = true if and only if all elements of the input vector u are true. If no connection to the input connector u is present, the output is y=false.

See Buildings.Controls.OBC.CDL.Logical.Validation.MultiAnd for an example.

Connectors

TypeNameDescription
input BooleanInputu[nu]Connector of Boolean input signals
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block MultiAnd "Logical MultiAnd, y = u[1] and u[2] and u[3] and ..." parameter Integer nu(min=0) = 0 "Number of input connections"; Interfaces.BooleanInput u[nu] "Connector of Boolean input signals"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; protected Boolean uTemp[nu] "Temporary variable"; equation if size(u, 1) > 1 then uTemp[1] = u[1]; for i in 2:size(u, 1) loop uTemp[i] = u[i] and uTemp[i-1]; end for; y = uTemp[nu]; elseif (size(u, 1) == 1) then uTemp[1] = u[1]; y = uTemp[1]; else y = false; end if; end MultiAnd;

Buildings.Controls.OBC.CDL.Logical.MultiOr Buildings.Controls.OBC.CDL.Logical.MultiOr

Logical MultiOr, y = u[1] or u[2] or u[3] or ...

Buildings.Controls.OBC.CDL.Logical.MultiOr

Information

Block that outputs y = true if any element in the input vector u is true. If no connection to the input connector u is present, the output is y=false.

See Buildings.Controls.OBC.CDL.Logical.Validation.MultiOr for an example.

Connectors

TypeNameDescription
input BooleanInputu[nu]Connector of Boolean input signals
output BooleanOutputyConnector of Boolean output signal

Modelica definition

block MultiOr "Logical MultiOr, y = u[1] or u[2] or u[3] or ..." parameter Integer nu(min=0) = 0 "Number of input connections"; Interfaces.BooleanInput u[nu] "Connector of Boolean input signals"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; protected Boolean uTemp[nu] "Temporary variable"; equation if size(u, 1) > 1 then uTemp[1] = u[1]; for i in 2:size(u, 1) loop uTemp[i] = u[i] or uTemp[i-1]; end for; y = uTemp[nu]; elseif (size(u, 1) == 1) then uTemp[1] = u[1]; y = uTemp[1]; else y = false; end if; end MultiOr;

Buildings.Controls.OBC.CDL.Logical.Nand Buildings.Controls.OBC.CDL.Logical.Nand

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

Buildings.Controls.OBC.CDL.Logical.Nand

Information

Block that outputs true if at least one input is false. Otherwise the output is false.

Connectors

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

Modelica definition

block Nand "Logical 'nand': y = not (u1 and u2)" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = not (u1 and u2); end Nand;

Buildings.Controls.OBC.CDL.Logical.Nor Buildings.Controls.OBC.CDL.Logical.Nor

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

Buildings.Controls.OBC.CDL.Logical.Nor

Information

Block that outputs true if none of the inputs is true. Otherwise the output is false.

Connectors

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

Modelica definition

block Nor "Logical 'nor': y = not (u1 or u2)" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = not (u1 or u2); end Nor;

Buildings.Controls.OBC.CDL.Logical.Not Buildings.Controls.OBC.CDL.Logical.Not

Logical not

Buildings.Controls.OBC.CDL.Logical.Not

Information

Block that outputs true if the input is false, and false if the input is true.

Connectors

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

Modelica definition

block Not "Logical not" Interfaces.BooleanInput u "Connector of Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = not u; end Not;

Buildings.Controls.OBC.CDL.Logical.OnOffController Buildings.Controls.OBC.CDL.Logical.OnOffController

On-off controller

Buildings.Controls.OBC.CDL.Logical.OnOffController

Information

Block that represents and on/off controller.

The block outputs true when the input signal u falls below the reference signal minus half of the bandwidth. It sets the output signal to false when the input signal u exceeds the reference signal plus half of the bandwidth. The parameter pre_y_start is used to initialize the previous value of the output pre(y).

Parameters

TypeNameDefaultDescription
Realbandwidthbandwidth(min=0)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" parameter Real bandwidth(min=0) "Bandwidth around reference signal"; parameter Boolean pre_y_start=false "Value of pre(y) at initial time"; Interfaces.RealInput reference "Connector of Real input signal used as reference signal"; Interfaces.RealInput u "Connector of Real input signal used as measurement signal"; Interfaces.BooleanOutput y "Connector of Real output signal used as actuator signal"; initial equation pre(y) = pre_y_start; equation y = pre(y) and (u < reference + bandwidth/2) or (u < reference - bandwidth/2); end OnOffController;

Buildings.Controls.OBC.CDL.Logical.Or Buildings.Controls.OBC.CDL.Logical.Or

Logical 'or': y = u1 or u2

Buildings.Controls.OBC.CDL.Logical.Or

Information

Block that outputs true if at least one input is true. Otherwise the output is false.

Connectors

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

Modelica definition

block Or "Logical 'or': y = u1 or u2" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 or u2; end Or;

Buildings.Controls.OBC.CDL.Logical.Or3 Buildings.Controls.OBC.CDL.Logical.Or3

Logical 'or': y = u1 or u2 or u3

Buildings.Controls.OBC.CDL.Logical.Or3

Information

Block that outputs true if at least one input is true. Otherwise the output is false.

Connectors

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

Modelica definition

block Or3 "Logical 'or': y = u1 or u2 or u3" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanInput u3 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 or u2 or u3; end Or3;

Buildings.Controls.OBC.CDL.Logical.Pre Buildings.Controls.OBC.CDL.Logical.Pre

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

Buildings.Controls.OBC.CDL.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 solvable.

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

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

block 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"; Interfaces.BooleanInput u "Connector of Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; initial equation pre(u) = pre_u_start; equation y = pre(u); end Pre;

Buildings.Controls.OBC.CDL.Logical.Switch Buildings.Controls.OBC.CDL.Logical.Switch

Switch between two Real signals

Buildings.Controls.OBC.CDL.Logical.Switch

Information

Block that outputs one of two real input signals based on a boolean input signal.

If the input signal u2 is true, the block outputs y = u1. Otherwise, it outputs y = u3.

Connectors

TypeNameDescription
input RealInputu1Real input signal
input BooleanInputu2Boolean switch input signal, if true, y=u1, else y=u3
input RealInputu3Real input signal
output RealOutputyReal output signal

Modelica definition

block Switch "Switch between two Real signals" Interfaces.RealInput u1 "Real input signal"; Interfaces.BooleanInput u2 "Boolean switch input signal, if true, y=u1, else y=u3"; Interfaces.RealInput u3 "Real input signal"; Interfaces.RealOutput y "Real output signal"; equation y = if u2 then u1 else u3; end Switch;

Buildings.Controls.OBC.CDL.Logical.Timer Buildings.Controls.OBC.CDL.Logical.Timer

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

Buildings.Controls.OBC.CDL.Logical.Timer

Information

Timer with option to accumulate time until it is reset by an input signal.

Each time the Boolean input u becomes true, the timer runs, otherwise it is dormant. If the parameter accumulate is false, the timer is set to zero each time the input u becomes false. If accumulate = true, an input reset is enabled, the timer accumulates time, and the timer is set to zero only when the value of the input reset becomes true.

Parameters

TypeNameDefaultDescription
BooleanaccumulatefalseIf true, accumulate time until Boolean input 'reset' becomes true, otherwise reset timer whenever u becomes true

Connectors

TypeNameDescription
input BooleanInputuConnector for signal that switches timer on if true, and off if false
input BooleanInputresetConnector for signal that sets timer to zero if it switches to true
output RealOutputyTimer output [s]

Modelica definition

block Timer "Timer measuring the time from the time instant where the Boolean input became true" parameter Boolean accumulate = false "If true, accumulate time until Boolean input 'reset' becomes true, otherwise reset timer whenever u becomes true"; Interfaces.BooleanInput u "Connector for signal that switches timer on if true, and off if false"; Interfaces.BooleanInput reset if accumulate "Connector for signal that sets timer to zero if it switches to true"; Interfaces.RealOutput y( final quantity="Time", final unit="s") "Timer output"; protected discrete Modelica.SIunits.Time entryTime "Time instant when u became true"; discrete Modelica.SIunits.Time yAcc "Accumulated time up to last change to true"; Interfaces.BooleanInput reset_internal( final start=false, final fixed=true) "Internal connector"; initial equation pre(entryTime) = 0; yAcc = 0; equation connect(reset, reset_internal); if not accumulate then reset_internal = false; end if; when u and (not edge(reset_internal)) then entryTime = time; elsewhen reset_internal then entryTime = time; end when; when reset_internal then yAcc = 0; elsewhen (not u) then yAcc = pre(y); end when; if not accumulate then y = if u then time - entryTime else 0.0; else y = if u then yAcc + (time - entryTime) else yAcc; end if; end Timer;

Buildings.Controls.OBC.CDL.Logical.Toggle Buildings.Controls.OBC.CDL.Logical.Toggle

Toggles output value whenever its input turns true

Buildings.Controls.OBC.CDL.Logical.Toggle

Information

Block that generates a true output when toggle input u rises from false to true, provided that the clear input clr is false or also became at the same time false. The output remains true until

If the clear input clr is true, the output y switches to false (if it was true) and it remains false, regardless of the value of the toggle input u.

At initial time, if clr = false, then the output will be y = pre_y_start. Otherwise it will be y=false (because the clear input clr is true).

Toggle.png

Parameters

TypeNameDefaultDescription
Booleanpre_y_startfalseStart value of pre(y) if clr=false

Connectors

TypeNameDescription
input BooleanInputuToggle input
input BooleanInputclrClear input
output BooleanOutputyOutput signal

Modelica definition

block Toggle "Toggles output value whenever its input turns true" parameter Boolean pre_y_start=false "Start value of pre(y) if clr=false"; Interfaces.BooleanInput u "Toggle input"; Interfaces.BooleanInput clr "Clear input"; Interfaces.BooleanOutput y "Output signal"; initial equation pre(y) = pre_y_start; pre(u) = false; pre(clr) = false; equation when initial() then //scenario = 1 y = if clr then false else pre(y); elsewhen (not clr) and change(u) and (pre(u) == false) and (pre(y) == false) then //scenario = 2 y = true; elsewhen (not clr) and change(u) and (pre(u) == false) and (pre(y) == true) then //scenario = 3 y = false; elsewhen (not clr) and change(u) and (pre(u) == true) then //scenario = 4 y = pre(y); elsewhen clr then //scenario = 5 y = false; end when; end Toggle;

Buildings.Controls.OBC.CDL.Logical.TriggeredTrapezoid Buildings.Controls.OBC.CDL.Logical.TriggeredTrapezoid

Triggered trapezoid generator

Buildings.Controls.OBC.CDL.Logical.TriggeredTrapezoid

Information

Block that represents a triggered trapezoid.

The block 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.

TriggeredTrapezoid.png

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

Parameters

TypeNameDefaultDescription
Realamplitude Amplitude 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" parameter Real amplitude "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"; Interfaces.BooleanInput u "Connector of Boolean input signal"; 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"; 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;

Buildings.Controls.OBC.CDL.Logical.TrueDelay Buildings.Controls.OBC.CDL.Logical.TrueDelay

Delay a rising edge of the input, but do not delay a falling edge.

Buildings.Controls.OBC.CDL.Logical.TrueDelay

Information

Block that delays a signal when it becomes true.

A rising edge of the Boolean input u gives a delayed output. A falling edge of the input is immediately given to the output. If delayOnInit = true, then a true input signal at the start time is also delayed, otherwise the input signal is produced immediately at the output.

Simulation results of a typical example with a delay time of 0.1 second is shown below.

OnDelay1.png
OnDelay2.png

Parameters

TypeNameDefaultDescription
TimedelayTime Delay time [s]
BooleandelayOnInitfalseSet to true to delay initial true input

Connectors

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

Modelica definition

block TrueDelay "Delay a rising edge of the input, but do not delay a falling edge." parameter Modelica.SIunits.Time delayTime "Delay time"; parameter Boolean delayOnInit = false "Set to true to delay initial true input"; Interfaces.BooleanInput u "Connector of Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; protected parameter Modelica.SIunits.Time t_past(fixed=false) "Time before simulation started"; Modelica.SIunits.Time t_next; initial equation t_past = time - 1000; pre(u) = false; pre(t_next) = time - 1000; equation when initial() then t_next = if not delayOnInit then t_past else time + delayTime; y = if not (delayOnInit and delayTime > 0) then u else false; elsewhen u then t_next = time + delayTime; y = if delayTime > 0 then false else true; elsewhen not u then t_next = t_past; y = false; elsewhen time >= pre(t_next) then t_next = t_past; y = u; end when; end TrueDelay;

Buildings.Controls.OBC.CDL.Logical.TrueFalseHold Buildings.Controls.OBC.CDL.Logical.TrueFalseHold

Block that holds an output signal for at least a specified duration

Buildings.Controls.OBC.CDL.Logical.TrueFalseHold

Information

Block that holds a true or false signal for at least a defined time period.

Whenever the input u switches, the output y switches and remains at that value for at least duration seconds, where duration is a parameter. After duration elapsed, the output will be y = u. If this change required changing the value of y, then y will remain at that value for at least duration. Otherwise, y will change immediately whenever u changes.

This block could for example be used to disable an economizer, and not re-enable it for 10 minutes, and vice versa.

The image below shows the implementation with a state graph in which each transition is only triggered when the input has the corresponding value, and the current state has been active for at least duration seconds.

Input and output of the block

Simulation results of a typical example with duration = 1000 seconds.

Input and output of the block

Parameters

TypeNameDefaultDescription
TimetrueHoldDuration true hold duration [s]
TimefalseHoldDurationtrueHoldDurationfalse hold duration [s]

Connectors

TypeNameDescription
input BooleanInputuBoolean input signal
output BooleanOutputyBoolean output signal

Modelica definition

block TrueFalseHold "Block that holds an output signal for at least a specified duration" parameter Modelica.SIunits.Time trueHoldDuration "true hold duration"; parameter Modelica.SIunits.Time falseHoldDuration = trueHoldDuration "false hold duration"; Interfaces.BooleanInput u "Boolean input signal"; Interfaces.BooleanOutput y "Boolean output signal"; protected Buildings.Controls.OBC.CDL.Logical.TrueDelay onDel1( delayTime=falseHoldDuration) "Output true when timer elapsed the required time"; Buildings.Controls.OBC.CDL.Logical.TrueDelay onDel2( delayTime=trueHoldDuration) "Output true when timer elapsed the required time"; inner Modelica.StateGraph.StateGraphRoot stateGraphRoot "Root of state graph"; Modelica.StateGraph.StepWithSignal outputFalse(nIn=2) "State for which the block outputs false"; Modelica.StateGraph.TransitionWithSignal toTrue "Transition to true"; CDL.Logical.Not notU "Negation of input"; Modelica.StateGraph.StepWithSignal outputTrue(nIn=2) "State with true output signal"; Modelica.StateGraph.TransitionWithSignal toFalse "Transition to false"; CDL.Logical.And and2 "Check for input and elapsed timer"; CDL.Logical.And and1 "Check for input and elapsed timer"; Modelica.StateGraph.InitialStep initialStep(nIn=0, nOut=2) "Initial state"; Modelica.StateGraph.TransitionWithSignal toTrue1 "Transition to true"; Modelica.StateGraph.TransitionWithSignal toFalse1 "Transition to false"; equation connect(outputTrue.outPort[1], toFalse.inPort); connect(outputTrue.active, y); connect(outputFalse.outPort[1], toTrue.inPort); connect(toFalse.outPort, outputFalse.inPort[1]); connect(outputTrue.active,onDel2. u); connect(notU.y, and2.u2); connect(and2.y, toFalse.condition); connect(outputFalse.active,onDel1. u); connect(u, and1.u2); connect(and1.y, toTrue.condition); connect(u, toTrue1.condition); connect(toTrue1.outPort, outputTrue.inPort[1]); connect(toTrue.outPort, outputTrue.inPort[2]); connect(toFalse1.outPort, outputFalse.inPort[2]); connect(initialStep.outPort[1], toTrue1.inPort); connect(initialStep.outPort[2], toFalse1.inPort); connect(notU.u, u); connect(notU.y, toFalse1.condition); connect(onDel1.y, and1.u1); connect(onDel2.y, and2.u1); end TrueFalseHold;

Buildings.Controls.OBC.CDL.Logical.TrueHoldWithReset Buildings.Controls.OBC.CDL.Logical.TrueHoldWithReset

Block that holds a true signal for at least a requested duration

Buildings.Controls.OBC.CDL.Logical.TrueHoldWithReset

Information

Block that holds a true input signal for at least a defined time period.

At initialization, the output y is equal to the input u. If the input u becomes true, or is true during intialization, a timer starts and the Boolean output y stays true for the time period provided by the parameter duration. When this time is elapsed, the input is checked again. If it is true, then the timer is restarted and the output remains true for another duration seconds. If the input u is false after holdTime seconds, then the ouput is switched to false, until the input becomes true again.

The figure below shows the state chart of the implementation. Note that the transition are done in zero time.

Input and output of the block

The figure below shows an example with a hold time of 3600 seconds and a pulse width period 9000 seconds that starts at t=200 seconds.

Input and output of the block

The figure below shows an example with a hold time of 60 seconds and a pulse width period 3600 seconds that starts at t=0 seconds.

Input and output of the block

The next two figures show the same experiment, except that the input u has been negated. The figure below has again a hold time of 3600 seconds and a pulse width period 9000 seconds that starts at t=200 seconds.

Input and output of the block

The figure below has again a hold time of 60 seconds and a pulse width period 3600 seconds that starts at t=0 seconds.

Input and output of the block

Parameters

TypeNameDefaultDescription
Timeduration Time duration of the true output signal hold [s]

Connectors

TypeNameDescription
input BooleanInputuBoolean input signal
output BooleanOutputyBoolean output signal

Modelica definition

block TrueHoldWithReset "Block that holds a true signal for at least a requested duration" parameter Modelica.SIunits.Time duration "Time duration of the true output signal hold"; Interfaces.BooleanInput u "Boolean input signal"; Interfaces.BooleanOutput y "Boolean output signal"; protected inner Modelica.StateGraph.StateGraphRoot stateGraphRoot "Root of state graph"; Buildings.Controls.OBC.CDL.Logical.TrueDelay onDelay( final delayTime=duration) "Delay for the on signal"; Modelica.StateGraph.InitialStep initialStep "Initial step"; Modelica.StateGraph.StepWithSignal outputTrue "Holds the output at true"; Modelica.StateGraph.TransitionWithSignal toOutputTrue "Transition that activates sending a true output signal"; Modelica.StateGraph.TransitionWithSignal toInitial "Transition that activates the initial state"; equation connect(initialStep.outPort[1], toOutputTrue.inPort); connect(outputTrue.active, y); connect(toOutputTrue.condition, u); connect(toInitial.outPort, initialStep.inPort[1]); connect(outputTrue.active, onDelay.u); connect(toOutputTrue.outPort, outputTrue.inPort[1]); connect(outputTrue.outPort[1], toInitial.inPort); connect(onDelay.y, toInitial.condition); end TrueHoldWithReset;

Buildings.Controls.OBC.CDL.Logical.Xor Buildings.Controls.OBC.CDL.Logical.Xor

Logical 'xor': y = u1 xor u2

Buildings.Controls.OBC.CDL.Logical.Xor

Information

Block that outputs true if exactly one input is true. Otherwise the output is false.

Connectors

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

Modelica definition

block Xor "Logical 'xor': y = u1 xor u2" Interfaces.BooleanInput u1 "Connector of first Boolean input signal"; Interfaces.BooleanInput u2 "Connector of second Boolean input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = not ((u1 and u2) or (not u1 and not u2)); end Xor;

Buildings.Controls.OBC.CDL.Logical.ZeroCrossing Buildings.Controls.OBC.CDL.Logical.ZeroCrossing

Trigger zero crossing of input u

Buildings.Controls.OBC.CDL.Logical.ZeroCrossing

Information

Block that detects zero crossings.

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 Buildings.Controls.OBC.CDL.Discrete.TriggeredSampler.

Connectors

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

Modelica definition

block ZeroCrossing "Trigger zero crossing of input u" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; Interfaces.BooleanInput enable "Zero input crossing is triggered if the enable input signal is true"; protected Boolean disable=not enable "Boolean not of enable input"; Boolean u_pos "Positive real input"; 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;