Buildings.Controls.OBC.CDL.Continuous

Package with elementary mathematical functions for continuous variables

Information

Package with blocks for elementary mathematical functions for continuous variables.

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

Package Content

Name Description
Buildings.Controls.OBC.CDL.Continuous.Abs Abs Output the absolute value of the input
Buildings.Controls.OBC.CDL.Continuous.Add Add Output the sum of the two inputs
Buildings.Controls.OBC.CDL.Continuous.AddParameter AddParameter Output the sum of an input plus a parameter
Buildings.Controls.OBC.CDL.Continuous.Atan Atan Output the arc tangent of the input
Buildings.Controls.OBC.CDL.Continuous.Atan2 Atan2 Output atan(u1/u2) of the inputs u1 and u2
Buildings.Controls.OBC.CDL.Continuous.Average Average Output the average of its two inputs
Buildings.Controls.OBC.CDL.Continuous.ChangeSign ChangeSign Change sign of the input
Buildings.Controls.OBC.CDL.Continuous.Cos Cos Output the cosine of the input
Buildings.Controls.OBC.CDL.Continuous.Derivative Derivative Block that approximates the derivative of the input
Buildings.Controls.OBC.CDL.Continuous.Division Division Output first input divided by second input
Buildings.Controls.OBC.CDL.Continuous.Exp Exp Output the exponential (base e) of the input
Buildings.Controls.OBC.CDL.Continuous.Feedback Feedback Output difference between commanded and feedback input
Buildings.Controls.OBC.CDL.Continuous.Gain Gain Output the product of a gain value with the input signal
Buildings.Controls.OBC.CDL.Continuous.Greater Greater Output y is true, if input u1 is greater than input u2
Buildings.Controls.OBC.CDL.Continuous.GreaterEqual GreaterEqual Output y is true, if input u1 is greater or equal than input u2
Buildings.Controls.OBC.CDL.Continuous.GreaterEqualThreshold GreaterEqualThreshold Output y is true, if input u is greater or equal than threshold
Buildings.Controls.OBC.CDL.Continuous.GreaterThreshold GreaterThreshold Output y is true, if input u is greater than threshold
Buildings.Controls.OBC.CDL.Continuous.Hysteresis Hysteresis Transform Real to Boolean signal with Hysteresis
Buildings.Controls.OBC.CDL.Continuous.HysteresisWithHold HysteresisWithHold Hysteresis block that optionally allows to specify a hold time
Buildings.Controls.OBC.CDL.Continuous.IntegratorWithReset IntegratorWithReset Output the integral of the input signal
Buildings.Controls.OBC.CDL.Continuous.Less Less Output y is true, if input u1 is less than input u2
Buildings.Controls.OBC.CDL.Continuous.LessEqual LessEqual Output y is true, if input u1 is less or equal than input u2
Buildings.Controls.OBC.CDL.Continuous.LessEqualThreshold LessEqualThreshold Output y is true, if input u is less or equal than threshold
Buildings.Controls.OBC.CDL.Continuous.LessThreshold LessThreshold Output y is true, if input u is less than threshold
Buildings.Controls.OBC.CDL.Continuous.LimPID LimPID P, PI, PD, and PID controller with limited output, anti-windup compensation and setpoint weighting
Buildings.Controls.OBC.CDL.Continuous.Limiter Limiter Limit the range of a signal
Buildings.Controls.OBC.CDL.Continuous.Line Line Output the value of the input x along a line specified by two points
Buildings.Controls.OBC.CDL.Continuous.Log Log Output the natural (base e) logarithm of the input (input > 0 required)
Buildings.Controls.OBC.CDL.Continuous.Log10 Log10 Output the base 10 logarithm of the input (input > 0 required)
Buildings.Controls.OBC.CDL.Continuous.Max Max Pass through the largest signal
Buildings.Controls.OBC.CDL.Continuous.Min Min Pass through the smallest signal
Buildings.Controls.OBC.CDL.Continuous.Modulo Modulo Output the remainder of first input divided by second input (~=0)
Buildings.Controls.OBC.CDL.Continuous.MovingMean MovingMean Block to output moving average
Buildings.Controls.OBC.CDL.Continuous.MultiMax MultiMax Output the maximum element of the input vector
Buildings.Controls.OBC.CDL.Continuous.MultiMin MultiMin Output the minimum element of the input vector
Buildings.Controls.OBC.CDL.Continuous.MultiSum MultiSum Sum of Reals, y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]
Buildings.Controls.OBC.CDL.Continuous.NumberOfRequests NumberOfRequests Outputs the number of signals that are above/below a certain threshold
Buildings.Controls.OBC.CDL.Continuous.Product Product Output product of the two inputs
Buildings.Controls.OBC.CDL.Continuous.Round Round Round real number to given digits
Buildings.Controls.OBC.CDL.Continuous.Sin Sin Output the sine of the input
Buildings.Controls.OBC.CDL.Continuous.SlewRateLimiter SlewRateLimiter Limit the increase or decrease rate of input
Buildings.Controls.OBC.CDL.Continuous.Sort Sort Sort elements of input vector in ascending or descending order
Buildings.Controls.OBC.CDL.Continuous.Sqrt Sqrt Output the square root of the input (input >= 0 required)
Buildings.Controls.OBC.CDL.Continuous.Tan Tan Output the tangent of the input
Buildings.Controls.OBC.CDL.Continuous.Sources Sources Package with blocks that generate source signals
Buildings.Controls.OBC.CDL.Continuous.Validation Validation Collection of models that validate the continuous blocks of the CDL

Buildings.Controls.OBC.CDL.Continuous.Abs Buildings.Controls.OBC.CDL.Continuous.Abs

Output the absolute value of the input

Buildings.Controls.OBC.CDL.Continuous.Abs

Information

Block that outputs y = abs(u), where u is an input.

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Abs "Output the absolute value of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = abs(u); end Abs;

Buildings.Controls.OBC.CDL.Continuous.Add Buildings.Controls.OBC.CDL.Continuous.Add

Output the sum of the two inputs

Buildings.Controls.OBC.CDL.Continuous.Add

Information

Block that outputs y as the weighted sum of the two input signals u1 and u2,

    y = k1*u1 + k2*u2;

where k1 and k2 are parameters.

Parameters

TypeNameDefaultDescription
Realk1+1Gain for input u1
Realk2+1Gain for input u2

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Add "Output the sum of the two inputs" parameter Real k1=+1 "Gain for input u1"; parameter Real k2=+1 "Gain for input u2"; Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = k1*u1 + k2*u2; end Add;

