Skip to content

Commit

Permalink
Merge pull request #3184 from SenHuang19/issue2884_PID_autotuning
Browse files Browse the repository at this point in the history
Issue2884 pid autotuning update the doc and add more parameters
  • Loading branch information
JayHuLBL authored Mar 9, 2023
2 parents 6445f67 + abc55bd commit 0a205a7
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,57 @@ block FirstOrderAMIGO
"A autotuning PID controller with an AMIGO tuner and a first order time delayed system model"
parameter Buildings.Controls.OBC.CDL.Types.SimpleController controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI
"Type of controller";
parameter Real k_start(
parameter Real r(
min=100*CDL.Constants.eps)=1
"Typical range of control error, used for scaling the control error";
parameter Real yMax=1
"Upper limit of output"
annotation (Dialog(group="Limits"));
parameter Real yMin=0
"Lower limit of output"
annotation (Dialog(group="Limits"));
parameter Real Ni(
min=100*CDL.Constants.eps)=0.9
"Ni*Ti is time constant of anti-windup compensation"
annotation (Dialog(tab="Advanced",group="Integrator anti-windup",enable=controllerType == CDL.Types.SimpleController.PI or controllerType ==CDL.Types.SimpleController.PID));
parameter Real Nd(
min=100*CDL.Constants.eps)=10
"The higher Nd, the more ideal the derivative block"
annotation (Dialog(tab="Advanced",group="Derivative block",enable=controllerType == CDL.Types.SimpleController.PD or controllerType ==CDL.Types.SimpleController.PID));
parameter Real xi_start=0
"Initial value of integrator state"
annotation (Dialog(tab="Advanced",group="Initialization",enable=controllerType == CDL.Types.SimpleController.PI or controllerType == CDL.Types.SimpleController.PID));
parameter Real yd_start=0
"Initial value of derivative output"
annotation (Dialog(tab="Advanced",group="Initialization",enable=controllerType == CDL.Types.SimpleController.PD or controllerType == CDL.Types.SimpleController.PID));
parameter Boolean reverseActing=true
"Set to true for reverse acting, or false for direct acting control action";
parameter Real y_reset=xi_start
"Value to which the controller output is reset if the boolean trigger has a rising edge"
annotation (Dialog(enable=controllerType == CDL.Types.SimpleController.PI or controllerType == CDL.Types.SimpleController.PID,group="Integrator reset"));
final parameter Real k_start(
min=100*Buildings.Controls.OBC.CDL.Constants.eps)=1
"Start value of the gain of controller"
annotation (Dialog(group="Control gains"));
parameter Real Ti_start(
final parameter Real Ti_start(
final quantity="Time",
final unit="s",
min=100*Buildings.Controls.OBC.CDL.Constants.eps)=0.5
"Start value of the time constant of integrator block"
annotation (Dialog(group="Control gains",enable=controllerType == CDL.Types.SimpleController.PI or controllerType == CDL.Types.SimpleController.PID));
parameter Real Td_start(
final parameter Real Td_start(
final quantity="Time",
final unit="s",
min=100*Buildings.Controls.OBC.CDL.Constants.eps)=0.1
"Start value of the time constant of derivative block"
annotation (Dialog(group="Control gains",enable=controllerType == CDL.Types.SimpleController.PD or controllerType == CDL.Types.SimpleController.PID));
parameter Real yHig(min=1E-6) = 1
final parameter Real yHig(min=1E-6) = 1
"Higher value for the relay output";
parameter Real yLow(min=1E-6) = 0.5
final parameter Real yLow(min=1E-6) = 0.1
"Lower value for the relay output";
parameter Real deaBan(min=1E-6) = 0.5
final parameter Real deaBan(min=1E-6) = 0.1
"Deadband for holding the output value";
parameter Real yRef(min=1E-6) = 0.8
final parameter Real yRef(min=1E-6) = 0.8
"Reference output for the tuning process";
Buildings.Controls.OBC.CDL.Interfaces.RealInput u_s
"Setpoint"
Expand All @@ -48,7 +76,16 @@ block FirstOrderAMIGO
"A relay controller"
annotation (Placement(transformation(extent={{20,0},{40,20}})));
Buildings.Controls.OBC.Utilities.PIDWithInputGains PID(
controllerType=controllerType)
final controllerType=controllerType,
final r=r,
final yMax=yMax,
final yMin=yMin,
final Ni=Ni,
final Nd= Nd,
final xi_start=xi_start,
final yd_start=yd_start,
final reverseActing=reverseActing,
final y_reset=xi_start)
"A PID controller"
annotation (Placement(transformation(extent={{0,-50},{20,-30}})));
Buildings.Controls.OBC.CDL.Continuous.Switch swi
Expand Down Expand Up @@ -169,10 +206,27 @@ equation
-52}}, color={0,0,127}));
annotation (Documentation(info="<html>
<p>
This blocks implements a AMIGO PID tuning method and the control process is approximated with a first order delay process.
This block implements a rule-based PID tuning method.
Specifically, this PID tuning method approximates the control process with a first-order delay (FOD) model.
It then determines the parameters of this FOD model based on the responses of the control process to an asymmetric relay feedback.
After that, taking the parameters of this FOD mode as inputs, this PID tuning method calculates the PID parameters based on prescribed rules, i.e., Approximate M-constrained Integral Gain Optimization (AMIGO) Tuner.
This block is built based on <a href=\\\"modelica://Buildings.Controls.OBC.Utilities.PIDWithInputGains\\\"> Buildings.Controls.OBC.Utilities.PIDWithInputGains</a> and inherits all the parameters of the latter.
However, through the parameter <code>controllerType</code>, the controller can only be configured as PI or PID controller.
</p>
<h4>Breif guidance</h4>
<p>
Noted that this block can only support a PI controller or a PID controller.
To use this block, connect it to the control loop.
It will start the PID tuning process once the simulation starts.
During the PID tuning process, the control loop is controlled by a relay feedback controller.
The PID tuning process will ends automatically based on the algorithm defined in <a href=\"modelica://Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.HalfPeriodRatio\">Buildings.Controls.OBC.Utilities.PIDWithAutotuning.Relay.HalfPeriodRatio</a>.
Starting from then, the control loop is controlled by a PI or PID controller.
Note that the output of this block is limited from 0 to 1.
</p>
<h4>References</h4>
<p>
J. Berner (2017).
<a href=\"https://lucris.lub.lu.se/ws/portalfiles/portal/33100749/ThesisJosefinBerner.pdf\">\"Automatic Controller Tuning using Relay-based Model Identification.\"</a>
Department of Automatic Control, Lund University.
</p>
</html>", revisions="<html>
<ul>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,8 @@ First implementation<br/>
</li>
</ul>
</html>", info="<html>
<p>This block processes a relay swtich output signal and calculates</p>
<ol>
<li>the length of the On period (when the relay switch signal becomes True);</li>
<li>the length of the Off period (when the relay switch signal becomes False).</li>
</ol>
<p>This block processes a relay swtich output signal and calculates the length of the On period (when the relay switch signal becomes True),
and the length of the Off period (when the relay switch signal becomes False), respectively.
<h4>References</h4>
<p>
Josefin Berner (2017)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ model PIDWithFirstOrderAMIGO "Test model for FirstOrderAMIGO"
"Setpoint value"
annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.FirstOrderAMIGO PIDWitTun(
controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PID,
yHig=1,
yLow=0.1,
deaBan=0.1,
yRef=0.8) "PID controller with an autotuning feature"
controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PID)
"PID controller with an autotuning feature"
annotation (Placement(transformation(extent={{-20,-30},{0,-10}})));
Buildings.Controls.OBC.CDL.Continuous.PIDWithReset PID(
controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PID,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,8 @@ model PIWithFirstOrderAMIGO "Test model for FirstOrderAMIGO"
"Setpoint value"
annotation (Placement(transformation(extent={{-80,0},{-60,20}})));
Buildings.Controls.OBC.Utilities.PIDWithAutotuning.FirstOrderAMIGO PIWitTun(
controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI,
yHig=1,
yLow=0.1,
deaBan=0.1,
yRef=0.8) "PI controller with an autotuning feature"
controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI)
"PI controller with an autotuning feature"
annotation (Placement(transformation(extent={{-20,-30},{0,-10}})));
Buildings.Controls.OBC.CDL.Continuous.PIDWithReset PI(
controllerType=Buildings.Controls.OBC.CDL.Types.SimpleController.PI,
Expand Down

0 comments on commit 0a205a7

Please sign in to comment.