Removal of functional range constraint

Also lined up the >> 1 and / 2 mentioned earlier in the unconstrained I term issue,
This commit is contained in:
Rerouter 2016-10-02 08:43:46 +11:00 committed by Scott Lahteine
parent 5f5d87cad3
commit 02fe9cf558
2 changed files with 5 additions and 17 deletions

View File

@ -137,7 +137,6 @@ volatile bool Temperature::temp_meas_ready = false;
#endif
float Temperature::pid_error[HOTENDS];
bool Temperature::pid_reset[HOTENDS];
#endif
#if ENABLED(PIDTEMPBED)
@ -195,7 +194,6 @@ uint8_t Temperature::soft_pwm[HOTENDS];
#endif
#if HAS_PID_HEATING
void Temperature::PID_autotune(float temp, int hotend, int ncycles, bool set_result/*=false*/) {
float input = 0.0;
int cycles = 0;
@ -452,7 +450,6 @@ int Temperature::getHeaterPower(int heater) {
}
#if HAS_AUTO_FAN
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 int fanBit[] = {
@ -535,23 +532,17 @@ float Temperature::get_pid_output(int e) {
#endif
float pid_output;
#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];
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];
if (pid_error[HOTEND_INDEX] > PID_FUNCTIONAL_RANGE) {
pid_output = BANG_MAX;
pid_reset[HOTEND_INDEX] = true;
}
else if (pid_error[HOTEND_INDEX] < -(PID_FUNCTIONAL_RANGE) || target_temperature[HOTEND_INDEX] == 0) {
if (target_temperature[HOTEND_INDEX] == 0) {
pid_output = 0;
pid_reset[HOTEND_INDEX] = true;
temp_iState[HOTEND_INDEX] = 0.0;
}
else {
if (pid_reset[HOTEND_INDEX]) {
temp_iState[HOTEND_INDEX] = 0.0;
pid_reset[HOTEND_INDEX] = false;
}
pTerm[HOTEND_INDEX] = PID_PARAM(Kp, 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];
@ -584,8 +575,6 @@ float Temperature::get_pid_output(int e) {
pid_output = 0;
}
}
#else
pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
#endif //PID_OPENLOOP
#if ENABLED(PID_DEBUG)

View File

@ -158,7 +158,6 @@ class Temperature {
#endif
static float pid_error[HOTENDS];
static bool pid_reset[HOTENDS];
#endif
#if ENABLED(PIDTEMPBED)