Buildings.Controls.OBC.CDL.Continuous.AddParameter Buildings.Controls.OBC.CDL.Continuous.AddParameter

Output the sum of an input plus a parameter

Buildings.Controls.OBC.CDL.Continuous.AddParameter

Information

Block that outputs y = k u + p, where k and p are parameters and u is an input.

Parameters

TypeNameDefaultDescription
Realp Value to be added
Realk Gain of input

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block AddParameter "Output the sum of an input plus a parameter" parameter Real p "Value to be added"; parameter Real k "Gain of input"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = k*u + p; end AddParameter;

Buildings.Controls.OBC.CDL.Continuous.Atan Buildings.Controls.OBC.CDL.Continuous.Atan

Output the arc tangent of the input

Buildings.Controls.OBC.CDL.Continuous.Atan

Information

Block that outputs y = atan(u), where u is an input.

atan.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Atan "Output the arc tangent of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.atan(u); end Atan;

Buildings.Controls.OBC.CDL.Continuous.Atan2 Buildings.Controls.OBC.CDL.Continuous.Atan2

Output atan(u1/u2) of the inputs u1 and u2

Buildings.Controls.OBC.CDL.Continuous.Atan2

Information

Block that outputs the tangent-inverse y = atan2(u1, u2) of the input u1 divided by the input u2.

u1 and u2 shall not be zero at the same time instant. Atan2 uses the sign of u1 and u2 in order to construct the solution in the range -π ≤ y ≤ π, whereas Buildings.Controls.OBC.CDL.Continuous.Atan gives a solution in the range -π/2 ≤ y ≤ π/2.

atan2.png

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Atan2 "Output atan(u1/u2) of the inputs u1 and u2" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.atan2(u1, u2); end Atan2;

Buildings.Controls.OBC.CDL.Continuous.Average Buildings.Controls.OBC.CDL.Continuous.Average

Output the average of its two inputs

Buildings.Controls.OBC.CDL.Continuous.Average

Information

Block that outputs y = avg(u1,u2), where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Average "Output the average of its two inputs" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = 0.5*(u1 + u2); end Average;

Buildings.Controls.OBC.CDL.Continuous.ChangeSign Buildings.Controls.OBC.CDL.Continuous.ChangeSign

Change sign of the input

Buildings.Controls.OBC.CDL.Continuous.ChangeSign

Information

Block that outputs y = -u, where u is an input.

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block ChangeSign "Change sign of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = -u; end ChangeSign;

Buildings.Controls.OBC.CDL.Continuous.Cos Buildings.Controls.OBC.CDL.Continuous.Cos

Output the cosine of the input

Buildings.Controls.OBC.CDL.Continuous.Cos

Information

Block that outputs y = cos(u), where u is an input.

cos.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Cos "Output the cosine of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.cos(u); end Cos;

Buildings.Controls.OBC.CDL.Continuous.Derivative Buildings.Controls.OBC.CDL.Continuous.Derivative

Block that approximates the derivative of the input

Buildings.Controls.OBC.CDL.Continuous.Derivative

Information

This blocks defines the transfer function between the input u and the output y (element-wise) as approximated derivative:

             k * s
     y = ------------ * u
            T * s + 1

If k=0, the block reduces to y=0.

Parameters

TypeNameDefaultDescription
Realk1Gains [1]
TimeT0.01Time constant (T>0 required) [s]
Initialization
InitinitTypeBuildings.Controls.OBC.CDL.T...Type of initialization (1: no init, 2: initial state, 3: initial output)
Realx_start0Initial or guess value of state
Realy_start0Initial value of output (= state)

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Derivative "Block that approximates the derivative of the input" parameter Real k(unit="1") = 1 "Gains"; parameter Modelica.SIunits.Time T(min=1E-60) = 0.01 "Time constant (T>0 required)"; parameter Buildings.Controls.OBC.CDL.Types.Init initType=Buildings.Controls.OBC.CDL.Types.Init.NoInit "Type of initialization (1: no init, 2: initial state, 3: initial output)"; parameter Real x_start=0 "Initial or guess value of state"; parameter Real y_start=0 "Initial value of output (= state)"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; output Real x(start=x_start) "State of block"; protected parameter Boolean zeroGain=abs(k) < 100*1E-15; initial equation if initType == Buildings.Controls.OBC.CDL.Types.Init.InitialState then x = x_start; elseif initType == Buildings.Controls.OBC.CDL.Types.Init.InitialOutput then if zeroGain then x = u; else y = y_start; end if; end if; equation der(x) = if zeroGain then 0 else (u - x)/T; y = if zeroGain then 0 else (k/T)*(u - x); end Derivative;

Buildings.Controls.OBC.CDL.Continuous.Division Buildings.Controls.OBC.CDL.Continuous.Division

Output first input divided by second input

Buildings.Controls.OBC.CDL.Continuous.Division

Information

Block that outputs y = u1 / u2, where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Division "Output first input divided by second input" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y*u2 = u1; end Division;

Buildings.Controls.OBC.CDL.Continuous.Exp Buildings.Controls.OBC.CDL.Continuous.Exp

Output the exponential (base e) of the input

Buildings.Controls.OBC.CDL.Continuous.Exp

Information

Block that outputs y = exp(u), where u is an input and exp() is the base-e exponential function.

exp.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Exp "Output the exponential (base e) of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.exp(u); end Exp;

Buildings.Controls.OBC.CDL.Continuous.Feedback Buildings.Controls.OBC.CDL.Continuous.Feedback

Output difference between commanded and feedback input

Buildings.Controls.OBC.CDL.Continuous.Feedback

Information

Block that outputs y = u1 - u2, where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Feedback "Output difference between commanded and feedback input" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = u1 - u2; end Feedback;

Buildings.Controls.OBC.CDL.Continuous.Gain Buildings.Controls.OBC.CDL.Continuous.Gain

Output the product of a gain value with the input signal

Buildings.Controls.OBC.CDL.Continuous.Gain

Information

Block that outputs y = k * u, where k is a parameter and u is an input.

Parameters

TypeNameDefaultDescription
Realk Gain value multiplied with input signal

Connectors

TypeNameDescription
input RealInputuInput signal connector
output RealOutputyOutput signal connector

Modelica definition

block Gain "Output the product of a gain value with the input signal" parameter Real k "Gain value multiplied with input signal"; Interfaces.RealInput u "Input signal connector"; Interfaces.RealOutput y "Output signal connector"; equation y = k*u; end Gain;

Buildings.Controls.OBC.CDL.Continuous.Greater Buildings.Controls.OBC.CDL.Continuous.Greater

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

Buildings.Controls.OBC.CDL.Continuous.Greater

