#pragma once // --------------------------------------------------------------------------- // I2C — Nano default: A4 (SDA), A5 (SCL). Wire handles pin assignment. // --------------------------------------------------------------------------- static const uint8_t TCA9548A_ADDRESS = 0x70; // Four SHT31 sensors on TCA9548A channels 2, 3, 4, 5 static const uint8_t SENSOR_CHANNELS[] = {2, 3, 4, 5}; static const uint8_t SENSOR_COUNT = sizeof(SENSOR_CHANNELS) / sizeof(SENSOR_CHANNELS[0]); // SHT31 I2C address (ADDR pin low → 0x44, high → 0x45) static const uint8_t SHT31_ADDRESS = 0x44; // --------------------------------------------------------------------------- // Outputs — D5 has hardware PWM; heater on A2 uses burst control (SSR-friendly) // --------------------------------------------------------------------------- static const uint8_t FAN_PIN = 5; // D5 — 24 V fan via N-channel MOSFET static const uint8_t HEATER_PIN = A2; // heater via solid-state relay // --------------------------------------------------------------------------- // Temperature control // --------------------------------------------------------------------------- static const float TARGET_TEMP_C = 0.0f; static const float AUTOTUNE_DEFAULT_TEMP_C = 40.0f; static const float TARGET_MIN_C = 0.0f; static const float TARGET_MAX_C = 80.0f; // Absolute max corner — heater off + full fan (decoupled from PID target). static const float EMERGENCY_MAX_TEMP_C = 70.0f; static const float CORNER_STOP_MARGIN_C = 3.0f; // Dual PI — heat on avg, mix on spread (no D term) static const float HEAT_PI_KP = 4.0f; static const float HEAT_PI_KI = 0.05f; 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; // Legacy aliases for autotuner relay math only static const float PID_KP = HEAT_PI_KP; static const float PID_KI = HEAT_PI_KI; static const float PID_KD = 0.0f; static const float GOOD_SPREAD_C = 5.0f; // Tiered heater cap during heat-up static const float HEATER_MAX_DUTY_COLD = 85.0f; static const float HEATER_MAX_DUTY_MID = 65.0f; static const float HEATER_MAX_DUTY_NEAR = 45.0f; static const float HEATER_COLD_BELOW_C = 10.0f; static const float HEATER_WARM_BELOW_C = 3.0f; static const float CORNER_LIMIT_BAND_C = 10.0f; static const float HEATER_SLEW_UP_PER_S = 18.0f; static const float MAX_TEMP_HEADROOM_C = 15.0f; static const uint16_t HEATER_CYCLE_MS = 3000; // Fan PWM 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; static const bool FAN_PWM_INVERT = true; static const float SPREAD_EMA_ALPHA = 0.45f; // PID auto-tune (relay method) — heat PI only static const float AUTOTUNE_HYSTERESIS_C = 0.4f; static const float AUTOTUNE_PREHEAT_BAND_C = 3.0f; static const float AUTOTUNE_PREHEAT_DUTY = 100.0f; static const uint8_t AUTOTUNE_PREHEAT_FAN_PWM = 0; static const uint8_t AUTOTUNE_CYCLES_REQUIRED = 5; static const uint32_t AUTOTUNE_PREHEAT_TIMEOUT_MS = 1200000UL; 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]); // --------------------------------------------------------------------------- // Timing // --------------------------------------------------------------------------- static const uint32_t SENSOR_READ_INTERVAL_MS = 1000; static const uint32_t CONTROL_INTERVAL_MS = 500; static const uint32_t SERIAL_REPORT_INTERVAL_MS = 2000; static const bool LOG_CSV_DEFAULT = false;