DPL: (re-)send power limits periodically (#483)
avoid staleness in case the same power limit is calculated over and over again, hence no new power limit value is calculated and hence no power limit command is sent to the inverter. staleness occurs in this case if the first power limit command to establish the respective limit was not received by the inverter. one can easily simulate a situation where the same power limit is caluclated over and over again: with a battery above the start threshold, set a very low upper power limit for the inverter (DPL setting). that value will be used as the limit as long as the power meter reading is larger than that. we could also check the limit reported by the inverter. however, that value is in percent of the inverter's max AC output, and is often not the same value as we requested as the limit, but slightly off. we then would have to decide how much deviation is okay, which is unreasonably complicated. closes #478.
This commit is contained in:
parent
f7abbdbe06
commit
116da05114
@ -64,6 +64,7 @@ public:
|
||||
|
||||
private:
|
||||
int32_t _lastRequestedPowerLimit = 0;
|
||||
uint32_t _lastPowerLimitMillis = 0;
|
||||
uint32_t _shutdownTimeout = 0;
|
||||
Status _lastStatus = Status::Initializing;
|
||||
uint32_t _lastStatusPrinted = 0;
|
||||
|
||||
@ -496,6 +496,7 @@ void PowerLimiterClass::commitPowerLimit(std::shared_ptr<InverterAbstract> inver
|
||||
PowerLimitControlType::AbsolutNonPersistent);
|
||||
|
||||
_lastRequestedPowerLimit = limit;
|
||||
_lastPowerLimitMillis = millis();
|
||||
|
||||
// enable power production only after setting the desired limit,
|
||||
// such that an older, greater limit will not cause power spikes.
|
||||
@ -546,17 +547,23 @@ bool PowerLimiterClass::setNewPowerLimit(std::shared_ptr<InverterAbstract> inver
|
||||
|
||||
// Check if the new value is within the limits of the hysteresis
|
||||
auto diff = std::abs(effPowerLimit - _lastRequestedPowerLimit);
|
||||
if ( diff < config.PowerLimiter_TargetPowerConsumptionHysteresis) {
|
||||
auto hysteresis = config.PowerLimiter_TargetPowerConsumptionHysteresis;
|
||||
|
||||
// (re-)send power limit in case the last was sent a long time ago. avoids
|
||||
// staleness in case a power limit update was not received by the inverter.
|
||||
auto ageMillis = millis() - _lastPowerLimitMillis;
|
||||
|
||||
if (diff < hysteresis && ageMillis < 60 * 1000) {
|
||||
if (_verboseLogging) {
|
||||
MessageOutput.printf("[DPL::setNewPowerLimit] reusing old limit: %d W, diff: %d W, hysteresis: %d W\r\n",
|
||||
_lastRequestedPowerLimit, diff, config.PowerLimiter_TargetPowerConsumptionHysteresis);
|
||||
MessageOutput.printf("[DPL::setNewPowerLimit] requested: %d W, last limit: %d W, diff: %d W, hysteresis: %d W, age: %ld ms\r\n",
|
||||
newPowerLimit, _lastRequestedPowerLimit, diff, hysteresis, ageMillis);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if (_verboseLogging) {
|
||||
MessageOutput.printf("[DPL::setNewPowerLimit] using new limit: %d W, requested power limit: %d W\r\n",
|
||||
effPowerLimit, newPowerLimit);
|
||||
MessageOutput.printf("[DPL::setNewPowerLimit] requested: %d W, (re-)sending limit: %d W\r\n",
|
||||
newPowerLimit, effPowerLimit);
|
||||
}
|
||||
|
||||
commitPowerLimit(inverter, effPowerLimit, true);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user