Information

Block that outputs true if the Real input u1 is greater than the Real input u2. Otherwise the output is false.

Connectors

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

Modelica definition

block Greater "Output y is true, if input u1 is greater than input u2" Interfaces.RealInput u1 "Connector of first Real input signal"; Interfaces.RealInput u2 "Connector of second Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 > u2; end Greater;

Buildings.Controls.OBC.CDL.Continuous.GreaterEqual Buildings.Controls.OBC.CDL.Continuous.GreaterEqual

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

Buildings.Controls.OBC.CDL.Continuous.GreaterEqual

Information

Block that outputs true if Real the input u1 is greater than or equal to the Real input u2. Otherwise the output is false.

Connectors

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

Modelica definition

block GreaterEqual "Output y is true, if input u1 is greater or equal than input u2" Interfaces.RealInput u1 "Connector of first Real input signal"; Interfaces.RealInput u2 "Connector of second Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 >= u2; end GreaterEqual;

Buildings.Controls.OBC.CDL.Continuous.GreaterEqualThreshold Buildings.Controls.OBC.CDL.Continuous.GreaterEqualThreshold

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

Buildings.Controls.OBC.CDL.Continuous.GreaterEqualThreshold

Information

Block that outputs true if the Real input is greater than or equal to the parameter threshold. Otherwise the output is false.

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

TypeNameDescription
input RealInputuConnector of Real 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" parameter Real threshold=0 "Comparison with respect to threshold"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u >= threshold; end GreaterEqualThreshold;

Buildings.Controls.OBC.CDL.Continuous.GreaterThreshold Buildings.Controls.OBC.CDL.Continuous.GreaterThreshold

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

Buildings.Controls.OBC.CDL.Continuous.GreaterThreshold

Information

Block that outputs true if the Real input is greater than the parameter threshold. Otherwise the output is false.

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

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

Modelica definition

block GreaterThreshold "Output y is true, if input u is greater than threshold" parameter Real threshold=0 "Comparison with respect to threshold"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u > threshold; end GreaterThreshold;

Buildings.Controls.OBC.CDL.Continuous.Hysteresis Buildings.Controls.OBC.CDL.Continuous.Hysteresis

Transform Real to Boolean signal with Hysteresis

Buildings.Controls.OBC.CDL.Continuous.Hysteresis

Information

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

Hysteresis.png

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 RealInputuReal input signal
output BooleanOutputyBoolean output signal

Modelica definition

block Hysteresis "Transform Real to Boolean signal with Hysteresis" parameter Real uLow "if y=true and u<=uLow, switch to y=false"; parameter Real uHigh "if y=false and u>=uHigh, switch to y=true"; parameter Boolean pre_y_start=false "Value of pre(y) at initial time"; Interfaces.RealInput u "Real input signal"; Interfaces.BooleanOutput y "Boolean output signal"; initial equation assert(uHigh > uLow, "Hysteresis limits wrong. uHigh must be larger than uLow"); pre(y) = pre_y_start; equation y = not pre(y) and u > uHigh or pre(y) and u >= uLow; end Hysteresis;

Buildings.Controls.OBC.CDL.Continuous.HysteresisWithHold Buildings.Controls.OBC.CDL.Continuous.HysteresisWithHold

Hysteresis block that optionally allows to specify a hold time

Buildings.Controls.OBC.CDL.Continuous.HysteresisWithHold

Information

Model for a hysteresis block that optionally allows to specify a hold time. During the hold time, the output is not allowed to switch.

When the input u becomes greater than uHigh, the output y becomes true and remains true for at least trueHoldDuration seconds, after which time it is allowed to switch immediately.

When the input u becomes less than uLow, the output y becomes false and remains false for at least falseHoldDuration seconds, after which time it is allowed to switch immediately.

Input and output of the block

This model for example could be used to disable an economizer, and not re-enable it for 10 minutes, and vice versa. Using hysteresis can avoid the distraction from the input noise.

Parameters

TypeNameDefaultDescription
RealuLow if y=true and u<=uLow, switch to y=false
RealuHigh if y=false and u>=uHigh, switch to y=true
TimetrueHoldDuration true hold duration [s]
TimefalseHoldDurationtrueHoldDurationfalse hold duration [s]

Connectors

TypeNameDescription
input RealInputuReal input signal
output BooleanOutputyBoolean output signal

Modelica definition

block HysteresisWithHold "Hysteresis block that optionally allows to specify a hold time" parameter Real uLow "if y=true and u<=uLow, switch to y=false"; parameter Real uHigh "if y=false and u>=uHigh, switch to y=true"; parameter Modelica.SIunits.Time trueHoldDuration "true hold duration"; parameter Modelica.SIunits.Time falseHoldDuration=trueHoldDuration "false hold duration"; Interfaces.RealInput u "Real input signal"; Interfaces.BooleanOutput y "Boolean output signal"; protected Continuous.Hysteresis hysteresis(final uLow=uLow, final uHigh=uHigh) "Transform Real to Boolean signal with Hysteresis"; Logical.TrueFalseHold truFalHol(final trueHoldDuration=trueHoldDuration, final falseHoldDuration=falseHoldDuration) "True/false hold"; equation connect(u, hysteresis.u); connect(hysteresis.y, truFalHol.u); connect(truFalHol.y, y); end HysteresisWithHold;

Buildings.Controls.OBC.CDL.Continuous.IntegratorWithReset Buildings.Controls.OBC.CDL.Continuous.IntegratorWithReset

Output the integral of the input signal

Buildings.Controls.OBC.CDL.Continuous.IntegratorWithReset

Information

This model is similar to Modelica.Blocks.Continuous.Integrator except that it optionally allows to reset the output y of the integrator.

The output of the integrator can be reset as follows:

Implementation

To adjust the icon layer, the code of Modelica.Blocks.Continuous.Integrator has been copied into this model rather than extended.

Parameters

TypeNameDefaultDescription
Realk1Integrator gain [1]
ResetresetBuildings.Controls.OBC.CDL.T...Type of integrator reset
Initialization
InitinitTypeBuildings.Controls.OBC.CDL.T...Type of initialization (1: no init, 2: initial state, 3: initial output)
Realy_start0Initial or guess value of output (= state)
Integrator reset
Realy_reset0Value to which integrator is reset, used if reset = Types.Reset.Parameter

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal
input RealInputy_reset_inInput signal for state to which integrator is reset, enabled if reset = Types.Reset.Input
input BooleanInputtriggerResets the integrator output when trigger becomes true

Modelica definition

