Browse Source

Merge Extrusion_rate_heater_compensation

Richard Wackerbarth 9 years ago
parent
commit
42e381f8e2

+ 2
- 1
Marlin/Configuration_adv.h View File

41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
42
   #define PID_ADD_EXTRUSION_RATE
42
   #define PID_ADD_EXTRUSION_RATE
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
44
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
44
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
45
+    #define LPQ_MAX_LEN 50
45
   #endif
46
   #endif
46
 #endif
47
 #endif
47
 
48
 

+ 4
- 0
Marlin/Marlin.h View File

329
   extern int meas_delay_cm; //delay distance
329
   extern int meas_delay_cm; //delay distance
330
 #endif
330
 #endif
331
 
331
 
332
+#if ENABLED(PID_ADD_EXTRUSION_RATE)
333
+  extern int lpq_len;
334
+#endif
335
+
332
 #if ENABLED(FWRETRACT)
336
 #if ENABLED(FWRETRACT)
333
   extern bool autoretract_enabled;
337
   extern bool autoretract_enabled;
334
   extern bool retracted[EXTRUDERS]; // extruder[n].retracted
338
   extern bool retracted[EXTRUDERS]; // extruder[n].retracted

+ 16
- 1
Marlin/Marlin_main.cpp View File

420
   boolean chdkActive = false;
420
   boolean chdkActive = false;
421
 #endif
421
 #endif
422
 
422
 
423
+#if ENABLED(PID_ADD_EXTRUSION_RATE)
424
+  int lpq_len = 20;
425
+#endif
426
+
423
 //===========================================================================
427
 //===========================================================================
424
 //================================ Functions ================================
428
 //================================ Functions ================================
425
 //===========================================================================
429
 //===========================================================================
4770
 #if ENABLED(PIDTEMP)
4774
 #if ENABLED(PIDTEMP)
4771
 
4775
 
4772
   /**
4776
   /**
4773
-   * M301: Set PID parameters P I D (and optionally C)
4777
+   * M301: Set PID parameters P I D (and optionally C, L)
4778
+   *
4779
+   *   P[float] Kp term
4780
+   *   I[float] Ki term (unscaled)
4781
+   *   D[float] Kd term (unscaled)
4782
+   *
4783
+   * With PID_ADD_EXTRUSION_RATE:
4784
+   *
4785
+   *   C[float] Kc term
4786
+   *   L[float] LPQ length
4774
    */
4787
    */
