safety commit

This commit is contained in:
2026-07-06 20:16:51 +02:00
parent 02e51717e8
commit 28ae97fa45
8 changed files with 806 additions and 34 deletions

View File

@@ -25,7 +25,10 @@ static const float TARGET_TEMP_C = 0.0f; // power-on default: idle (heater off)
static const float AUTOTUNE_DEFAULT_TEMP_C = 40.0f; // autotune when no temp given and idle
static const float TARGET_MIN_C = 0.0f; // 0 = idle (heater off, fan at idle speed)
static const float TARGET_MAX_C = 80.0f;
static const float OVERTEMP_FRACTION = 0.05f; // hard cutoff at target * 1.05
// Absolute max corner temp — heater off + full fan. Decoupled from PID target so you can
// run target 5055 while tuning with headroom for hot corners (ABS in chamber).
static const float EMERGENCY_MAX_TEMP_C = 70.0f;
static const float CORNER_STOP_MARGIN_C = 3.0f; // taper heater when max within this of emergency
// PID on chamber average
static const float PID_KP = 4.0f;
@@ -67,6 +70,9 @@ static const float FAN_OFF_BELOW_TARGET_C = 8.0f; // no heat-up fan when avg thi
static const float FAN_RAMP_BELOW_TARGET_C = 15.0f; // fan ramps in between this and FAN_OFF_BELOW
static const uint8_t FAN_MIX_MAX_PWM = 200; // ~78 % — cap for spread-driven mixing
static const uint8_t FAN_MAX_PWM = 255; // failsafe / over-temp only
// Most 24 V MOSFET modules are active-low (pin LOW = fan on). If off/speed seem wrong,
// try flipping this and reflash. Test: `fan test 0` (off) vs `fan test 200` vs `fan test 255`.
static const bool FAN_PWM_INVERT = true;
// Corner mixing — moderate airflow; full speed reserved for safety
static const float SPREAD_DEADBAND_C = 0.5f;
@@ -84,6 +90,20 @@ static const uint32_t AUTOTUNE_RELAY_STALL_MS = 1500000UL; // 25 min in rel
static const uint32_t AUTOTUNE_SESSION_TIMEOUT_MS = 3600000UL; // 60 min total
static const uint32_t AUTOTUNE_RELAY_PERIOD_MAX_MS = 2400000UL;
// Fan step-response — open-loop heater, fan PWM steps (command: stepresp)
static const float STEPRESP_DEFAULT_TEMP_C = 45.0f;
static const float STEPRESP_DEFAULT_HEATER_PCT = 35.0f;
static const float STEPRESP_MIN_HEATER_PCT = 10.0f;
static const float STEPRESP_MAX_HEATER_PCT = 70.0f;
static const float STEPRESP_PREHEAT_BAND_C = 2.0f;
static const uint32_t STEPRESP_PREHEAT_TIMEOUT_MS = 1200000UL; // 20 min
static const uint32_t STEPRESP_BASELINE_MS = 120000UL; // 2 min fan-off baseline
static const uint32_t STEPRESP_STEP_HOLD_MS = 300000UL; // 5 min per fan level
static const uint32_t STEPRESP_LOG_INTERVAL_MS = 1000UL;
static const uint8_t STEPRESP_FAN_STEPS[] = {0, 77, 140, 200, 255};
static const uint8_t STEPRESP_FAN_STEP_COUNT =
sizeof(STEPRESP_FAN_STEPS) / sizeof(STEPRESP_FAN_STEPS[0]);
// ---------------------------------------------------------------------------
// Timing
// ---------------------------------------------------------------------------