Skip to content

Commit 3d1dbd2

Browse files
committed
DPL: reduce/increase limits of solar and smart-buffer inverters based on current AC power
1 parent 256c03d commit 3d1dbd2

File tree

3 files changed

+13
-37
lines changed

3 files changed

+13
-37
lines changed

src/PowerLimiterOverscalingInverter.cpp

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,20 +44,8 @@ uint16_t PowerLimiterOverscalingInverter::applyIncrease(uint16_t increase)
4444
// do not wake inverter up if it would produce too much power
4545
if (!isProducing() && _config.LowerPowerLimit > increase) { return 0; }
4646

47-
uint16_t baseline = getCurrentLimitWatts();
48-
49-
// when overscaling is in use we must not use the current limit
50-
// because it might be scaled.
51-
if (overscalingEnabled()) {
52-
baseline = getCurrentOutputAcWatts();
53-
}
54-
55-
// inverters in standby can have an arbitrary limit, yet
56-
// the baseline is 0 in case we are about to wake it up from standby.
57-
if (!isProducing()) { baseline = 0; }
58-
5947
auto actualIncrease = std::min(increase, getMaxIncreaseWatts());
60-
setAcOutput(baseline + actualIncrease);
48+
setAcOutput(getCurrentOutputAcWatts() + actualIncrease);
6149
return actualIncrease;
6250
}
6351

src/PowerLimiterSmartBufferInverter.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,29 @@ uint16_t PowerLimiterSmartBufferInverter::applyReduction(uint16_t reduction, boo
5959

6060
if (reduction == 0) { return 0; }
6161

62-
auto low = std::min(getCurrentLimitWatts(), getCurrentOutputAcWatts());
62+
uint16_t currentOutputAcWatts = getCurrentOutputAcWatts();
63+
64+
auto low = std::min(getCurrentLimitWatts(), currentOutputAcWatts);
6365
if (low <= _config.LowerPowerLimit) {
6466
if (allowStandby && _config.AllowStandby) {
6567
standby();
66-
return std::min(reduction, getCurrentOutputAcWatts());
68+
return std::min(reduction, currentOutputAcWatts);
6769
}
6870
return 0;
6971
}
7072

71-
uint16_t baseline = getCurrentLimitWatts();
72-
73-
// when overscaling is in use we must not use the current limit
74-
// because it might be scaled.
75-
if (overscalingEnabled()) {
76-
baseline = getCurrentOutputAcWatts();
77-
}
78-
79-
if ((baseline - _config.LowerPowerLimit) >= reduction) {
80-
setAcOutput(baseline - reduction);
73+
if ((currentOutputAcWatts - _config.LowerPowerLimit) >= reduction) {
74+
setAcOutput(currentOutputAcWatts - reduction);
8175
return reduction;
8276
}
8377

8478
if (allowStandby && _config.AllowStandby) {
8579
standby();
86-
return std::min(reduction, getCurrentOutputAcWatts());
80+
return std::min(reduction, currentOutputAcWatts);
8781
}
8882

8983
setAcOutput(_config.LowerPowerLimit);
90-
return getCurrentOutputAcWatts() - _config.LowerPowerLimit;
84+
return currentOutputAcWatts - _config.LowerPowerLimit;
9185
}
9286

9387
uint16_t PowerLimiterSmartBufferInverter::standby()

src/PowerLimiterSolarInverter.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,15 @@ uint16_t PowerLimiterSolarInverter::applyReduction(uint16_t reduction, bool)
108108

109109
if (reduction == 0) { return 0; }
110110

111-
uint16_t baseline = getCurrentLimitWatts();
111+
uint16_t currentOutputAcWatts = getCurrentOutputAcWatts();
112112

113-
// when overscaling is in use we must not use the current limit
114-
// because it might be scaled.
115-
if (overscalingEnabled()) {
116-
baseline = getCurrentOutputAcWatts();
117-
}
118-
119-
if ((baseline - _config.LowerPowerLimit) >= reduction) {
120-
setAcOutput(baseline - reduction);
113+
if ((currentOutputAcWatts - _config.LowerPowerLimit) >= reduction) {
114+
setAcOutput(currentOutputAcWatts - reduction);
121115
return reduction;
122116
}
123117

124118
setAcOutput(_config.LowerPowerLimit);
125-
return getCurrentOutputAcWatts() - _config.LowerPowerLimit;
119+
return currentOutputAcWatts - _config.LowerPowerLimit;
126120
}
127121

128122
uint16_t PowerLimiterSolarInverter::standby()

0 commit comments

Comments
 (0)