fix an issue if inverter is behind power meter

This commit is contained in:
MalteSchm 2023-04-23 11:30:08 +02:00
parent 82699b1c88
commit 8c9afbcdc0

View File

@ -149,14 +149,6 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve
return config.PowerLimiter_LowerPowerLimit; return config.PowerLimiter_LowerPowerLimit;
} }
// check if grid power consumption is within the limits of the target consumption + hysteresis
if (newPowerLimit >= (config.PowerLimiter_TargetPowerConsumption - config.PowerLimiter_TargetPowerConsumptionHysteresis) &&
newPowerLimit <= (config.PowerLimiter_TargetPowerConsumption + config.PowerLimiter_TargetPowerConsumptionHysteresis)) {
// The values have not changed much. We just use the old setting
MessageOutput.println("[PowerLimiterClass::loop] reusing old limit");
return _lastRequestedPowerLimit;
}
if (config.PowerLimiter_IsInverterBehindPowerMeter) { if (config.PowerLimiter_IsInverterBehindPowerMeter) {
// If the inverter the behind the power meter (part of measurement), // If the inverter the behind the power meter (part of measurement),
// the produced power of this inverter has also to be taken into account. // the produced power of this inverter has also to be taken into account.
@ -166,6 +158,16 @@ int32_t PowerLimiterClass::calcPowerLimit(std::shared_ptr<InverterAbstract> inve
newPowerLimit += static_cast<int>(acPower); newPowerLimit += static_cast<int>(acPower);
} }
// check if grid power consumption is within the limits of the target consumption + hysteresis
if (newPowerLimit >= (config.PowerLimiter_TargetPowerConsumption - config.PowerLimiter_TargetPowerConsumptionHysteresis) &&
newPowerLimit <= (config.PowerLimiter_TargetPowerConsumption + config.PowerLimiter_TargetPowerConsumptionHysteresis)) {
// The values have not changed much. We just use the old setting
MessageOutput.println("[PowerLimiterClass::loop] reusing old limit");
return _lastRequestedPowerLimit;
}
float efficency = inverter->Statistics()->getChannelFieldValue(TYPE_AC, (ChannelNum_t) config.PowerLimiter_InverterChannelId, FLD_EFF); float efficency = inverter->Statistics()->getChannelFieldValue(TYPE_AC, (ChannelNum_t) config.PowerLimiter_InverterChannelId, FLD_EFF);
int32_t victronChargePower = this->getDirectSolarPower(); int32_t victronChargePower = this->getDirectSolarPower();
int32_t adjustedVictronChargePower = victronChargePower * (efficency > 0.0 ? (efficency / 100.0) : 1.0); // if inverter is off, use 1.0 int32_t adjustedVictronChargePower = victronChargePower * (efficency > 0.0 ? (efficency / 100.0) : 1.0); // if inverter is off, use 1.0