Skip to content

Commit

Permalink
Merge branch 'hoylabs:development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Snoopy-HSS authored Jan 12, 2025
2 parents 1f97c57 + bd2252e commit 58edc02
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
27 changes: 20 additions & 7 deletions src/PowerLimiterSolarInverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ uint16_t PowerLimiterSolarInverter::getMaxIncreaseWatts() const
{
if (isEligible() != Eligibility::Eligible) { return 0; }

// the maximum increase possible for this inverter
int16_t maxTotalIncrease = getConfiguredMaxPowerWatts() - getCurrentOutputAcWatts();

if (!isProducing()) {
// the inverter is not producing, we don't know how much we can increase
// the power, so we return the maximum possible increase
return maxTotalIncrease;
return getConfiguredMaxPowerWatts();
}

// the maximum increase possible for this inverter
int16_t maxTotalIncrease = getConfiguredMaxPowerWatts() - getCurrentOutputAcWatts();

// when the current limit is less than 15% of the max power of the inverter
// the output will not match the limit as the inverters are not able to work
// with those low limits. In this case we assume that the inverter is able to
Expand Down Expand Up @@ -82,14 +82,27 @@ uint16_t PowerLimiterSolarInverter::getMaxIncreaseWatts() const
return maxTotalIncrease;
}

int16_t maxPowerPerMppt = getConfiguredMaxPowerWatts() / dcTotalMppts;
// for inverters without PDL we use the configured max power, because the limit will be divided equally across the MPPTs by the inverter.
int16_t inverterMaxPower = getConfiguredMaxPowerWatts();

// for inverter with PDL or when overscaling is enabled we use the max power of the inverter because each MPPT can deliver its max power.
if (_spInverter->supportsPowerDistributionLogic() || _config.UseOverscaling) {
inverterMaxPower = getInverterMaxPowerWatts();
}

int16_t maxPowerPerMppt = inverterMaxPower / dcTotalMppts;

int16_t currentPowerPerNonShadedMppt = nonShadedMpptACPowerSum / dcNonShadedMppts;

int16_t maxIncreasePerNonShadedMppt = maxPowerPerMppt - currentPowerPerNonShadedMppt;

// maximum increase based on the non-shaded mppts
return maxIncreasePerNonShadedMppt * dcNonShadedMppts;
// maximum increase based on the non-shaded mppts, can be higher than maxTotalIncrease for inverters
// with PDL when getConfiguredMaxPowerWatts() is less than getInverterMaxPowerWatts() divided by
// the number of used/unshaded MPPTs.
int16_t maxIncreaseNonShadedMppts = maxIncreasePerNonShadedMppt * dcNonShadedMppts;

// maximum increase should not exceed the max total increase
return std::min(maxTotalIncrease, maxIncreaseNonShadedMppts);
}

uint16_t PowerLimiterSolarInverter::applyReduction(uint16_t reduction, bool)
Expand Down
4 changes: 3 additions & 1 deletion src/gridcharger/huawei/Controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,8 @@ void Controller::loop()

void Controller::setParameter(float val, HardwareInterface::Setting setting)
{
std::lock_guard<std::mutex> lock(_mutex);

if (_mode == HUAWEI_MODE_AUTO_INT &&
setting != HardwareInterface::Setting::OfflineVoltage &&
setting != HardwareInterface::Setting::OfflineCurrent) { return; }
Expand All @@ -296,7 +298,7 @@ void Controller::setParameter(float val, HardwareInterface::Setting setting)

void Controller::_setParameter(float val, HardwareInterface::Setting setting)
{
std::lock_guard<std::mutex> lock(_mutex);
// NOTE: the mutex is locked by any method calling this private method

if (!_upHardwareInterface) { return; }

Expand Down

0 comments on commit 58edc02

Please sign in to comment.