Browse Source

Merge pull request #1141 from filipmu/Filament-Sensor

Display filament sensor data on a 20x4 LCD or Graphical LCD
Bo Herrmannsen 9 years ago
parent
commit
91d740e128

+ 3
- 1
Marlin/Configuration.h View File

773
  * 
773
  * 
774
  * Motherboards
774
  * Motherboards
775
  * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector 
775
  * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector 
776
- * 81 - Printrboard - Uses Analog input 2 on the Aux 2 connector
776
+ * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E)
777
  * 301 - Rambo  - uses Analog input 3
777
  * 301 - Rambo  - uses Analog input 3
778
  * Note may require analog pins to be defined for different motherboards
778
  * Note may require analog pins to be defined for different motherboards
779
  **********************************************************************/
779
  **********************************************************************/
791
 //defines used in the code
791
 //defines used in the code
792
 #define DEFAULT_MEASURED_FILAMENT_DIA  DEFAULT_NOMINAL_FILAMENT_DIA  //set measured to nominal initially 
792
 #define DEFAULT_MEASURED_FILAMENT_DIA  DEFAULT_NOMINAL_FILAMENT_DIA  //set measured to nominal initially 
793
 
793
 
794
+//When using an LCD, uncomment the line below to display the Filament sensor data on the last line instead of status.  Status will appear for 5 sec.
795
+//#define FILAMENT_LCD_DISPLAY
794
 
796
 
795
 
797
 
796
 
798
 

+ 15
- 1
Marlin/dogm_lcd_implementation.h View File

328
  // Status line
328
  // Status line
329
  u8g.setFont(FONT_STATUSMENU);
329
  u8g.setFont(FONT_STATUSMENU);
330
  u8g.setPrintPos(0,61);
330
  u8g.setPrintPos(0,61);
331
- u8g.print(lcd_status_message);
331
+ #ifndef FILAMENT_LCD_DISPLAY
332
+ 	u8g.print(lcd_status_message);
333
+ #else
334
+	if(message_millis+5000>millis()){  //Display both Status message line and Filament display on the last line
335
+	 u8g.print(lcd_status_message);
336
+ 	}
337
+ 	else
338
+	{
339
+	 lcd_printPGM(PSTR("dia:"));
340
+	 u8g.print(ftostr12ns(filament_width_meas));
341
+	 lcd_printPGM(PSTR(" factor:"));
342
+	 u8g.print(itostr3(extrudemultiply));
343
+	 u8g.print('%');
344
+	}
345
+ #endif 	
332
 
346
 
333
 }
347
 }
334
 
348
 

+ 29
- 0
Marlin/ultralcd.cpp View File

20
 int absPreheatFanSpeed;
20
 int absPreheatFanSpeed;
21
 
21
 
22
 
22
 
23
+#ifdef FILAMENT_LCD_DISPLAY
24
+unsigned long message_millis=0;
25
+#endif
26
+
27
+
28
+
23
 #ifdef ULTIPANEL
29
 #ifdef ULTIPANEL
24
 static float manual_feedrate[] = MANUAL_FEEDRATE;
30
 static float manual_feedrate[] = MANUAL_FEEDRATE;
25
 #endif // ULTIPANEL
31
 #endif // ULTIPANEL
216
         encoderPosition = 0;
222
         encoderPosition = 0;
217
         lcd_quick_feedback();
223
         lcd_quick_feedback();
218
         lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it.
224
         lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it.
225
+#ifdef FILAMENT_LCD_DISPLAY
226
+        message_millis=millis();  //get status message to show up for a while
227
+#endif
219
     }
228
     }
220
 
229
 
221
 #ifdef ULTIPANEL_FEEDMULTIPLY
230
 #ifdef ULTIPANEL_FEEDMULTIPLY
1355
         return;
1364
         return;
1356
     strncpy(lcd_status_message, message, LCD_WIDTH);
1365
     strncpy(lcd_status_message, message, LCD_WIDTH);
1357
     lcdDrawUpdate = 2;
1366
     lcdDrawUpdate = 2;
1367
+#ifdef FILAMENT_LCD_DISPLAY
1368
+        message_millis=millis();  //get status message to show up for a while
1369
+#endif
1358
 }
1370
 }
1359
 void lcd_setstatuspgm(const char* message)
1371
 void lcd_setstatuspgm(const char* message)
1360
 {
1372
 {
1362
         return;
1374
         return;
1363
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
1375
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
1364
     lcdDrawUpdate = 2;
1376
     lcdDrawUpdate = 2;
1377
+#ifdef FILAMENT_LCD_DISPLAY
1378
+        message_millis=millis();  //get status message to show up for a while
1379
+#endif
1365
 }
1380
 }
1366
 void lcd_setalertstatuspgm(const char* message)
1381
 void lcd_setalertstatuspgm(const char* message)
1367
 {
1382
 {
1549
   return conv;
1564
   return conv;
1550
 }
1565
 }
1551
 
1566
 
