1

I build a fluid model with a PID control system, and I wanna run my model until reaching a steady state and then keep the output signal of the PID system unchanged, so I could do step excitation stability tests. But right now I am not sure how to keep the output signal of the PID control system unchanged after a fixed time point. So I have to use a logical switch to change the signal source at a fixed time point.
My question is:
How could keep the output signal of a Block Component unchanged after a fixed time point?

enter image description here

Jonas
  • 121,568
  • 97
  • 310
  • 388
Jack
  • 1,094
  • 6
  • 16

2 Answers2

2

I dont't think there is a suitable block in the Modelica Standard Library.

But would that code do it?

model KeepValueTime
  extends Modelica.Blocks.Interfaces.SISO;

  parameter Modelica.Units.SI.Time t = Modelica.Constants.inf "Time at which the value shall be kept";
  Real u_keep(start=0) "Value to be output when 'keepValue = true'";

equation 
  if time < t then
    y = u;
  else
    y = u_keep;
  end if;

  when time >= t then
    u_keep = u;
  end when;

  annotation (uses(Modelica(version="4.0.0")));
end KeepValueTime;

A bit more general with a Boolean input:

model KeepValue
  extends Modelica.Blocks.Interfaces.SISO;

  Real u_keep(start=0) "Value to be output when 'keepValue = true'";

  Modelica.Blocks.Interfaces.BooleanInput keepValue annotation (Placement(transformation(
        extent={{-20,-20},{20,20}},
        rotation=0,
        origin={-120,80}), iconTransformation(extent={{-140,60},{-100,100}}, rotation=0)));

equation 
  if not keepValue then
    y = u;
  else
    y = u_keep;
  end if;

  when keepValue then
    u_keep = u;
  end when;

  annotation (uses(Modelica(version="4.0.0")));
end KeepValue;

A quick test:

Test Example

...seems to do what you need: Example Result

Markus A.
  • 6,300
  • 10
  • 26
1

An alternative to the solution suggested by Markus A. could be to switch the control error to zero. This will freeze the controller output, provided that the switch is done when the system is already in steady state (zero control error).

Rene Just Nielsen
  • 3,023
  • 12
  • 15
  • I think the limitation to this, would be that there is an integral part in the controller - which judging from the question should be the case, but still... – Markus A. Jun 17 '21 at 12:51