|
|
@ -137,7 +137,6 @@ volatile bool Temperature::temp_meas_ready = false;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
float Temperature::pid_error[HOTENDS];
|
|
|
|
float Temperature::pid_error[HOTENDS];
|
|
|
|
bool Temperature::pid_reset[HOTENDS];
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
|
|
|
#if ENABLED(PIDTEMPBED)
|
|
|
@ -195,7 +194,6 @@ uint8_t Temperature::soft_pwm[HOTENDS];
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_PID_HEATING
|
|
|
|
#if HAS_PID_HEATING
|
|
|
|
|
|
|
|
|
|
|
|
void Temperature::PID_autotune(float temp, int hotend, int ncycles, bool set_result/*=false*/) {
|
|
|
|
void Temperature::PID_autotune(float temp, int hotend, int ncycles, bool set_result/*=false*/) {
|
|
|
|
float input = 0.0;
|
|
|
|
float input = 0.0;
|
|
|
|
int cycles = 0;
|
|
|
|
int cycles = 0;
|
|
|
@ -452,7 +450,6 @@ int Temperature::getHeaterPower(int heater) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if HAS_AUTO_FAN
|
|
|
|
#if HAS_AUTO_FAN
|
|
|
|
|
|
|
|
|
|
|
|
void Temperature::checkExtruderAutoFans() {
|
|
|
|
void Temperature::checkExtruderAutoFans() {
|
|
|
|
const int8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
|
|
|
|
const int8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
|
|
|
|
const int fanBit[] = {
|
|
|
|
const int fanBit[] = {
|
|
|
@ -535,23 +532,17 @@ float Temperature::get_pid_output(int e) {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
float pid_output;
|
|
|
|
float pid_output;
|
|
|
|
#if ENABLED(PIDTEMP)
|
|
|
|
#if ENABLED(PIDTEMP)
|
|
|
|
#if DISABLED(PID_OPENLOOP)
|
|
|
|
#if ENABLED(PID_OPENLOOP)
|
|
|
|
|
|
|
|
pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
|
|
|
|
|
|
|
|
#else
|
|
|
|
pid_error[HOTEND_INDEX] = target_temperature[HOTEND_INDEX] - current_temperature[HOTEND_INDEX];
|
|
|
|
pid_error[HOTEND_INDEX] = target_temperature[HOTEND_INDEX] - current_temperature[HOTEND_INDEX];
|
|
|
|
dTerm[HOTEND_INDEX] = K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + K1 * dTerm[HOTEND_INDEX];
|
|
|
|
dTerm[HOTEND_INDEX] = K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + K1 * dTerm[HOTEND_INDEX];
|
|
|
|
temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
|
|
|
|
temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
|
|
|
|
if (pid_error[HOTEND_INDEX] > PID_FUNCTIONAL_RANGE) {
|
|
|
|
if (target_temperature[HOTEND_INDEX] == 0) {
|
|
|
|
pid_output = BANG_MAX;
|
|
|
|
|
|
|
|
pid_reset[HOTEND_INDEX] = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (pid_error[HOTEND_INDEX] < -(PID_FUNCTIONAL_RANGE) || target_temperature[HOTEND_INDEX] == 0) {
|
|
|
|
|
|
|
|
pid_output = 0;
|
|
|
|
pid_output = 0;
|
|
|
|
pid_reset[HOTEND_INDEX] = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
if (pid_reset[HOTEND_INDEX]) {
|
|
|
|
|
|
|
|
temp_iState[HOTEND_INDEX] = 0.0;
|
|
|
|
temp_iState[HOTEND_INDEX] = 0.0;
|
|
|
|
pid_reset[HOTEND_INDEX] = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
pTerm[HOTEND_INDEX] = PID_PARAM(Kp, HOTEND_INDEX) * pid_error[HOTEND_INDEX];
|
|
|
|
pTerm[HOTEND_INDEX] = PID_PARAM(Kp, HOTEND_INDEX) * pid_error[HOTEND_INDEX];
|
|
|
|
temp_iState[HOTEND_INDEX] += pid_error[HOTEND_INDEX];
|
|
|
|
temp_iState[HOTEND_INDEX] += pid_error[HOTEND_INDEX];
|
|
|
|
iTerm[HOTEND_INDEX] = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX];
|
|
|
|
iTerm[HOTEND_INDEX] = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX];
|
|
|
@ -584,8 +575,6 @@ float Temperature::get_pid_output(int e) {
|
|
|
|
pid_output = 0;
|
|
|
|
pid_output = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
|
|
|
|
pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
|
|
|
|
|
|
|
|
#endif //PID_OPENLOOP
|
|
|
|
#endif //PID_OPENLOOP
|
|
|
|
|
|
|
|
|
|
|
|
#if ENABLED(PID_DEBUG)
|
|
|
|
#if ENABLED(PID_DEBUG)
|
|
|
|