From 85a47d61e62713c00f2512415701631e3c53b78f 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 c8e69e7010..b97824c305 100644 --- a/Marlin/src/module/temperature.cpp +++ b/Marlin/src/module/temperature.cpp @@ -1394,6 +1394,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; @@ -1403,7 +1405,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) @@ -1466,7 +1468,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; @@ -1492,7 +1494,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