Skip to content

Commit

Permalink
Feature: include MPPT power in debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasBoehm authored and schlimmchen committed Jan 3, 2025
1 parent 8069cb6 commit e8a5102
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 21 deletions.
2 changes: 2 additions & 0 deletions include/PowerLimiterInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ class PowerLimiterInverter {
void setTargetPowerState(bool enable) { _oTargetPowerState = enable; }
void setExpectedOutputAcWatts(uint16_t power) { _expectedOutputAcWatts = power; }

static char mpptName(MpptNum_t mppt);

// copied to avoid races with web UI
PowerLimiterInverterConfig _config;

Expand Down
1 change: 0 additions & 1 deletion include/PowerLimiterSolarInverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,4 @@ class PowerLimiterSolarInverter : public PowerLimiterInverter {
private:
uint16_t scaleLimit(uint16_t expectedOutputWatts);
void setAcOutput(uint16_t expectedOutputWatts) final;
static char mpptName(MpptNum_t mppt);
};
40 changes: 40 additions & 0 deletions src/PowerLimiterInverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -349,4 +349,44 @@ void PowerLimiterInverter::debug() const
(_oTargetPowerState.has_value()?(*_oTargetPowerState?"production":"standby"):"unchanged"),
getUpdateTimeouts()
);

MessageOutput.printf(" MPPTs AC power:");

auto pStats = _spInverter->Statistics();
float inverterEfficiencyFactor = pStats->getChannelFieldValue(TYPE_INV, CH0, FLD_EFF) / 100;
std::vector<MpptNum_t> dcMppts = _spInverter->getMppts();

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;
}

MessageOutput.printf(" %c: %.0f W",
mpptName(m), mpptPowerAC);
}

MessageOutput.printf("\r\n");
}

char PowerLimiterInverter::mpptName(MpptNum_t mppt)
{
switch (mppt) {
case MpptNum_t::MPPT_A:
return 'a';

case MpptNum_t::MPPT_B:
return 'b';

case MpptNum_t::MPPT_C:
return 'c';

case MpptNum_t::MPPT_D:
return 'd';

default:
return '?';
}
}
20 changes: 0 additions & 20 deletions src/PowerLimiterSolarInverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,23 +244,3 @@ void PowerLimiterSolarInverter::setAcOutput(uint16_t expectedOutputWatts)
setTargetPowerLimitWatts(scaleLimit(expectedOutputWatts));
setTargetPowerState(true);
}

char PowerLimiterSolarInverter::mpptName(MpptNum_t mppt)
{
switch (mppt) {
case MpptNum_t::MPPT_A:
return 'a';

case MpptNum_t::MPPT_B:
return 'b';

case MpptNum_t::MPPT_C:
return 'c';

case MpptNum_t::MPPT_D:
return 'd';

default:
return '?';
}
}

0 comments on commit e8a5102

Please sign in to comment.