Browse Source

Merge pull request #1581 from msutas/Development

Filament Runout Sensor Feature
alexborro 10 years ago
parent
commit
d3259d0dba
4 changed files with 54 additions and 0 deletions
  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 View File

@@ -362,6 +362,15 @@ const bool Z_MAX_ENDSTOP_INVERTING = false; // set to true to invert the logic o
362 362
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
363 363
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
364 364
 
365
+//===========================================================================
366
+//============================= Filament Runout Sensor ======================
367
+//===========================================================================
368
+//#define FILAMENT_RUNOUT_SENSOR // Uncomment for defining a filament runout sensor such as a mechanical or opto endstop to check the existence of filament
369
+                                 // In RAMPS uses servo pin 2. Can be changed in pins file. For other boards pin definition should be made.
370
+                                 // It is assumed that when logic high = filament available
371
+                                 //                    when logic  low = filament ran out
372
+//const bool FIL_RUNOUT_INVERTING = true;  // Should be uncommented and true or false should assigned
373
+//#define ENDSTOPPULLUP_FIL_RUNOUT // Uncomment to use internal pullup for filament runout pins if the sensor is defined.
365 374
 
366 375
 //===========================================================================
367 376
 //============================= Bed Auto Leveling ===========================

+ 4
- 0
Marlin/Marlin.h View File

@@ -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 View File

@@ -370,6 +370,10 @@ bool cancel_heatup = false;
370 370
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
371 371
 #endif
372 372
 
373
+#ifdef FILAMENT_RUNOUT_SENSOR
374
+   static bool filrunoutEnqued = false;
375
+#endif
376
+
373 377
 const char errormagic[] PROGMEM = "Error:";
374 378
 const char echomagic[] PROGMEM = "echo:";
375 379
 
@@ -529,6 +533,16 @@ void setup_killpin()
529 533
   #endif
530 534
 }
531 535
 
536
+void setup_filrunoutpin()
537
+{
538
+#if defined(FILRUNOUT_PIN) && FILRUNOUT_PIN > -1
539
+   pinMode(FILRUNOUT_PIN,INPUT);
540
+   #if defined(ENDSTOPPULLUP_FIL_RUNOUT)
541
+      WRITE(FILLRUNOUT_PIN,HIGH);
542
+   #endif
543
+#endif
544
+}
545
+
532 546
 // Set home pin
533 547
 void setup_homepin(void)
534 548
 {
@@ -605,6 +619,7 @@ void servo_init()
605 619
 void setup()
606 620
 {
607 621
   setup_killpin();
622
+  setup_filrunoutpin();
608 623
   setup_powerhold();
609 624
   MYSERIAL.begin(BAUDRATE);
610 625
   SERIAL_PROTOCOLLNPGM("start");
@@ -4136,6 +4151,11 @@ inline void gcode_M503() {
4136 4151
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
4137 4152
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
4138 4153
     #endif        
4154
+
4155
+    #ifdef FILAMENT_RUNOUT_SENSOR
4156
+      filrunoutEnqued = false;
4157
+    #endif
4158
+    
4139 4159
   }
4140 4160
 
4141 4161
 #endif // FILAMENTCHANGEENABLE
@@ -5275,6 +5295,12 @@ void manage_inactivity(bool ignore_stepper_queue/*=false*/) //default argument s
5275 5295
    const int KILL_DELAY = 10000;
5276 5296
 #endif
5277 5297
 
5298
+#if defined(FILRUNOUT_PIN) && FILRUNOUT_PIN > -1
5299
+    if(card.sdprinting) {
5300
+      if(!(READ(FILRUNOUT_PIN))^FIL_RUNOUT_INVERTING)
5301
+      filrunout();        }
5302
+#endif
5303
+
5278 5304
 #if defined(HOME_PIN) && HOME_PIN > -1
5279 5305
    static int homeDebounceCount = 0;   // poor man's debouncing count
5280 5306
    const int HOME_DEBOUNCE_DELAY = 10000;
@@ -5423,6 +5449,16 @@ void kill()
5423 5449
   while(1) { /* Intentionally left empty */ } // Wait for reset
5424 5450
 }
5425 5451
 
5452
+#ifdef FILAMENT_RUNOUT_SENSOR
5453
+   void filrunout()
5454
+   {
5455
+      if filrunoutEnqued == false {
5456
+         filrunoutEnqued = true;
5457
+         enquecommand("M600");
5458
+      }
5459
+   }
5460
+#endif
5461
+
5426 5462
 void Stop()
5427 5463
 {
5428 5464
   disable_heater();

+ 5
- 0
Marlin/pins_RAMPS_13.h View File

@@ -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…
Cancel
Save