Ver código fonte

Implementation of M190 bed temp hysteresis

gralco 9 anos atrás
pai
commit
178aeb79c8
2 arquivos alterados com 46 adições e 5 exclusões
  1. 5
    1
      Marlin/Configuration.h
  2. 41
    4
      Marlin/Marlin_main.cpp

+ 5
- 1
Marlin/Configuration.h Ver arquivo

@@ -192,11 +192,15 @@
192 192
 //#define TEMP_SENSOR_1_AS_REDUNDANT
193 193
 #define MAX_REDUNDANT_TEMP_SENSOR_DIFF 10
194 194
 
195
-// Actual temperature must be close to target for this long before M109 returns success
195
+// Actual temperature must be close to target for this long before M109/M190 returns success
196 196
 #define TEMP_RESIDENCY_TIME 10  // (seconds)
197 197
 #define TEMP_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
198 198
 #define TEMP_WINDOW     1       // (degC) Window around target to start the residency timer x degC early.
199 199
 
200
+#define TEMP_BED_RESIDENCY_TIME 10  // (seconds)
201
+#define TEMP_BED_HYSTERESIS 3       // (degC) range of +/- temperatures considered "close" to the target one
202
+#define TEMP_BED_WINDOW     1       // (degC) Window around target to start the residency timer x degC early.
203
+
200 204
 // The minimal temperature defines the temperature below which the heater will not be enabled It is used
201 205
 // to check that the wiring to the thermistor is not broken.
202 206
 // Otherwise this would lead to the heater being powered on all the time.

+ 41
- 4
Marlin/Marlin_main.cpp Ver arquivo

@@ -4389,20 +4389,57 @@ inline void gcode_M109() {
4389 4389
     // Exit if S<lower>, continue if S<higher>, R<lower>, or R<higher>
4390 4390
     if (no_wait_for_cooling && wants_to_cool) return;
4391 4391
 
4392
+    #ifdef TEMP_BED_RESIDENCY_TIME
4393
+      millis_t residency_start_ms = 0;
4394
+      // Loop until the temperature has stabilized
4395
+      #define TEMP_BED_CONDITIONS (!residency_start_ms || PENDING(now, residency_start_ms + (TEMP_BED_RESIDENCY_TIME) * 1000UL))
4396
+    #else
4397
+      // Loop until the temperature is very close target
4398
+      #define TEMP_BED_CONDITIONS (wants_to_cool ? isCoolingBed() : isHeatingBed())
4399
+    #endif //TEMP_BED_RESIDENCY_TIME
4400
+
4392 4401
     cancel_heatup = false;
4393
-    millis_t next_temp_ms = 0;
4402
+    millis_t now, next_temp_ms = 0;
4394 4403
 
4395 4404
     // Wait for temperature to come close enough
4396 4405
     do {
4397
-      millis_t now = millis();
4406
+      now = millis();
4398 4407
       if (ELAPSED(now, next_temp_ms)) { //Print Temp Reading every 1 second while heating up.
4399 4408
         next_temp_ms = now + 1000UL;
4400 4409
         print_heaterstates();
4401
-        SERIAL_EOL;
4410
+        #ifdef TEMP_BED_RESIDENCY_TIME
4411
+          SERIAL_PROTOCOLPGM(" W:");
4412
+          if (residency_start_ms) {
4413
+            long rem = (((TEMP_BED_RESIDENCY_TIME) * 1000UL) - (now - residency_start_ms)) / 1000UL;
4414
+            SERIAL_PROTOCOLLN(rem);
4415
+          }
4416
+          else {
4417
+            SERIAL_PROTOCOLLNPGM("?");
4418
+          }
4419
+        #else
4420
+          SERIAL_EOL;
4421
+        #endif
4402 4422
       }
4423
+
4403 4424
       idle();
4404 4425
       refresh_cmd_timeout(); // to prevent stepper_inactive_time from running out
4405
-    } while (!cancel_heatup && (wants_to_cool ? isCoolingBed() : isHeatingBed()));
4426
+
4427
+      #ifdef TEMP_BED_RESIDENCY_TIME
4428
+
4429
+        float temp_diff = fabs(degBed() - degTargetBed());
4430
+
4431
+        if (!residency_start_ms) {
4432
+          // Start the TEMP_BED_RESIDENCY_TIME timer when we reach target temp for the first time.
4433
+          if (temp_diff < TEMP_BED_WINDOW) residency_start_ms = millis();
4434
+        }
4435
+        else if (temp_diff > TEMP_BED_HYSTERESIS) {
4436
+          // Restart the timer whenever the temperature falls outside the hysteresis.
4437
+          residency_start_ms = millis();
4438
+        }
4439
+
4440
+      #endif //TEMP_BED_RESIDENCY_TIME
4441
+
4442
+    } while (!cancel_heatup && TEMP_BED_CONDITIONS);
4406 4443
     LCD_MESSAGEPGM(MSG_BED_DONE);
4407 4444
   }
4408 4445
 

Carregando…
Cancelar
Salvar