From 7268d46508089cf88bf451de67a195df818fc849 Mon Sep 17 00:00:00 2001 From: ayberkozgur Date: Mon, 13 Jul 2015 14:54:14 +0200 Subject: [PATCH] Always calculate extruder temperature PID d term (PR#2432) --- Marlin/temperature.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 2b36477169..a662e99af8 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -476,6 +476,8 @@ float get_pid_output(int e) { #ifdef PIDTEMP #ifndef PID_OPENLOOP pid_error[e] = target_temperature[e] - current_temperature[e]; + dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e]; + temp_dState[e] = current_temperature[e]; if (pid_error[e] > PID_FUNCTIONAL_RANGE) { pid_output = BANG_MAX; pid_reset[e] = true; @@ -494,7 +496,6 @@ float get_pid_output(int e) { temp_iState[e] = constrain(temp_iState[e], temp_iState_min[e], temp_iState_max[e]); iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e]; - dTerm[e] = K2 * PID_PARAM(Kd,e) * (current_temperature[e] - temp_dState[e]) + K1 * dTerm[e]; pid_output = pTerm[e] + iTerm[e] - dTerm[e]; if (pid_output > PID_MAX) { if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration @@ -505,7 +506,6 @@ float get_pid_output(int e) { pid_output = 0; } } - temp_dState[e] = current_temperature[e]; #else pid_output = constrain(target_temperature[e], 0, PID_MAX); #endif //PID_OPENLOOP