add fanchars

This commit is contained in:
2026-07-06 22:19:43 +02:00
parent 55cf03c015
commit 8182b9efd2
9 changed files with 296 additions and 439 deletions

View File

@@ -36,7 +36,9 @@ static const float MIX_PI_KP = 40.0f;
static const float MIX_PI_KI = 2.0f;
static const float SPREAD_TARGET_C = 0.5f;
static const float HEAT_UP_BAND_C = 8.0f;
static const uint8_t FAN_COLD_CAP_PWM = 0;
// Mix PI only at/above target; below target use minimum stir only (no mix PI).
// Cap mix fan — high airflow often increases spread / heat loss rather than fixing it.
static const uint8_t FAN_MIX_MAX_PWM = 140;
// Legacy aliases for autotuner relay math only
static const float PID_KP = HEAT_PI_KP;
@@ -56,7 +58,7 @@ static const float MAX_TEMP_HEADROOM_C = 15.0f;
static const uint16_t HEATER_CYCLE_MS = 3000;
// Fan PWM
// Fan PWM — FAN_IDLE_PWM ≈ 30%; off only while chamber avg is below 40°C
static const uint8_t FAN_IDLE_PWM = 77;
static const float IDLE_AUTO_FAN_OFF_TEMP_C = 40.0f;
static const uint8_t FAN_MAX_PWM = 255;
@@ -75,19 +77,22 @@ static const uint32_t AUTOTUNE_RELAY_STALL_MS = 1500000UL;
static const uint32_t AUTOTUNE_SESSION_TIMEOUT_MS = 3600000UL;
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;
static const uint32_t STEPRESP_BASELINE_MS = 120000UL;
static const uint32_t STEPRESP_STEP_HOLD_MS = 300000UL;
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]);
// Fan characterize — fixed heater, sweep fan PWMs, pick lowest spread
static const float FANCHARS_MAX_CORNER_C = 60.0f;
static const float FANCHARS_COOL_AVG_C = 40.0f;
static const float FANCHARS_PRECOOL_MARGIN_C = 2.0f;
static const float FANCHARS_HEATER_PCT = 85.0f;
// Coarse sweep order: 30%, 100%, 60%, 80% fan
static const uint8_t FANCHARS_COARSE_PWM[] = {77, 255, 153, 204};
static const uint8_t FANCHARS_COARSE_COUNT =
sizeof(FANCHARS_COARSE_PWM) / sizeof(FANCHARS_COARSE_PWM[0]);
static const uint8_t FANCHARS_LIMIT_LOW_PWM = 77;
static const uint8_t FANCHARS_LIMIT_HIGH_PWM = 255;
static const uint8_t FANCHARS_MAX_RESULTS = FANCHARS_COARSE_COUNT + 1;
static const uint32_t FANCHARS_HOLD_MS = 60000UL;
static const uint32_t FANCHARS_HEAT_TIMEOUT_MS = 2700000UL;
static const uint32_t FANCHARS_COOLDOWN_TIMEOUT_MS = 2700000UL;
static const uint32_t FANCHARS_LOG_INTERVAL_MS = 1000UL;
// ---------------------------------------------------------------------------
// Timing