Remove PidController

This commit is contained in:
2023-02-19 09:44:28 +01:00
parent d079d81230
commit fd7f67da04
3 changed files with 1 additions and 33 deletions

View File

@@ -47,7 +47,7 @@ namespace TestApp
yield return (current.I2, current.I1, current.I3); yield return (current.I2, current.I1, current.I3);
yield return (current.I3, current.I1, current.I2); yield return (current.I3, current.I1, current.I2);
yield return (current.I3, current.I2, current.I1); yield return (current.I3, current.I2, current.I1);
} }
private static bool IsValidCombinition((double I1, double I2, double I3) measuredCurrent, (double I1, double I2, double I3) wallBoxCurrent) { private static bool IsValidCombinition((double I1, double I2, double I3) measuredCurrent, (double I1, double I2, double I3) wallBoxCurrent) {
if (measuredCurrent.I1 < wallBoxCurrent.I1) { return false; } // even this is not correct if a PV is generating power ! if (measuredCurrent.I1 < wallBoxCurrent.I1) { return false; } // even this is not correct if a PV is generating power !

View File

@@ -1,31 +0,0 @@
using TestApp.Configuration;
namespace TestApp
{
internal class PidController
{
private DateTime _PreviousUpdateTime;
private double _PreviousError;
private double _Integral;
public PidSetting PositiveSettings { get; set; } = new PidSetting();
public PidSetting NegativeSettings { get; set; } = new PidSetting();
public double SetPoint { get; set; }
public double Update(double measurement) {
var error = measurement - SetPoint;
var dt = (DateTime.UtcNow - _PreviousUpdateTime).TotalSeconds;
var settings = error > 0 ? PositiveSettings : NegativeSettings;
var proportional = error * settings.KP;
_Integral += error * settings.KI * dt;
var differential = (error - _PreviousError) * settings.KD / dt;
_PreviousError = error;
_PreviousUpdateTime = DateTime.UtcNow;
return proportional + _Integral + differential;
}
}
}

View File

@@ -106,6 +106,5 @@ namespace TestApp
_Driver.HostAddress = settings.ChargerAddress ?? Settings.DEFAULT_CHARGER_ADDRESS; _Driver.HostAddress = settings.ChargerAddress ?? Settings.DEFAULT_CHARGER_ADDRESS;
_Driver.Port = settings.ChargerPort ?? Settings.DEFAULT_CHARGER_PORT; _Driver.Port = settings.ChargerPort ?? Settings.DEFAULT_CHARGER_PORT;
} }
} }
} }