Only a single E axis. Can tool-change reseed position[E_AXIS]?

This commit is contained in:
Scott Lahteine 2016-07-11 22:06:44 -07:00
parent 0ccc5d1dd9
commit 11dcbae7a2
2 changed files with 15 additions and 13 deletions

View file

@ -128,7 +128,7 @@ volatile bool Temperature::temp_meas_ready = false;
#if ENABLED(PID_ADD_EXTRUSION_RATE) #if ENABLED(PID_ADD_EXTRUSION_RATE)
float Temperature::cTerm[HOTENDS]; float Temperature::cTerm[HOTENDS];
long Temperature::last_position[HOTENDS]; long Temperature::last_e_position;
long Temperature::lpq[LPQ_MAX_LEN]; long Temperature::lpq[LPQ_MAX_LEN];
int Temperature::lpq_ptr = 0; int Temperature::lpq_ptr = 0;
#endif #endif
@ -444,11 +444,11 @@ Temperature::Temperature() { }
void Temperature::updatePID() { void Temperature::updatePID() {
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
#if ENABLED(PID_ADD_EXTRUSION_RATE)
last_e_position = 0;
#endif
HOTEND_LOOP() { HOTEND_LOOP() {
temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e); temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
#if ENABLED(PID_ADD_EXTRUSION_RATE)
last_position[e] = 0;
#endif
} }
#endif #endif
#if ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPBED)
@ -531,10 +531,8 @@ float Temperature::get_pid_output(int e) {
#if HOTENDS == 1 #if HOTENDS == 1
UNUSED(e); UNUSED(e);
#define _HOTEND_TEST true #define _HOTEND_TEST true
#define _HOTEND_EXTRUDER active_extruder
#else #else
#define _HOTEND_TEST e == active_extruder #define _HOTEND_TEST e == active_extruder
#define _HOTEND_EXTRUDER e
#endif #endif
float pid_output; float pid_output;
#if ENABLED(PIDTEMP) #if ENABLED(PIDTEMP)
@ -566,14 +564,14 @@ float Temperature::get_pid_output(int e) {
cTerm[HOTEND_INDEX] = 0; cTerm[HOTEND_INDEX] = 0;
if (_HOTEND_TEST) { if (_HOTEND_TEST) {
long e_position = stepper.position(E_AXIS); long e_position = stepper.position(E_AXIS);
if (e_position > last_position[_HOTEND_EXTRUDER]) { if (e_position > last_e_position) {
lpq[lpq_ptr++] = e_position - last_position[_HOTEND_EXTRUDER]; lpq[lpq_ptr] = e_position - last_e_position;
last_position[_HOTEND_EXTRUDER] = e_position; last_e_position = 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[HOTEND_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX); cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
pid_output += cTerm[HOTEND_INDEX]; pid_output += cTerm[HOTEND_INDEX];
} }
@ -952,7 +950,7 @@ void Temperature::init() {
temp_iState_min[e] = 0.0; temp_iState_min[e] = 0.0;
temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e); temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
#if ENABLED(PID_ADD_EXTRUSION_RATE) #if ENABLED(PID_ADD_EXTRUSION_RATE)
last_position[e] = 0; last_e_position = 0;
#endif #endif
#endif //PIDTEMP #endif //PIDTEMP
#if ENABLED(PIDTEMPBED) #if ENABLED(PIDTEMPBED)
@ -961,6 +959,10 @@ void Temperature::init() {
#endif //PIDTEMPBED #endif //PIDTEMPBED
} }
#if ENABLED(PIDTEMP) && ENABLED(PID_ADD_EXTRUSION_RATE)
last_e_position = 0;
#endif
#if HAS_HEATER_0 #if HAS_HEATER_0
SET_OUTPUT(HEATER_0_PIN); SET_OUTPUT(HEATER_0_PIN);
#endif #endif

View file

@ -150,7 +150,7 @@ class Temperature {
#if ENABLED(PID_ADD_EXTRUSION_RATE) #if ENABLED(PID_ADD_EXTRUSION_RATE)
static float cTerm[HOTENDS]; static float cTerm[HOTENDS];
static long last_position[HOTENDS]; static long last_e_position;
static long lpq[LPQ_MAX_LEN]; static long lpq[LPQ_MAX_LEN];
static int lpq_ptr; static int lpq_ptr;
#endif #endif