Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses

Package with base classes

Information

This package contains base classes to construct blocks in Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.

Package Content

Name Description
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.Gain Gain Identify the gain of a first-order plus time-delay model
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.TimeConstantDelay TimeConstantDelay Calculate the time constant and the time delay of a first-order plus time-delay model
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.Validation Validation Collection of validation models

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.Gain Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.Gain

Identify the gain of a first-order plus time-delay model

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.Gain

Information

This block calculates the gain of a first-order plus time-delay model.

k = Iy/Iu,

Iy is calculated by

Iy = ∫ u(t) dt;

where u(t) is the relay output at t (see details in Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Controller).

Iu is calculated by

Iu = ton yhig - toffylow,

where yhig and ylow are constants related to an asymmetric relay output. ton and toff are the length of the on period and the off period of the same asymmetric relay output, respectively.

References

J. Berner (2017). "Automatic Controller Tuning using Relay-based Model Identification." Department of Automatic Control, Lund University.

Parameters

TypeNameDefaultDescription
RealyHig Higher value for the output (assuming the reference output is 0)
RealyLow Lower value for the output (assuming the reference output is 0)

Connectors

TypeNameDescription
input RealInputuRelay controller output, (measurement - setpoint)
input RealInputtOnLength for the on period [s]
input RealInputtOffLength for the off period [s]
input BooleanInputtriStaRelay tuning status, true if the tuning starts
output RealOutputkGain

Modelica definition

