Skip to content

Commit

Permalink
- updating how the sign of the process gain is inferrred by CLUI
Browse files Browse the repository at this point in the history
  • Loading branch information
Steinar Elgsæter committed Dec 11, 2024
1 parent 0c4f64f commit 92c5eca
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
13 changes: 12 additions & 1 deletion Dynamic/Identification/ClosedLoopUnitIdentifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -835,9 +835,17 @@ double Range(double[] inSignal)
/// <param name="unitDataSet"></param>
/// <param name="pidParams"></param>
/// <param name="pidInputIdx"></param>
/// <returns></returns>
/// <returns>returns 1 if gain is positive or -1 if gain is negative.</returns>
private static double GuessSignOfProcessGain(UnitDataSet unitDataSet, PidParameters pidParams, int pidInputIdx)
{
if (pidParams.Kp != 0 && !Double.IsNaN(pidParams.Kp) && pidParams.Kp != -9999)
{
if (pidParams.Kp > 0)
return 1;
else
return -1;
}

var vec = new Vec(unitDataSet.BadDataID);
double[] e = vec.Subtract(unitDataSet.Y_meas, unitDataSet.Y_setpoint);
double pidInput_processGainSign = 1;
Expand Down Expand Up @@ -876,6 +884,9 @@ private static double GuessSignOfProcessGain(UnitDataSet unitDataSet, PidParamet
/// <returns></returns>
private static UnitModel EstimateClosedLoopProcessGain(UnitDataSet unitDataSet, PidParameters pidParams, int pidInputIdx)
{



var unitModel = new UnitModel();
var vec = new Vec(unitDataSet.BadDataID);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,20 +82,19 @@ public void SinusDisturbance(double distSinusAmplitude)


// 0.25: saturates the controller
[TestCase(0.5, 0.1, Category = "NotWorking_AcceptanceTest")]
[TestCase(0.5, 1, Category = "NotWorking_AcceptanceTest")]
[TestCase(1, 0.1, Category = "NotWorking_AcceptanceTest")]
[TestCase(1, 1, Category = "NotWorking_AcceptanceTest")]
[TestCase(2, 0.1)]
[TestCase(2, 1)]
[TestCase(0.5, 0.1,20, Category = "NotWorking_AcceptanceTest")]
[TestCase(0.5, 1, 20, Category = "NotWorking_AcceptanceTest")]
[TestCase(1, 0.1, 20, Category = "NotWorking_AcceptanceTest")]
[TestCase(1, 1, 20, Category = "NotWorking_AcceptanceTest")]
[TestCase(2, 0.1, 20)]
[TestCase(2, 1, 20)]
// gain of 5 starts giving huge oscillations...

public void RandomWalkDisturbance(double procGain, double distAmplitude)
public void RandomWalkDisturbance(double procGain, double distAmplitude, double precisionPrc)
{
// int seed = 50;// works fairly well..
// int seed = 100;// much harder for some reason
int seed = 105;
double precisionPrc = 20;

int N = 2000;

Expand Down
12 changes: 8 additions & 4 deletions docs/articles/sysid_disturbance.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,15 @@ G_0 = max(e)/(max(u)-min(u))
```

The PID-controller integral effect time constant meant that a peak in the deviation ``e`` will not coincide with the peak
in ``u''.
in ``u``.
The idea of creating an inital estimate withh ``min`` and ``max`` values is that it circumvents the lack
of knowledge of the dynamics at this early stage of estimaton.

It has been observed in unit tests that this estimate in some cases is spot on the actual gain, such as when
the disturbance is a perfect step.
the disturbance is a perfect step.

It seems that the accuracy of this initial estimate may depend on how much the process is close to steady-state for different disturbance values,
as disturbance step produces far better gain estiamtes than if the disturbance is a steady sinus(so that the system never reaches steady-state.)

Given the gain an inital UnitModel is created with a rudimentary bias and operating point ``u0``, so that the model can
be simulated to give an inital ``y_mod(u)``, so that an estimate ``d_est(t)`` can be found.
Expand Down Expand Up @@ -184,12 +187,13 @@ where there are changes in the setpoint, found as_

``var uPidVariance = vec.Mean(vec.Abs(vec.Diff(u_pid_adjusted))).Value``

The algorithm seems to in general give better estiamtes of the process if there are step changes in the external inputs
or in the pid-setpoint, and the algorithm appears to be able to handle both cases.





### Estimating upper-and lower boundds on the process gain
### Estimating upper-and lower bounds on the process gain

It may be that the algorithm has a better accuracy when there are setpoint changes in the dataset.
It may also be that there the model will do better when there are large "wavy" disturbances than when the
Expand Down

0 comments on commit 92c5eca

Please sign in to comment.