Skip to content

Commit

Permalink
Assert statement to avoid zero gain in controller and improved descri…
Browse files Browse the repository at this point in the history
…ption string for controller gain
  • Loading branch information
arunkumar-narasimhan committed May 5, 2023
1 parent a848744 commit 4813c74
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Modelica/Blocks/Continuous.mo
Expand Up @@ -765,7 +765,7 @@ to compute u by an algebraic equation.
"Control error (set point - measurement)";
parameter .Modelica.Blocks.Types.SimpleController controllerType=
.Modelica.Blocks.Types.SimpleController.PID "Type of controller";
parameter Real k = 1 "Gain of controller";
parameter Real k = 1 "Gain of controller, must be non-zero";
parameter SI.Time Ti(min=Modelica.Constants.small)=0.5
"Time constant of Integrator block" annotation (Dialog(enable=
controllerType == .Modelica.Blocks.Types.SimpleController.PI or
Expand Down Expand Up @@ -881,6 +881,7 @@ to compute u by an algebraic equation.
gainPID.y = y_start;
end if;
equation
assert(abs(k) >= Constants.small, "Controller gain must be non-zero.");
if initType == 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) + ")");
Expand Down

0 comments on commit 4813c74

Please sign in to comment.