block IntegratorWithReset "Output the integral of the input signal" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; parameter Real k(unit="1") = 1 "Integrator gain"; /* InitialState is the default, because it was the default in Modelica 2.2 and therefore this setting is backward compatible */ parameter Buildings.Controls.OBC.CDL.Types.Init initType=Buildings.Controls.OBC.CDL.Types.Init.InitialState "Type of initialization (1: no init, 2: initial state, 3: initial output)"; parameter Real y_start=0 "Initial or guess value of output (= state)"; parameter Buildings.Controls.OBC.CDL.Types.Reset reset=Buildings.Controls.OBC.CDL.Types.Reset.Disabled "Type of integrator reset"; parameter Real y_reset=0 "Value to which integrator is reset, used if reset = Types.Reset.Parameter"; Buildings.Controls.OBC.CDL.Interfaces.RealInput y_reset_in if reset == Buildings.Controls.OBC.CDL.Types.Reset.Input "Input signal for state to which integrator is reset, enabled if reset = Types.Reset.Input"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput trigger if reset <> Buildings.Controls.OBC.CDL.Types.Reset.Disabled "Resets the integrator output when trigger becomes true"; protected Buildings.Controls.OBC.CDL.Interfaces.RealInput y_reset_internal "Internal connector for integrator reset"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput trigger_internal "Needed to use conditional connector trigger"; initial equation if initType == Buildings.Controls.OBC.CDL.Types.Init.InitialState or initType == Buildings.Controls.OBC.CDL.Types.Init.InitialOutput then y = y_start; end if; equation der(y) = k*u; // Equations for integrator reset connect(trigger, trigger_internal); connect(y_reset_in, y_reset_internal); if reset <> Buildings.Controls.OBC.CDL.Types.Reset.Input then y_reset_internal = y_reset; end if; if reset == Buildings.Controls.OBC.CDL.Types.Reset.Disabled then trigger_internal = false; else when trigger_internal then reinit(y, y_reset_internal); end when; end if; end IntegratorWithReset;

Buildings.Controls.OBC.CDL.Continuous.Less Buildings.Controls.OBC.CDL.Continuous.Less

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

Buildings.Controls.OBC.CDL.Continuous.Less

Information

Block that outputs true if the Real input u1 is less than the Real input u2. Otherwise the output is false.

Connectors

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

Modelica definition

block Less "Output y is true, if input u1 is less than input u2" Interfaces.RealInput u1 "Connector of first Real input signal"; Interfaces.RealInput u2 "Connector of second Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 < u2; end Less;

Buildings.Controls.OBC.CDL.Continuous.LessEqual Buildings.Controls.OBC.CDL.Continuous.LessEqual

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

Buildings.Controls.OBC.CDL.Continuous.LessEqual

Information

Block that outputs true if the Real input u1 is less than or equal to the Real input u2. Otherwise the output is false.

Connectors

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

Modelica definition

block LessEqual "Output y is true, if input u1 is less or equal than input u2" Interfaces.RealInput u1 "Connector of first Real input signal"; Interfaces.RealInput u2 "Connector of second Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u1 <= u2; end LessEqual;

Buildings.Controls.OBC.CDL.Continuous.LessEqualThreshold Buildings.Controls.OBC.CDL.Continuous.LessEqualThreshold

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

Buildings.Controls.OBC.CDL.Continuous.LessEqualThreshold

Information

Block that outputs true if the Real input is less than or equal to the parameter threshold. Otherwise the output is false.

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

TypeNameDescription
input RealInputuConnector of Real 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" parameter Real threshold=0 "Comparison with respect to threshold"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u <= threshold; end LessEqualThreshold;

Buildings.Controls.OBC.CDL.Continuous.LessThreshold Buildings.Controls.OBC.CDL.Continuous.LessThreshold

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

Buildings.Controls.OBC.CDL.Continuous.LessThreshold

Information

Block that outputs true if the Real input is less than the parameter threshold. Otherwise the output is false.

Parameters

TypeNameDefaultDescription
Realthreshold0Comparison with respect to threshold

Connectors

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

Modelica definition

block LessThreshold "Output y is true, if input u is less than threshold" parameter Real threshold=0 "Comparison with respect to threshold"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.BooleanOutput y "Connector of Boolean output signal"; equation y = u < threshold; end LessThreshold;

Buildings.Controls.OBC.CDL.Continuous.LimPID Buildings.Controls.OBC.CDL.Continuous.LimPID

P, PI, PD, and PID controller with limited output, anti-windup compensation and setpoint weighting

Buildings.Controls.OBC.CDL.Continuous.LimPID

Information

PID controller in the standard form

y = k   ( e(t) + 1 ⁄ Ti   ∫ e(s) ds + Td de(t)⁄dt ),

where y is the control signal, e(t) = us - um is the control error, with us being the set point and um being the measured quantity, k is the gain, Ti is the time constant of the integral term and Td is the time constant of the derivative term.

Note that the units of k are the inverse of the units of the control error, while the units of Ti and Td are seconds.

For detailed treatment of integrator anti-windup, set-point weights and output limitation, see Modelica.Blocks.Continuous.LimPID. The model is similar to Modelica.Blocks.Continuous.LimPID, except for the following changes:

  1. It can be configured to have a reverse action.

    If the parameter reverseAction=false (the default), then u_m < u_s increases the controller output, otherwise the controller output is decreased. Thus,

    • for a heating coil with a two-way valve, set reverseAction = false,
    • for a cooling coils with a two-way valve, set reverseAction = true.
  2. It can be configured to enable an input port that allows resetting the controller output. The controller output can be reset as follows:

    • If reset = CDL.Types.Reset.Disabled, which is the default, then the controller output is never reset.
    • If reset = CDL.Types.Reset.Parameter, then a boolean input signal trigger is enabled. Whenever the value of this input changes from false to true, the controller output is reset by setting y to the value of the parameter y_reset.
    • If reset = CDL.Types.Reset.Input, then a boolean input signal trigger is enabled. Whenever the value of this input changes from false to true, the controller output is reset by setting y to the value of the input signal y_reset_in.

    Note that this controller implements an integrator anti-windup. Therefore, for most applications, keeping the default setting of reset = CDL.Types.Reset.Disabled is sufficient. Examples where it may be beneficial to reset the controller output are situations where the equipment control input should continuously increase as the equipment is switched on, such as as a light dimmer that may slowly increase the luminance, or a variable speed drive of a motor that should continuously increase the speed.

  3. The parameter limitsAtInit has been removed.
  4. Some parameters assignments in the instances have been made final.

For recommendations regarding tuning of closed loop control, see Modelica.Blocks.Continuous.LimPID or the control literature.

Parameters

