From 460b788d78c81a63cf49e910a65bcc306ce94c55 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Wed, 7 Dec 2011 20:54:34 +0100 Subject: [PATCH 01/18] repaired homing position setting. --- Marlin/Marlin.pde | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 226a7d35d..d0b5a0925 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -539,33 +539,52 @@ FORCE_INLINE void process_commands() #ifdef QUICK_HOME if( code_seen(axis_codes[0]) && code_seen(axis_codes[1]) ) //first diagonal move { - current_position[X_AXIS] = 0; current_position[Y_AXIS] = 0; + current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR; - destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR; - feedrate =homing_feedrate[X_AXIS]; + destination[X_AXIS] = 1.5 * X_MAX_LENGTH * X_HOME_DIR;destination[Y_AXIS] = 1.5 * Y_MAX_LENGTH * Y_HOME_DIR; + feedrate = homing_feedrate[X_AXIS]; if(homing_feedrate[Y_AXIS] Date: Wed, 7 Dec 2011 20:56:47 +0100 Subject: [PATCH 02/18] moved to more dominant location. --- Marlin/Marlin.h | 1 + Marlin/Marlin.pde | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 910cf46ad..73ffd421a 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -4,6 +4,7 @@ // Tonokip RepRap firmware rewrite based off of Hydra-mmm firmware. // Licence: GPL #define HardwareSerial_h // trick to disable the standard HWserial +#include #include #if ARDUINO >= 100 #include "Arduino.h" diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index d0b5a0925..ac42c1584 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -27,6 +27,8 @@ #include #include +#include + #include "EEPROMwrite.h" #include "fastio.h" #include "Configuration.h" @@ -39,7 +41,7 @@ #include "motion_control.h" #include "cardreader.h" #include "watchdog.h" -#include + #define VERSION_STRING "1.0.0 Beta 1" From 754d2d69b2e39d4a5ce0cae66974af289f4d5c8e Mon Sep 17 00:00:00 2001 From: Bernhard Date: Wed, 7 Dec 2011 23:08:13 +0100 Subject: [PATCH 03/18] z homing sound fix, for now until the actual cause is found.. --- Marlin/stepper.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 9cf8ddd17..e993d7303 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -706,6 +706,10 @@ void st_init() sei(); } +#define TEMPORARY_Z_HOME_SOUND_FIX +#ifdef TEMPORARY_Z_HOME_SOUND_FIX + #include +#endif // Block until all buffered steps are executed void st_synchronize() { @@ -713,6 +717,10 @@ void st_synchronize() manage_heater(); manage_inactivity(1); LCD_STATUS; + #ifdef TEMPORARY_Z_HOME_SOUND_FIX + _delay_ms(200); + _delay_ms(200); + #endif } } From bae1e422f615d585081078e88103af6742ded8c4 Mon Sep 17 00:00:00 2001 From: Keegi Date: Thu, 8 Dec 2011 12:25:32 +0200 Subject: [PATCH 04/18] Fix M201 not saving settings in all places, so the changes did not get written into EEPROM --- Marlin/Marlin.pde | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index ac42c1584..9deac7966 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -984,7 +984,11 @@ FORCE_INLINE void process_commands() case 201: // M201 for(int8_t i=0; i < NUM_AXIS; i++) { - if(code_seen(axis_codes[i])) axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i]; + if(code_seen(axis_codes[i])) + { + max_acceleration_units_per_sq_second[i] = code_value(); + axis_steps_per_sqr_second[i] = code_value() * axis_steps_per_unit[i]; + } } break; #if 0 // Not used for Sprinter/grbl gen6 From 61c943b4bfdb80ca8145cb66d16169a8891bdb94 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 12:32:31 +0100 Subject: [PATCH 05/18] fixed the st_synchronize. it would have continued if there is only the last move of the buffer being stepped. --- Marlin/planner.h | 10 ++++++++++ Marlin/stepper.cpp | 15 +++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/Marlin/planner.h b/Marlin/planner.h index 53ac3d844..b1e028f00 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -130,4 +130,14 @@ FORCE_INLINE block_t *plan_get_current_block() block->busy = true; return(block); } + +// Gets the current block. Returns NULL if buffer empty +FORCE_INLINE bool blocks_queued() +{ + if (block_buffer_head == block_buffer_tail) { + return false; + } + else + return true; +} #endif diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index e993d7303..2ef077346 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -706,22 +706,17 @@ void st_init() sei(); } -#define TEMPORARY_Z_HOME_SOUND_FIX -#ifdef TEMPORARY_Z_HOME_SOUND_FIX - #include -#endif + +#include // Block until all buffered steps are executed void st_synchronize() { - while(plan_get_current_block()) { + while(current_block!=0 || blocks_queued()) { manage_heater(); manage_inactivity(1); LCD_STATUS; - #ifdef TEMPORARY_Z_HOME_SOUND_FIX - _delay_ms(200); - _delay_ms(200); - #endif - } + //_delay_ms(1); + } } void st_set_position(const long &x, const long &y, const long &z, const long &e) From cc4a9cdb69081f4498a5268a682c8d9674f66bcb Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 12:33:00 +0100 Subject: [PATCH 06/18] added autostart procedure trigger to the ultralcd menu --- Marlin/cardreader.h | 1 + Marlin/cardreader.pde | 6 ++++-- Marlin/ultralcd.pde | 15 ++++++++++----- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/Marlin/cardreader.h b/Marlin/cardreader.h index 70244a877..70f0d2c1d 100644 --- a/Marlin/cardreader.h +++ b/Marlin/cardreader.h @@ -44,6 +44,7 @@ public: bool cardOK ; char filename[11]; bool filenameIsDir; + int lastnr; //last number of the autostart; private: SdFile root,*curDir,workDir,workDirParent,workDirParentParent; Sd2Card card; diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 1eb19ba00..8355f6aed 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -14,6 +14,7 @@ CardReader::CardReader() autostart_atmillis=0; autostart_stilltocheck=true; //the sd start is delayed, because otherwise the serial cannot answer fast enought to make contact with the hostsoftware. + lastnr=0; //power to SD reader #if SDPOWER > -1 SET_OUTPUT(SDPOWER); @@ -334,7 +335,7 @@ void CardReader::checkautostart(bool force) if(!cardOK) //fail return; } - static int lastnr=0; + char autoname[30]; sprintf(autoname,"auto%i.g",lastnr); for(int8_t i=0;i<(int)strlen(autoname);i++) @@ -434,7 +435,8 @@ void CardReader::printingHasFinished() sdprinting = false; if(SD_FINISHED_STEPPERRELEASE) { - finishAndDisableSteppers(); + //finishAndDisableSteppers(); + enquecommand("M84"); } autotempShutdown(); } diff --git a/Marlin/ultralcd.pde b/Marlin/ultralcd.pde index 88f8f32fb..e89474ed2 100644 --- a/Marlin/ultralcd.pde +++ b/Marlin/ultralcd.pde @@ -437,7 +437,7 @@ void MainMenu::showStatus() force_lcd_update=false; } -enum {ItemP_exit, ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude, ItemP_disstep}; +enum {ItemP_exit, ItemP_autostart,ItemP_disstep,ItemP_home, ItemP_origin, ItemP_preheat, ItemP_extrude}; //any action must not contain a ',' character anywhere, or this breaks: #define MENUITEM(repaint_action, click_action) \ @@ -458,6 +458,12 @@ void MainMenu::showPrepare() case ItemP_exit: MENUITEM( lcdprintPGM(" Main \003") , BLOCK;status=Main_Menu;beepshort(); ) ; break; + case ItemP_autostart: + MENUITEM( lcdprintPGM(" Autostart") , BLOCK;card.lastnr=0;card.checkautostart(true);beepshort(); ) ; + break; + case ItemP_disstep: + MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ; + break; case ItemP_home: MENUITEM( lcdprintPGM(" Auto Home") , BLOCK;enquecommand("G28 X-105 Y-105 Z0");beepshort(); ) ; break; @@ -470,15 +476,14 @@ void MainMenu::showPrepare() case ItemP_extrude: MENUITEM( lcdprintPGM(" Extrude") , BLOCK;enquecommand("G92 E0");enquecommand("G1 F700 E50");beepshort(); ) ; break; - case ItemP_disstep: - MENUITEM( lcdprintPGM(" Disable Steppers") , BLOCK;enquecommand("M84");beepshort(); ) ; - break; + + default: break; } line++; } - updateActiveLines(ItemP_disstep,encoderpos); + updateActiveLines(ItemP_extrude,encoderpos); } enum {ItemT_exit,ItemT_speed,ItemT_flow,ItemT_nozzle,ItemT_fan}; From 5b4625f79c9f5176168fd101b1cae74e829f6d93 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 12:51:08 +0100 Subject: [PATCH 07/18] added a partial release option to "m84" aka "stepper release". If you do tiny layers, you might want to keep the z-axis powered to not loose height positioning after homeing. --- Marlin/Configuration.h | 1 + Marlin/Marlin.pde | 24 ++++++++++++++---------- Marlin/cardreader.pde | 2 +- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e8b960f78..febc3bcca 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -292,6 +292,7 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th //#define ULTRA_LCD //general lcd support, also 16x2 //#define SDSUPPORT // Enable SD Card Support in Hardware Console #define SD_FINISHED_STEPPERRELEASE true //if sd support and the file is finished: disable steppers? +#define SD_FINISHED_RELEASECOMMAND "M84 X Y E" // no z because of layer shift. //#define ULTIPANEL #ifdef ULTIPANEL diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index ac42c1584..f3182a7d0 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -903,18 +903,22 @@ FORCE_INLINE void process_commands() } else { - #if ((E_ENABLE_PIN != X_ENABLE_PIN) && (E_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS - if(code_seen('E')) { - st_synchronize(); - LCD_MESSAGEPGM("Free Move"); - disable_e(); - } - else { + bool all_axis = !((code_seen(axis_codes[0])) || (code_seen(axis_codes[1])) || (code_seen(axis_codes[2]))|| (code_seen(axis_codes[3]))); + if(all_axis) + { finishAndDisableSteppers(); } - #else - finishAndDisableSteppers(); - #endif + else + { + st_synchronize(); + if(code_seen('X')) disable_x(); + if(code_seen('Y')) disable_y(); + if(code_seen('Z')) disable_z(); + #if ((E_ENABLE_PIN != X_ENABLE_PIN) && (E_ENABLE_PIN != Y_ENABLE_PIN)) // Only enable on boards that have seperate ENABLE_PINS + if(code_seen('E')) disable_e(); + #endif + LCD_MESSAGEPGM("Partial Release"); + } } break; case 85: // M85 diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 8355f6aed..6ad04068e 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -436,7 +436,7 @@ void CardReader::printingHasFinished() if(SD_FINISHED_STEPPERRELEASE) { //finishAndDisableSteppers(); - enquecommand("M84"); + enquecommand(SD_FINISHED_RELEASECOMMAND); } autotempShutdown(); } From 1ec0c3b68a250ef5d947509122777ed5ba43a91f Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 13:39:00 +0100 Subject: [PATCH 08/18] extruder runout prevention. --- Marlin/Configuration.h | 8 ++++++++ Marlin/Marlin.pde | 24 ++++++++++++++++++++---- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index febc3bcca..222fb3ade 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -156,6 +156,14 @@ #endif #endif // PIDTEMP +// extruder run-out prevention. +//if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded +//#define EXTRUDER_RUNOUT_PREVENT +#define EXTRUDER_RUNOUT_MINTEMP 190 +#define EXTRUDER_RUNOUT_SECONDS 60 +#define EXTRUDER_RUNOUT_EXTRUDE 10 //mm filament +#define EXTRUDER_RUNOUT_SPEED 20 //extrusion speed + //=========================================================================== //=============================Mechanical Settings=========================== diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index f3182a7d0..e80628e8b 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -499,19 +499,16 @@ FORCE_INLINE void process_commands() case 1: // G1 get_coordinates(); // For X Y Z E F prepare_move(); - previous_millis_cmd = millis(); //ClearToSend(); return; //break; case 2: // G2 - CW ARC get_arc_coordinates(); prepare_arc_move(true); - previous_millis_cmd = millis(); return; case 3: // G3 - CCW ARC get_arc_coordinates(); prepare_arc_move(false); - previous_millis_cmd = millis(); return; case 4: // G4 dwell LCD_MESSAGEPGM("DWELL..."); @@ -521,7 +518,7 @@ FORCE_INLINE void process_commands() st_synchronize(); codenum += millis(); // keep track of when we started waiting - + previous_millis_cmd = millis(); while(millis() < codenum ){ manage_heater(); } @@ -837,6 +834,7 @@ FORCE_INLINE void process_commands() } LCD_MESSAGEPGM("Heating done."); starttime=millis(); + previous_millis_cmd = millis(); } break; case 190: // M190 - Wait bed for heater to reach target. @@ -860,6 +858,7 @@ FORCE_INLINE void process_commands() manage_heater(); } LCD_MESSAGEPGM("Bed done."); + previous_millis_cmd = millis(); #endif break; @@ -1149,6 +1148,7 @@ FORCE_INLINE void get_arc_coordinates() void prepare_move() { + if (min_software_endstops) { if (destination[X_AXIS] < 0) destination[X_AXIS] = 0.0; if (destination[Y_AXIS] < 0) destination[Y_AXIS] = 0.0; @@ -1165,6 +1165,7 @@ void prepare_move() for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; } + previous_millis_cmd = millis(); } void prepare_arc_move(char isclockwise) { @@ -1179,6 +1180,7 @@ void prepare_arc_move(char isclockwise) { for(int8_t i=0; i < NUM_AXIS; i++) { current_position[i] = destination[i]; } + previous_millis_cmd = millis(); } void manage_inactivity(byte debug) @@ -1194,6 +1196,20 @@ void manage_inactivity(byte debug) disable_z(); disable_e(); } + #ifdef EXTRUDER_RUNOUT_PREVENT + if( (millis()-previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 ) + if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) + { + enable_e(); + float oldepos=current_position[E_AXIS]; + float oldedes=destination[E_AXIS]; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE, EXTRUDER_RUNOUT_SPEED*feedmultiply/60/100.0, active_extruder); + current_position[E_AXIS]=oldepos; + destination[E_AXIS]=oldedes; + plan_set_e_position(oldepos); + previous_millis_cmd=millis(); + } + #endif check_axes_activity(); } From 87fd249c4311fc3de7e1872f742b5ae3b632e85b Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 13:56:28 +0100 Subject: [PATCH 09/18] made runout prevention independent of tempeorarily set esteps --- Marlin/Configuration.h | 5 +++-- Marlin/Marlin.pde | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 222fb3ade..9574e0982 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -161,8 +161,9 @@ //#define EXTRUDER_RUNOUT_PREVENT #define EXTRUDER_RUNOUT_MINTEMP 190 #define EXTRUDER_RUNOUT_SECONDS 60 -#define EXTRUDER_RUNOUT_EXTRUDE 10 //mm filament -#define EXTRUDER_RUNOUT_SPEED 20 //extrusion speed +#define EXTRUDER_RUNOUT_ESTEPS 14 //mm filament +#define EXTRUDER_RUNOUT_EXTRUDE 100 //mm filament +#define EXTRUDER_RUNOUT_SPEED 1500 //extrusion speed //=========================================================================== diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index e80628e8b..30d65d3d9 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -1203,7 +1203,9 @@ void manage_inactivity(byte debug) enable_e(); float oldepos=current_position[E_AXIS]; float oldedes=destination[E_AXIS]; - plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE, EXTRUDER_RUNOUT_SPEED*feedmultiply/60/100.0, active_extruder); + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], + current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], + EXTRUDER_RUNOUT_SPEED*feedmultiply/60/100.0*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], active_extruder); current_position[E_AXIS]=oldepos; destination[E_AXIS]=oldedes; plan_set_e_position(oldepos); From aa4f9a64746f213cafce7cf58414d47619824a2b Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 14:07:32 +0100 Subject: [PATCH 10/18] better values. --- Marlin/Configuration.h | 8 ++++---- Marlin/Marlin.pde | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 9574e0982..47ad0b732 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -160,10 +160,10 @@ //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded //#define EXTRUDER_RUNOUT_PREVENT #define EXTRUDER_RUNOUT_MINTEMP 190 -#define EXTRUDER_RUNOUT_SECONDS 60 -#define EXTRUDER_RUNOUT_ESTEPS 14 //mm filament -#define EXTRUDER_RUNOUT_EXTRUDE 100 //mm filament -#define EXTRUDER_RUNOUT_SPEED 1500 //extrusion speed +#define EXTRUDER_RUNOUT_SECONDS 60. +#define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament +#define EXTRUDER_RUNOUT_EXTRUDE 50. //mm filament +#define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed //=========================================================================== diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 30d65d3d9..b3291cb0b 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -1205,7 +1205,7 @@ void manage_inactivity(byte debug) float oldedes=destination[E_AXIS]; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]+EXTRUDER_RUNOUT_EXTRUDE*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], - EXTRUDER_RUNOUT_SPEED*feedmultiply/60/100.0*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], active_extruder); + EXTRUDER_RUNOUT_SPEED/60.*EXTRUDER_RUNOUT_ESTEPS/axis_steps_per_unit[E_AXIS], active_extruder); current_position[E_AXIS]=oldepos; destination[E_AXIS]=oldedes; plan_set_e_position(oldepos); From 2bc5e7ec9efeeb2c72b1448565ce3c5481248f3b Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 15:09:52 +0100 Subject: [PATCH 11/18] prevent too long extrudes, or too cold extrudes --- Marlin/Configuration.h | 13 ++++++++++--- Marlin/Marlin.pde | 27 +++++++++++++++++++-------- Marlin/planner.cpp | 28 ++++++++++++++++++++++++++-- Marlin/planner.h | 2 ++ 4 files changed, 57 insertions(+), 13 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 47ad0b732..2b60c3602 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -20,9 +20,6 @@ // if unwanted behavior is observed on a user's machine when running at very slow speeds. #define MINIMUM_PLANNER_SPEED 2.0 // (mm/sec) -// If defined the movements slow down when the look ahead buffer is only half full -#define SLOWDOWN - // BASIC SETTINGS: select your board type, thermistor type, axis scaling, and endstop configuration //// The following define selects which electronics board you have. Please choose the one that matches your setup @@ -248,7 +245,12 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define DEFAULT_XYJERK 20.0 // (mm/sec) #define DEFAULT_ZJERK 0.4 // (mm/sec) +// If defined the movements slow down when the look ahead buffer is only half full +#define SLOWDOWN +//default stepper release if idle +#define DEFAULT_STEPPER_DEACTIVE_TIME 60 +#define DEFAULT_STEPPER_DEACTIVE_COMMAND "M84 X Y E" //z stays powered //=========================================================================== @@ -338,6 +340,11 @@ const bool Z_ENDSTOPS_INVERTING = true; // set to true to invert the logic of th #define AUTOTEMP_OLDWEIGHT 0.98 #endif +//this prevents dangerous Extruder moves, i.e. if the temperature is under the limit +//can be software-disabled for whatever purposes by +#define PREVENT_DANGEROUS_EXTRUDE +#define EXTRUDE_MINTEMP 190 +#define EXTRUDE_MAXLENGTH (X_MAX_LENGTH+Y_MAX_LENGTH) //prevent extrusion of very large distances. const int dropsegments=5; //everything with less than this number of steps will be ignored as move and joined with the next movement diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index b3291cb0b..c6251927e 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -110,6 +110,7 @@ // M206 - set additional homeing offset // M220 - set speed factor override percentage S:factor in percent // M301 - Set PID parameters P I and D +// M302 - Allow cold extrudes // M400 - Finish all moves // M500 - stores paramters in EEPROM // M501 - reads parameters from EEPROM (if you need reset them after you changed them temporarily). @@ -176,7 +177,8 @@ const int sensitive_pins[] = SENSITIVE_PINS; // Sensitive pin list for M42 //Inactivity shutdown variables static unsigned long previous_millis_cmd = 0; static unsigned long max_inactive_time = 0; -static unsigned long stepper_inactive_time = 0; +static unsigned long stepper_inactive_time = DEFAULT_STEPPER_DEACTIVE_TIME*1000; +static unsigned long last_stepperdisabled_time=30*1000; //first release check after 30 seconds static unsigned long starttime=0; static unsigned long stoptime=0; @@ -1057,6 +1059,12 @@ FORCE_INLINE void process_commands() } break; #endif //PIDTEMP + + case 302: // finish all moves + { + allow_cold_extrudes(true); + } + break; case 400: // finish all moves { st_synchronize(); @@ -1188,14 +1196,17 @@ void manage_inactivity(byte debug) if( (millis()-previous_millis_cmd) > max_inactive_time ) if(max_inactive_time) kill(); - if( (millis()-previous_millis_cmd) > stepper_inactive_time ) - if(stepper_inactive_time) - { - disable_x(); - disable_y(); - disable_z(); - disable_e(); + if(stepper_inactive_time) + if( (millis()-last_stepperdisabled_time) > stepper_inactive_time ) + { + if(previous_millis_cmd>last_stepperdisabled_time) + last_stepperdisabled_time=previous_millis_cmd; + else + { + enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); + last_stepperdisabled_time=millis(); } + } #ifdef EXTRUDER_RUNOUT_PREVENT if( (millis()-previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 ) if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) diff --git a/Marlin/planner.cpp b/Marlin/planner.cpp index a8f41d353..df255443d 100644 --- a/Marlin/planner.cpp +++ b/Marlin/planner.cpp @@ -106,7 +106,9 @@ volatile unsigned char block_buffer_tail; // Index of the block to pro //=========================================================================== //=============================private variables ============================ //=========================================================================== - +#ifdef PREVENT_DANGEROUS_EXTRUDE + bool allow_cold_extrude=false; +#endif #ifdef XY_FREQUENCY_LIMIT // Used for the frequency limit static unsigned char old_direction_bits = 0; // Old direction bits. Used for speed calculations @@ -465,7 +467,23 @@ void plan_buffer_line(const float &x, const float &y, const float &z, const floa target[X_AXIS] = lround(x*axis_steps_per_unit[X_AXIS]); target[Y_AXIS] = lround(y*axis_steps_per_unit[Y_AXIS]); target[Z_AXIS] = lround(z*axis_steps_per_unit[Z_AXIS]); - target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + target[E_AXIS] = lround(e*axis_steps_per_unit[E_AXIS]); + + #ifdef PREVENT_DANGEROUS_EXTRUDE + if(target[E_AXIS]!=position[E_AXIS]) + if(degHotend(active_extruder)axis_steps_per_unit[E_AXIS]*EXTRUDE_MAXLENGTH) + { + position[E_AXIS]=target[E_AXIS]; //behave as if the move really took place, but ignore E part + SERIAL_ECHO_START; + SERIAL_ECHOLNPGM(" too long extrusion prevented"); + } + #endif // Prepare to set up new block block_t *block = &block_buffer[block_buffer_head]; @@ -786,3 +804,9 @@ uint8_t movesplanned() return (block_buffer_head-block_buffer_tail + BLOCK_BUFFER_SIZE) & (BLOCK_BUFFER_SIZE - 1); } +void allow_cold_extrudes(bool allow) +{ + #ifdef PREVENT_DANGEROUS_EXTRUDE + allow_cold_extrude=allow; + #endif +} \ No newline at end of file diff --git a/Marlin/planner.h b/Marlin/planner.h index b1e028f00..b2d1c6c6c 100644 --- a/Marlin/planner.h +++ b/Marlin/planner.h @@ -140,4 +140,6 @@ FORCE_INLINE bool blocks_queued() else return true; } + +void allow_cold_extrudes(bool allow); #endif From dde4b40fa9e312bb6cb76b7fe9c8e0f8a2e28caf Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 15:37:24 +0100 Subject: [PATCH 12/18] disable steppers in runout prevention --- Marlin/Marlin.pde | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index c6251927e..05924b93a 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -1221,6 +1221,7 @@ void manage_inactivity(byte debug) destination[E_AXIS]=oldedes; plan_set_e_position(oldepos); previous_millis_cmd=millis(); + enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); } #endif check_axes_activity(); From b1d84d879b7ddb6119ce7c8a5ce2c8df9986636e Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 16:13:58 +0100 Subject: [PATCH 13/18] st_synchronize back to normal.. --- Marlin/stepper.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 2ef077346..33c7e154c 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -707,15 +707,13 @@ void st_init() } -#include // Block until all buffered steps are executed void st_synchronize() { - while(current_block!=0 || blocks_queued()) { + while( blocks_queued()) { manage_heater(); manage_inactivity(1); LCD_STATUS; - //_delay_ms(1); } } From 88ee053af0a7d71cea23cbc1adf5b101e0b1a7fa Mon Sep 17 00:00:00 2001 From: Bernhard Date: Fri, 9 Dec 2011 17:06:56 +0100 Subject: [PATCH 14/18] heating up santity, formarly knows as "watchdog", but renamed due to the existance of the real watchdog, works now. --- Marlin/Configuration.h | 10 +++++----- Marlin/temperature.cpp | 19 ++++++++++++++++--- Marlin/temperature.h | 8 ++++---- 3 files changed, 25 insertions(+), 12 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 2b60c3602..e2fe8403e 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -58,11 +58,11 @@ #define BED_CHECK_INTERVAL 5000 //ms -//// Experimental watchdog and minimal temp -// The watchdog waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature -// If the temperature has not increased at the end of that period, the target temperature is set to zero. It can be reset with another M104/M109 -/// CURRENTLY NOT IMPLEMENTED AND UNUSEABLE -//#define WATCHPERIOD 5000 //5 seconds +//// Heating sanity check: +// This waits for the watchperiod in milliseconds whenever an M104 or M109 increases the target temperature +// If the temperature has not increased at the end of that period, the target temperature is set to zero. +// It can be reset with another M104/M109 +//#define WATCHPERIOD 20000 //20 seconds // Actual temperature must be close to target for this long before M109 returns success //#define TEMP_RESIDENCY_TIME 20 // (seconds) diff --git a/Marlin/temperature.cpp b/Marlin/temperature.cpp index ac5aeaa3e..785da6c92 100644 --- a/Marlin/temperature.cpp +++ b/Marlin/temperature.cpp @@ -88,7 +88,7 @@ static unsigned long previous_millis_bed_heater; #endif //PIDTEMP #ifdef WATCHPERIOD - static int watch_raw[3] = {-1000,-1000,-1000}; + static int watch_oldtemp[3] = {0,0,0}; static unsigned long watchmillis = 0; #endif //WATCHPERIOD @@ -186,7 +186,20 @@ void manage_heater() WRITE(HEATER_0_PIN,LOW); } #endif - + + #ifdef WATCHPERIOD + if(watchmillis && millis() - watchmillis > WATCHPERIOD){ + if(watch_oldtemp[TEMPSENSOR_HOTEND_0] >= degHotend(active_extruder)){ + setTargetHotend(0,active_extruder); + LCD_MESSAGEPGM("Heating failed"); + SERIAL_ECHO_START; + SERIAL_ECHOLN("Heating failed"); + }else{ + watchmillis = 0; + } + } + #endif + if(millis() - previous_millis_bed_heater < BED_CHECK_INTERVAL) return; previous_millis_bed_heater = millis(); @@ -426,7 +439,7 @@ void setWatch() if(isHeatingHotend0()) { watchmillis = max(1,millis()); - watch_raw[TEMPSENSOR_HOTEND_0] = current_raw[TEMPSENSOR_HOTEND_0]; + watch_oldtemp[TEMPSENSOR_HOTEND_0] = degHotend(0); } else { diff --git a/Marlin/temperature.h b/Marlin/temperature.h index 623f890bb..fae27f734 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -49,10 +49,10 @@ extern float Kp,Ki,Kd,Kc; extern float pid_setpoint ; #endif -#ifdef WATCHPERIOD - extern int watch_raw[3] ; - extern unsigned long watchmillis; -#endif +// #ifdef WATCHPERIOD +// extern int watch_raw[3] ; +// extern unsigned long watchmillis; +// #endif From 01001b89d200111f95be0d7ce87aa16e91ddf998 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Sun, 11 Dec 2011 15:42:56 +0100 Subject: [PATCH 15/18] repaired nozzle runout prevention to not collide with automatic stepper disabeling. --- Marlin/Configuration.h | 3 +-- Marlin/Marlin.pde | 12 +++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index e2fe8403e..dc8c799f5 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -157,9 +157,8 @@ //if the machine is idle, and the temperature over MINTEMP, every couple of SECONDS some filament is extruded //#define EXTRUDER_RUNOUT_PREVENT #define EXTRUDER_RUNOUT_MINTEMP 190 -#define EXTRUDER_RUNOUT_SECONDS 60. +#define EXTRUDER_RUNOUT_SECONDS 30. #define EXTRUDER_RUNOUT_ESTEPS 14. //mm filament -#define EXTRUDER_RUNOUT_EXTRUDE 50. //mm filament #define EXTRUDER_RUNOUT_SPEED 1500. //extrusion speed diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 538920da2..0a8a80c4c 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -235,7 +235,9 @@ void setup() SERIAL_PROTOCOLLNPGM("start"); SERIAL_ECHO_START; SERIAL_ECHOPGM("Free Memory:"); - SERIAL_ECHOLN(freeMemory()); + SERIAL_ECHO(freeMemory()); + SERIAL_ECHOPGM(" PlannerBufferBytes:"); + SERIAL_ECHOLN((int)sizeof(block_t)*BLOCK_BUFFER_SIZE); for(int8_t i = 0; i < BUFSIZE; i++) { fromsd[i] = false; @@ -1207,7 +1209,8 @@ void manage_inactivity(byte debug) last_stepperdisabled_time=previous_millis_cmd; else { - enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); + if( (X_ENABLE_ON && (READ(X_ENABLE_PIN)!=0)) || (!X_ENABLE_ON && READ(X_ENABLE_PIN)==0) ) + enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); last_stepperdisabled_time=millis(); } } @@ -1215,6 +1218,7 @@ void manage_inactivity(byte debug) if( (millis()-previous_millis_cmd) > EXTRUDER_RUNOUT_SECONDS*1000 ) if(degHotend(active_extruder)>EXTRUDER_RUNOUT_MINTEMP) { + bool oldstatus=READ(E_ENABLE_PIN); enable_e(); float oldepos=current_position[E_AXIS]; float oldedes=destination[E_AXIS]; @@ -1225,7 +1229,9 @@ void manage_inactivity(byte debug) destination[E_AXIS]=oldedes; plan_set_e_position(oldepos); previous_millis_cmd=millis(); - enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); + //enquecommand(DEFAULT_STEPPER_DEACTIVE_COMMAND); + st_synchronize(); + WRITE(E_ENABLE_PIN,oldstatus); } #endif check_axes_activity(); From 82c99625facf9711dc974759f3ed31320abd90d2 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Sun, 11 Dec 2011 22:10:06 +0100 Subject: [PATCH 16/18] instant stop of sd prints from the panel. --- Marlin/cardreader.pde | 1 + Marlin/stepper.cpp | 9 +++++++++ Marlin/stepper.h | 2 +- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 6ad04068e..735a1cdcd 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -432,6 +432,7 @@ void CardReader::updir() void CardReader::printingHasFinished() { + quickStop(); sdprinting = false; if(SD_FINISHED_STEPPERRELEASE) { diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 33c7e154c..51a9fe071 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -752,3 +752,12 @@ void finishAndDisableSteppers() disable_z(); disable_e(); } + +void quickStop() +{ + DISABLE_STEPPER_DRIVER_INTERRUPT(); + while(blocks_queued()) + plan_discard_current_block(); + ENABLE_STEPPER_DRIVER_INTERRUPT(); +} + diff --git a/Marlin/stepper.h b/Marlin/stepper.h index fd388ca68..37ce3b546 100644 --- a/Marlin/stepper.h +++ b/Marlin/stepper.h @@ -52,5 +52,5 @@ void finishAndDisableSteppers(); extern block_t *current_block; // A pointer to the block currently being traced - +void quickStop(); #endif From 06411d5c9e39bda41be21d56cec0f4cc21e2e612 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Sun, 11 Dec 2011 22:18:50 +0100 Subject: [PATCH 17/18] ultralcd can now also stop the wait loop for the hot-end m109 heating when stopping sd prints. --- Marlin/Marlin.h | 1 + Marlin/Marlin.pde | 3 ++- Marlin/cardreader.pde | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Marlin/Marlin.h b/Marlin/Marlin.h index 73ffd421a..8f9824408 100644 --- a/Marlin/Marlin.h +++ b/Marlin/Marlin.h @@ -131,5 +131,6 @@ extern float homing_feedrate[]; extern bool axis_relative_modes[]; extern float current_position[NUM_AXIS] ; extern float add_homeing[3]; +extern bool stop_heating_wait; #endif diff --git a/Marlin/Marlin.pde b/Marlin/Marlin.pde index 0a8a80c4c..4d031ea78 100644 --- a/Marlin/Marlin.pde +++ b/Marlin/Marlin.pde @@ -138,7 +138,7 @@ int saved_feedmultiply; volatile bool feedmultiplychanged=false; float current_position[NUM_AXIS] = { 0.0, 0.0, 0.0, 0.0}; float add_homeing[3]={0,0,0}; - +bool stop_heating_wait=false; //=========================================================================== //=============================private variables============================= //=========================================================================== @@ -825,6 +825,7 @@ FORCE_INLINE void process_commands() } manage_heater(); LCD_STATUS; + if(stop_heating_wait) break; #ifdef TEMP_RESIDENCY_TIME /* start/restart the TEMP_RESIDENCY_TIME timer whenever we reach target temp for the first time or when current temp falls outside the hysteresis after target temp was reached */ diff --git a/Marlin/cardreader.pde b/Marlin/cardreader.pde index 735a1cdcd..2cf44e6cd 100644 --- a/Marlin/cardreader.pde +++ b/Marlin/cardreader.pde @@ -434,6 +434,7 @@ void CardReader::printingHasFinished() { quickStop(); sdprinting = false; + stop_heating_wait=true; if(SD_FINISHED_STEPPERRELEASE) { //finishAndDisableSteppers(); From 3320a5b37d9125d29dba6108a2846257c3d3b470 Mon Sep 17 00:00:00 2001 From: Bernhard Date: Sun, 11 Dec 2011 22:25:52 +0100 Subject: [PATCH 18/18] make autotemp compatile for use without pid --- Marlin/temperature.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Marlin/temperature.h b/Marlin/temperature.h index fae27f734..2580947e7 100644 --- a/Marlin/temperature.h +++ b/Marlin/temperature.h @@ -23,6 +23,7 @@ #include "Marlin.h" #include "fastio.h" +#include "planner.h" #ifdef PID_ADD_EXTRUSION_RATE #include "stepper.h" #endif