Selaa lähdekoodia

Removal of functional range constraint

Also lined up the >> 1 and / 2 mentioned earlier in the unconstrained I term issue,
Rerouter 8 vuotta sitten
vanhempi
commit
02fe9cf558
2 muutettua tiedostoa jossa 5 lisäystä ja 17 poistoa
  1. 5
    16
      Marlin/temperature.cpp
  2. 0
    1
      Marlin/temperature.h

+ 5
- 16
Marlin/temperature.cpp Näytä tiedosto

@@ -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)

+ 0
- 1
Marlin/temperature.h Näytä tiedosto

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

Loading…
Peruuta
Tallenna