From 324e501b181a50d74d4b475b48e3fb24354ae6c9 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 12 Dec 2022 13:58:58 +0100 Subject: [PATCH] TM: Set default resistance levels for MK3/MK3S Provide average calibrated values for all fan levels for MK3/MK3S variants and enable the model by default. This ensures the calibration step is not skipped unless explicitly disabled. Force-clear fan values during autotune to restore the previous calibration behavior, as fan resistance levels can be too big and prevent the autotune-with-selfcheck to fail. --- Firmware/temp_model.h | 1 + Firmware/temperature.cpp | 11 +++++++---- Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h | 3 +++ Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Firmware/temp_model.h b/Firmware/temp_model.h index c1a851536..47d86d600 100644 --- a/Firmware/temp_model.h +++ b/Firmware/temp_model.h @@ -15,6 +15,7 @@ constexpr uint8_t TEMP_MODEL_LAG_SIZE = (TEMP_MODEL_LAG / TEMP_MGR_INTV + 0.5); // resistance values for all fan levels constexpr uint8_t TEMP_MODEL_R_SIZE = (1 << FAN_SOFT_PWM_BITS); +static const float TEMP_MODEL_R_DEFAULT[TEMP_MODEL_R_SIZE] PROGMEM = TEMP_MODEL_Rv; namespace temp_model { diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 7427711b3..39c5b1590 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2581,14 +2581,13 @@ void temp_model_reset_settings() temp_model::data.P = TEMP_MODEL_P; temp_model::data.C = TEMP_MODEL_C; - temp_model::data.R[0] = TEMP_MODEL_R; - for(uint8_t i = 1; i != TEMP_MODEL_R_SIZE; ++i) - temp_model::data.R[i] = NAN; + for(uint8_t i = 0; i != TEMP_MODEL_R_SIZE; ++i) + temp_model::data.R[i] = pgm_read_float(TEMP_MODEL_R_DEFAULT + i); temp_model::data.Ta_corr = TEMP_MODEL_Ta_corr; temp_model::data.warn = TEMP_MODEL_W; temp_model::data.err = TEMP_MODEL_E; temp_model::warn_beep = true; - temp_model::enabled = false; + temp_model::enabled = true; temp_model::valid = false; } @@ -2844,6 +2843,10 @@ static bool autotune(int16_t cal_temp) wait(30000); for(int8_t i = TEMP_MODEL_R_SIZE - 1; i > 0; i -= TEMP_MODEL_CAL_R_STEP) { + // always disable the checker while estimating fan resistance as the difference + // (esp with 3rd-party blowers) can be massive + temp_model::data.R[i] = NAN; + uint8_t speed = 256 / TEMP_MODEL_R_SIZE * (i + 1) - 1; set_fan_speed(speed); wait(10000); diff --git a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h index e35a58f9a..95fede839 100644 --- a/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3-EINSy10a-E3Dv6full.h @@ -437,6 +437,9 @@ #define TEMP_MODEL_CAL_Th 230 // Default calibration working temperature (C) #define TEMP_MODEL_CAL_Tl 50 // Default calibration cooling temperature (C) +// fall-back resistance vector (R0-15) +#define TEMP_MODEL_Rv {TEMP_MODEL_R, 18.4, 16.7, 15.2, 14.1, 13.3, 12.7, 12.1, 11.7, 11.3, 11., 10.8, 10.6, 10.4, 10.2, 10.1} + /*------------------------------------ MOTOR CURRENT SETTINGS diff --git a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h index 3560e484e..9058a57f9 100644 --- a/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h +++ b/Firmware/variants/1_75mm_MK3S-EINSy10a-E3Dv6full.h @@ -441,6 +441,9 @@ #define TEMP_MODEL_CAL_Th 230 // Default calibration working temperature (C) #define TEMP_MODEL_CAL_Tl 50 // Default calibration cooling temperature (C) +// fall-back resistance vector (R0-15) +#define TEMP_MODEL_Rv {TEMP_MODEL_R, 18.4, 16.7, 15.2, 14.1, 13.3, 12.7, 12.1, 11.7, 11.3, 11., 10.8, 10.6, 10.4, 10.2, 10.1} + /*------------------------------------ MOTOR CURRENT SETTINGS