From d84934d8c5bdb7f8298760ce487da4c9c33bc438 Mon Sep 17 00:00:00 2001 From: Filip Mulier Date: Mon, 10 Nov 2014 21:43:58 -0600 Subject: [PATCH 1/3] Display Filament Sensor data on 20x4 LCD Changes to support displaying the real-time filament width and the volume factor on a 20x4 LCD. The data is displayed on the 4th line. First the status message is displayed for 5 seconds, and then the filament data is displayed. The status message can be seen by re-selecting the info screen in the menu. --- Marlin/Configuration.h | 4 ++- Marlin/ultralcd.cpp | 29 +++++++++++++++++++ Marlin/ultralcd.h | 5 ++++ .../ultralcd_implementation_hitachi_HD44780.h | 16 +++++++++- 4 files changed, 52 insertions(+), 2 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index d2aba196d9..e2cadaa17f 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -773,7 +773,7 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of * * Motherboards * 34 - RAMPS1.4 - uses Analog input 5 on the AUX2 connector - * 81 - Printrboard - Uses Analog input 2 on the Aux 2 connector + * 81 - Printrboard - Uses Analog input 2 on the Exp1 connector (version B,C,D,E) * 301 - Rambo - uses Analog input 3 * Note may require analog pins to be defined for different motherboards **********************************************************************/ @@ -789,6 +789,8 @@ const bool Z_MAX_ENDSTOP_INVERTING = true; // set to true to invert the logic of //defines used in the code #define DEFAULT_MEASURED_FILAMENT_DIA DEFAULT_NOMINAL_FILAMENT_DIA //set measured to nominal initially +//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. +//#define FILAMENT_LCD_DISPLAY diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index 734c859d02..5873cc7146 100644 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -20,6 +20,12 @@ int absPreheatHPBTemp; int absPreheatFanSpeed; +#ifdef FILAMENT_LCD_DISPLAY +unsigned long message_millis=0; +#endif + + + #ifdef ULTIPANEL static float manual_feedrate[] = MANUAL_FEEDRATE; #endif // ULTIPANEL @@ -195,6 +201,9 @@ static void lcd_status_screen() encoderPosition = 0; lcd_quick_feedback(); lcd_implementation_init(); // to maybe revive the LCD if static electricity killed it. +#ifdef FILAMENT_LCD_DISPLAY + message_millis=millis(); //get status message to show up for a while +#endif } #ifdef ULTIPANEL_FEEDMULTIPLY @@ -1321,6 +1330,9 @@ void lcd_setstatus(const char* message) return; strncpy(lcd_status_message, message, LCD_WIDTH); lcdDrawUpdate = 2; +#ifdef FILAMENT_LCD_DISPLAY + message_millis=millis(); //get status message to show up for a while +#endif } void lcd_setstatuspgm(const char* message) { @@ -1328,6 +1340,9 @@ void lcd_setstatuspgm(const char* message) return; strncpy_P(lcd_status_message, message, LCD_WIDTH); lcdDrawUpdate = 2; +#ifdef FILAMENT_LCD_DISPLAY + message_millis=millis(); //get status message to show up for a while +#endif } void lcd_setalertstatuspgm(const char* message) { @@ -1515,6 +1530,20 @@ char *ftostr32(const float &x) return conv; } +//Float to string with 1.23 format +char *ftostr12ns(const float &x) +{ + long xx=x*100; + + xx=abs(xx); + conv[0]=(xx/100)%10+'0'; + conv[1]='.'; + conv[2]=(xx/10)%10+'0'; + conv[3]=(xx)%10+'0'; + conv[4]=0; + return conv; +} + char *itostr31(const int &xx) { conv[0]=(xx>=0)?'+':'-'; diff --git a/Marlin/ultralcd.h b/Marlin/ultralcd.h index 9bf685805d..ca342c144e 100644 --- a/Marlin/ultralcd.h +++ b/Marlin/ultralcd.h @@ -44,6 +44,10 @@ extern int absPreheatFanSpeed; extern bool cancel_heatup; + + #ifdef FILAMENT_LCD_DISPLAY + extern unsigned long message_millis; + #endif void lcd_buzz(long duration,uint16_t freq); bool lcd_clicked(); @@ -109,6 +113,7 @@ char *ftostr3(const float &x); char *ftostr31ns(const float &x); // float to string without sign character char *ftostr31(const float &x); char *ftostr32(const float &x); +char *ftostr12ns(const float &x); char *ftostr5(const float &x); char *ftostr51(const float &x); char *ftostr52(const float &x); diff --git a/Marlin/ultralcd_implementation_hitachi_HD44780.h b/Marlin/ultralcd_implementation_hitachi_HD44780.h index befb25bfdb..d5f62e8697 100644 --- a/Marlin/ultralcd_implementation_hitachi_HD44780.h +++ b/Marlin/ultralcd_implementation_hitachi_HD44780.h @@ -499,9 +499,23 @@ static void lcd_implementation_status_screen() } #endif - //Status message line on the last line + //Display both Status message line and Filament display on the last line + #ifdef FILAMENT_LCD_DISPLAY + if(message_millis+5000>millis()){ //display any status for the first 5 sec after screen is initiated + lcd.setCursor(0, LCD_HEIGHT - 1); + lcd.print(lcd_status_message); + } else { + lcd.setCursor(0,LCD_HEIGHT - 1); + lcd_printPGM(PSTR("Dia ")); + lcd.print(ftostr12ns(filament_width_meas)); + lcd_printPGM(PSTR(" V")); + lcd.print(itostr3(100.0*volumetric_multiplier[FILAMENT_SENSOR_EXTRUDER_NUM])); + lcd.print('%'); + } + #else lcd.setCursor(0, LCD_HEIGHT - 1); lcd.print(lcd_status_message); + #endif } static void lcd_implementation_drawmenu_generic(uint8_t row, const char* pstr, char pre_char, char post_char) { From 3b1ab845362328802a10c00ef153e80ec13f1c22 Mon Sep 17 00:00:00 2001 From: Filip Mulier Date: Mon, 10 Nov 2014 21:46:37 -0600 Subject: [PATCH 2/3] Display Filament Sensor data on graphic LCD Added support to show the filament width on the status line of the graphic LCD. The status will show for 5 sec and then switch over to data. Status can be seen by clicking the button. --- Marlin/dogm_lcd_implementation.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Marlin/dogm_lcd_implementation.h b/Marlin/dogm_lcd_implementation.h index 8d450cb370..ec661f15c6 100644 --- a/Marlin/dogm_lcd_implementation.h +++ b/Marlin/dogm_lcd_implementation.h @@ -334,7 +334,21 @@ static void lcd_implementation_status_screen() // Status line u8g.setFont(FONT_STATUSMENU); u8g.setPrintPos(0,61); - u8g.print(lcd_status_message); + #ifndef FILAMENT_LCD_DISPLAY + u8g.print(lcd_status_message); + #else + if(message_millis+5000>millis()){ //Display both Status message line and Filament display on the last line + u8g.print(lcd_status_message); + } + else + { + lcd_printPGM(PSTR("dia:")); + u8g.print(ftostr12ns(filament_width_meas)); + lcd_printPGM(PSTR(" factor:")); + u8g.print(itostr3(extrudemultiply)); + u8g.print('%'); + } + #endif } From 1651ccc0cc483fb8f65b4d2adf0518fb6488fb3b Mon Sep 17 00:00:00 2001 From: Filip Mulier Date: Mon, 10 Nov 2014 22:05:20 -0600 Subject: [PATCH 3/3] Added Filament Sensor to the README Added some background on the filament sensor to explain it better. --- README.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/README.md b/README.md index 5eda8465cd..8b4bebb041 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ Features: * Automatic operation of extruder/cold-end cooling fans based on nozzle temperature * RC Servo Support, specify angle or duration for continuous rotation servos. * Bed Auto Leveling. +* Support for a filament diameter sensor, which adjusts extrusion volume 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. @@ -391,6 +392,13 @@ For example, suppose you measured the endstop position and it was 20mm to the ri That's it.. enjoy never having to calibrate your Z endstop neither leveling your bed by hand anymore ;-) +Filament Sensor +--------------- +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. +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. +4 new Mcodes are defined to set relevant parameters: M404, M405, M406, M407 - see above. + + Implements a delay buffer to handle the transit delay between where the filament is measured and when it gets to the extruder.