Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: DPL: support for multiple inverters: solar inverter #1343

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 53 additions & 2 deletions src/PowerLimiterSolarInverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,59 @@ uint16_t PowerLimiterSolarInverter::getMaxIncreaseWatts() const
{
if (!isEligible()) { return 0; }

// TODO(schlimmchen): left for the author of the scaling method: @AndreasBoehm
return std::min(getConfiguredMaxPowerWatts() - getCurrentOutputAcWatts(), 100);
// 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;
}

auto pStats = _spInverter->Statistics();
std::vector<MpptNum_t> dcMppts = _spInverter->getMppts();
size_t dcTotalMppts = dcMppts.size();

float inverterEfficiencyFactor = pStats->getChannelFieldValue(TYPE_INV, CH0, FLD_EFF) / 100;

// 98% of the expected power is good enough
auto expectedAcPowerPerMppt = (getCurrentLimitWatts() / dcTotalMppts) * 0.98;

size_t dcNonShadedMppts = 0;
auto nonShadedMpptACPowerSum = 0.0;

for (auto& m : dcMppts) {
float mpptPowerAC = 0.0;
std::vector<ChannelNum_t> mpptChnls = _spInverter->getChannelsDCByMppt(m);

for (auto& c : mpptChnls) {
mpptPowerAC += pStats->getChannelFieldValue(TYPE_DC, c, FLD_PDC) * inverterEfficiencyFactor;
}

if (mpptPowerAC >= expectedAcPowerPerMppt) {
nonShadedMpptACPowerSum += mpptPowerAC;
dcNonShadedMppts++;
}
}

if (dcNonShadedMppts == 0) {
// all mppts are shaded, we can't increase the power
return 0;
}

if (dcNonShadedMppts == dcTotalMppts) {
// no mppt is shaded, we assume that we can increase the power by the maximum
return maxTotalIncrease;
schlimmchen marked this conversation as resolved.
Show resolved Hide resolved
}

int16_t maxPowerPerMppt = getConfiguredMaxPowerWatts() / dcTotalMppts;

int16_t currentPowerPerNonShadedMppt = nonShadedMpptACPowerSum / dcNonShadedMppts;

int16_t maxIncreasePerNonShadedMppt = maxPowerPerMppt - currentPowerPerNonShadedMppt;

// maximum increase based on the non-shaded mppts
return maxIncreasePerNonShadedMppt * dcNonShadedMppts;
}

uint16_t PowerLimiterSolarInverter::applyReduction(uint16_t reduction, bool)
Expand Down