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 1 commit
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
57 changes: 55 additions & 2 deletions src/PowerLimiterSolarInverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,61 @@ 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
// TODO(AndreasBoehm): should we increas by only 100W in this case? Or go for the max?
return 100; // TODO(AndreasBoehm) or maxTotalIncrease
schlimmchen marked this conversation as resolved.
Show resolved Hide resolved
}

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

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

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

// fall back to hoymiles peak efficiency as per datasheet if inverter
// is currently not producing (efficiency is zero in that case)
inverterEfficiencyFactor = (inverterEfficiencyFactor > 0) ? inverterEfficiencyFactor/100 : 0.967;
schlimmchen marked this conversation as resolved.
Show resolved Hide resolved

size_t dcNonShadedMppts = 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) {
dcNonShadedMppts++;
}
}

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

if (dcNonShadedMppts == dcTotalMppts) {
// no mppt is shaded, we can increase the power by the maximum
// TODO(AndreasBoehm): If none of the mppts are shaded we assume that we can increase the power by the maximum. is this correct?
return maxTotalIncrease;
schlimmchen marked this conversation as resolved.
Show resolved Hide resolved
}

// maximum increase per mppt, required to calculate how much the non-shaded mppts can increase
int16_t maxIncreasePerMppt = maxTotalIncrease / dcTotalMppts;

// maximum increase based on the non-shaded mppts
int16_t maxIncrease = maxIncreasePerMppt * dcNonShadedMppts;
schlimmchen marked this conversation as resolved.
Show resolved Hide resolved

return maxIncrease;
}

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