From a504c883468829d487f63a048996fe0db037daf2 Mon Sep 17 00:00:00 2001
From: daid <daid303@gmail.com>
Date: Thu, 1 Aug 2013 14:12:30 +0200
Subject: [PATCH] Fix a bug where the PID controllers D action kicks in hard as
 soon as the PID controller starts.

---
 Marlin/temperature.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp
index f5df7a1e72..5cbe1b4fa7 100644
--- a/Marlin/temperature.cpp
+++ b/Marlin/temperature.cpp
@@ -436,10 +436,9 @@ void manage_heater()
           //K1 defined in Configuration.h in the PID settings
           #define K2 (1.0-K1)
           dTerm[e] = (Kd * (pid_input - temp_dState[e]))*K2 + (K1 * dTerm[e]);
-          temp_dState[e] = pid_input;
-
           pid_output = constrain(pTerm[e] + iTerm[e] - dTerm[e], 0, PID_MAX);
         }
+        temp_dState[e] = pid_input;
     #else 
           pid_output = constrain(target_temperature[e], 0, PID_MAX);
     #endif //PID_OPENLOOP
-- 
GitLab