TypeNameDefaultDescription
SimpleControllercontrollerTypeBuildings.Controls.OBC.CDL.T...Type of controller
Realk1Gain of controller [1]
TimeTi0.5Time constant of integrator block [s]
TimeTd0.1Time constant of derivative block [s]
RealyMax Upper limit of output
RealyMin-yMaxLower limit of output
Realwp1Set-point weight for Proportional block (0..1)
Realwd0Set-point weight for Derivative block (0..1)
RealNi0.9Ni*Ti is time constant of anti-windup compensation
RealNd10The higher Nd, the more ideal the derivative block
BooleanreverseActionfalseSet to true for throttling the water flow rate through a cooling coil controller
Initialization
InitinitTypeBuildings.Controls.OBC.CDL.T...Type of initialization
Realxi_start0Initial or guess value value for integrator output (= integrator state)
Realxd_start0Initial or guess value for state of derivative block
Realy_start0Initial value of output
Integrator reset
ResetresetBuildings.Controls.OBC.CDL.T...Type of controller output reset
Realy_resetxi_startValue to which the controller output is reset if the boolean trigger has a rising edge, used if reset == CDL.Types.Reset.Parameter
Advanced
Booleanstricttrue= true, if strict limits with noEvent(..)

Connectors

TypeNameDescription
input BooleanInputtriggerResets the controller output when trigger becomes true
input RealInputy_reset_inInput signal for state to which integrator is reset, enabled if reset = CDL.Types.Reset.Input
input RealInputu_sConnector of setpoint input signal
input RealInputu_mConnector of measurement input signal
output RealOutputyConnector of actuator output signal

Modelica definition

block LimPID "P, PI, PD, and PID controller with limited output, anti-windup compensation and setpoint weighting" output Real controlError=u_s - u_m "Control error (set point - measurement)"; parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerType= Buildings.Controls.OBC.CDL.Types.SimpleController.PI "Type of controller"; parameter Real k( min=0, unit="1") = 1 "Gain of controller"; parameter Modelica.SIunits.Time Ti(min=Constants.small) = 0.5 "Time constant of integrator block"; parameter Modelica.SIunits.Time Td(min=0) = 0.1 "Time constant of derivative block"; parameter Real yMax "Upper limit of output"; parameter Real yMin=-yMax "Lower limit of output"; parameter Real wp(min=0) = 1 "Set-point weight for Proportional block (0..1)"; parameter Real wd(min=0) = 0 "Set-point weight for Derivative block (0..1)"; parameter Real Ni(min=100*Modelica.Constants.eps) = 0.9 "Ni*Ti is time constant of anti-windup compensation"; parameter Real Nd(min=100*Modelica.Constants.eps) = 10 "The higher Nd, the more ideal the derivative block"; parameter Buildings.Controls.OBC.CDL.Types.Init initType=Buildings.Controls.OBC.CDL.Types.Init.InitialState "Type of initialization"; // Removed as the Limiter block no longer uses this parameter. // parameter Boolean limitsAtInit = true // "= false, if limits are ignored during initialization" // annotation(Evaluate=true, Dialog(group="Initialization")); parameter Real xi_start=0 "Initial or guess value value for integrator output (= integrator state)"; parameter Real xd_start=0 "Initial or guess value for state of derivative block"; parameter Real y_start=0 "Initial value of output"; parameter Boolean strict=true "= true, if strict limits with noEvent(..)"; parameter Boolean reverseAction=false "Set to true for throttling the water flow rate through a cooling coil controller"; parameter Buildings.Controls.OBC.CDL.Types.Reset reset=Buildings.Controls.OBC.CDL.Types.Reset.Disabled "Type of controller output reset"; parameter Real y_reset=xi_start "Value to which the controller output is reset if the boolean trigger has a rising edge, used if reset == CDL.Types.Reset.Parameter"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput trigger if reset <> Buildings.Controls.OBC.CDL.Types.Reset.Disabled "Resets the controller output when trigger becomes true"; Buildings.Controls.OBC.CDL.Interfaces.RealInput y_reset_in if reset == Buildings.Controls.OBC.CDL.Types.Reset.Input "Input signal for state to which integrator is reset, enabled if reset = CDL.Types.Reset.Input"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u_s "Connector of setpoint input signal"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u_m "Connector of measurement input signal"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput y "Connector of actuator output signal"; Buildings.Controls.OBC.CDL.Continuous.Add addP(k1=revAct*wp, k2=-revAct) "Adder for P gain"; Buildings.Controls.OBC.CDL.Continuous.Add addD(k1=revAct*wd, k2=-revAct) if with_D "Adder for D gain"; Buildings.Controls.OBC.CDL.Continuous.Gain P(k=1) "Proportional term"; Buildings.Controls.OBC.CDL.Continuous.IntegratorWithReset I( final reset=if reset == Buildings.Controls.OBC.CDL.Types.Reset.Disabled then reset else Buildings.Controls.OBC.CDL.Types.Reset.Input, final y_reset=y_reset, final k=unitTime/Ti, final y_start=xi_start, final initType=if initType == Buildings.Controls.OBC.CDL.Types.Init.InitialState then Buildings.Controls.OBC.CDL.Types.Init.InitialState else Buildings.Controls.OBC.CDL.Types.Init.NoInit) if with_I "Integral term"; Buildings.Controls.OBC.CDL.Continuous.Derivative D( final k=Td/unitTime, final T=max([Td/Nd, 1.e-14]), final x_start=xd_start, final initType=if initType == Buildings.Controls.OBC.CDL.Types.Init.InitialState then Buildings.Controls.OBC.CDL.Types.Init.InitialState else Buildings.Controls.OBC.CDL.Types.Init.NoInit) if with_D "Derivative term"; Modelica.Blocks.Math.Add3 addPID( final k1=1, final k2=1, final k3=1) "Adder for the gains"; protected constant Modelica.SIunits.Time unitTime=1; final parameter Real revAct=if reverseAction then -1 else 1 "Switch for sign for reverse action"; parameter Boolean with_I=controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PI or controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PID "Boolean flag to enable integral action"; parameter Boolean with_D=controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PD or controllerType == Buildings.Controls.OBC.CDL.Types.SimpleController.PID "Boolean flag to enable derivative action"; Buildings.Controls.OBC.CDL.Continuous.Sources.Constant Dzero(final k=0) if not with_D "Zero input signal"; Buildings.Controls.OBC.CDL.Continuous.Sources.Constant Izero(final k=0) if not with_I "Zero input signal"; Buildings.Controls.OBC.CDL.Interfaces.RealInput y_reset_internal "Internal connector for controller output reset"; Modelica.Blocks.Math.Add3 addI(final k1=revAct, final k2=-revAct) if with_I "Adder for I gain"; Buildings.Controls.OBC.CDL.Continuous.Add addSat(final k1=+1, final k2=-1) if with_I "Adder for integrator feedback"; Buildings.Controls.OBC.CDL.Continuous.Gain gainPID(final k=k) "Multiplier for control gain"; Buildings.Controls.OBC.CDL.Continuous.Gain gainTrack(k=1/(k*Ni)) if with_I "Gain for anti-windup compensation"; Modelica.Blocks.Nonlinear.Limiter limiter( final uMax=yMax, final uMin=yMin, final strict=strict) "Output limiter"; Modelica.Blocks.Sources.RealExpression intRes(final y=y_reset_internal/k - addPID.u1 - addPID.u2) if reset <> Buildings.Controls.OBC.CDL.Types.Reset.Disabled "Signal source for integrator reset"; initial equation if initType == Buildings.Controls.OBC.CDL.Types.Init.InitialOutput then gainPID.y = y_start; end if; equation assert(yMax >= yMin, "LimPID: Limits must be consistent. However, yMax (=" + String(yMax) + ") < yMin (=" + String(yMin) + ")"); if initType == Buildings.Controls.OBC.CDL.Types.Init.InitialOutput and ( y_start < yMin or y_start > yMax) then Modelica.Utilities.Streams.error("LimPID: Start value y_start (=" + String( y_start) + ") is outside of the limits of yMin (=" + String(yMin) + ") and yMax (=" + String(yMax) + ")"); end if; // Equations for conditional connectors connect(y_reset_in, y_reset_internal); if reset <> Buildings.Controls.OBC.CDL.Types.Reset.Input then y_reset_internal = y_reset; end if; connect(u_s, addP.u1); connect(u_s, addD.u1); connect(u_s, addI.u1); connect(addP.y, P.u); connect(addD.y, D.u); connect(addI.y, I.u); connect(P.y, addPID.u1); connect(D.y, addPID.u2); connect(I.y, addPID.u3); connect(addPID.y, gainPID.u); connect(gainPID.y, addSat.u2); connect(gainPID.y, limiter.u); connect(limiter.y, addSat.u1); connect(limiter.y, y); connect(addSat.y, gainTrack.u); connect(gainTrack.y, addI.u3); connect(u_m, addP.u2); connect(u_m, addD.u2); connect(u_m, addI.u2); connect(Dzero.y, addPID.u2); connect(Izero.y, addPID.u3); connect(trigger, I.trigger); connect(intRes.y, I.y_reset_in); end LimPID;