1567
+//Float to string with 1.23 format
1568
+char *ftostr12ns(const float &x)
1569
+{
1570
+  long xx=x*100;
1571
+  
1572
+  xx=abs(xx);
1573
+  conv[0]=(xx/100)%10+'0';
1574
+  conv[1]='.';
1575
+  conv[2]=(xx/10)%10+'0';
1576
+  conv[3]=(xx)%10+'0';
1577
+  conv[4]=0;
1578
+  return conv;
1579
+}
1580
+
1552
 char *itostr31(const int &xx)
1581
 char *itostr31(const int &xx)
1553
 {
1582
 {
1554
   conv[0]=(xx>=0)?'+':'-';
1583
   conv[0]=(xx>=0)?'+':'-';

+ 5
- 0
Marlin/ultralcd.h View File

44
   extern int absPreheatFanSpeed;
44
   extern int absPreheatFanSpeed;
45
   
45
   
46
   extern bool cancel_heatup;
46
   extern bool cancel_heatup;
47
+  
48
+  #ifdef FILAMENT_LCD_DISPLAY
49
+        extern unsigned long message_millis;
50
+  #endif
47
     
51
     
48
   void lcd_buzz(long duration,uint16_t freq);
52
   void lcd_buzz(long duration,uint16_t freq);
49
   bool lcd_clicked();
53
   bool lcd_clicked();
111
 char *ftostr31ns(const float &x); // float to string without sign character
115
 char *ftostr31ns(const float &x); // float to string without sign character
112
 char *ftostr31(const float &x);
116
 char *ftostr31(const float &x);
113
 char *ftostr32(const float &x);
117
 char *ftostr32(const float &x);
118
+char *ftostr12ns(const float &x); 
114
 char *ftostr5(const float &x);
119
 char *ftostr5(const float &x);
115
 char *ftostr51(const float &x);
120
 char *ftostr51(const float &x);
116
 char *ftostr52(const float &x);
121
 char *ftostr52(const float &x);

+ 15
- 1
Marlin/ultralcd_implementation_hitachi_HD44780.h View File

499
     }
499
     }
500
 #endif
500
 #endif
501
 
501
 
502
-    //Status message line on the last line
502
+    //Display both Status message line and Filament display on the last line
503
+    #ifdef FILAMENT_LCD_DISPLAY
504
+      if(message_millis+5000>millis()){  //display any status for the first 5 sec after screen is initiated
505
+         	 lcd.setCursor(0, LCD_HEIGHT - 1);
506
+        	 lcd.print(lcd_status_message);
507
+        } else {
508
+		     lcd.setCursor(0,LCD_HEIGHT - 1);
509
+		     lcd_printPGM(PSTR("Dia "));
510
+		     lcd.print(ftostr12ns(filament_width_meas));
511
+		     lcd_printPGM(PSTR(" V"));
512
+		     lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM]));
513
+    		 lcd.print('%');
514
+        }
515
+    #else
503
     lcd.setCursor(0, LCD_HEIGHT - 1);
516
     lcd.setCursor(0, LCD_HEIGHT - 1);
504
     lcd.print(lcd_status_message);
517
     lcd.print(lcd_status_message);
518
+    #endif
505
 }
519
 }
506
 static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
520
 static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char)
507
 {
521
 {

+ 8
- 0
README.md View File

54
 *   Automatic operation of extruder/cold-end cooling fans based on nozzle temperature
54
 *   Automatic operation of extruder/cold-end cooling fans based on nozzle temperature
55
 *   RC Servo Support, specify angle or duration for continuous rotation servos.
55
 *   RC Servo Support, specify angle or duration for continuous rotation servos.
56
 *   Bed Auto Leveling.
56
 *   Bed Auto Leveling.
57
+*   Support for a filament diameter sensor, which adjusts extrusion volume
57
 
58
 
58
 The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments.
59
 The default baudrate is 250000. This baudrate has less jitter and hence errors than the usual 115200 baud, but is less supported by drivers and host-environments.
59
 
60
 
392
 
393
 
393
 That's it.. enjoy never having to calibrate your Z endstop neither leveling your bed by hand anymore ;-)
394
 That's it.. enjoy never having to calibrate your Z endstop neither leveling your bed by hand anymore ;-)
394
 
395
 
396
+Filament Sensor
397
+---------------
398
+Supports the use of a real time filament diameter sensor that measures the diameter of the filament going into the extruder and then adjusts the extrusion rate to compensate for filament that does not match what is defined in the g-code.  The diameter can also be displayed on the LCD screen. This potentially eliminates the need to measure filament diameter when changing spools of filament. Gcode becomes independent of the filament diameter. Can also compensate for changing diameter.
395
 
399
 
400
+For examples of these sensors, see: http://www.thingiverse.com/thing:454584, https://www.youmagine.com/designs/filament-diameter-sensor, http://diy3dprinting.blogspot.com/2014/01/diy-filament-diameter-sensor.html. Any sensor which produces a voltage equivalent to the diameter in mm (i.e. 1v = 1mm) can be used. This provides a very simple interface and may encourage more innovation in this area.
396
 
401
 
402
+4 new Mcodes are defined to set relevant parameters: M404, M405, M406, M407 - see above.
403
+
404
+ Implements a delay buffer to handle the transit delay between where the filament is measured and when it gets to the extruder.
397
 
405
 

Loading…
Cancel
Save