Browse Source

Merge pull request #4222 from thinkyhead/rc_allow_cold_extrude

M302: Add "P" parameter, status output
Scott Lahteine 8 years ago
parent
commit
e5c7af5ddc
3 changed files with 85 additions and 59 deletions
  1. 28
    2
      Marlin/Marlin_main.cpp
  2. 27
    27
      Marlin/temperature.cpp
  3. 30
    30
      Marlin/temperature.h

+ 28
- 2
Marlin/Marlin_main.cpp View File

@@ -5697,10 +5697,36 @@ inline void gcode_M226() {
5697 5697
 #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
5698 5698
 
5699 5699
   /**
5700
-   * M302: Allow cold extrudes, or set the minimum extrude S<temperature>.
5700
+   * M302: Allow cold extrudes, or set the minimum extrude temperature
5701
+   *
5702
+   *       S<temperature> sets the minimum extrude temperature
5703
+   *       P<bool> enables (1) or disables (0) cold extrusion
5704
+   *
5705
+   *  Examples:
5706
+   *
5707
+   *       M302         ; report current cold extrusion state
5708
+   *       M302 P0      ; enable cold extrusion checking
5709
+   *       M302 P1      ; disables cold extrusion checking
5710
+   *       M302 S0      ; always allow extrusion (disables checking)
5711
+   *       M302 S170    ; only allow extrusion above 170
5712
+   *       M302 S170 P1 ; set min extrude temp to 170 but leave disabled
5701 5713
    */
5702 5714
   inline void gcode_M302() {
5703
-    thermalManager.extrude_min_temp = code_seen('S') ? code_value_temp_abs() : 0;
5715
+    bool seen_S = code_seen('S');
5716
+    if (seen_S) {
5717
+      thermalManager.extrude_min_temp = code_value_temp_abs();
5718
+      thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0);
5719
+    }
5720
+
5721
+    if (code_seen('P'))
5722
+      thermalManager.allow_cold_extrude = (thermalManager.extrude_min_temp == 0) || code_value_bool();
5723
+    else if (!seen_S) {
5724
+      // Report current state
5725
+      SERIAL_ECHO_START;
5726
+      SERIAL_ECHOPAIR("Cold extrudes are ", (thermalManager.allow_cold_extrude ? "en" : "dis"));
5727
+      SERIAL_ECHOPAIR("abled (min temp ", int(thermalManager.extrude_min_temp + 0.5));
5728
+      SERIAL_ECHOLNPGM("C)");
5729
+    }
5704 5730
   }
5705 5731
 
5706 5732
 #endif // PREVENT_DANGEROUS_EXTRUDE

+ 27
- 27
Marlin/temperature.cpp View File

@@ -50,13 +50,12 @@ Temperature thermalManager;
50 50
 
51 51
 // public:
52 52
 
53
-int Temperature::current_temperature_raw[HOTENDS] = { 0 };
54
-float Temperature::current_temperature[HOTENDS] = { 0.0 };
55
-int Temperature::target_temperature[HOTENDS] = { 0 };
56
-
57
-int Temperature::current_temperature_bed_raw = 0;
58
-float Temperature::current_temperature_bed = 0.0;
59
-int Temperature::target_temperature_bed = 0;
53
+float Temperature::current_temperature[HOTENDS] = { 0.0 },
54
+      Temperature::current_temperature_bed = 0.0;
55
+int   Temperature::current_temperature_raw[HOTENDS] = { 0 },
56
+      Temperature::target_temperature[HOTENDS] = { 0 },
57
+      Temperature::current_temperature_bed_raw = 0,
58
+      Temperature::target_temperature_bed = 0;
60 59
 
61 60
 #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
62 61
   float Temperature::redundant_temperature = 0.0;
@@ -107,6 +106,7 @@ unsigned char Temperature::soft_pwm_bed;
107 106
 #endif
108 107
 
109 108
 #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
109
+  bool Temperature::allow_cold_extrude = false;
110 110
   float Temperature::extrude_min_temp = EXTRUDE_MINTEMP;
111 111
 #endif
112 112
 
@@ -120,11 +120,11 @@ unsigned char Temperature::soft_pwm_bed;
120 120
 volatile bool Temperature::temp_meas_ready = false;
121 121
 