4775
   inline void gcode_M301() {
4788
   inline void gcode_M301() {
4776
 
4789
 
4784
       if (code_seen('D')) PID_PARAM(Kd, e) = scalePID_d(code_value());
4797
       if (code_seen('D')) PID_PARAM(Kd, e) = scalePID_d(code_value());
4785
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
4798
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
4786
         if (code_seen('C')) PID_PARAM(Kc, e) = code_value();
4799
         if (code_seen('C')) PID_PARAM(Kc, e) = code_value();
4800
+        if (code_seen('L')) lpq_len = code_value();
4801
+        NOMORE(lpq_len, LPQ_MAX_LEN);
4787
       #endif
4802
       #endif
4788
 
4803
 
4789
       updatePID();
4804
       updatePID();

+ 19
- 3
Marlin/configuration_store.cpp View File

14
  *
14
  *
15
  */
15
  */
16
 
16
 
17
-#define EEPROM_VERSION "V20"
17
+#define EEPROM_VERSION "V21"
18
 
18
 
19
 /**
19
 /**
20
  * V19 EEPROM Layout:
20
  * V19 EEPROM Layout:
60
  *  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1]
60
  *  M301 E1 PIDC  Kp[1], Ki[1], Kd[1], Kc[1]
61
  *  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2]
61
  *  M301 E2 PIDC  Kp[2], Ki[2], Kd[2], Kc[2]
62
  *  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3]
62
  *  M301 E3 PIDC  Kp[3], Ki[3], Kd[3], Kc[3]
63
+ *  M301 L        lpq_len
63
  *
64
  *
64
  * PIDTEMPBED:
65
  * PIDTEMPBED:
65
  *  M304 PID  bedKp, bedKi, bedKd
66
  *  M304 PID  bedKp, bedKi, bedKd
227
 
228
 
228
   } // Extruders Loop
229
   } // Extruders Loop
229
 
230
 
231
+  #if DISABLED(PID_ADD_EXTRUSION_RATE)
232
+    int lpq_len = 20;
233
+  #endif
234
+  EEPROM_WRITE_VAR(i, lpq_len);
235
+
230
   #if DISABLED(PIDTEMPBED)
236
   #if DISABLED(PIDTEMPBED)
231
     float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
237
     float bedKp = DUMMY_PID_VALUE, bedKi = DUMMY_PID_VALUE, bedKd = DUMMY_PID_VALUE;
232
   #endif
238
   #endif
393
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
399
       for (int q=16; q--;) EEPROM_READ_VAR(i, dummy);  // 4x Kp, Ki, Kd, Kc
394
     #endif // !PIDTEMP
400
     #endif // !PIDTEMP
395
 
401
 
402
+    #if DISABLED(PID_ADD_EXTRUSION_RATE)
403
+      int lpq_len;
404
+    #endif
405
+    EEPROM_READ_VAR(i, lpq_len);
406
+
396
     #if DISABLED(PIDTEMPBED)
407
     #if DISABLED(PIDTEMPBED)
397
       float bedKp, bedKi, bedKd;
408
       float bedKp, bedKi, bedKd;
398
     #endif
409
     #endif
539
         PID_PARAM(Kc, e) = DEFAULT_Kc;
550
         PID_PARAM(Kc, e) = DEFAULT_Kc;
540
       #endif
551
       #endif
541
     }
552
     }
553
+    #if ENABLED(PID_ADD_EXTRUSION_RATE)
554
+      lpq_len = 20; // default last-position-queue size
555
+    #endif
542
     // call updatePID (similar to when we have processed M301)
556
     // call updatePID (similar to when we have processed M301)
543
     updatePID();
557
     updatePID();
544
   #endif // PIDTEMP
558
   #endif // PIDTEMP
744
             SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i)));
758
             SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, i)));
745
             #if ENABLED(PID_ADD_EXTRUSION_RATE)
759
             #if ENABLED(PID_ADD_EXTRUSION_RATE)
746
               SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, i));
760
               SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, i));
747
-            #endif      
761
+              if (i == 0) SERIAL_ECHOPAIR(" L", lpq_len);
762
+            #endif
748
             SERIAL_EOL;
763
             SERIAL_EOL;
749
           }
764
           }
750
         }
765
         }
758
         SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
773
         SERIAL_ECHOPAIR(" D", unscalePID_d(PID_PARAM(Kd, 0)));
759
         #if ENABLED(PID_ADD_EXTRUSION_RATE)
774
         #if ENABLED(PID_ADD_EXTRUSION_RATE)
760
           SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
775
           SERIAL_ECHOPAIR(" C", PID_PARAM(Kc, 0));
761
-        #endif      
776
+          SERIAL_ECHOPAIR(" L", lpq_len);
777
+        #endif
762
         SERIAL_EOL;
778
         SERIAL_EOL;
763
       }
779
       }
764
     #endif // PIDTEMP
780
     #endif // PIDTEMP

+ 2
- 1
Marlin/configurator/config/Configuration_adv.h View File

41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
42
   #define PID_ADD_EXTRUSION_RATE
42
   #define PID_ADD_EXTRUSION_RATE
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
44
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
44
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
45
+    #define LPQ_MAX_LEN 50
45
   #endif
46
   #endif
46
 #endif
47
 #endif
47
 
48
 

+ 1
- 0
Marlin/configurator/config/language.h View File

199
 #define MSG_PID_DEBUG_PTERM                 " pTerm "
199
 #define MSG_PID_DEBUG_PTERM                 " pTerm "
200
 #define MSG_PID_DEBUG_ITERM                 " iTerm "
200
 #define MSG_PID_DEBUG_ITERM                 " iTerm "
201
 #define MSG_PID_DEBUG_DTERM                 " dTerm "
201
 #define MSG_PID_DEBUG_DTERM                 " dTerm "
202
+#define MSG_PID_DEBUG_CTERM                 " cTerm "
202
 #define MSG_INVALID_EXTRUDER_NUM            " - Invalid extruder number !"
203
 #define MSG_INVALID_EXTRUDER_NUM            " - Invalid extruder number !"
203
 
204
 
204
 #define MSG_HEATER_BED                      "bed"
205
 #define MSG_HEATER_BED                      "bed"

+ 2
- 1
Marlin/example_configurations/Felix/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/Hephestos/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/K8200/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/RigidBot/Configuration_adv.h View File

41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
42
   #define PID_ADD_EXTRUSION_RATE
42
   #define PID_ADD_EXTRUSION_RATE
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
44
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
44
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
45
+    #define LPQ_MAX_LEN 50
45
   #endif
46
   #endif
46
 #endif
47
 #endif
47
 
48
 

+ 2
- 1
Marlin/example_configurations/SCARA/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/TAZ4/Configuration_adv.h View File

41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
41
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
42
   #define PID_ADD_EXTRUSION_RATE
42
   #define PID_ADD_EXTRUSION_RATE
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
43
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
44
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
44
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
45
+    #define LPQ_MAX_LEN 50
45
   #endif
46
   #endif
46
 #endif
47
 #endif
47
 
48
 

+ 2
- 1
Marlin/example_configurations/WITBOX/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/delta/biv2.5/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/delta/generic/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/delta/kossel_mini/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/delta/kossel_pro/Configuration_adv.h View File

55
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
55
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
56
   #define PID_ADD_EXTRUSION_RATE
56
   #define PID_ADD_EXTRUSION_RATE
57
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
57
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
58
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
58
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
59
+    #define LPQ_MAX_LEN 50
59
   #endif
60
   #endif
60
 #endif
61
 #endif
61
 
62
 

+ 2
- 1
Marlin/example_configurations/makibox/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 2
- 1
Marlin/example_configurations/tvrrug/Round2/Configuration_adv.h View File

51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
51
   // if Kc is chosen well, the additional required power due to increased melting should be compensated.
52
   #define PID_ADD_EXTRUSION_RATE
52
   #define PID_ADD_EXTRUSION_RATE
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
53
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
54
-    #define  DEFAULT_Kc (1) //heating power=Kc*(e_speed)
54
+    #define DEFAULT_Kc (100) //heating power=Kc*(e_speed)
55
+    #define LPQ_MAX_LEN 50
55
   #endif
56
   #endif
56
 #endif
57
 #endif
57
 
58
 

+ 1
- 0
Marlin/language.h View File

200
 #define MSG_PID_DEBUG_PTERM                 " pTerm "
200
 #define MSG_PID_DEBUG_PTERM                 " pTerm "
201
 #define MSG_PID_DEBUG_ITERM                 " iTerm "
201
 #define MSG_PID_DEBUG_ITERM                 " iTerm "
202
 #define MSG_PID_DEBUG_DTERM                 " dTerm "
202
 #define MSG_PID_DEBUG_DTERM                 " dTerm "
203
+#define MSG_PID_DEBUG_CTERM                 " cTerm "
203
 #define MSG_INVALID_EXTRUDER_NUM            " - Invalid extruder number !"
204
 #define MSG_INVALID_EXTRUDER_NUM            " - Invalid extruder number !"
204
 
205
 
205
 #define MSG_HEATER_BED                      "bed"
206
 #define MSG_HEATER_BED                      "bed"

+ 39
- 12
Marlin/temperature.cpp View File

99
   static float pTerm[EXTRUDERS];
99
   static float pTerm[EXTRUDERS];
100
   static float iTerm[EXTRUDERS];
100
   static float iTerm[EXTRUDERS];
101
   static float dTerm[EXTRUDERS];
101
   static float dTerm[EXTRUDERS];
102
+  #if ENABLED(PID_ADD_EXTRUSION_RATE)
103
+    static float cTerm[EXTRUDERS];
104
+    static long last_position[EXTRUDERS];
105
+    static long lpq[LPQ_MAX_LEN];
106
+    static int lpq_ptr = 0;
107
+  #endif
102
   //int output;
108
   //int output;
103
   static float pid_error[EXTRUDERS];
109
   static float pid_error[EXTRUDERS];
104
   static float temp_iState_min[EXTRUDERS];
110
   static float temp_iState_min[EXTRUDERS];
357
   #if ENABLED(PIDTEMP)
363
   #if ENABLED(PIDTEMP)
358
     for (int e = 0; e < EXTRUDERS; e++) {
364
     for (int e = 0; e < EXTRUDERS; e++) {
359
       temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
365
       temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
366
+      #if ENABLED(PID_ADD_EXTRUSION_RATE)
367
+        last_position[e] = 0;
368
+      #endif
360
     }
369
     }
361
   #endif
370
   #endif
362
   #if ENABLED(PIDTEMPBED)
371
   #if ENABLED(PIDTEMPBED)
497
         iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e];
506
         iTerm[e] = PID_PARAM(Ki,e) * temp_iState[e];
498
 
507
 
499
         pid_output = pTerm[e] + iTerm[e] - dTerm[e];
508
         pid_output = pTerm[e] + iTerm[e] - dTerm[e];
509
+
510
+        #if ENABLED(PID_ADD_EXTRUSION_RATE)
511
+          cTerm[e] = 0;
512
+          if (e == active_extruder) {
513
+            long e_position = st_get_position(E_AXIS);
514
+            if (e_position > last_position[e]) {
515
+              lpq[lpq_ptr++] = e_position - last_position[e];
516
+              last_position[e] = e_position;
517
+            } else {
518
+              lpq[lpq_ptr++] = 0;
519
+            }
520
+            if (lpq_ptr >= lpq_len) lpq_ptr = 0;
521
+            cTerm[e] = (lpq[lpq_ptr] / axis_steps_per_unit[E_AXIS]) * Kc;
522
+            pid_output += cTerm[e];
523
+          }
524
+        #endif //PID_ADD_EXTRUSION_RATE
525
+
500
         if (pid_output > PID_MAX) {
526
         if (pid_output > PID_MAX) {
501
           if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
527
           if (pid_error[e] > 0) temp_iState[e] -= pid_error[e]; // conditional un-integration
502
           pid_output = PID_MAX;
528
           pid_output = PID_MAX;
512
 
538
 
513
     #if ENABLED(PID_DEBUG)
539
     #if ENABLED(PID_DEBUG)
514
       SERIAL_ECHO_START;
540
       SERIAL_ECHO_START;
515
-      SERIAL_ECHO(MSG_PID_DEBUG);
516
-      SERIAL_ECHO(e);
517
-      SERIAL_ECHO(MSG_PID_DEBUG_INPUT);
518
-      SERIAL_ECHO(current_temperature[e]);
519
-      SERIAL_ECHO(MSG_PID_DEBUG_OUTPUT);
520
-      SERIAL_ECHO(pid_output);
521
-      SERIAL_ECHO(MSG_PID_DEBUG_PTERM);
522
-      SERIAL_ECHO(pTerm[e]);
523
-      SERIAL_ECHO(MSG_PID_DEBUG_ITERM);
524
-      SERIAL_ECHO(iTerm[e]);
525
-      SERIAL_ECHO(MSG_PID_DEBUG_DTERM);
526
-      SERIAL_ECHOLN(dTerm[e]);
541
+      SERIAL_ECHOPAIR(MSG_PID_DEBUG, e);
542
+      SERIAL_ECHOPAIR(MSG_PID_DEBUG_INPUT, current_temperature[e]);
543
+      SERIAL_ECHOPAIR(MSG_PID_DEBUG_OUTPUT, pid_output);
544
+      SERIAL_ECHOPAIR(MSG_PID_DEBUG_PTERM, pTerm[e]);
545
+      SERIAL_ECHOPAIR(MSG_PID_DEBUG_ITERM, iTerm[e]);
546
+      SERIAL_ECHOPAIR(MSG_PID_DEBUG_DTERM, dTerm[e]);
547
+      #if ENABLED(PID_ADD_EXTRUSION_RATE)
548
+        SERIAL_ECHOPAIR(MSG_PID_DEBUG_CTERM, cTerm[e]);
549
+      #endif
550
+      SERIAL_EOL;
527
     #endif //PID_DEBUG
551
     #endif //PID_DEBUG
528
 
552
 
529
   #else /* PID off */
553
   #else /* PID off */
837
     #if ENABLED(PIDTEMP)
861
     #if ENABLED(PIDTEMP)
838
       temp_iState_min[e] = 0.0;
862
       temp_iState_min[e] = 0.0;
839
       temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
863
       temp_iState_max[e] = PID_INTEGRAL_DRIVE_MAX / PID_PARAM(Ki,e);
864
+      #if ENABLED(PID_ADD_EXTRUSION_RATE)
865
+        last_position[e] = 0;
866
+      #endif
840
     #endif //PIDTEMP
867
     #endif //PIDTEMP
841
     #if ENABLED(PIDTEMPBED)
868
     #if ENABLED(PIDTEMPBED)
842
       temp_iState_min_bed = 0.0;
869
       temp_iState_min_bed = 0.0;

Loading…
Cancel
Save