Buildings.Controls.OBC.CDL.Continuous.Limiter Buildings.Controls.OBC.CDL.Continuous.Limiter

Limit the range of a signal

Buildings.Controls.OBC.CDL.Continuous.Limiter

Information

Block that outputs y = min(uMax, max(uMin, u)), where u is an input and uMax and uMin are parameters.

If uMax < uMin, an error occurs and no output is produced.

Parameters

TypeNameDefaultDescription
RealuMax Upper limit of input signal
RealuMin Lower limit of input signal

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Limiter "Limit the range of a signal" parameter Real uMax "Upper limit of input signal"; parameter Real uMin "Lower limit of input signal"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; initial equation assert(uMin < uMax, "uMin must be smaller than uMax. Check parameters."); equation y = homotopy(actual=smooth(0, noEvent(if u > uMax then uMax else if u < uMin then uMin else u)), simplified=u); end Limiter;

Buildings.Controls.OBC.CDL.Continuous.Line Buildings.Controls.OBC.CDL.Continuous.Line

Output the value of the input x along a line specified by two points

Buildings.Controls.OBC.CDL.Continuous.Line

Information

Block that outputs y = a + b u, where u is an input and the coefficients a and b are determined so that the line intercepts the two input points specified by the two points x1 and f1, and x2 and f2.

The parameters limitBelow and limitAbove determine whether x1 and x2 are also used to limit the input u.

Parameters

TypeNameDefaultDescription
BooleanlimitBelowtrueIf true, limit input u to be no smaller than x1
BooleanlimitAbovetrueIf true, limit input u to be no larger than x2

Connectors

TypeNameDescription
input RealInputx1Support point x1
input RealInputf1Support point f(x1)
input RealInputx2Support point x2
input RealInputf2Support point f(x2)
input RealInputuIndependent variable
output RealOutputyf(x) along the line specified by (x1, f1) and (x2, f2)

Modelica definition

block Line "Output the value of the input x along a line specified by two points" parameter Boolean limitBelow=true "If true, limit input u to be no smaller than x1"; parameter Boolean limitAbove=true "If true, limit input u to be no larger than x2"; Interfaces.RealInput x1 "Support point x1"; Interfaces.RealInput f1 "Support point f(x1)"; Interfaces.RealInput x2 "Support point x2"; Interfaces.RealInput f2 "Support point f(x2)"; Interfaces.RealInput u "Independent variable"; Interfaces.RealOutput y "f(x) along the line specified by (x1, f1) and (x2, f2)"; protected Real a "Intercept"; Real b "Slope"; Real xLim "Input value after applying the limits"; equation b = (f2 - f1)/(x2 - x1); a = f2 - b*x2; if limitBelow and limitAbove then xLim = min(x2, max(x1, u)); elseif limitBelow then xLim = max(x1, u); elseif limitAbove then xLim = min(x2, u); else xLim = u; end if; y = a + b*xLim; end Line;

Buildings.Controls.OBC.CDL.Continuous.Log Buildings.Controls.OBC.CDL.Continuous.Log

Output the natural (base e) logarithm of the input (input > 0 required)

Buildings.Controls.OBC.CDL.Continuous.Log

Information

Block that outputs y = log(u), where u is an input and log() is the natural logarithm (base-e) function.

An error occurs if the input u is zero or negative.

log.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Log "Output the natural (base e) logarithm of the input (input > 0 required)" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.log(u); end Log;

Buildings.Controls.OBC.CDL.Continuous.Log10 Buildings.Controls.OBC.CDL.Continuous.Log10

Output the base 10 logarithm of the input (input > 0 required)

Buildings.Controls.OBC.CDL.Continuous.Log10

Information

Block that outputs y = log10(u), where u is an input and log10() is the logarithm (base-10) function.

An error occurs if the input u is zero or negative.

log10.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Log10 "Output the base 10 logarithm of the input (input > 0 required)" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.log10(u); end Log10;

Buildings.Controls.OBC.CDL.Continuous.Max Buildings.Controls.OBC.CDL.Continuous.Max