122 122
 #if ENABLED(PIDTEMP)
123
-  float Temperature::temp_iState[HOTENDS] = { 0 };
124
-  float Temperature::temp_dState[HOTENDS] = { 0 };
125
-  float Temperature::pTerm[HOTENDS];
126
-  float Temperature::iTerm[HOTENDS];
127
-  float Temperature::dTerm[HOTENDS];
123
+  float Temperature::temp_iState[HOTENDS] = { 0 },
124
+        Temperature::temp_dState[HOTENDS] = { 0 },
125
+        Temperature::pTerm[HOTENDS],
126
+        Temperature::iTerm[HOTENDS],
127
+        Temperature::dTerm[HOTENDS];
128 128
 
129 129
   #if ENABLED(PID_ADD_EXTRUSION_RATE)
130 130
     float Temperature::cTerm[HOTENDS];
@@ -133,21 +133,21 @@ volatile bool Temperature::temp_meas_ready = false;
133 133
     int Temperature::lpq_ptr = 0;
134 134
   #endif
135 135
 
136
-  float Temperature::pid_error[HOTENDS];
137
-  float Temperature::temp_iState_min[HOTENDS];
138
-  float Temperature::temp_iState_max[HOTENDS];
136
+  float Temperature::pid_error[HOTENDS],
137
+        Temperature::temp_iState_min[HOTENDS],
138
+        Temperature::temp_iState_max[HOTENDS];
139 139
   bool Temperature::pid_reset[HOTENDS];
140 140
 #endif
141 141
 
142 142
 #if ENABLED(PIDTEMPBED)
143
-  float Temperature::temp_iState_bed = { 0 };
144
-  float Temperature::temp_dState_bed = { 0 };
145
-  float Temperature::pTerm_bed;
146
-  float Temperature::iTerm_bed;
147
-  float Temperature::dTerm_bed;
148
-  float Temperature::pid_error_bed;
149
-  float Temperature::temp_iState_min_bed;
150
-  float Temperature::temp_iState_max_bed;
143
+  float Temperature::temp_iState_bed = { 0 },
144
+        Temperature::temp_dState_bed = { 0 },
145
+        Temperature::pTerm_bed,
146
+        Temperature::iTerm_bed,
147
+        Temperature::dTerm_bed,
148
+        Temperature::pid_error_bed,
149
+        Temperature::temp_iState_min_bed,
150
+        Temperature::temp_iState_max_bed;
151 151
 #else
152 152
   millis_t Temperature::next_bed_check_ms;
153 153
 #endif
@@ -156,10 +156,10 @@ unsigned long Temperature::raw_temp_value[4] = { 0 };
156 156
 unsigned long Temperature::raw_temp_bed_value = 0;
157 157
 
158 158
 // Init min and max temp with extreme values to prevent false errors during startup
159
-int Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP);
160
-int Temperature::maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP);
161
-int Temperature::minttemp[HOTENDS] = { 0 };
162
-int Temperature::maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1(16383);
159
+int Temperature::minttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_LO_TEMP , HEATER_1_RAW_LO_TEMP , HEATER_2_RAW_LO_TEMP, HEATER_3_RAW_LO_TEMP),
160
+    Temperature::maxttemp_raw[HOTENDS] = ARRAY_BY_HOTENDS(HEATER_0_RAW_HI_TEMP , HEATER_1_RAW_HI_TEMP , HEATER_2_RAW_HI_TEMP, HEATER_3_RAW_HI_TEMP),
161
+    Temperature::minttemp[HOTENDS] = { 0 },
162
+    Temperature::maxttemp[HOTENDS] = ARRAY_BY_HOTENDS1(16383);
163 163
 
164 164
 #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
165 165
   int Temperature::consecutive_low_temperature_error[HOTENDS] = { 0 };

+ 30
- 30
Marlin/temperature.h View File

