From dc0b490bf0ad4f3e5a5bcaad13e88c84d220fb62 Mon Sep 17 00:00:00 2001 From: Giuliano Zaro <3684609+GMagician@users.noreply.github.com> Date: Fri, 9 Sep 2022 20:54:29 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20heater=20timeout=20PID=20o?= =?UTF-8?q?utput=20(#24682)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/module/temperature.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Marlin/src/module/temperature.cpp b/Marlin/src/module/temperature.cpp index 1372f2ec72..dd5712e1b0 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1391,6 +1391,8 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { float Temperature::get_pid_output_hotend(const uint8_t E_NAME) { const uint8_t ee = HOTEND_INDEX; + const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); + #if ENABLED(PIDTEMP) typedef PIDRunner PIDRunnerHotend; @@ -1400,7 +1402,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { REPEAT(HOTENDS, _HOTENDPID) }; - const float pid_output = hotend_pid[ee].get_pid_output(); + const float pid_output = is_idling ? 0 : hotend_pid[ee].get_pid_output(); #if ENABLED(PID_DEBUG) if (ee == active_extruder) @@ -1463,7 +1465,7 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { hotend.modeled_ambient_temp += delta_to_apply > 0.f ? _MAX(delta_to_apply, MPC_MIN_AMBIENT_CHANGE * MPC_dT) : _MIN(delta_to_apply, -MPC_MIN_AMBIENT_CHANGE * MPC_dT); float power = 0.0; - if (hotend.target != 0 && TERN1(HEATER_IDLE_HANDLER, !heater_idle[ee].timed_out)) { + if (hotend.target != 0 && !is_idling) { // Plan power level to get to target temperature in 2 seconds power = (hotend.target - hotend.modeled_block_temp) * constants.block_heat_capacity / 2.0f; power -= (hotend.modeled_ambient_temp - hotend.modeled_block_temp) * ambient_xfer_coeff; @@ -1489,7 +1491,6 @@ void Temperature::min_temp_error(const heater_id_t heater_id) { #else // No PID or MPC enabled - const bool is_idling = TERN0(HEATER_IDLE_HANDLER, heater_idle[ee].timed_out); const float pid_output = (!is_idling && temp_hotend[ee].is_below_target()) ? BANG_MAX : 0; #endif