Pass through the largest signal

Buildings.Controls.OBC.CDL.Continuous.Max

Information

Block that outputs y = max(u1, u2), where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Max "Pass through the largest signal" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = max(u1, u2); end Max;

Buildings.Controls.OBC.CDL.Continuous.Min Buildings.Controls.OBC.CDL.Continuous.Min

Pass through the smallest signal

Buildings.Controls.OBC.CDL.Continuous.Min

Information

Block that outputs y = min(u1, u2), where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Min "Pass through the smallest signal" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = min(u1, u2); end Min;

Buildings.Controls.OBC.CDL.Continuous.Modulo Buildings.Controls.OBC.CDL.Continuous.Modulo

Output the remainder of first input divided by second input (~=0)

Buildings.Controls.OBC.CDL.Continuous.Modulo

Information

Block that outputs y = mod(u1/u2), where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Modulo "Output the remainder of first input divided by second input (~=0)" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = mod(u1, u2); end Modulo;

Buildings.Controls.OBC.CDL.Continuous.MovingMean Buildings.Controls.OBC.CDL.Continuous.MovingMean

Block to output moving average

Buildings.Controls.OBC.CDL.Continuous.MovingMean

Information

This block outputs the mean value of its input signal as

      1  t
y =   -  ∫   u(s) ds
      δ  t-δ

where δ is a parameter that determines the time window over which the input is averaged. For t < δ seconds, it outputs

           1      t
y =   --------    ∫   u(s) ds
      t-t0+10-10   t0

where t0 is the initial time.

This block can for example be used to output the moving average of a noisy measurement signal.

See Buildings.Controls.OBC.CDL.Continuous.Validation.MovingMean and Buildings.Controls.OBC.CDL.Continuous.Validation.MovingMean_nonZeroStart for example.

Parameters

TypeNameDefaultDescription
Timedelta Time horizon over which the input is averaged [s]

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block MovingMean "Block to output moving average" parameter Modelica.SIunits.Time delta(min=1E-5) "Time horizon over which the input is averaged"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; protected parameter Modelica.SIunits.Time tStart(fixed=false) "Start time"; Real mu "Internal integrator variable"; Real muDel "Internal integrator variable with delay"; Boolean mode(start=false, fixed=true) "Calculation mode"; initial equation tStart = time; mu = 0; equation u = der(mu); muDel = delay(mu, delta); // Compute the mode so that Dymola generates // time and not state events as it would with // an if-then construct when time >= tStart + delta then mode = true; end when; if mode then y = (mu - muDel)/delta; else y = (mu - muDel)/(time - tStart + 1E-3); end if; end MovingMean;

Buildings.Controls.OBC.CDL.Continuous.MultiMax Buildings.Controls.OBC.CDL.Continuous.MultiMax

Output the maximum element of the input vector

Buildings.Controls.OBC.CDL.Continuous.MultiMax

Information

Outputs the maximum element of the input vector.

Connectors

TypeNameDescription
input RealInputu[nin] 
output RealOutputyMax 

Modelica definition

block MultiMax "Output the maximum element of the input vector" parameter Integer nin(min=0) = 0 "Number of input connections"; Interfaces.RealInput u[nin]; Interfaces.RealOutput yMax; equation yMax = max(u); end MultiMax;

Buildings.Controls.OBC.CDL.Continuous.MultiMin Buildings.Controls.OBC.CDL.Continuous.MultiMin

Output the minimum element of the input vector

Buildings.Controls.OBC.CDL.Continuous.MultiMin

Information

Outputs the minimum element of the input vector.

Connectors

TypeNameDescription
input RealInputu[nin] 
output RealOutputyMin 

Modelica definition

block MultiMin "Output the minimum element of the input vector" parameter Integer nin(min=0) = 0 "Number of input connections"; Interfaces.RealInput u[nin]; Interfaces.RealOutput yMin; equation yMin = min(u); end MultiMin;

Buildings.Controls.OBC.CDL.Continuous.MultiSum Buildings.Controls.OBC.CDL.Continuous.MultiSum

Sum of Reals, y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]

Buildings.Controls.OBC.CDL.Continuous.MultiSum

Information

Block that outputs

y = ∑i=1n ki   ui,

where k is a parameter with n elements and u is an input of the same length. The dimension of u can be enlarged by drawing an additional connection line. The connection is automatically connected to this new free index.

If no connection to the input connector u is present, the output is y=0.

See Buildings.Controls.OBC.CDL.Continuous.Validation.MultiSum for an example.

Parameters

TypeNameDefaultDescription
Realk[nin]fill(1, nin)Input gains

Connectors

TypeNameDescription
input RealInputu[nin]Connector of Real input signals
output RealOutputyConnector of Real output signal

Modelica definition

block MultiSum "Sum of Reals, y = k[1]*u[1] + k[2]*u[2] + ... + k[n]*u[n]" parameter Integer nin(min=0) = 0 "Number of input connections"; parameter Real k[nin]=fill(1, nin) "Input gains"; Interfaces.RealInput u[nin] "Connector of Real input signals"; Interfaces.RealOutput y "Connector of Real output signal"; equation if size(u, 1) > 0 then y = k*u; else y = 0; end if; end MultiSum;

Buildings.Controls.OBC.CDL.Continuous.NumberOfRequests Buildings.Controls.OBC.CDL.Continuous.NumberOfRequests

Outputs the number of signals that are above/below a certain threshold

Buildings.Controls.OBC.CDL.Continuous.NumberOfRequests

Information

Block that outputs the number of inputs that exceed a threshold. The parameter kind is used to determine the kind of the inequality. The table below shows the allowed settings.

Value of parameter kind Output signal incremented by 1 for each i ∈ {1, ..., nin} if
0 u[i] > threShold
1 u[i] ≥ threShold
2 u[i] ≤ threShold
3 u[i] < threShold

This model may be used to check how many rooms exceed a temperature threshold.

Parameters

TypeNameDefaultDescription
Integernin Number of inputs
RealthreShold0Threshold
Integerkind Set to 0 for u>threShold, to 1 for >=, to 2 for <= or to 3 for <

Connectors

TypeNameDescription
output IntegerOutputyNumber of input signals that violate the threshold
input RealInputu[nin]Input signals

Modelica definition

