From 28c29e4093796d2b2202d3eb047547d3e55c58ec Mon Sep 17 00:00:00 2001 From: "Ben V. Brown" Date: Sat, 8 Jun 2024 20:30:32 +1000 Subject: [PATCH] Compensate for heater coil resistance change --- source/Core/BSP/Sequre/BSP.cpp | 20 +++++++++++++++++++- source/Core/BSP/Sequre/configuration.h | 22 +++++++++++++--------- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/source/Core/BSP/Sequre/BSP.cpp b/source/Core/BSP/Sequre/BSP.cpp index 436cd22f35..16d6dfd611 100644 --- a/source/Core/BSP/Sequre/BSP.cpp +++ b/source/Core/BSP/Sequre/BSP.cpp @@ -246,7 +246,25 @@ uint64_t getDeviceID() { return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32); } -uint8_t getTipResistanceX10() { return TIP_RESISTANCE; } +uint8_t getTipResistanceX10() { +#ifdef COPPER_HEATER_COIL + + // TODO + //! Warning, must never return 0. + TemperatureType_t measuredTemperature = TipThermoModel::getTipInC(false); + if (measuredTemperature < 25) { + return 50; // Start assuming under spec to soft-start + } + + // Assuming a temperature rise of 0.00393 per deg c over 20C + + uint32_t scaler = 393 * (measuredTemperature - 20); + + return TIP_RESISTANCE + ((TIP_RESISTANCE * scaler) / 100000); +#else + return TIP_RESISTANCE; +#endif +} bool isTipShorted() { return false; } uint8_t preStartChecksDone() { return 1; } diff --git a/source/Core/BSP/Sequre/configuration.h b/source/Core/BSP/Sequre/configuration.h index 8a8345d4b8..9813e91521 100644 --- a/source/Core/BSP/Sequre/configuration.h +++ b/source/Core/BSP/Sequre/configuration.h @@ -99,9 +99,6 @@ #define DETAILED_SOLDERING 0 // 0: Disable 1: Enable - Default 0 #define DETAILED_IDLE 0 // 0: Disable 1: Enable - Default 0 -#define THERMAL_RUNAWAY_TIME_SEC 20 -#define THERMAL_RUNAWAY_TEMP_C 10 - #define CUT_OUT_SETTING 0 // default to no cut-off voltage #define RECOM_VOL_CELL 33 // Minimum voltage per cell (Recommended 3.3V (33)) #define TEMPERATURE_INF 0 // default to 0 @@ -144,7 +141,9 @@ #define POWER_LIMIT_STEPS 5 #define OP_AMP_GAIN_STAGE 536 #define TEMP_uV_LOOKUP_S60 -#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate +#define USB_PD_VMAX 12 // Maximum voltage for PD to negotiate +#define THERMAL_RUNAWAY_TIME_SEC 20 +#define THERMAL_RUNAWAY_TEMP_C 10 #define HARDWARE_MAX_WATTAGE_X10 600 @@ -176,7 +175,9 @@ #define POWER_LIMIT_STEPS 5 #define OP_AMP_GAIN_STAGE 536 #define TEMP_uV_LOOKUP_S60 -#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate +#define USB_PD_VMAX 20 // Maximum voltage for PD to negotiate +#define THERMAL_RUNAWAY_TIME_SEC 20 +#define THERMAL_RUNAWAY_TEMP_C 10 #define HARDWARE_MAX_WATTAGE_X10 600 @@ -224,10 +225,13 @@ #define NO_SLEEP_MODE #define HARDWARE_MAX_WATTAGE_X10 850 -#define TIP_THERMAL_MASS 10 // X10 watts to raise 1 deg C in 1 second -#define TIP_THERMAL_INERTIA 128 // We use a large inertia value to smooth out the drive to the tip since its stupidly sensitive +#define TIP_THERMAL_MASS 30 // X10 watts to raise 1 deg C in 1 second +#define TIP_THERMAL_INERTIA 10 // We use a large inertia value to smooth out the drive to the tip since its stupidly sensitive +#define THERMAL_RUNAWAY_TIME_SEC 60 +#define THERMAL_RUNAWAY_TEMP_C 3 -#define TIP_RESISTANCE 52 // PCB heater, measured at ~19C. Will shift by temp a decent amount +#define COPPER_HEATER_COIL 1 // Have a heater coil that changes resistance on us +#define TIP_RESISTANCE 52 // PCB heater, measured at ~19C. Will shift by temp a decent amount #define CUSTOM_MAX_TEMP_C #define PROFILE_SUPPORT 1 // Soldering Profiles #define OLED_128x32 1 // Larger OLED @@ -239,7 +243,7 @@ #define NO_ACCEL 1 #define I2C_SOFT_BUS_2 // For now we are doing software I2C to get around hardware chip issues #define OLED_I2CBB2 -#define FILTER_DISPLAYED_TIP_TEMP 4 // Filtering for GUI display +#define FILTER_DISPLAYED_TIP_TEMP 16 // Filtering for GUI display #define MODEL_HAS_DCDC // We dont have DC/DC but have reallly fast PWM that gets us roughly the same place #endif /* T55 */