Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay

Package with blocks for a relay controller

Information

This package contains blocks related to a relay controller.

Package Content

Name Description
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Controller Controller Output relay signals for tuning PID controllers
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.ResponseProcess ResponseProcess Calculate the lengths of the on and off period, the half period ratio, and the times when the tuning starts and ends
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Validation Validation Collection of models that validate the blocks of a relay controller
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.BaseClasses BaseClasses Package with base classes

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Controller Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Controller

Output relay signals for tuning PID controllers

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Controller

Information

This block generates a relay output yDif = (u_m - u_s)/r, where u_m is the measurement, u_s is the setpoint and r is the typical range of control error.

This block also generates the control output y, and a boolean relay switch output yOn using the following procedure.

Step 1: Calculate control error,

Step 2: Calculate y and yOn,

where deaBan is a dead band, yHig and yLow are the higher value and the lower value of the output y, respectively.

References

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

Parameters

TypeNameDefaultDescription
Realr1Typical range of control error, used for scaling the control error
RealyHig Higher value for the relay output
RealyLow Lower value for the relay output
RealdeaBan Deadband for holding the relay output
BooleanreverseActingtrueSet to true for reverse acting, or false for direct acting control action

Connectors

TypeNameDescription
input RealInputu_sSetpoint input signal
input RealInputu_mMeasurement input signal
input BooleanInputtriggerConnector for enabling the relay controller
output RealOutputyControl output
output BooleanOutputyOnRelay switch output, true when control output switches to the higher value
output RealOutputyDifInput difference, measurement - setpoint

Modelica definition

block Controller "Output relay signals for tuning PID controllers" parameter Real r(min=100*Buildings.Controls.OBC.CDL.Constants.eps) = 1 "Typical range of control error, used for scaling the control error"; parameter Real yHig( final min=1E-6) "Higher value for the relay output"; parameter Real yLow( final min=1E-6, final max=yHig) "Lower value for the relay output"; parameter Real deaBan(min=1E-6) "Deadband for holding the relay output"; parameter Boolean reverseActing=true "Set to true for reverse acting, or false for direct acting control action"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u_s "Setpoint input signal"; Buildings.Controls.OBC.CDL.Interfaces.RealInput u_m "Measurement input signal"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput trigger "Connector for enabling the relay controller"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput y "Control output"; Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput yOn "Relay switch output, true when control output switches to the higher value"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput yDif "Input difference, measurement - setpoint"; protected Buildings.Controls.OBC.CDL.Reals.Switch swi "Switch between a higher value and a lower value"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant higVal( final k=yHig) "Higher value for the output"; Buildings.Controls.OBC.CDL.Reals.Sources.Constant lowVal( final k=yLow) "Lower value for the output"; Buildings.Controls.OBC.CDL.Reals.Switch swi1 "Switch between a higher value and a lower value"; Buildings.Controls.OBC.CDL.Reals.Subtract revActErr if reverseActing "Control error when reverse acting, setpoint - measurement"; Buildings.Controls.OBC.CDL.Reals.Hysteresis hys( final uLow=-deaBan, final uHigh=deaBan, final pre_y_start=true) "Check if the input difference exceeds the thresholds, by default the relay control is on"; Buildings.Controls.OBC.CDL.Reals.Subtract dirActErr if not reverseActing "Control error when direct acting, measurement - setpoint"; Buildings.Controls.OBC.CDL.Reals.Subtract meaSetDif "Inputs difference, (measurement - setpoint)"; Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gaiYDif( final k=1/r) "Gain to normalized control error by r"; Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gaiRevActErr( final k=1/r) if reverseActing "Gain to normalized control error by r"; Buildings.Controls.OBC.CDL.Reals.MultiplyByParameter gaiDirActErr( final k=1/r) if not reverseActing "Gain to normalized control error by r"; equation connect(swi.y, y); connect(higVal.y, swi.u1); connect(lowVal.y, swi.u3); connect(swi1.u3, u_s); connect(trigger, swi1.u2); connect(u_m, swi1.u1); connect(u_s, revActErr.u1); connect(u_s, dirActErr.u2); connect(swi1.y, revActErr.u2); connect(swi1.y, dirActErr.u1); connect(hys.y, swi.u2); connect(hys.y, yOn); connect(swi1.y, meaSetDif.u1); connect(u_s, meaSetDif.u2); connect(meaSetDif.y, gaiYDif.u); connect(gaiYDif.y, yDif); connect(revActErr.y, gaiRevActErr.u); connect(gaiRevActErr.y, hys.u); connect(dirActErr.y, gaiDirActErr.u); connect(gaiDirActErr.y, hys.u); end Controller;

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.ResponseProcess Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.ResponseProcess