block NumberOfRequests "Outputs the number of signals that are above/below a certain threshold" parameter Integer nin "Number of inputs"; parameter Real threShold=0 "Threshold"; parameter Integer kind "Set to 0 for u>threShold, to 1 for >=, to 2 for <= or to 3 for <"; Interfaces.IntegerOutput y "Number of input signals that violate the threshold"; Interfaces.RealInput u[nin] "Input signals"; algorithm y := 0; for i in 1:nin loop if kind == 0 then if u[i] > threShold then y := y + 1; end if; end if; if kind == 1 then if u[i] >= threShold then y := y + 1; end if; end if; if kind == 2 then if u[i] <= threShold then y := y + 1; end if; end if; if kind == 3 then if u[i] < threShold then y := y + 1; end if; end if; end for; end NumberOfRequests;

Buildings.Controls.OBC.CDL.Continuous.Product Buildings.Controls.OBC.CDL.Continuous.Product

Output product of the two inputs

Buildings.Controls.OBC.CDL.Continuous.Product

Information

Block that outputs y = u1 * u2, where u1 and u2 are inputs.

Connectors

TypeNameDescription
input RealInputu1Connector of Real input signal 1
input RealInputu2Connector of Real input signal 2
output RealOutputyConnector of Real output signal

Modelica definition

block Product "Output product of the two inputs" Interfaces.RealInput u1 "Connector of Real input signal 1"; Interfaces.RealInput u2 "Connector of Real input signal 2"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = u1*u2; end Product;

Buildings.Controls.OBC.CDL.Continuous.Round Buildings.Controls.OBC.CDL.Continuous.Round

Round real number to given digits

Buildings.Controls.OBC.CDL.Continuous.Round

Information

Block that outputs the input after rounding it to n digits.

For example,

Hence, the block outputs

    y = floor(u*(10^n) + 0.5)/(10^n)  for  u > 0,
    y = ceil(u*(10^n) - 0.5)/(10^n)   for  u < 0.

Parameters

TypeNameDefaultDescription
Integern Number of digits being round to

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Round "Round real number to given digits" parameter Integer n "Number of digits being round to"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; protected parameter Real fac=10^n "Factor used for rounding"; equation y = if (u > 0) then floor(u*fac + 0.5)/fac else ceil(u*fac - 0.5)/fac; end Round;

Buildings.Controls.OBC.CDL.Continuous.Sin Buildings.Controls.OBC.CDL.Continuous.Sin

Output the sine of the input

Buildings.Controls.OBC.CDL.Continuous.Sin

Information

Block that outputs y = sin(u), where u is an input.

sin.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Sin "Output the sine of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.sin(u); end Sin;

Buildings.Controls.OBC.CDL.Continuous.SlewRateLimiter Buildings.Controls.OBC.CDL.Continuous.SlewRateLimiter

Limit the increase or decrease rate of input

Buildings.Controls.OBC.CDL.Continuous.SlewRateLimiter

Information

The block limits the rate of change of the input by a ramp. This block computes a threshold for the rate of change between input u and output y as thr = (u-y)/Td, where Td > 0 is parameter. The output y is computed as follows:
If thr < fallingSlewRate, then dy/dt = fallingSlewRate,
if thr > raisingSlewRate, then dy/dt = raisingSlewRate,
otherwise, dy/dt = thr.

Implementation

For the block to work with arbitrary inputs and in order to produce a differential output, the input is numerically differentiated with derivative time constant Td. Smaller time constant Td means nearer ideal derivative.

Parameters

TypeNameDefaultDescription
RealraisingSlewRate Speed with which to increase the output [1/s]
RealfallingSlewRate-raisingSlewRateSpeed with which to decrease the output [1/s]
TimeTdraisingSlewRate*10Derivative time constant [s]
BooleanenabletrueSet to false to disable rate limiter

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block SlewRateLimiter "Limit the increase or decrease rate of input" parameter Real raisingSlewRate(min=Constants.small, final unit="1/s") "Speed with which to increase the output"; parameter Real fallingSlewRate( max=-Constants.small, final unit="1/s") = -raisingSlewRate "Speed with which to decrease the output"; parameter Modelica.SIunits.Time Td(min=Constants.eps) = raisingSlewRate*10 "Derivative time constant"; parameter Boolean enable=true "Set to false to disable rate limiter"; Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; protected Real thr=(u - y)/Td "Approximation to derivative between input and output"; initial equation y = u; equation if enable then der(y) = smooth(1, noEvent(if thr < fallingSlewRate then fallingSlewRate else if thr > raisingSlewRate then raisingSlewRate else thr)); else y = u; end if; end SlewRateLimiter;

Buildings.Controls.OBC.CDL.Continuous.Sort Buildings.Controls.OBC.CDL.Continuous.Sort

Sort elements of input vector in ascending or descending order

Buildings.Controls.OBC.CDL.Continuous.Sort

Information

Block that sorts the elements of the input signal u. If the parameter ascending = true, then the output signal satisfies yi <= yi+1 for all i ∈ {1, ..., n-1}. Otherwise, it satisfies yi >= yi+1 for all i ∈ {1, ..., n-1}.

This block may for example be used in a variable air volume flow controller to access the position of the dampers that are most open.

Parameters

TypeNameDefaultDescription
Booleanascendingtrue= true if ascending order, otherwise descending order

Connectors

TypeNameDescription
input RealInputu[nin]Connector of Real input signals
output RealOutputy[nin]Connector of Real output signals

Modelica definition

block Sort "Sort elements of input vector in ascending or descending order" parameter Integer nin(min=0) = 0 "Number of input connections"; parameter Boolean ascending=true "= true if ascending order, otherwise descending order"; Interfaces.RealInput u[nin] "Connector of Real input signals"; Interfaces.RealOutput y[nin] "Connector of Real output signals"; equation y = Modelica.Math.Vectors.sort(u, ascending=ascending); end Sort;

Buildings.Controls.OBC.CDL.Continuous.Sqrt Buildings.Controls.OBC.CDL.Continuous.Sqrt

Output the square root of the input (input >= 0 required)

Buildings.Controls.OBC.CDL.Continuous.Sqrt

Information

Block that outputs square root of the input y = sqrt(u), where u is an input. All elements of the input vector shall be non-negative.

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Sqrt "Output the square root of the input (input >= 0 required)" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = sqrt(u); end Sqrt;

Buildings.Controls.OBC.CDL.Continuous.Tan Buildings.Controls.OBC.CDL.Continuous.Tan

Output the tangent of the input

Buildings.Controls.OBC.CDL.Continuous.Tan

Information

Block that outputs y = tan(u), where u is an input.

tan.png

Connectors

TypeNameDescription
input RealInputuConnector of Real input signal
output RealOutputyConnector of Real output signal

Modelica definition

block Tan "Output the tangent of the input" Interfaces.RealInput u "Connector of Real input signal"; Interfaces.RealOutput y "Connector of Real output signal"; equation y = Modelica.Math.tan(u); end Tan;