From 0c7c45063be83d4e01dfb3ed61f3cf8142d10cec Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Fri, 20 May 2016 15:57:51 -0700 Subject: [PATCH] PID_ADD_EXTRUSION_RATE based on MarlinKimbra --- Marlin/temperature.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index ebebc3bd2..10a503472 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -417,19 +417,29 @@ float Temperature::get_pid_output(int e) { pid_output = pTerm[e] + iTerm[e] - dTerm[e]; + #if ENABLED(SINGLENOZZLE) + #define _NOZZLE_TEST true + #define _NOZZLE_EXTRUDER active_extruder + #define _CTERM_INDEX 0 + #else + #define _NOZZLE_TEST e == active_extruder + #define _NOZZLE_EXTRUDER e + #define _CTERM_INDEX e + #endif + #if ENABLED(PID_ADD_EXTRUSION_RATE) - cTerm[e] = 0; - if (e == active_extruder) { + cTerm[_CTERM_INDEX] = 0; + if (_NOZZLE_TEST) { long e_position = stepper.position(E_AXIS); - if (e_position > last_position[e]) { - lpq[lpq_ptr++] = e_position - last_position[e]; - last_position[e] = e_position; + if (e_position > last_position[_NOZZLE_EXTRUDER]) { + lpq[lpq_ptr++] = e_position - last_position[_NOZZLE_EXTRUDER]; + last_position[_NOZZLE_EXTRUDER] = e_position; } else { lpq[lpq_ptr++] = 0; } if (lpq_ptr >= lpq_len) lpq_ptr = 0; - cTerm[e] = (lpq[lpq_ptr] / planner.axis_steps_per_unit[E_AXIS]) * PID_PARAM(Kc, e); + cTerm[_CTERM_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_unit[E_AXIS]) * PID_PARAM(Kc, e); pid_output += cTerm[e]; } #endif //PID_ADD_EXTRUSION_RATE