@@ -52,13 +52,12 @@ class Temperature {
52 52
 
53 53
   public:
54 54
 
55
-    static int current_temperature_raw[HOTENDS];
56
-    static float current_temperature[HOTENDS];
57
-    static int target_temperature[HOTENDS];
58
-
59
-    static int current_temperature_bed_raw;
60
-    static float current_temperature_bed;
61
-    static int target_temperature_bed;
55
+    static float current_temperature[HOTENDS],
56
+                 current_temperature_bed;
57
+    static int   current_temperature_raw[HOTENDS],
58
+                 target_temperature[HOTENDS],
59
+                 current_temperature_bed_raw,
60
+                 target_temperature_bed;
62 61
 
63 62
     #if ENABLED(TEMP_SENSOR_1_AS_REDUNDANT)
64 63
       static float redundant_temperature;
@@ -121,12 +120,13 @@ class Temperature {
121 120
     #endif
122 121
 
123 122
     #if ENABLED(PREVENT_DANGEROUS_EXTRUDE)
123
+      static bool allow_cold_extrude;
124 124
       static float extrude_min_temp;
125 125
       static bool tooColdToExtrude(uint8_t e) {
126 126
         #if HOTENDS == 1
127 127
           UNUSED(e);
128 128
         #endif
129
-        return degHotend(HOTEND_INDEX) < extrude_min_temp;
129
+        return allow_cold_extrude ? false : degHotend(HOTEND_INDEX) < extrude_min_temp;
130 130
       }
131 131
     #else
132 132
       static bool tooColdToExtrude(uint8_t e) { UNUSED(e); return false; }
@@ -142,11 +142,11 @@ class Temperature {
142 142
     static volatile bool temp_meas_ready;
143 143
 
144 144
     #if ENABLED(PIDTEMP)
145
-      static float temp_iState[HOTENDS];
146
-      static float temp_dState[HOTENDS];
147
-      static float pTerm[HOTENDS];
148
-      static float iTerm[HOTENDS];
149
-      static float dTerm[HOTENDS];
145
+      static float temp_iState[HOTENDS],
146
+                   temp_dState[HOTENDS],
147
+                   pTerm[HOTENDS],
148
+                   iTerm[HOTENDS],
149
+                   dTerm[HOTENDS];
150 150
 
151 151
       #if ENABLED(PID_ADD_EXTRUSION_RATE)
152 152
         static float cTerm[HOTENDS];
@@ -155,33 +155,33 @@ class Temperature {
155 155
         static int lpq_ptr;
156 156
       #endif
157 157
 
158
-      static float pid_error[HOTENDS];
159
-      static float temp_iState_min[HOTENDS];
160
-      static float temp_iState_max[HOTENDS];
158
+      static float pid_error[HOTENDS],
159
+                   temp_iState_min[HOTENDS],
160
+                   temp_iState_max[HOTENDS];
161 161
       static bool pid_reset[HOTENDS];
162 162
     #endif
163 163
 
164 164
     #if ENABLED(PIDTEMPBED)
165
-      static float temp_iState_bed;
166
-      static float temp_dState_bed;
167
-      static float pTerm_bed;
168
-      static float iTerm_bed;
169
-      static float dTerm_bed;
170
-      static float pid_error_bed;
171
-      static float temp_iState_min_bed;
172
-      static float temp_iState_max_bed;
165
+      static float temp_iState_bed,
166
+                   temp_dState_bed,
167
+                   pTerm_bed,
168
+                   iTerm_bed,
169
+                   dTerm_bed,
170
+                   pid_error_bed,
171
+                   temp_iState_min_bed,
172
+                   temp_iState_max_bed;
173 173
     #else
174 174
       static millis_t next_bed_check_ms;
175 175
     #endif
176 176
 
177
-    static unsigned long raw_temp_value[4];
178
-    static unsigned long raw_temp_bed_value;
177
+    static unsigned long raw_temp_value[4],
178
+                         raw_temp_bed_value;
179 179
 
180 180
     // Init min and max temp with extreme values to prevent false errors during startup
181
-    static int minttemp_raw[HOTENDS];
182
-    static int maxttemp_raw[HOTENDS];
183
-    static int minttemp[HOTENDS];
184
-    static int maxttemp[HOTENDS];
181
+    static int minttemp_raw[HOTENDS],
182
+               maxttemp_raw[HOTENDS],
183
+               minttemp[HOTENDS],
184
+               maxttemp[HOTENDS];
185 185
 
186 186
     #ifdef MAX_CONSECUTIVE_LOW_TEMPERATURE_ERROR_ALLOWED
187 187
       static int consecutive_low_temperature_error[HOTENDS];

Loading…
Cancel
Save