From 984177c40cd3d6dc897d8f11407d6c424037843e Mon Sep 17 00:00:00 2001 From: David Forrest Date: Sun, 8 Jun 2014 01:05:11 -0400 Subject: [PATCH] temperature.cpp:Add PID Conditional integration on heated bed. --- Marlin/temperature.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index f0b6f20ee..e7f640953 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -565,7 +565,14 @@ void manage_heater() dTerm_bed= (bedKd * (pid_input - temp_dState_bed))*K2 + (K1 * dTerm_bed); temp_dState_bed = pid_input; - pid_output = constrain(pTerm_bed + iTerm_bed - dTerm_bed, 0, MAX_BED_POWER); + pid_output = pTerm_bed + iTerm_bed - dTerm_bed; + if (pid_output > MAX_BED_PID) { + if (pid_error_bed > 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration + pid_output=PID_MAX; + } else if (pid_output < 0){ + if (pid_error_bed < 0 ) temp_iState_bed -= pid_error_bed; // conditional un-integration + pid_output=0; + } #else pid_output = constrain(target_temperature_bed, 0, MAX_BED_POWER);