Przeglądaj źródła

Merge pull request #1141 from filipmu/Filament-Sensor

Display filament sensor data on a 20x4 LCD or Graphical LCD
Bo Herrmannsen 9 lat temu
rodzic
commit
91d740e128

+ 3
- 1
Marlin/Configuration.h Wyświetl plik

@@ -773,7 +773,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
773 773
  * 
774 774
  * Motherboards
775 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 777
  * 301 - Rambo  - uses Analog input 3
778 778
  * Note may require analog pins to be defined for different motherboards
779 779
  **********************************************************************/
@@ -791,6 +791,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of
791 791
 //defines used in the code
792 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 Wyświetl plik

@@ -328,7 +328,21 @@ static void lcd_implementation_status_screen()
328 328
  // Status line
329 329
  u8g.setFont(FONT_STATUSMENU);
330 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 Wyświetl plik

@@ -20,6 +20,12 @@ int absPreheatHPBTemp;
20 20
 int absPreheatFanSpeed;
21 21
 
22 22
 
23
+#ifdef FILAMENT_LCD_DISPLAY
24
+unsigned long message_millis=0;
25
+#endif
26
+
27
+
28
+
23 29
 #ifdef ULTIPANEL
24 30
 static float manual_feedrate[] = MANUAL_FEEDRATE;
25 31
 #endif // ULTIPANEL
@@ -216,6 +222,9 @@ static void lcd_status_screen()
216 222
         encoderPosition = 0;
217 223
         lcd_quick_feedback();
218 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 230
 #ifdef ULTIPANEL_FEEDMULTIPLY
@@ -1355,6 +1364,9 @@ void lcd_setstatus(const char* message)
1355 1364
         return;
1356 1365
     strncpy(lcd_status_message, message, LCD_WIDTH);
1357 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 1371
 void lcd_setstatuspgm(const char* message)
1360 1372
 {
@@ -1362,6 +1374,9 @@ void lcd_setstatuspgm(const char* message)
1362 1374
         return;
1363 1375
     strncpy_P(lcd_status_message, message, LCD_WIDTH);
1364 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 1381
 void lcd_setalertstatuspgm(const char* message)
1367 1382
 {
@@ -1549,6 +1564,20 @@ char *ftostr32(const float &x)
1549 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 1581
 char *itostr31(const int &xx)
1553 1582
 {
1554 1583
   conv[0]=(xx>=0)?'+':'-';

+ 5
- 0
Marlin/ultralcd.h Wyświetl plik

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

+ 15
- 1
Marlin/ultralcd_implementation_hitachi_HD44780.h Wyświetl plik

@@ -499,9 +499,23 @@ static void lcd_implementation_status_screen()
499 499
     }
500 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 516
     lcd.setCursor(0, LCD_HEIGHT - 1);
504 517
     lcd.print(lcd_status_message);
518
+    #endif
505 519
 }
506 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 Wyświetl plik

@@ -54,6 +54,7 @@ Features:
54 54
 *   Automatic operation of extruder/cold-end cooling fans based on nozzle temperature
55 55
 *   RC Servo Support, specify angle or duration for continuous rotation servos.
56 56
 *   Bed Auto Leveling.
57
+*   Support for a filament diameter sensor, which adjusts extrusion volume
57 58
 
58 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,6 +393,13 @@ For example, suppose you measured the endstop position and it was 20mm to the ri
392 393
 
393 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
 

Ładowanie…
Anuluj
Zapisz