Browse Source

Allow PID_DEBUG to be turned on and off (#17284)

M303 D will now toggle activation of PID_DEBUG output.   This allows the debug capability to be built into the firmware, but turned on and off as needed.
Roxy-3D 5 years ago
parent
commit
1986e1cdf8
No account linked to committer's email address
3 changed files with 23 additions and 13 deletions
  1. 1
    1
      Marlin/Configuration.h
  2. 16
    0
      Marlin/src/gcode/temp/M303.cpp
  3. 6
    12
      Marlin/src/module/temperature.cpp

+ 1
- 1
Marlin/Configuration.h View File

@@ -473,7 +473,7 @@
473 473
 #if ENABLED(PIDTEMP)
474 474
   //#define PID_EDIT_MENU         // Add PID editing to the "Advanced Settings" menu. (~700 bytes of PROGMEM)
475 475
   //#define PID_AUTOTUNE_MENU     // Add PID auto-tuning to the "Advanced Settings" menu. (~250 bytes of PROGMEM)
476
-  //#define PID_DEBUG             // Sends debug data to the serial port.
476
+  //#define PID_DEBUG             // Sends debug data to the serial port.  Use M303 D to toggle activation.
477 477
   //#define PID_OPENLOOP 1        // Puts PID in open loop. M104/M140 sets the output power from 0 to PID_MAX
478 478
   //#define SLOW_PWM_HEATERS      // PWM with very low frequency (roughly 0.125Hz=8s) and minimum state time of approximately 1s useful for heaters driven by a relay
479 479
   //#define PID_PARAMS_PER_HOTEND // Uses separate PID parameters for each extruder (useful for mismatched extruders)

+ 16
- 0
Marlin/src/gcode/temp/M303.cpp View File

@@ -38,7 +38,13 @@
38 38
  *       E<extruder> (-1 for the bed) (default 0)
39 39
  *       C<cycles> Minimum 3. Default 5.
40 40
  *       U<bool> with a non-zero value will apply the result to current settings
41
+ *       D Toggles PID_DEBUG flag. No other action happens even if more parameters are specified.
41 42
  */
43
+
44
+#if ENABLED(PID_DEBUG)
45
+  bool PID_Debug_Flag = 0;
46
+#endif
47
+
42 48
 void GcodeSuite::M303() {
43 49
   #if ENABLED(PIDTEMPBED)
44 50
     #define SI H_BED
@@ -63,6 +69,16 @@ void GcodeSuite::M303() {
63 69
   const bool u = parser.boolval('U');
64 70
   const int16_t temp = parser.celsiusval('S', e < 0 ? 70 : 150);
65 71
 
72
+  #if ENABLED(PID_DEBUG)
73
+    bool d = parser.boolval('D');
74
+    if (d) {
75
+      PID_Debug_Flag = !PID_Debug_Flag;
76
+      SERIAL_ECHOPGM("PID Debug set to: ");
77
+      SERIAL_ECHOLN( PID_Debug_Flag );
78
+      return;
79
+    }
80
+  #endif
81
+
66 82
   #if DISABLED(BUSY_WHILE_HEATING)
67 83
     KEEPALIVE_STATE(NOT_BUSY);
68 84
   #endif

+ 6
- 12
Marlin/src/module/temperature.cpp View File

@@ -830,6 +830,9 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
830 830
 }
831 831
 
832 832
 #if HOTENDS
833
+  #if ENABLED(PID_DEBUG)
834
+    extern bool PID_Debug_Flag;
835
+  #endif
833 836
 
834 837
   float Temperature::get_pid_output_hotend(const uint8_t E_NAME) {
835 838
     const uint8_t ee = HOTEND_INDEX;
@@ -911,24 +914,15 @@ void Temperature::min_temp_error(const heater_ind_t heater) {
911 914
       #endif // PID_OPENLOOP
912 915
 
913 916
       #if ENABLED(PID_DEBUG)
914
-        if (ee == active_extruder) {
917
+        if (ee == active_extruder && PID_Debug_Flag) {
915 918
           SERIAL_ECHO_START();
916
-          SERIAL_ECHOPAIR(
917
-            STR_PID_DEBUG, ee,
918
-            STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius,
919
-            STR_PID_DEBUG_OUTPUT, pid_output
920
-          );
919
+          SERIAL_ECHOPAIR(STR_PID_DEBUG, ee, STR_PID_DEBUG_INPUT, temp_hotend[ee].celsius, STR_PID_DEBUG_OUTPUT, pid_output);
921 920
           #if DISABLED(PID_OPENLOOP)
922
-          {
923
-            SERIAL_ECHOPAIR(
924
-              STR_PID_DEBUG_PTERM, work_pid[ee].Kp,
925
-              STR_PID_DEBUG_ITERM, work_pid[ee].Ki,
926
-              STR_PID_DEBUG_DTERM, work_pid[ee].Kd
921
+            SERIAL_ECHOPAIR( STR_PID_DEBUG_PTERM, work_pid[ee].Kp, STR_PID_DEBUG_ITERM, work_pid[ee].Ki, STR_PID_DEBUG_DTERM, work_pid[ee].Kd
927 922
               #if ENABLED(PID_EXTRUSION_SCALING)
928 923
                 , STR_PID_DEBUG_CTERM, work_pid[ee].Kc
929 924
               #endif
930 925
             );
931
-          }
932 926
           #endif
933 927
           SERIAL_EOL();
934 928
         }

Loading…
Cancel
Save