diff --git a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/FirstOrderAMIGO.mo b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/FirstOrderAMIGO.mo index 1345d4bbc09..9cf8136dc42 100644 --- a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/FirstOrderAMIGO.mo +++ b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/FirstOrderAMIGO.mo @@ -116,7 +116,8 @@ block FirstOrderAMIGO conProMod( final yHig=yHig - yRef, final yLow=yRef + yLow, - final deaBan=deaBan) + final deaBan=deaBan, + final reverseActing=reverseActing) "Calculates the parameters of a first-order time delayed model" annotation (Placement(transformation(extent={{40,30},{60,50}}))); Buildings.Controls.OBC.CDL.Logical.Latch inTunPro @@ -179,8 +180,8 @@ equation {30,44},{22,44}},color={0,0,127})); connect(resPro.tOn, conProMod.tOn) annotation (Line(points={{22,48},{32,48},{32, 44},{38,44}},color={0,0,127})); - connect(rel.yErr, conProMod.u) annotation (Line(points={{-18,40},{-12,40},{-12, - 60},{34,60},{34,48},{38,48}},color={0,0,127})); + connect(rel.yDiff, conProMod.u) annotation (Line(points={{-18,40},{-12,40},{-12, + 60},{34,60},{34,48},{38,48}}, color={0,0,127})); connect(PIDPar.kp, conProMod.k) annotation (Line(points={{78,46},{62,46}}, color={0,0,127})); connect(PIDPar.T, conProMod.T) annotation (Line(points={{78,40},{62,40}}, color={0,0,127})); connect(PIDPar.L, conProMod.L) annotation (Line(points={{78,34},{62,34}}, color={0,0,127})); diff --git a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Controller.mo b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Controller.mo index b5ae105e3f5..20946ace0d4 100644 --- a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Controller.mo +++ b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Controller.mo @@ -32,10 +32,9 @@ block Controller Buildings.Controls.OBC.CDL.Interfaces.BooleanOutput yOn "Relay switch output, true when control output switches to the higher value" annotation (Placement(transformation(extent={{100,-80},{140,-40}}))); - Buildings.Controls.OBC.CDL.Interfaces.RealOutput yErr - "Control error" + Buildings.Controls.OBC.CDL.Interfaces.RealOutput yDiff "Input difference" annotation (Placement(transformation(extent={{100,-10},{140,30}}), - iconTransformation(extent={{100,-20},{140,20}}))); + iconTransformation(extent={{100,-20},{140,20}}))); protected Buildings.Controls.OBC.CDL.Reals.Switch swi @@ -49,24 +48,21 @@ protected final k=-yLow) "Lower value for the output" annotation (Placement(transformation(extent={{-80,20},{-60,40}}))); - Buildings.Controls.OBC.CDL.Reals.Subtract conErr - "Control error (set point - measurement)" - annotation (Placement(transformation(extent={{40,0},{60,20}}))); Buildings.Controls.OBC.CDL.Reals.Switch swi1 "Switch between a higher value and a lower value" annotation (Placement(transformation(extent={{-10,-10},{10,10}}, origin={-50,-60}))); Buildings.Controls.OBC.CDL.Reals.Subtract sub - if reverseActing "Inputs difference" + if reverseActing "Inputs difference for reverse acting" annotation (Placement(transformation(extent={{0,-50},{20,-30}}))); Buildings.Controls.OBC.CDL.Reals.Hysteresis hys( - final uLow=-deaBa, - final uHigh=deaBa, + final uLow=-deaBan, + final uHigh=deaBan, final pre_y_start=true) - "Check if the measured value is larger than the reference, by default the relay control is on" + "Check if the input difference exceeds the thresholds, by default the relay control is on" annotation (Placement(transformation(extent={{40,-60},{60,-40}}))); Buildings.Controls.OBC.CDL.Reals.Subtract sub1 - if not reverseActing "Inputs difference" + if not reverseActing "Inputs difference for direct acting" annotation (Placement(transformation(extent={{0,-80},{20,-60}}))); Buildings.Controls.OBC.CDL.Reals.Greater gre "Check if the higher value is greater than the lower value" @@ -85,39 +81,25 @@ equation connect(higVal.y, swi.u1) annotation (Line(points={{-58,80},{-20,80},{-20,58},{58,58}},color={0,0,127})); connect(lowVal.y, swi.u3) annotation (Line(points={{-58,30},{-20,30},{-20,42}, - {58,42}}, - color={0,0,127})); - connect(conErr.y, yErr) annotation (Line(points={{62,10},{120,10}}, - color={0,0,127})); + {58,42}},color={0,0,127})); connect(swi1.u3, u_s) annotation (Line(points={{-62,-68},{-90,-68},{-90,0},{ - -120,0}}, - color={0,0,127})); + -120,0}},color={0,0,127})); connect(trigger, swi1.u2) annotation (Line(points={{-80,-120},{-80,-60},{-62, - -60}}, - color={255,0,255})); + -60}},color={255,0,255})); connect(u_m, swi1.u1) annotation (Line(points={{0,-120},{0,-90},{-70,-90},{ - -70,-52},{-62,-52}}, - color={0,0,127})); - connect(swi1.y, conErr.u1) annotation (Line(points={{-38,-60},{-20,-60},{-20, - 16},{38,16}}, color={0,0,127})); - connect(conErr.u2, u_s) annotation (Line(points={{38,4},{-42,4},{-42,0},{ - -120,0}}, - color={0,0,127})); + -70,-52},{-62,-52}},color={0,0,127})); connect(sub1.y, hys.u) annotation (Line(points={{22,-70},{30,-70},{30,-50},{ - 38,-50}}, - color={0,0,127})); + 38,-50}},color={0,0,127})); connect(sub.y, hys.u) annotation (Line(points={{22,-40},{30,-40},{30,-50},{38, -50}}, color={0,0,127})); connect(u_s, sub.u1) annotation (Line(points={{-120,0},{-90,0},{-90,-34},{-2, - -34}}, - color={0,0,127})); + -34}},color={0,0,127})); connect(u_s, sub1.u2) annotation (Line(points={{-120,0},{-90,0},{-90,-76},{-2, -76}}, color={0,0,127})); connect(swi1.y, sub.u2) annotation (Line(points={{-38,-60},{-20,-60},{-20,-46}, {-2,-46}}, color={0,0,127})); connect(swi1.y, sub1.u1) annotation (Line(points={{-38,-60},{-20,-60},{-20, - -64},{-2,-64}}, - color={0,0,127})); + -64},{-2,-64}},color={0,0,127})); connect(hys.y, swi.u2) annotation (Line(points={{62,-50},{80,-50},{80,30},{50, 30},{50,50},{58,50}}, color={255,0,255})); connect(gre.y, assMes.u) @@ -129,9 +111,12 @@ equation connect(higVal.y, gre.u1) annotation (Line(points={{-58,80},{-2,80}}, color={0,0,127})); connect(hys.y, yOn) annotation (Line(points={{62,-50},{80,-50},{80,-60},{120, - -60}}, - color={255,0,255})); - annotation (defaultComponentName = "relCon", + -60}},color={255,0,255})); + connect(yDiff, sub.y) annotation (Line(points={{120,10},{36,10},{36,-40},{22, + -40}}, color={0,0,127})); + connect(sub1.y, yDiff) annotation (Line(points={{22,-70},{36,-70},{36,10},{ + 120,10}}, color={0,0,127})); + annotation (defaultComponentName = "relCon", Icon(coordinateSystem(preserveAspectRatio=false), graphics={ Rectangle( extent={{-100,-100},{100,100}}, @@ -164,21 +149,22 @@ equation fillPattern=FillPattern.Solid, fillColor={175,175,175}, textString="Relay"), - Line(points={{-70,24},{-34,24},{-34,58},{38,58},{38,24},{66,24}}, color - ={28,108,200})}), Diagram( + Line(points={{-70,24},{-34,24},{-34,58},{38,58},{38,24},{66,24}}, color= + {28,108,200})}), Diagram( coordinateSystem(preserveAspectRatio=false)), Documentation(info="
This block generates a real control output y
, a
-boolean relay switch output yOn
, and the control error
-yErr
. They are calculated as below:
+boolean relay switch output yOn
,
+and an input difference yDiff
.
+They are calculated as below:
reverseActing = false
+if the parameter reverseActing = true
yErr = u_m - u_s
,
+yDiff = u_s - u_m
,
reverseActing = false
else
yErr = u_s - u_m
,
+yDiff = u_m - u_s
,
yErr < -deaBan
and trigger
is true
,
+if yDiff > deaBan
and trigger
is true
,
then y = yHig
, yOn = true
,
yErr > deaBan
and trigger
is true
,
+else if yDiff < -deaBan
and trigger
is true
,
then y = -yLow
,
yOn = false
,
Iy is calculated by
-Iy = ∫ u(t) dt;
-where u is the process output.
+Iy = ∫ -u(t) dt;
+where u is the input difference of a relay controller, see details in +Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Controller +
Iu is calculated by
Iu = ton (yhig - yref)+ toff(-ylow - yref), diff --git a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/BaseClasses/Validation/Gain.mo b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/BaseClasses/Validation/Gain.mo index d4251ecb888..fff0e1f3aed 100644 --- a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/BaseClasses/Validation/Gain.mo +++ b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/BaseClasses/Validation/Gain.mo @@ -1,7 +1,7 @@ within Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimedelayed.BaseClasses.Validation; model Gain "Test model for identifying the gain of the control process" Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimedelayed.BaseClasses.Gain - gai + gai(reverseActing=false) "Block that calculates the gain of a first-order model" annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); Buildings.Controls.OBC.CDL.Reals.Sources.Pulse u( diff --git a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/ControlProcessModel.mo b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/ControlProcessModel.mo index b4c1497b8ae..89667f4c95a 100644 --- a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/ControlProcessModel.mo +++ b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/ControlProcessModel.mo @@ -7,6 +7,8 @@ block ControlProcessModel "Lower value for the output"; parameter Real deaBan(min=0) = 0.5 "Deadband for holding the output value"; + parameter Boolean reverseActing=true + "Set to true for reverse acting, or false for direct acting control action"; Buildings.Controls.OBC.CDL.Interfaces.RealInput tOn( final quantity="Time", final unit="s", @@ -74,7 +76,8 @@ protected annotation (Placement(transformation(extent={{12,-30},{32,-10}}))); Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimedelayed.BaseClasses.Gain gain( final yHig=yHig, - final yLow=yLow) + final yLow=yLow, + final reverseActing = reverseActing) "Block that calculates the gain" annotation (Placement(transformation(extent={{-84,10},{-64,30}}))); Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimedelayed.BaseClasses.TimeConstantDelay diff --git a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/Validation/ControlProcessModel.mo b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/Validation/ControlProcessModel.mo index 08a1f4072b8..420c309fca4 100644 --- a/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/Validation/ControlProcessModel.mo +++ b/Buildings/Controls/OBC/Utilities/PIDWithAutotuning/SystemIdentification/FirstOrderTimedelayed/Validation/ControlProcessModel.mo @@ -2,7 +2,8 @@ within Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.F model ControlProcessModel "Test model for identifying the reduced-order model of the control process" Buildings.Controls.OBC.Utilities.PIDWithAutotuning.SystemIdentification.FirstOrderTimedelayed.ControlProcessModel - conProMod(yLow=0.1, deaBan=0.05) + conProMod(yLow=0.1, deaBan=0.05, + reverseActing=false) "Calculate the parameters of a first-order model" annotation (Placement(transformation(extent={{-10,-10},{10,10}}))); Buildings.Controls.OBC.CDL.Reals.Sources.Pulse u( diff --git a/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Validation/Controller.mos b/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Validation/Controller.mos index ec5423133e8..b40e52e278a 100644 --- a/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Validation/Controller.mos +++ b/Buildings/Resources/Scripts/Dymola/Controls/OBC/Utilities/PIDWithAutotuning/Relay/Validation/Controller.mos @@ -4,4 +4,4 @@ plotExpression(apply(Controller[end].relCon.u_s-0.4), false, "controller[end].re plotExpression(apply(Controller[end].relCon.u_s+0.4), false, "controller[end].relCon.u_s+deaBan", 1); createPlot(id=1, position={15, 15, 1148, 620}, y={"enaSig.y"}, range={0.0, 1.0, -1.0, 2.0}, grid=true, subPlot=102, colors={{28,108,200}}); createPlot(id=1, position={15, 15, 1148, 620}, y={"relCon.y"}, range={0.0, 1.0, -2.0, 2.0}, grid=true, subPlot=103, colors={{28,108,200}}); -createPlot(id=1, position={15, 15, 1148, 620}, y={"relCon.yErr", "relCon.yOn"}, range={0.0, 1.0, -2.0, 2.0}, grid=true, subPlot=104, colors={{28,108,200}, {238,46,47}}); \ No newline at end of file +createPlot(id=1, position={15, 15, 1148, 620}, y={"relCon.yDiff", "relCon.yOn"}, range={0.0, 1.0, -2.0, 2.0}, grid=true, subPlot=104, colors={{28,108,200}, {238,46,47}}); \ No newline at end of file diff --git a/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Validation.Controller.mos b/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Validation.Controller.mos index 39f12c5b1e3..bf63a686995 100644 --- a/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Validation.Controller.mos +++ b/Buildings/Resources/Scripts/OpenModelica/compareVars/Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.Validation.Controller.mos @@ -3,6 +3,6 @@ compareVars := "relCon.u_m", "enaSig.y", "relCon.y", - "relCon.yErr", + "relCon.yDiff", "relCon.yOn" };