|
@@ -137,7 +137,6 @@ volatile bool Temperature::temp_meas_ready = false;
|
137
|
137
|
#endif
|
138
|
138
|
|
139
|
139
|
float Temperature::pid_error[HOTENDS];
|
140
|
|
- bool Temperature::pid_reset[HOTENDS];
|
141
|
140
|
#endif
|
142
|
141
|
|
143
|
142
|
#if ENABLED(PIDTEMPBED)
|
|
@@ -195,7 +194,6 @@ uint8_t Temperature::soft_pwm[HOTENDS];
|
195
|
194
|
#endif
|
196
|
195
|
|
197
|
196
|
#if HAS_PID_HEATING
|
198
|
|
-
|
199
|
197
|
void Temperature::PID_autotune(float temp, int hotend, int ncycles, bool set_result/*=false*/) {
|
200
|
198
|
float input = 0.0;
|
201
|
199
|
int cycles = 0;
|
|
@@ -452,7 +450,6 @@ int Temperature::getHeaterPower(int heater) {
|
452
|
450
|
}
|
453
|
451
|
|
454
|
452
|
#if HAS_AUTO_FAN
|
455
|
|
-
|
456
|
453
|
void Temperature::checkExtruderAutoFans() {
|
457
|
454
|
const int8_t fanPin[] = { EXTRUDER_0_AUTO_FAN_PIN, EXTRUDER_1_AUTO_FAN_PIN, EXTRUDER_2_AUTO_FAN_PIN, EXTRUDER_3_AUTO_FAN_PIN };
|
458
|
455
|
const int fanBit[] = {
|
|
@@ -535,23 +532,17 @@ float Temperature::get_pid_output(int e) {
|
535
|
532
|
#endif
|
536
|
533
|
float pid_output;
|
537
|
534
|
#if ENABLED(PIDTEMP)
|
538
|
|
- #if DISABLED(PID_OPENLOOP)
|
|
535
|
+ #if ENABLED(PID_OPENLOOP)
|
|
536
|
+ pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
|
|
537
|
+ #else
|
539
|
538
|
pid_error[HOTEND_INDEX] = target_temperature[HOTEND_INDEX] - current_temperature[HOTEND_INDEX];
|
540
|
539
|
dTerm[HOTEND_INDEX] = K2 * PID_PARAM(Kd, HOTEND_INDEX) * (current_temperature[HOTEND_INDEX] - temp_dState[HOTEND_INDEX]) + K1 * dTerm[HOTEND_INDEX];
|
541
|
540
|
temp_dState[HOTEND_INDEX] = current_temperature[HOTEND_INDEX];
|
542
|
|
- if (pid_error[HOTEND_INDEX] > PID_FUNCTIONAL_RANGE) {
|
543
|
|
- pid_output = BANG_MAX;
|
544
|
|
- pid_reset[HOTEND_INDEX] = true;
|
545
|
|
- }
|
546
|
|
- else if (pid_error[HOTEND_INDEX] < -(PID_FUNCTIONAL_RANGE) || target_temperature[HOTEND_INDEX] == 0) {
|
|
541
|
+ if (target_temperature[HOTEND_INDEX] == 0) {
|
547
|
542
|
pid_output = 0;
|
548
|
|
- pid_reset[HOTEND_INDEX] = true;
|
|
543
|
+ temp_iState[HOTEND_INDEX] = 0.0;
|
549
|
544
|
}
|
550
|
545
|
else {
|
551
|
|
- if (pid_reset[HOTEND_INDEX]) {
|
552
|
|
- temp_iState[HOTEND_INDEX] = 0.0;
|
553
|
|
- pid_reset[HOTEND_INDEX] = false;
|
554
|
|
- }
|
555
|
546
|
pTerm[HOTEND_INDEX] = PID_PARAM(Kp, HOTEND_INDEX) * pid_error[HOTEND_INDEX];
|
556
|
547
|
temp_iState[HOTEND_INDEX] += pid_error[HOTEND_INDEX];
|
557
|
548
|
iTerm[HOTEND_INDEX] = PID_PARAM(Ki, HOTEND_INDEX) * temp_iState[HOTEND_INDEX];
|
|
@@ -584,8 +575,6 @@ float Temperature::get_pid_output(int e) {
|
584
|
575
|
pid_output = 0;
|
585
|
576
|
}
|
586
|
577
|
}
|
587
|
|
- #else
|
588
|
|
- pid_output = constrain(target_temperature[HOTEND_INDEX], 0, PID_MAX);
|
589
|
578
|
#endif //PID_OPENLOOP
|
590
|
579
|
|
591
|
580
|
#if ENABLED(PID_DEBUG)
|