freitag
This commit is contained in:
@@ -299,11 +299,13 @@ public:
|
||||
|
||||
bool isIdle() const { return targetTempC_ <= 0.0f; }
|
||||
|
||||
float emergencyCutoffC() const { return emergencyCutoffForTarget(targetTempC_); }
|
||||
|
||||
float cutoffThreshold() const {
|
||||
if (isIdle()) {
|
||||
return INFINITY;
|
||||
}
|
||||
return EMERGENCY_MAX_TEMP_C;
|
||||
return emergencyCutoffC();
|
||||
}
|
||||
|
||||
bool isCutoffActive() const { return cutoffActive_; }
|
||||
@@ -470,7 +472,8 @@ private:
|
||||
}
|
||||
|
||||
void updateRegulating(float avgTempC, float maxTempC, uint32_t nowMs) {
|
||||
if (maxTempC >= EMERGENCY_MAX_TEMP_C) {
|
||||
const float cutoffC = emergencyCutoffC();
|
||||
if (maxTempC >= cutoffC) {
|
||||
cutoffActive_ = true;
|
||||
heaterDutyPercent_ = 0.0f;
|
||||
heaterAllowancePercent_ = 0.0f;
|
||||
@@ -480,7 +483,7 @@ private:
|
||||
return;
|
||||
}
|
||||
|
||||
if (cutoffActive_ && maxTempC < EMERGENCY_MAX_TEMP_C - 5.0f) {
|
||||
if (cutoffActive_ && maxTempC < cutoffC - CUTOFF_RECOVERY_BAND_C) {
|
||||
cutoffActive_ = false;
|
||||
heatPi_.reset();
|
||||
}
|
||||
@@ -494,24 +497,14 @@ private:
|
||||
heaterAllowancePercent_ = allowanceFromMaxCorner(maxTempC, avgTempC);
|
||||
|
||||
float duty = heatPi_.compute(avgTempC, nowMs);
|
||||
const float below = targetTempC_ - avgTempC;
|
||||
if (below > 8.0f) {
|
||||
const float floor = below > 15.0f ? 75.0f : 60.0f;
|
||||
if (duty < floor) {
|
||||
duty = floor;
|
||||
}
|
||||
}
|
||||
const float maxDuty = heaterMaxDuty(avgTempC);
|
||||
if (duty > maxDuty) {
|
||||
duty = maxDuty;
|
||||
}
|
||||
duty = clampPercent(duty);
|
||||
if (duty > heaterAllowancePercent_) {
|
||||
duty = heaterAllowancePercent_;
|
||||
if (heaterAllowancePercent_ < 100.0f) {
|
||||
heaterBlock_ = HeaterBlock::Corner;
|
||||
}
|
||||
}
|
||||
heaterDutyPercent_ = applyHeaterRamp(duty, avgTempC, nowMs);
|
||||
heaterDutyPercent_ = duty;
|
||||
|
||||
regulatingFanPwm_ = fanManualActive_ ? fanManualPwm_ : stirFanPwm_;
|
||||
}
|
||||
@@ -532,16 +525,17 @@ private:
|
||||
|
||||
float maxHeatStopTemp(float avgTempC) const {
|
||||
if (!shouldLimitMaxCorner(avgTempC)) {
|
||||
return EMERGENCY_MAX_TEMP_C;
|
||||
return emergencyCutoffC();
|
||||
}
|
||||
return EMERGENCY_MAX_TEMP_C - CORNER_STOP_MARGIN_C;
|
||||
return emergencyCutoffC() - CORNER_STOP_MARGIN_C;
|
||||
}
|
||||
|
||||
float allowanceFromMaxCorner(float maxTempC, float avgTempC) const {
|
||||
const float cutoffC = emergencyCutoffC();
|
||||
if (!shouldLimitMaxCorner(avgTempC)) {
|
||||
// Heat-up: only taper when a hot corner nears the emergency ceiling
|
||||
if (maxTempC >= EMERGENCY_MAX_TEMP_C - 3.0f) {
|
||||
const float headroom = EMERGENCY_MAX_TEMP_C - maxTempC;
|
||||
// Heat-up: only taper when a hot corner nears the dynamic cutoff
|
||||
if (maxTempC >= cutoffC - 3.0f) {
|
||||
const float headroom = cutoffC - maxTempC;
|
||||
return clampPercent((headroom / 3.0f) * 100.0f);
|
||||
}
|
||||
return 100.0f;
|
||||
@@ -560,38 +554,6 @@ private:
|
||||
return clampPercent((headroom / MAX_TEMP_HEADROOM_C) * 100.0f);
|
||||
}
|
||||
|
||||
float heaterMaxDuty(float avgTempC) const {
|
||||
if (avgTempC >= targetTempC_) {
|
||||
return HEATER_MAX_DUTY_NEAR;
|
||||
}
|
||||
|
||||
const float below = targetTempC_ - avgTempC;
|
||||
if (below >= HEATER_COLD_BELOW_C) {
|
||||
return HEATER_MAX_DUTY_COLD;
|
||||
}
|
||||
if (below >= HEATER_WARM_BELOW_C) {
|
||||
return HEATER_MAX_DUTY_MID;
|
||||
}
|
||||
return HEATER_MAX_DUTY_NEAR;
|
||||
}
|
||||
|
||||
float applyHeaterRamp(float requestedDuty, float avgTempC, uint32_t nowMs) {
|
||||
const float maxDuty = heaterMaxDuty(avgTempC);
|
||||
if (requestedDuty > maxDuty) {
|
||||
requestedDuty = maxDuty;
|
||||
}
|
||||
|
||||
if (lastHeaterUpdateMs_ > 0 && requestedDuty > heaterDutyPercent_) {
|
||||
const float dt = static_cast<float>(nowMs - lastHeaterUpdateMs_) / 1000.0f;
|
||||
const float maxUp = heaterDutyPercent_ + HEATER_SLEW_UP_PER_S * dt;
|
||||
if (requestedDuty > maxUp) {
|
||||
requestedDuty = maxUp;
|
||||
}
|
||||
}
|
||||
|
||||
return requestedDuty;
|
||||
}
|
||||
|
||||
void applyHeaterBurst(uint32_t nowMs) {
|
||||
if (heaterDutyPercent_ <= 0.0f) {
|
||||
forceHeaterOff();
|
||||
|
||||
Reference in New Issue
Block a user