|
|
@ -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
|
|
|
|