mirror of
https://github.com/MarlinFirmware/Marlin.git
synced 2024-11-27 22:08:02 +00:00
PID_ADD_EXTRUSION_RATE based on MarlinKimbra
This commit is contained in:
parent
92ac133f2b
commit
0c7c45063b
@ -417,19 +417,29 @@ float Temperature::get_pid_output(int e) {
|
|||||||
|
|
||||||
pid_output = pTerm[e] + iTerm[e] - dTerm[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)
|
#if ENABLED(PID_ADD_EXTRUSION_RATE)
|
||||||
cTerm[e] = 0;
|
cTerm[_CTERM_INDEX] = 0;
|
||||||
if (e == active_extruder) {
|
if (_NOZZLE_TEST) {
|
||||||
long e_position = stepper.position(E_AXIS);
|
long e_position = stepper.position(E_AXIS);
|
||||||
if (e_position > last_position[e]) {
|
if (e_position > last_position[_NOZZLE_EXTRUDER]) {
|
||||||
lpq[lpq_ptr++] = e_position - last_position[e];
|
lpq[lpq_ptr++] = e_position - last_position[_NOZZLE_EXTRUDER];
|
||||||
last_position[e] = e_position;
|
last_position[_NOZZLE_EXTRUDER] = e_position;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lpq[lpq_ptr++] = 0;
|
lpq[lpq_ptr++] = 0;
|
||||||
}
|
}
|
||||||
if (lpq_ptr >= lpq_len) 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];
|
pid_output += cTerm[e];
|
||||||
}
|
}
|
||||||
#endif //PID_ADD_EXTRUSION_RATE
|
#endif //PID_ADD_EXTRUSION_RATE
|
||||||
|
Loading…
Reference in New Issue
Block a user