瀏覽代碼

Filament Runout Sensor Feature

With this change a mechanical or optical switch may be used to check the
availability of the filament and when the filament runs out an M600
(filament change) command is issued. This is only done while printing
with an SD card.

This feature was requested several times (issue #679), but the requests
were not accepted since it was believed that this situation should be
handled at host side. However during an SD print the control is totally
on firmware and I think that during an SD print it should be handled by
the firmware.

The original code was posted at reprap forum
(http://forums.reprap.org/read.php?1,297350) by Lazymonk. I have only
corrected some bugs of the code and improved it by adding definitions to
the configuration.h in order to make it more standardized.
Mehmet Sutas 9 年之前
父節點
當前提交
cfc6a3a87a
共有 4 個文件被更改,包括 54 次插入0 次删除
  1. 9
    0
      Marlin/Configuration.h
  2. 4
    0
      Marlin/Marlin.h
  3. 36
    0
      Marlin/Marlin_main.cpp
  4. 5
    0
      Marlin/pins_RAMPS_13.h

+ 9
- 0
Marlin/Configuration.h 查看文件

@@ -375,6 +375,15 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
375 375
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
376 376
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
377 377
 
378
+//===========================================================================
379
+//============================= Filament Runout Sensor ======================
380
+//===========================================================================
381
+//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament
382
+                                 // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made.
383
+                                 // It is assumed that when logic high = filament available
384
+                                 //                    when logic  low = filament ran out
385
+//const bool FIL_RUNOUT_INVERTING = true;  // Should be uncommented and true or false should assigned
386
+//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined.
378 387
 
379 388
 //===========================================================================
380 389
 //============================= Bed Auto Leveling ===========================

+ 4
- 0
Marlin/Marlin.h 查看文件

@@ -199,6 +199,10 @@ void prepare_move();
199 199
 void kill();
200 200
 void Stop();
201 201
 
202
+#ifdef FILAMENT_RUNOUT_SENSOR
203
+void filrunout();
204
+#endif
205
+
202 206
 bool IsStopped();
203 207
 
204 208
 bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full

+ 36
- 0
Marlin/Marlin_main.cpp 查看文件

@@ -366,6 +366,10 @@ bool cancel_heatup = false;
366 366
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
367 367
 #endif
368 368
 
369
+#ifdef FILAMENT_RUNOUT_SENSOR
370
+   static bool filrunoutEnqued = false;
371
+#endif
372
+
369 373
 const char errormagic[] PROGMEM = "Error:";
370 374
 const char echomagic[] PROGMEM = "echo:";
371 375
 
@@ -525,6 +529,16 @@ void setup_killpin()
525 529
   #endif
526 530
 }
527 531
 
532
+void setup_filrunoutpin()
533
+{
534
+#if defined(FILRUNOUT_PIN) && FILRUNOUT_PIN > -1
535
+   pinMode(FILRUNOUT_PIN,INPUT);
536
+   #if defined(ENDSTOPPULLUP_FIL_RUNOUT)
537
+      WRITE(FILLRUNOUT_PIN,HIGH);
538
+   #endif
539
+#endif
540
+}
541
+
528 542
 // Set home pin
529 543
 void setup_homepin(void)
530 544
 {
@@ -601,6 +615,7 @@ void servo_init()
601 615
 void setup()
602 616
 {
603 617
   setup_killpin();
618
+  setup_filrunoutpin();
604 619
   setup_powerhold();
605 620
   MYSERIAL.begin(BAUDRATE);
606 621
   SERIAL_PROTOCOLLNPGM("start");
@@ -4091,6 +4106,11 @@ inline void gcode_M503() {
4091 4106
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
4092 4107
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
4093 4108
     #endif        
4109
+
4110
+    #ifdef FILAMENT_RUNOUT_SENSOR
4111
+      filrunoutEnqued = false;
4112
+    #endif
4113
+    
4094 4114
   }
4095 4115
 
4096 4116
 #endif // FILAMENTCHANGEENABLE
@@ -5230,6 +5250,12 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
5230 5250
    const int KILL_DELAY = 10000;
5231 5251
 #endif
5232 5252
 
5253
+#if defined(FILRUNOUT_PIN) && FILRUNOUT_PIN > -1
5254
+    if(card.sdprinting) {
5255
+      if(!(READ(FILRUNOUT_PIN))^FIL_RUNOUT_INVERTING)
5256
+      filrunout();        }
5257
+#endif
5258
+
5233 5259
 #if defined(HOME_PIN) && HOME_PIN > -1
5234 5260
    static int homeDebounceCount = 0;   // poor man's debouncing count
5235 5261
    const int HOME_DEBOUNCE_DELAY = 10000;
@@ -5378,6 +5404,16 @@ void kill()
5378 5404
   while(1) { /* Intentionally left empty */ } // Wait for reset
5379 5405
 }
5380 5406
 
5407
+#ifdef FILAMENT_RUNOUT_SENSOR
5408
+   void filrunout()
5409
+   {
5410
+      if filrunoutEnqued == false {
5411
+         filrunoutEnqued = true;
5412
+         enquecommand("M600");
5413
+      }
5414
+   }
5415
+#endif
5416
+
5381 5417
 void Stop()
5382 5418
 {
5383 5419
   disable_heater();

+ 5
- 0
Marlin/pins_RAMPS_13.h 查看文件

@@ -61,6 +61,11 @@
61 61
   #define FILWIDTH_PIN        5
62 62
 #endif
63 63
 
64
+#if defined(FILAMENT_RUNOUT_SENSOR)
65
+  // define digital pin 4 for the filament runout sensor. Use the RAMPS 1.4 digital input 4 on the servos connector
66
+  #define FILRUNOUT_PIN        4
67
+#endif
68
+
64 69
 #if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF)
65 70
   #define FAN_PIN            9 // (Sprinter config)
66 71
   #if MB(RAMPS_13_EFF)

Loading…
取消
儲存