Explorar el Código

Only a single E axis. Can tool-change reseed position[E_AXIS]?

Scott Lahteine hace 9 años
padre
commit
11dcbae7a2
Se han modificado 2 ficheros con 15 adiciones y 13 borrados
  1. 14
    12
      Marlin/temperature.cpp
  2. 1
    1
      Marlin/temperature.h

+ 14
- 12
Marlin/temperature.cpp Ver fichero

128
 
128
 
129
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
129
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
130
     float Temperature::cTerm[HOTENDS];
130
     float Temperature::cTerm[HOTENDS];
131
-    long Temperature::last_position[HOTENDS];
131
+    long Temperature::last_e_position;
132
     long Temperature::lpq[LPQ_MAX_LEN];
132
     long Temperature::lpq[LPQ_MAX_LEN];
133
     int Temperature::lpq_ptr = 0;
133
     int Temperature::lpq_ptr = 0;
134
   #endif
134
   #endif
444
 
444
 
445
 void Temperature::updatePID() {
445
 void Temperature::updatePID() {
446
   #if ENABLED(PIDTEMP)
446
   #if ENABLED(PIDTEMP)
447
+    #if ENABLED(PID_ADD_EXTRUSION_RATE)
448
+      last_e_position = 0;
449
+    #endif
447
     HOTEND_LOOP() {
450
     HOTEND_LOOP() {
448
       temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
451
       temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
449
-      #if ENABLED(PID_ADD_EXTRUSION_RATE)
450
-        last_position[e] = 0;
451
-      #endif
452
     }
452
     }
453
   #endif
453
   #endif
454
   #if ENABLED(PIDTEMPBED)
454
   #if ENABLED(PIDTEMPBED)
531
   #if HOTENDS == 1
531
   #if HOTENDS == 1
532
     UNUSED(e);
532
     UNUSED(e);
533
     #define _HOTEND_TEST     true
533
     #define _HOTEND_TEST     true
534
-    #define _HOTEND_EXTRUDER active_extruder
535
   #else
534
   #else
536
     #define _HOTEND_TEST     e == active_extruder
535
     #define _HOTEND_TEST     e == active_extruder
537
-    #define _HOTEND_EXTRUDER e
538
   #endif
536
   #endif
539
   float pid_output;
537
   float pid_output;
540
   #if ENABLED(PIDTEMP)
538
   #if ENABLED(PIDTEMP)
566
           cTerm[HOTEND_INDEX] = 0;
564
           cTerm[HOTEND_INDEX] = 0;
567
           if (_HOTEND_TEST) {
565
           if (_HOTEND_TEST) {
568
             long e_position = stepper.position(E_AXIS);
566
             long e_position = stepper.position(E_AXIS);
569
-            if (e_position > last_position[_HOTEND_EXTRUDER]) {
570
-              lpq[lpq_ptr++] = e_position - last_position[_HOTEND_EXTRUDER];
571
-              last_position[_HOTEND_EXTRUDER] = e_position;
567
+            if (e_position > last_e_position) {
568
+              lpq[lpq_ptr] = e_position - last_e_position;
569
+              last_e_position = e_position;
572
             }
570
             }
573
             else {
571
             else {
574
-              lpq[lpq_ptr++] = 0;
572
+              lpq[lpq_ptr] = 0;
575
             }
573
             }
576
-            if (lpq_ptr >= lpq_len) lpq_ptr = 0;
574
+            if (++lpq_ptr >= lpq_len) lpq_ptr = 0;
577
             cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
575
             cTerm[HOTEND_INDEX] = (lpq[lpq_ptr] / planner.axis_steps_per_mm[E_AXIS]) * PID_PARAM(Kc, HOTEND_INDEX);
578
             pid_output += cTerm[HOTEND_INDEX];
576
             pid_output += cTerm[HOTEND_INDEX];
579
           }
577
           }
952
       temp_iState_min[e] = 0.0;
950
       temp_iState_min[e] = 0.0;
953
       temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
951
       temp_iState_max[e] = (PID_INTEGRAL_DRIVE_MAX) / PID_PARAM(Ki, e);
954
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
952
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
955
-        last_position[e] = 0;
953
+        last_e_position = 0;
956
       #endif
954
       #endif
957
     #endif //PIDTEMP
955
     #endif //PIDTEMP
958
     #if ENABLED(PIDTEMPBED)
956
     #if ENABLED(PIDTEMPBED)
961
     #endif //PIDTEMPBED
959
     #endif //PIDTEMPBED
962
   }
960
   }
963
 
961
 
962
+  #if ENABLED(PIDTEMP) && ENABLED(PID_ADD_EXTRUSION_RATE)
963
+    last_e_position = 0;
964
+  #endif
965
+
964
   #if HAS_HEATER_0
966
   #if HAS_HEATER_0
965
     SET_OUTPUT(HEATER_0_PIN);
967
     SET_OUTPUT(HEATER_0_PIN);
966
   #endif
968
   #endif

+ 1
- 1
Marlin/temperature.h Ver fichero

150
 
150
 
151
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
151
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
152
         static float cTerm[HOTENDS];
152
         static float cTerm[HOTENDS];
153
-        static long last_position[HOTENDS];
153
+        static long last_e_position;
154
         static long lpq[LPQ_MAX_LEN];
154
         static long lpq[LPQ_MAX_LEN];
155
         static int lpq_ptr;
155
         static int lpq_ptr;
156
       #endif
156
       #endif

Loading…
Cancelar
Guardar