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
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
362
 #define Y_MAX_LENGTH (Y_MAX_POS - Y_MIN_POS)
363
 #define Z_MAX_LENGTH (Z_MAX_POS - Z_MIN_POS)
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
 //============================= Bed Auto Leveling ===========================
376
 //============================= Bed Auto Leveling ===========================

+ 4
- 0
Marlin/Marlin.h View File

199
 void kill();
199
 void kill();
200
 void Stop();
200
 void Stop();
201
 
201
 
202
+#ifdef FILAMENT_RUNOUT_SENSOR
203
+void filrunout();
204
+#endif
205
+
202
 bool IsStopped();
206
 bool IsStopped();
203
 
207
 
204
 bool enquecommand(const char *cmd); //put a single ASCII command at the end of the current buffer or return false when it is full
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
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
370
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
371
 #endif
371
 #endif
372
 
372
 
373
+#ifdef FILAMENT_RUNOUT_SENSOR
374
+   static bool filrunoutEnqued = false;
375
+#endif
376
+
373
 const char errormagic[] PROGMEM = "Error:";
377
 const char errormagic[] PROGMEM = "Error:";
374
 const char echomagic[] PROGMEM = "echo:";
378
 const char echomagic[] PROGMEM = "echo:";
375
 
379
 
529
   #endif
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
 // Set home pin
546
 // Set home pin
533
 void setup_homepin(void)
547
 void setup_homepin(void)
534
 {
548
 {
605
 void setup()
619
 void setup()
606
 {
620
 {
607
   setup_killpin();
621
   setup_killpin();
622
+  setup_filrunoutpin();
608
   setup_powerhold();
623
   setup_powerhold();
609
   MYSERIAL.begin(BAUDRATE);
624
   MYSERIAL.begin(BAUDRATE);
610
   SERIAL_PROTOCOLLNPGM("start");
625
   SERIAL_PROTOCOLLNPGM("start");
4136
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
4151
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], target[E_AXIS], fr60, active_extruder); //move z back
4137
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
4152
       plan_buffer_line(lastpos[X_AXIS], lastpos[Y_AXIS], lastpos[Z_AXIS], lastpos[E_AXIS], fr60, active_extruder); //final untretract
4138
     #endif        
4153
     #endif        
4154
+
4155
+    #ifdef FILAMENT_RUNOUT_SENSOR
4156
+      filrunoutEnqued = false;
4157
+    #endif
4158
+    
4139
   }
4159
   }
4140
 
4160
 
4141
 #endif // FILAMENTCHANGEENABLE
4161
 #endif // FILAMENTCHANGEENABLE
5275
    const int KILL_DELAY = 10000;
5295
    const int KILL_DELAY = 10000;
5276
 #endif
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
 #if defined(HOME_PIN) && HOME_PIN > -1
5304
 #if defined(HOME_PIN) && HOME_PIN > -1
5279
    static int homeDebounceCount = 0;   // poor man's debouncing count
5305
    static int homeDebounceCount = 0;   // poor man's debouncing count
5280
    const int HOME_DEBOUNCE_DELAY = 10000;
5306
    const int HOME_DEBOUNCE_DELAY = 10000;
5423
   while(1) { /* Intentionally left empty */ } // Wait for reset
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
 void Stop()
5462
 void Stop()
5427
 {
5463
 {
5428
   disable_heater();
5464
   disable_heater();

+ 5
- 0
Marlin/pins_RAMPS_13.h View File

61
   #define FILWIDTH_PIN        5
61
   #define FILWIDTH_PIN        5
62
 #endif
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
 #if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF)
69
 #if MB(RAMPS_13_EFB) || MB(RAMPS_13_EFF)
65
   #define FAN_PIN            9 // (Sprinter config)
70
   #define FAN_PIN            9 // (Sprinter config)
66
   #if MB(RAMPS_13_EFF)
71
   #if MB(RAMPS_13_EFF)

Loading…
Cancel
Save