Calculate the lengths of the on and off period, the half period ratio, and the times when the tuning starts and ends

Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.ResponseProcess

Information

This block processes a relay switch output signal and calculates

  1. the length of the on period,
  2. the length of the off period,
  3. the normalized time delay of the responses, and
  4. the flags which indicate if the tuning starts and completes.

For more details, please refer to:

Parameters

TypeNameDefaultDescription
RealyHig Higher value for the output
RealyLow Lower value for the output

Connectors

TypeNameDescription
input BooleanInputonRelay switch. True: tuning on perid, False: tuning off period
input RealInputtimSimulation time [s]
input BooleanInputtriggerReset the output when trigger becomes true
input BooleanInputinTunCheck if a tuning is ongoing
output RealOutputtOnLength of the on period [s]
output RealOutputtOffLength of the off period [s]
output BooleanOutputtriStaTrue: the tuning starts
output BooleanOutputtriEndTrue: the tuning ends
output RealOutputtauNormalized time delay

Modelica definition

block ResponseProcess "Calculate the lengths of the on and off period, the half period ratio, and the times when the tuning starts and ends" parameter Real yHig(min=1E-6) "Higher value for the output"; parameter Real yLow(min=1E-6) "Lower value for the output"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput on "Relay switch. True: tuning on perid, False: tuning off period"; Buildings.Controls.OBC.CDL.Interfaces.RealInput tim( final quantity="Time", final unit="s") "Simulation time"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput trigger "Reset the output when trigger becomes true"; Buildings.Controls.OBC.CDL.Interfaces.BooleanInput inTun "Check if a tuning is ongoing"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput tOn( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Length of the on period"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput tOff( final quantity="Time", final unit="s", min=100*Buildings.Controls.OBC.CDL.Constants.eps) "Length of the off period"; Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput triSta "True: the tuning starts"; Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput triEnd "True: the tuning ends"; Buildings.Controls.OBC.CDL.Interfaces.RealOutput tau "Normalized time delay"; protected Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.BaseClasses.OnOffPeriod onOffPer "Block that calculates the length of the on period and the off period"; Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.BaseClasses.HalfPeriodRatio halPerRatio "Block that calculates the half period ratio"; Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.BaseClasses.NormalizedTimeDelay norTimDel( final gamma=max(yHig, yLow)/min(yLow, yHig)) "Block that calculates the normalized time delay"; Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.BaseClasses.TuningMonitor tunMon "Block that detects when the tuning period starts and ends"; equation connect(onOffPer.on,on); connect(onOffPer.tim, tim); connect(onOffPer.tOn, halPerRatio.tOn); connect(onOffPer.tOff, halPerRatio.tOff); connect(halPerRatio.rho, norTimDel.rho); connect(tOn, halPerRatio.tOn); connect(tOff, halPerRatio.tOff); connect(norTimDel.tau, tau); connect(tunMon.triSta, triSta); connect(tunMon.triEnd, triEnd); connect(tunMon.tOn, onOffPer.tOn); connect(tunMon.tOff, onOffPer.tOff); connect(halPerRatio.TunEnd, tunMon.triEnd); connect(onOffPer.trigger, trigger); connect(norTimDel.inTun, inTun); end ResponseProcess;