From 55ba90ac195caa11115d74ea267802a6aafb8aea Mon Sep 17 00:00:00 2001 From: daid303 Date: Wed, 12 Dec 2012 09:08:37 +0100 Subject: [PATCH] Add PID functional range setting. With high powered heaters the current functional range of 10 degrees causes high overshoots as the PID needs to kick in before the temperature hits 10 degrees below target. --- Marlin/Configuration.h | 4 +++- Marlin/temperature.cpp | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9aa2e0d499..d7d35d2400 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -113,9 +113,11 @@ #ifdef PIDTEMP //#define PID_DEBUG // Sends debug data to the serial port. //#define PID_OPENLOOP 1 // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX + #define PID_FUNCTIONAL_RANGE 10 // If the temperature difference between the target temperature and the actual temperature + // is more then PID_FUNCTIONAL_RANGE then the PID will be shut off and the heater will be set to min/max. #define PID_INTEGRAL_DRIVE_MAX 255 //limit for the integral term #define K1 0.95 //smoothing factor withing the PID - #define PID_dT ((16.0 * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the + #define PID_dT ((16.0 * 8.0)/(F_CPU / 64.0 / 256.0)) //sampling period of the temperature routine // If you are using a preconfigured hotend then you can use one of the value sets by uncommenting it // Ultimaker diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index 663ea679ea..5a0762d9f1 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -319,11 +319,11 @@ void manage_heater() #ifndef PID_OPENLOOP pid_error[e] = target_temperature[e] - pid_input; - if(pid_error[e] > 10) { + if(pid_error[e] > PID_FUNCTIONAL_RANGE) { pid_output = PID_MAX; pid_reset[e] = true; } - else if(pid_error[e] < -10) { + else if(pid_error[e] < -PID_FUNCTIONAL_RANGE) { pid_output = 0; pid_reset[e] = true; }