block Gain "Identify the gain of a first-order plus time-delay model" parameter Real yHig(min=1E-6) "Higher value for the output (assuming the reference output is 0)"; parameter Real yLow(min=1E-6) "Lower value for the output (assuming the reference output is 0)"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u "Relay controller output, (measurement - setpoint)"; Buildings.Controls.OBC.CDL.Interfaces.RealInput tOn( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Length for the on period"; Buildings.Controls.OBC.CDL.Interfaces.RealInput tOff( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Length for the off period"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput triSta "Relay tuning status, true if the tuning starts"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput k "Gain"; protected Buildings.Controls.OBC.CDL.Reals.Add Iu "Integral of the relay output"; Buildings.Controls.OBC.CDL.Reals.IntegratorWithReset Iy( final k=1, final y_start=1E-3) "Integral of the process output"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant refRelOut( final k=0) "Reference value of the relay control output"; Buildings.Controls.OBC.CDL.Reals.Divide divIyIu "Calculate the gain"; Buildings.Controls.OBC.CDL.Reals.AddParameter addPar(final p=1E-3) "Block that avoids a divide-by-zero error"; Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gaiOnyHig( final k=yHig) "Product of tOn and yHig"; Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gaiOffyLow( final k=-yLow) "Product of tOff and yLow"; equation connect(refRelOut.y, Iy.y_reset_in); connect(Iy.trigger, triSta); connect(divIyIu.u1, Iy.y); connect(Iu.y, addPar.u); connect(addPar.y, divIyIu.u2); connect(gaiOnyHig.u, tOn); connect(gaiOnyHig.y, Iu.u1); connect(gaiOffyLow.u, tOff); connect(gaiOffyLow.y, Iu.u2); connect(divIyIu.y, k); connect(u, Iy.u); end Gain;

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.TimeConstantDelay Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.TimeConstantDelay

Calculate the time constant and the time delay of a first-order plus time-delay model

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimeDelay.BaseClasses.TimeConstantDelay

Information

This block calculates the time constant and the time delay of a first-order plus time-delay (FOPTD) model.

Main equations

The time constant, T, is calculated by

T = ton/(ln((δ/|k|-yhig+exp(τ/(1 - τ))(yhig + ylow))/(yhig-δ/|k|))),

where yhig and ylow are constants related to an asymmetric relay output. ton is the length of the on period of the same asymmetric relay output. δ is the dead band of the same asymmetric relay output. k is the gain of this FOPTD model. τ is the normalized time delay.

The time delay, L, is calculated by

L = T τ/(1 - τ),

References

J. Berner (2017). "Automatic Controller Tuning using Relay-based Model Identification." Department of Automatic Control, Lund University.

Parameters

TypeNameDefaultDescription
RealyHig Higher value for the output (assuming the reference output is 0)
RealyLow Lower value for the output (assuming the reference output is 0)
RealdeaBan Deadband for holding the output value

Connectors

TypeNameDescription
input RealInputtOnLength for the on period [s]
input RealInputkGain
input RealInputratRatio between the time constant and the time delay
output RealOutputTTime constant [s]
output RealOutputLTime delay [s]
output BooleanOutputtriFaiTrue when an error occurs in the autotuning process

Modelica definition

block TimeConstantDelay "Calculate the time constant and the time delay of a first-order plus time-delay model" parameter Real yHig(min=1E-6) "Higher value for the output (assuming the reference output is 0)"; parameter Real yLow(min=1E-6) "Lower value for the output (assuming the reference output is 0)"; parameter Real deaBan(min=1E-6) "Deadband for holding the output value"; Buildings.Controls.OBC.CDL.Interfaces.RealInput tOn( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Length for the on period"; Buildings.Controls.OBC.CDL.Interfaces.RealInput k "Gain"; Buildings.Controls.OBC.CDL.Interfaces.RealInput rat "Ratio between the time constant and the time delay"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput T( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Time constant"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput L( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Time delay"; Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput triFai "True when an error occurs in the autotuning process"; protected Buildings.Controls.OBC.CDL.Reals.Abs absk "Absoulte value of the gain"; Buildings.Controls.OBC.CDL.Reals.Exp exp "Exponential value of the ratio between time constant and the time delay"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant yHigSig( final k=yHig) "Higher value for the output"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant yLowSig( final k=yLow) "Lower value for the output"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant relDeaBan( final k=deaBan) "Dead band of the relay controller"; Buildings.Controls.OBC.CDL.Reals.Add add1 "Sum of the inputs"; Buildings.Controls.OBC.CDL.Reals.Add add2 "Sum of the higher value for the output and the lower value for the output"; Buildings.Controls.OBC.CDL.Reals.Divide div1 "Quotient of deadband divided by the absolute value of the gain"; Buildings.Controls.OBC.CDL.Reals.Divide div2 "Blocks that calculates input 1 by input 2"; Buildings.Controls.OBC.CDL.Reals.Divide div3 "Blocks that calculates the time constant"; Buildings.Controls.OBC.CDL.Reals.Multiply mul1 "Product of the two inputs"; Buildings.Controls.OBC.CDL.Reals.Multiply mul2 "Blocks that calculates time delay"; Buildings.Controls.OBC.CDL.Reals.Subtract sub1 "Blocks that calculates the difference of the two inputs"; Buildings.Controls.OBC.CDL.Reals.Subtract sub2 "Blocks that calculates the difference of the two inputs"; Buildings.Controls.OBC.CDL.Reals.Log log "Natural logarithm of the input"; Buildings.Controls.OBC.CDL.Reals.Greater gre1(final h=1e-6) "Check if the input is less than 0"; Buildings.Controls.OBC.CDL.Reals.Max max1 "Avoid a negative input for the log function"; Buildings.Controls.OBC.CDL.Logical.Edge edg "True when an negative input is given for the log function"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant con(final k=1e-6) "Constant"; Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gai(k=-1) "Opposite of the input"; equation connect(absk.u, k); connect(rat, exp.u); connect(relDeaBan.y, div1.u1); connect(sub2.u1, div1.y); connect(sub2.u2, yLowSig.y); connect(yHigSig.y, add2.u1); connect(add2.u2, yLowSig.y); connect(add2.y, mul1.u2); connect(exp.y, mul1.u1); connect(sub2.y, add1.u2); connect(add1.u1, mul1.y); connect(sub1.y, div2.u2); connect(div2.u1, add1.y); connect(tOn, div3.u1); connect(div3.y, T); connect(mul2.u2, T); connect(mul2.u1, exp.u); connect(mul2.y, L); connect(sub1.u2, div1.y); connect(absk.y, div1.u2); connect(yHigSig.y, sub1.u1); connect(log.y, div3.u2); connect(div2.y, max1.u1); connect(log.u, max1.y); connect(gre1.u2, div2.y); connect(con.y, max1.u2); connect(gre1.y, edg.u); connect(edg.y, triFai); connect(gre1.u1, gai.y); connect(gai.u, con.y); end TimeConstantDelay;