From 99876d7c6be231ed8fcabf5c3ffa666b9980ba8e Mon Sep 17 00:00:00 2001 From: Bernhard Kirchen Date: Sun, 2 Jul 2023 14:11:44 +0200 Subject: [PATCH] DPL: fix the configured upper limit not being respected (#286) the requested newPowerLimit was indeed limited to the configured maximum inverter output and the result was stored in effPowerLimit. later, however, effPowerLimit must be scaled up (if necessary), not newPowerLimit. the latter variable is not respecting the configured maximum inverter output. --- src/PowerLimiter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/PowerLimiter.cpp b/src/PowerLimiter.cpp index a5c3531fb..d10f22b4c 100644 --- a/src/PowerLimiter.cpp +++ b/src/PowerLimiter.cpp @@ -336,7 +336,6 @@ void PowerLimiterClass::setNewPowerLimit(std::shared_ptr inver // enforce configured upper power limit int32_t effPowerLimit = std::min(newPowerLimit, config.PowerLimiter_UpperPowerLimit); - // scale the power limit by the amount of all inverter channels devided by // the amount of producing inverter channels. the inverters limit each of // the n channels to 1/n of the total power limit. scaling the power limit @@ -351,7 +350,7 @@ void PowerLimiterClass::setNewPowerLimit(std::shared_ptr inver if (dcProdChnls > 0) { MessageOutput.printf("[PowerLimiterClass::setNewPowerLimit] %d channels total, %d producing channels, scaling power limit\r\n", dcTotalChnls, dcProdChnls); - effPowerLimit = round(newPowerLimit * static_cast(dcTotalChnls) / dcProdChnls); + effPowerLimit = round(effPowerLimit * static_cast(dcTotalChnls) / dcProdChnls); if (effPowerLimit > inverter->DevInfo()->getMaxPower()) { effPowerLimit = inverter->DevInfo()->getMaxPower(); } @@ -360,8 +359,9 @@ void PowerLimiterClass::setNewPowerLimit(std::shared_ptr inver // Check if the new value is within the limits of the hysteresis auto diff = std::abs(effPowerLimit - _lastRequestedPowerLimit); if ( diff < config.PowerLimiter_TargetPowerConsumptionHysteresis) { - MessageOutput.printf("[PowerLimiterClass::setNewPowerLimit] reusing old limit: %d W, diff: %d, hysteresis: %d\r\n", - _lastRequestedPowerLimit, diff, config.PowerLimiter_TargetPowerConsumptionHysteresis); + MessageOutput.printf("[PowerLimiterClass::setNewPowerLimit] reusing old limit: %d W, diff: %d, hysteresis: %d, requested power limit: %d\r\n", + _lastRequestedPowerLimit, diff, + config.PowerLimiter_TargetPowerConsumptionHysteresis, newPowerLimit); return; }