From 570b5989f4972b399e39ee2d74330928292e4cce Mon Sep 17 00:00:00 2001 From: leptun Date: Sun, 6 Oct 2019 10:50:11 +0300 Subject: [PATCH 01/26] Disable bed PWM while probing bed. --- Firmware/heatbed_pwm.cpp | 6 ++++++ Firmware/mesh_bed_calibration.cpp | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index a3e5444c3..6f5a93162 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -61,6 +61,8 @@ enum class States : uint8_t { ///! Inner states of the finite automaton static States state = States::ZERO_START; +bool bedPWMDisabled = 0; + ///! Fast PWM counter is used in the RISE and FALL states (62.5kHz) static uint8_t slowCounter = 0; ///! Slow PWM counter is used in the ZERO and ONE states (62.5kHz/8 or 64) @@ -93,6 +95,7 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine { switch(state){ case States::ZERO_START: + if (bedPWMDisabled) break; pwm = soft_pwm_bed << 1;// expecting soft_pwm_bed to be 7bit! if( pwm != 0 ){ state = States::ZERO; // do nothing, let it tick once again after the 30Hz period @@ -144,6 +147,9 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf } + if (bedPWMDisabled){ + return; + } // otherwise moving towards FALL // @@TODO it looks like ONE_TO_FALL isn't necessary, there are no artefacts at all state = States::ONE;//_TO_FALL; diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 6466edc45..36fbfda42 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -23,6 +23,7 @@ float world2machine_shift[2]; #define WEIGHT_FIRST_ROW_Y_HIGH (0.3f) #define WEIGHT_FIRST_ROW_Y_LOW (0.0f) +extern bool bedPWMDisabled; // Scaling of the real machine axes against the programmed dimensions in the firmware. @@ -946,6 +947,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i ) { bool high_deviation_occured = false; + bedPWMDisabled = 1; #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif @@ -1044,6 +1046,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i #ifdef TMC2130 FORCE_HIGH_POWER_END; #endif + bedPWMDisabled = 0; return true; error: @@ -1053,6 +1056,7 @@ error: #ifdef TMC2130 FORCE_HIGH_POWER_END; #endif + bedPWMDisabled = 0; return false; } From 7650e2b60cf6404924af8ae026bd92d10a75486a Mon Sep 17 00:00:00 2001 From: leptun Date: Sun, 6 Oct 2019 12:43:03 +0300 Subject: [PATCH 02/26] Handle disable_heater() --- Firmware/mesh_bed_calibration.cpp | 2 +- Firmware/temperature.cpp | 1 + Firmware/temperature.h | 2 ++ 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 36fbfda42..88cbc671a 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -6,6 +6,7 @@ #include "mesh_bed_leveling.h" #include "stepper.h" #include "ultralcd.h" +#include "temperature.h" #ifdef TMC2130 #include "tmc2130.h" @@ -23,7 +24,6 @@ float world2machine_shift[2]; #define WEIGHT_FIRST_ROW_Y_HIGH (0.3f) #define WEIGHT_FIRST_ROW_Y_LOW (0.0f) -extern bool bedPWMDisabled; // Scaling of the real machine axes against the programmed dimensions in the firmware. diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index df8a39e09..15f2d3a3a 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -1394,6 +1394,7 @@ void disable_heater() target_temperature_bed=0; soft_pwm_bed=0; timer02_set_pwm0(soft_pwm_bed << 1); + bedPWMDisabled = 0; #if defined(HEATER_BED_PIN) && HEATER_BED_PIN > -1 //WRITE(HEATER_BED_PIN,LOW); #endif diff --git a/Firmware/temperature.h b/Firmware/temperature.h index 7c40eae65..cbebb3f2c 100755 --- a/Firmware/temperature.h +++ b/Firmware/temperature.h @@ -79,6 +79,8 @@ extern int current_voltage_raw_bed; extern unsigned char soft_pwm_bed; #endif +extern bool bedPWMDisabled; + #ifdef PIDTEMP extern int pid_cycle, pid_number_of_cycles; extern float Kc,_Kp,_Ki,_Kd; From dde61bb444cebe490636baaa5a695475d46109a3 Mon Sep 17 00:00:00 2001 From: leptun Date: Sun, 6 Oct 2019 12:44:45 +0300 Subject: [PATCH 03/26] Automaton changes. Keep heater ON during probing only if pwm is high --- Firmware/heatbed_pwm.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index 6f5a93162..1e467c4e8 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -140,14 +140,16 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine case States::ONE: // state ONE - we'll either stay in ONE or change to FALL OCR0B = 255; slowCounter += slowInc; // this does software timer_clk/256 or less - if( slowCounter < pwm ){ - return; + if (!bedPWMDisabled){ //disable heating as soon as possible + if( slowCounter < pwm ){ + return; + } + if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain + // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating + return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf + } } - if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain - // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating - return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf - } - if (bedPWMDisabled){ + else if (pwm > 200){ //if duty cycle is high and BED PWM is disabled keep heater on. Prevents overcooling return; } // otherwise moving towards FALL From 28e812d91fe2b4633c9427abdf554e5a9449dd17 Mon Sep 17 00:00:00 2001 From: leptun Date: Wed, 2 Oct 2019 17:34:09 +0300 Subject: [PATCH 04/26] Mesh bed leveling testing --- Firmware/Marlin_main.cpp | 10 +++------- Firmware/mesh_bed_calibration.cpp | 8 ++++---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 45dd118c4..f65ec4b68 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4767,11 +4767,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * (ix + iy * 3 - 1))); } z0 = mbl.z_values[0][0] + *reinterpret_cast(&z_offset_u) * 0.01; - #ifdef SUPPORT_VERBOSITY - if (verbosity_level >= 1) { - printf_P(PSTR("Bed leveling, point: %d, calibration Z stored in eeprom: %d, calibration z: %f \n"), mesh_point, z_offset_u, z0); - } - #endif // SUPPORT_VERBOSITY + // printf_P(PSTR("Bed leveling, point: %d, calibration Z stored in eeprom: %d, calibration z: %f \n"), mesh_point, z_offset_u, z0); } // Move Z up to MESH_HOME_Z_SEARCH. @@ -4798,7 +4794,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); #endif // SUPPORT_VERBOSITY - //printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); + printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line_curposXYZE(XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); @@ -4809,7 +4805,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) break; } if (init_z_bckp - current_position[Z_AXIS] < 0.1f) { //broken cable or initial Z coordinate too low. Go to MESH_HOME_Z_SEARCH and repeat last step (z-probe) again to distinguish between these two cases. - //printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); + printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder); st_synchronize(); diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index 88cbc671a..fed100e68 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -991,7 +991,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i update_current_position_z(); //printf_P(PSTR("Zs: %f, Z: %f, delta Z: %f"), z_bckp, current_position[Z_AXIS], (z_bckp - current_position[Z_AXIS])); if (abs(current_position[Z_AXIS] - z_bckp) < 0.025) { - //printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); + printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); current_position[Z_AXIS] += 0.5; go_to_current(homing_feedrate[Z_AXIS]/60); current_position[Z_AXIS] = minimum_z; @@ -1019,10 +1019,10 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i float dz = i?abs(current_position[Z_AXIS] - (z / i)):0; z += current_position[Z_AXIS]; //printf_P(PSTR("Z[%d] = %d, dz=%d\n"), i, (int)(current_position[Z_AXIS] * 1000), (int)(dz * 1000)); - //printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); + printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); if (dz > 0.05) { //deviation > 50um if (high_deviation_occured == false) { //first occurence may be caused in some cases by mechanic resonance probably especially if printer is placed on unstable surface - //printf_P(PSTR("high dev. first occurence\n")); + printf_P(PSTR("high dev. first occurence\n")); delay_keep_alive(500); //damping //start measurement from the begining, but this time with higher movements in Z axis which should help to reduce mechanical resonance high_deviation_occured = true; @@ -1033,7 +1033,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i goto error; } } - //printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); + printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); } current_position[Z_AXIS] = z; if (n_iter > 1) From 301d64042bcb1a68744da60ccda02d549b37b578 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 27 Dec 2019 19:29:02 +0100 Subject: [PATCH 05/26] Set fsensor_watch_runout earlier to prevent re-entry Do not set/clear fsensor_watch_runout within fsensor_oq_meassure_start which is used outside of fsensor_update where it could have a different starting value. Set it within fsensor_stop_and_save_print to immediately prevent re-entry. --- Firmware/fsensor.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 1c28d025f..b9b1f0685 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -124,14 +124,16 @@ unsigned long nIRsensorLastTime; void fsensor_stop_and_save_print(void) { printf_P(PSTR("fsensor_stop_and_save_print\n")); - stop_and_save_print_to_ram(0, 0); //XYZE - no change + stop_and_save_print_to_ram(0, 0); + fsensor_watch_runout = false; } void fsensor_restore_print_and_continue(void) { printf_P(PSTR("fsensor_restore_print_and_continue\n")); + fsensor_watch_runout = true; fsensor_err_cnt = 0; - restore_print_from_ram_and_continue(0); //XYZ = orig, E - no change + restore_print_from_ram_and_continue(0); } // fsensor_checkpoint_print cuts the current print job at the current position, @@ -379,7 +381,6 @@ void fsensor_oq_meassure_start(uint8_t skip) fsensor_oq_sh_sum = 0; pat9125_update(); pat9125_y = 0; - fsensor_watch_runout = false; fsensor_oq_meassure = true; } @@ -391,7 +392,6 @@ void fsensor_oq_meassure_stop(void) printf_P(_N(" st_sum=%u yd_sum=%u er_sum=%u er_max=%hhu\n"), fsensor_oq_st_sum, fsensor_oq_yd_sum, fsensor_oq_er_sum, fsensor_oq_er_max); printf_P(_N(" yd_min=%u yd_max=%u yd_avg=%u sh_avg=%u\n"), fsensor_oq_yd_min, fsensor_oq_yd_max, (uint16_t)((uint32_t)fsensor_oq_yd_sum * fsensor_chunk_len / fsensor_oq_st_sum), (uint16_t)(fsensor_oq_sh_sum / fsensor_oq_samples)); fsensor_oq_meassure = false; - fsensor_watch_runout = true; fsensor_err_cnt = 0; } @@ -578,12 +578,13 @@ void fsensor_update(void) #ifdef PAT9125 if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX)) { + fsensor_stop_and_save_print(); + bool autoload_enabled_tmp = fsensor_autoload_enabled; fsensor_autoload_enabled = false; bool oq_meassure_enabled_tmp = fsensor_oq_meassure_enabled; fsensor_oq_meassure_enabled = true; - fsensor_stop_and_save_print(); fsensor_err_cnt = 0; fsensor_oq_meassure_start(0); From fe4c00fb8a8ff32fcafecb2a730e432a7f065607 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 27 Dec 2019 19:35:08 +0100 Subject: [PATCH 06/26] Lift the extruder when checking for the filament This avoids leaving marks on the print --- Firmware/fsensor.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index b9b1f0685..02f7d572b 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -585,6 +585,11 @@ void fsensor_update(void) bool oq_meassure_enabled_tmp = fsensor_oq_meassure_enabled; fsensor_oq_meassure_enabled = true; + // move the nozzle away while checking the filament + current_position[Z_AXIS] += 0.8; + if(current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; + plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS], active_extruder); + st_synchronize(); fsensor_err_cnt = 0; fsensor_oq_meassure_start(0); From 97170ed68dbfd5660f28f2f286d94bafee74d939 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Fri, 27 Dec 2019 19:37:20 +0100 Subject: [PATCH 07/26] Do not call process_commands() within fsensor_update() Plan moves directly to reduce the required stack size. --- Firmware/fsensor.cpp | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 02f7d572b..f9875fa6e 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -591,20 +591,15 @@ void fsensor_update(void) plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS], active_extruder); st_synchronize(); + // check the filament in isolation fsensor_err_cnt = 0; fsensor_oq_meassure_start(0); - - enquecommand_front_P((PSTR("G1 E-3 F200"))); - process_commands(); - KEEPALIVE_STATE(IN_HANDLER); - cmdqueue_pop_front(); - st_synchronize(); - - enquecommand_front_P((PSTR("G1 E3 F200"))); - process_commands(); - KEEPALIVE_STATE(IN_HANDLER); - cmdqueue_pop_front(); - st_synchronize(); + float e_tmp = current_position[E_AXIS]; + current_position[E_AXIS] -= 3; + plan_buffer_line_curposXYZE(200/60, active_extruder); + current_position[E_AXIS] = e_tmp; + plan_buffer_line_curposXYZE(200/60, active_extruder); + st_synchronize(); uint8_t err_cnt = fsensor_err_cnt; fsensor_oq_meassure_stop(); From bd80ee88a0f0c8d5a354f7c81a8551d9ee297f5d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sat, 28 Dec 2019 18:50:42 +0100 Subject: [PATCH 08/26] Set the IN_HANDLER busy state while checking the filament --- Firmware/fsensor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index f9875fa6e..0113317eb 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -579,6 +579,7 @@ void fsensor_update(void) if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX)) { fsensor_stop_and_save_print(); + KEEPALIVE_STATE(IN_HANDLER); bool autoload_enabled_tmp = fsensor_autoload_enabled; fsensor_autoload_enabled = false; From 186f8816000f0c8632fe3c8cfe0aac8c0b13d4b1 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Sun, 29 Dec 2019 22:08:44 +0100 Subject: [PATCH 09/26] Avoid calling fsensor_update() one level earlier Move the common checks between filament sensors out of fsensor_update(). Disable the runout check if a saved state is already present (this check was missing in the PAT9125 variant) as this is currently not supported. Note that the CHECK_FSENSOR looks completely redundant besides e_active(). --- Firmware/Marlin_main.cpp | 3 ++- Firmware/fsensor.cpp | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4970091ea..fc395900a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -8606,7 +8606,8 @@ if(0) #ifdef PAT9125 fsensor_autoload_check_stop(); #endif //PAT9125 - fsensor_update(); + if (fsensor_enabled && !saved_printing) + fsensor_update(); } } } diff --git a/Firmware/fsensor.cpp b/Firmware/fsensor.cpp index 0113317eb..a7dbce979 100755 --- a/Firmware/fsensor.cpp +++ b/Firmware/fsensor.cpp @@ -576,7 +576,7 @@ void fsensor_enque_M600(){ void fsensor_update(void) { #ifdef PAT9125 - if (fsensor_enabled && fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX)) + if (fsensor_watch_runout && (fsensor_err_cnt > FSENSOR_ERR_MAX)) { fsensor_stop_and_save_print(); KEEPALIVE_STATE(IN_HANDLER); @@ -621,7 +621,7 @@ void fsensor_update(void) fsensor_enque_M600(); } #else //PAT9125 - if (CHECK_FSENSOR && fsensor_enabled && ir_sensor_detected) + if (CHECK_FSENSOR && ir_sensor_detected) { if(digitalRead(IR_SENSOR_PIN)) { // IR_SENSOR_PIN ~ H From 73527d6069c5a4b6d75d8150887640c0ec2f4f6f Mon Sep 17 00:00:00 2001 From: MRprusa3d Date: Wed, 22 Jan 2020 04:45:13 +0100 Subject: [PATCH 10/26] selfTest workflow optimalization --- Firmware/ultralcd.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5d291f35c..38471b814 100755 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -7541,26 +7541,24 @@ bool lcd_selftest() int _progress = 0; bool _result = true; bool _swapped_fan = false; +#if IR_SENSOR_ANALOG + bool bAction; + bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is the filament unloaded?"),false,true); + if(!bAction) + return(false); +#endif //IR_SENSOR_ANALOG lcd_wait_for_cool_down(); lcd_clear(); lcd_set_cursor(0, 0); lcd_puts_P(_i("Self test start "));////MSG_SELFTEST_START c=20 #ifdef TMC2130 FORCE_HIGH_POWER_START; #endif // TMC2130 -#if !IR_SENSOR_ANALOG _delay(2000); -#endif //!IR_SENSOR_ANALOG FORCE_BL_ON_START; _delay(2000); KEEPALIVE_STATE(IN_HANDLER); -#if IR_SENSOR_ANALOG - bool bAction; - bAction=lcd_show_fullscreen_message_yes_no_and_wait_P(_i("Is filament unloaded?"),false,true); - if(!bAction) - return(false); -#endif //IR_SENSOR_ANALOG _progress = lcd_selftest_screen(TestScreen::ExtruderFan, _progress, 3, true, 2000); #if (defined(FANCHECK) && defined(TACH_0)) From 4055977a95fde87d7d78763e02c5838e9c48bbf0 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Sat, 25 Jan 2020 11:41:27 +0200 Subject: [PATCH 11/26] Do not clear axis known position when Z is set to silent Also removed unused (forgotten) variable. --- Firmware/Marlin_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 211384f9d..70cbd6d7a 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -11563,7 +11563,7 @@ if(!(bEnableForce_z||eeprom_read_byte((uint8_t*)EEPROM_SILENT))) void disable_force_z() { - uint16_t z_microsteps=0; + // uint16_t z_microsteps=0; if(!bEnableForce_z) return; // motor already disabled (may be ;-p ) @@ -11576,7 +11576,7 @@ void disable_force_z() tmc2130_init(true); #endif // TMC2130 - axis_known_position[Z_AXIS]=false; + // axis_known_position[Z_AXIS]=false; } From 3da20db02404f3654631bf99d8c4d8aea0e8c709 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 27 Jan 2020 18:50:17 +0100 Subject: [PATCH 12/26] Really poweroff Z motors when PSU_Delta is defined enable/disable_z behave differently when PSU_Delta is defined. During powerpanic and kill however we do *really* need to save energy and poweroff the motors. Rename enable/disable_z as poweron/poweroff_z and define some aliases so that we can use the low-level function where needed. --- Firmware/Marlin.h | 35 +++++++++++++++++------------------ Firmware/Marlin_main.cpp | 8 ++++---- 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index 58b3351de..a0b3c19b8 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -146,40 +146,39 @@ void manage_inactivity(bool ignore_stepper_queue=false); #if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1 #if defined(Z_AXIS_ALWAYS_ON) #ifdef Z_DUAL_STEPPER_DRIVERS - #define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } - #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } + #define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } + #define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #else - #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) - #define disable_z() {} + #define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) + #define poweroff_z() {} #endif #else #ifdef Z_DUAL_STEPPER_DRIVERS - #define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } - #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } + #define poweron_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } + #define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #else - #define enable_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) - #define disable_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } + #define poweron_z() WRITE(Z_ENABLE_PIN, Z_ENABLE_ON) + #define poweroff_z() { WRITE(Z_ENABLE_PIN,!Z_ENABLE_ON); axis_known_position[Z_AXIS] = false; } #endif #endif #else - #define enable_z() {} - #define disable_z() {} + #define poweron_z() {} + #define poweroff_z() {} #endif -#ifdef PSU_Delta +#ifndef PSU_Delta + #define enable_z() poweron_z() + #define disable_z() poweroff_z() +#else void init_force_z(); void check_force_z(); - #undef disable_z - #define disable_z() disable_force_z() - void disable_force_z(); - #undef enable_z - #define enable_z() enable_force_z() void enable_force_z(); + void disable_force_z(); + #define enable_z() enable_force_z() + #define disable_z() disable_force_z() #endif // PSU_Delta - - //#if defined(Z_ENABLE_PIN) && Z_ENABLE_PIN > -1 //#ifdef Z_DUAL_STEPPER_DRIVERS //#define enable_z() { WRITE(Z_ENABLE_PIN, Z_ENABLE_ON); WRITE(Z2_ENABLE_PIN, Z_ENABLE_ON); } diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index a204f9f0b..c80199a22 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -9595,7 +9595,7 @@ void kill(const char *full_screen_message, unsigned char id) disable_x(); // SERIAL_ECHOLNPGM("kill - disable Y"); disable_y(); - disable_z(); + poweroff_z(); disable_e0(); disable_e1(); disable_e2(); @@ -10579,7 +10579,7 @@ void uvlo_() + UVLO_Z_AXIS_SHIFT; plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); - disable_z(); + poweroff_z(); // Write the file position. eeprom_update_dword((uint32_t*)(EEPROM_FILE_POSITION), sd_position); @@ -10638,7 +10638,7 @@ void uvlo_() WRITE(BEEPER,HIGH); // All is set: with all the juice left, try to move extruder away to detach the nozzle completely from the print - enable_z(); + poweron_z(); current_position[X_AXIS] = (current_position[X_AXIS] < 0.5f * (X_MIN_POS + X_MAX_POS)) ? X_MIN_POS : X_MAX_POS; plan_buffer_line_curposXYZE(500, active_extruder); st_synchronize(); @@ -10693,7 +10693,7 @@ void uvlo_tiny() + UVLO_TINY_Z_AXIS_SHIFT; plan_buffer_line_curposXYZE(homing_feedrate[Z_AXIS]/60, active_extruder); st_synchronize(); - disable_z(); + poweroff_z(); // Update Z position eeprom_update_float((float*)(EEPROM_UVLO_TINY_CURRENT_POSITION_Z), current_position[Z_AXIS]); From 200cdde1af99ffc3d3c981f6d431cf0bc936ca2d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 28 Jan 2020 21:50:12 +0100 Subject: [PATCH 13/26] Setup the UVLO interrupt later during initialization Do not allow uvlo_tiny() to trigger before the previous print has already been recovered. A quick repeated power failure could cause uvlo_tiny to overwrite the Z position before it has been correctly recovered. --- Firmware/Marlin_main.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c80199a22..fbfb39f25 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -1298,10 +1298,6 @@ void setup() st_init(); // Initialize stepper, this enables interrupts! -#ifdef UVLO_SUPPORT - setup_uvlo_interrupt(); -#endif //UVLO_SUPPORT - #ifdef TMC2130 tmc2130_mode = silentMode?TMC2130_MODE_SILENT:TMC2130_MODE_NORMAL; update_mode_profile(); @@ -1596,12 +1592,14 @@ void setup() lcd_update(2); lcd_setstatuspgm(_T(WELCOME_MSG)); } - } - - } + + // Only arm the uvlo interrupt _after_ a recovering print has been initialized and + // the entire state machine initialized. + setup_uvlo_interrupt(); #endif //UVLO_SUPPORT + fCheckModeInit(); fSetMmuMode(mmu_enabled); KEEPALIVE_STATE(NOT_BUSY); From b46dc59fad9bf26534ac8e9d40e17c4404b2362d Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 29 Jan 2020 16:06:54 +0100 Subject: [PATCH 14/26] Refuse to start a print if power is lost before arming uvlo If power has been lost during startup already a falling edge would be skipped, causing the print to continue and lose its state without being able to save again. Check for a low line after arming the interrupt and simply wait for reset. --- Firmware/Marlin_main.cpp | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index fbfb39f25..5eb8d48b2 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10480,6 +10480,14 @@ void serialecho_temperatures() { } #ifdef UVLO_SUPPORT +void uvlo_drain_reset() +{ + // burn all that residual power + wdt_enable(WDTO_1S); + WRITE(BEEPER,HIGH); + while(1); +} + void uvlo_() { @@ -10709,11 +10717,7 @@ void uvlo_tiny() eeprom_update_word((uint16_t*)EEPROM_POWER_COUNT_TOT, eeprom_read_word((uint16_t*)EEPROM_POWER_COUNT_TOT) + 1); printf_P(_N("UVLO_TINY - end %d\n"), _millis() - time_start); - - // burn all that residual power - wdt_enable(WDTO_1S); - WRITE(BEEPER,HIGH); - while(1); + uvlo_drain_reset(); } #endif //UVLO_SUPPORT @@ -10760,12 +10764,19 @@ void setup_uvlo_interrupt() { DDRE &= ~(1 << 4); //input pin PORTE &= ~(1 << 4); //no internal pull-up - //sensing falling edge + // sensing falling edge EICRB |= (1 << 0); EICRB &= ~(1 << 1); - //enable INT4 interrupt + // enable INT4 interrupt EIMSK |= (1 << 4); + + // check if power was lost before we armed the interrupt + if(!(PINE & (1 << 4))) + { + SERIAL_ECHOLNPGM("INT4"); + uvlo_drain_reset(); + } } ISR(INT4_vect) { From 4fd913ddf3f7170456cbdf195c332a75f8f2012f Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 29 Jan 2020 17:45:47 +0200 Subject: [PATCH 15/26] Remove commented out code --- Firmware/Marlin_main.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 70cbd6d7a..1dc45eab5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -11563,8 +11563,6 @@ if(!(bEnableForce_z||eeprom_read_byte((uint8_t*)EEPROM_SILENT))) void disable_force_z() { - // uint16_t z_microsteps=0; - if(!bEnableForce_z) return; // motor already disabled (may be ;-p ) bEnableForce_z=false; @@ -11575,8 +11573,6 @@ void disable_force_z() update_mode_profile(); tmc2130_init(true); #endif // TMC2130 - - // axis_known_position[Z_AXIS]=false; } From 2b46fdac2d0251041cb89f96ae16e7e19e17473c Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 29 Jan 2020 17:56:26 +0100 Subject: [PATCH 16/26] Only trigger a quick reset if there's a pending saved state Thanks to @leptun --- Firmware/Marlin_main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 5eb8d48b2..169effb8d 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10772,7 +10772,7 @@ void setup_uvlo_interrupt() { EIMSK |= (1 << 4); // check if power was lost before we armed the interrupt - if(!(PINE & (1 << 4))) + if(!(PINE & (1 << 4)) && eeprom_read_byte((uint8_t*)EEPROM_UVLO)) { SERIAL_ECHOLNPGM("INT4"); uvlo_drain_reset(); From 02d1525445b81002cc591738d69cbdb05988ee18 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Wed, 29 Jan 2020 21:08:56 +0100 Subject: [PATCH 17/26] Display "POWER PANIC DETECTED" when possible Both during early init and in uvlo_tiny, display "POWER PANIC DETECTED" if enough charge is left. This is not worth doing in regular uvlo_, as we want to give full priority to the X motor --- Firmware/Marlin_main.cpp | 2 ++ Firmware/messages.c | 1 + Firmware/messages.h | 1 + 3 files changed, 4 insertions(+) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 169effb8d..20a269af5 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10485,6 +10485,8 @@ void uvlo_drain_reset() // burn all that residual power wdt_enable(WDTO_1S); WRITE(BEEPER,HIGH); + lcd_clear(); + lcd_puts_at_P(0, 1, MSG_POWERPANIC_DETECTED); while(1); } diff --git a/Firmware/messages.c b/Firmware/messages.c index 68bad5ffb..2b113673e 100644 --- a/Firmware/messages.c +++ b/Firmware/messages.c @@ -171,3 +171,4 @@ const char MSG_M112_KILL[] PROGMEM_N1 = "M112 called. Emergency Stop."; ////c=20 #ifdef LA_LIVE_K const char MSG_ADVANCE_K[] PROGMEM_N1 = "Advance K:"; ////c=13 #endif +const char MSG_POWERPANIC_DETECTED[] PROGMEM_N1 = "POWER PANIC DETECTED"; ////c=20 diff --git a/Firmware/messages.h b/Firmware/messages.h index 678524abb..7cc240d3b 100644 --- a/Firmware/messages.h +++ b/Firmware/messages.h @@ -170,6 +170,7 @@ extern const char MSG_FANCHECK_EXTRUDER[]; extern const char MSG_FANCHECK_PRINT[]; extern const char MSG_M112_KILL[]; extern const char MSG_ADVANCE_K[]; +extern const char MSG_POWERPANIC_DETECTED[]; #if defined(__cplusplus) } From a5198e32a3d041024fbf327d0e380bbd69543a5f Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 29 Jan 2020 22:44:19 +0200 Subject: [PATCH 18/26] Just keep the current state. ON or OFF. No switching allowed --- Firmware/heatbed_pwm.cpp | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index 1e467c4e8..612cf3c86 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -139,19 +139,15 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine break; case States::ONE: // state ONE - we'll either stay in ONE or change to FALL OCR0B = 255; + if (bedPWMDisabled) return; slowCounter += slowInc; // this does software timer_clk/256 or less - if (!bedPWMDisabled){ //disable heating as soon as possible - if( slowCounter < pwm ){ - return; - } - if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain - // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating - return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf - } - } - else if (pwm > 200){ //if duty cycle is high and BED PWM is disabled keep heater on. Prevents overcooling + if( slowCounter < pwm ){ return; } + if( (soft_pwm_bed << 1) >= (255 - slowInc - 1) ){ //@@TODO simplify & explain + // if slowInc==2, soft_pwm == 251 will be the first to do short drops to zero. 252 will keep full heating + return; // want full duty for the next ONE cycle again - so keep on heating and just wait for the next timer ovf + } // otherwise moving towards FALL // @@TODO it looks like ONE_TO_FALL isn't necessary, there are no artefacts at all state = States::ONE;//_TO_FALL; From 755230e2e750880de393586946dfa0c26a15737c Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 29 Jan 2020 22:47:28 +0200 Subject: [PATCH 19/26] fix small mistake --- Firmware/heatbed_pwm.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index 612cf3c86..4552bf966 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -95,7 +95,7 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine { switch(state){ case States::ZERO_START: - if (bedPWMDisabled) break; + if (bedPWMDisabled) return; pwm = soft_pwm_bed << 1;// expecting soft_pwm_bed to be 7bit! if( pwm != 0 ){ state = States::ZERO; // do nothing, let it tick once again after the 30Hz period From b86aafb56e2dd3b2ec162b7130ec28890ec908f4 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Wed, 29 Jan 2020 23:03:20 +0200 Subject: [PATCH 20/26] Documentation --- Firmware/heatbed_pwm.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Firmware/heatbed_pwm.cpp b/Firmware/heatbed_pwm.cpp index 4552bf966..e85515016 100755 --- a/Firmware/heatbed_pwm.cpp +++ b/Firmware/heatbed_pwm.cpp @@ -45,6 +45,12 @@ // If there are any change requirements in the future, the signal must be checked with an osciloscope again, // ad-hoc changes may completely screw things up! +// 2020-01-29 update: we are introducing a new option to the automaton that will allow us to force the output state +// to either full ON or OFF. This is so that interference during the MBL probing is minimal. +// To accomplish this goal we use bedPWMDisabled. It is only supposed to be used for brief periods of time as to +// not make the bed temperature too unstable. Also, careful consideration should be used when using this +// option as leaving this enabled will also keep the bed output in the state it stopped in. + ///! Definition off finite automaton states enum class States : uint8_t { ZERO_START = 0,///< entry point of the automaton - reads the soft_pwm_bed value for the next whole PWM cycle @@ -95,7 +101,7 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine { switch(state){ case States::ZERO_START: - if (bedPWMDisabled) return; + if (bedPWMDisabled) return; // stay in the OFF state and do not change the output pin pwm = soft_pwm_bed << 1;// expecting soft_pwm_bed to be 7bit! if( pwm != 0 ){ state = States::ZERO; // do nothing, let it tick once again after the 30Hz period @@ -139,7 +145,7 @@ ISR(TIMER0_OVF_vect) // timer compare interrupt service routine break; case States::ONE: // state ONE - we'll either stay in ONE or change to FALL OCR0B = 255; - if (bedPWMDisabled) return; + if (bedPWMDisabled) return; // stay in the ON state and do not change the output pin slowCounter += slowInc; // this does software timer_clk/256 or less if( slowCounter < pwm ){ return; From 8c2902a6605cacbc35232b3f6f1c49f9ca12a20f Mon Sep 17 00:00:00 2001 From: leptun Date: Wed, 2 Oct 2019 17:34:09 +0300 Subject: [PATCH 21/26] Revert "Mesh bed leveling testing" This reverts commit 28e812d91fe2b4633c9427abdf554e5a9449dd17. --- Firmware/Marlin_main.cpp | 10 +++++++--- Firmware/mesh_bed_calibration.cpp | 8 ++++---- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index e14dd2e35..fbfb39f25 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -4973,7 +4973,11 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) z_offset_u = eeprom_read_word((uint16_t*)(EEPROM_BED_CALIBRATION_Z_JITTER + 2 * (ix + iy * 3 - 1))); } z0 = mbl.z_values[0][0] + *reinterpret_cast(&z_offset_u) * 0.01; - // printf_P(PSTR("Bed leveling, point: %d, calibration Z stored in eeprom: %d, calibration z: %f \n"), mesh_point, z_offset_u, z0); + #ifdef SUPPORT_VERBOSITY + if (verbosity_level >= 1) { + printf_P(PSTR("Bed leveling, point: %d, calibration Z stored in eeprom: %d, calibration z: %f \n"), mesh_point, z_offset_u, z0); + } + #endif // SUPPORT_VERBOSITY } // Move Z up to MESH_HOME_Z_SEARCH. @@ -5000,7 +5004,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) world2machine_clamp(current_position[X_AXIS], current_position[Y_AXIS]); #endif // SUPPORT_VERBOSITY - printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); + //printf_P(PSTR("after clamping: [%f;%f]\n"), current_position[X_AXIS], current_position[Y_AXIS]); plan_buffer_line_curposXYZE(XY_AXIS_FEEDRATE, active_extruder); st_synchronize(); @@ -5011,7 +5015,7 @@ if(eSoundMode!=e_SOUND_MODE_SILENT) break; } if (init_z_bckp - current_position[Z_AXIS] < 0.1f) { //broken cable or initial Z coordinate too low. Go to MESH_HOME_Z_SEARCH and repeat last step (z-probe) again to distinguish between these two cases. - printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); + //printf_P(PSTR("Another attempt! Current Z position: %f\n"), current_position[Z_AXIS]); current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; plan_buffer_line_curposXYZE(Z_LIFT_FEEDRATE, active_extruder); st_synchronize(); diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index fed100e68..88cbc671a 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -991,7 +991,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i update_current_position_z(); //printf_P(PSTR("Zs: %f, Z: %f, delta Z: %f"), z_bckp, current_position[Z_AXIS], (z_bckp - current_position[Z_AXIS])); if (abs(current_position[Z_AXIS] - z_bckp) < 0.025) { - printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); + //printf_P(PSTR("PINDA triggered immediately, move Z higher and repeat measurement\n")); current_position[Z_AXIS] += 0.5; go_to_current(homing_feedrate[Z_AXIS]/60); current_position[Z_AXIS] = minimum_z; @@ -1019,10 +1019,10 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i float dz = i?abs(current_position[Z_AXIS] - (z / i)):0; z += current_position[Z_AXIS]; //printf_P(PSTR("Z[%d] = %d, dz=%d\n"), i, (int)(current_position[Z_AXIS] * 1000), (int)(dz * 1000)); - printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); + //printf_P(PSTR("Z- measurement deviation from avg value %f um\n"), dz); if (dz > 0.05) { //deviation > 50um if (high_deviation_occured == false) { //first occurence may be caused in some cases by mechanic resonance probably especially if printer is placed on unstable surface - printf_P(PSTR("high dev. first occurence\n")); + //printf_P(PSTR("high dev. first occurence\n")); delay_keep_alive(500); //damping //start measurement from the begining, but this time with higher movements in Z axis which should help to reduce mechanical resonance high_deviation_occured = true; @@ -1033,7 +1033,7 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i goto error; } } - printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); + //printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]); } current_position[Z_AXIS] = z; if (n_iter > 1) From 571906a494ac07d3450854b15b3068ecc5eb0655 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 28 Jan 2020 21:55:16 +0100 Subject: [PATCH 22/26] Do not update saved_target if there's no current_block There is a chance that current_block can be NULL despite the queue being non-empty. This can happen early after a block has been queued, but before the isr has picked it up for processing, and/or when the current block is at the last step and is being discarded. Check for current_block directly to avoid this race. --- Firmware/Marlin_main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 20a269af5..9d00d42bd 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10529,7 +10529,7 @@ void uvlo_() // save the global state at planning time uint16_t feedrate_bckp; - if (blocks_queued()) + if (current_block) { memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); feedrate_bckp = current_block->gcode_feedrate; @@ -11129,7 +11129,7 @@ void stop_and_save_print_to_ram(float z_move, float e_move) #endif // save the global state at planning time - if (blocks_queued()) + if (current_block) { memcpy(saved_target, current_block->gcode_target, sizeof(saved_target)); saved_feedrate2 = current_block->gcode_feedrate; From 1db024f17af6ed22f7836ebb553f6b7fe5215227 Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Tue, 28 Jan 2020 22:03:38 +0100 Subject: [PATCH 23/26] Always raise the extruder 25mm during power recovery Avoids oozed material (drooping more than ~1mm) to scrape and potentially detach the print. --- Firmware/Marlin_main.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 9d00d42bd..abd4c3685 100755 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -10798,10 +10798,13 @@ void recover_print(uint8_t automatic) { // Recover position, temperatures and extrude_multipliers bool mbl_was_active = recover_machine_state_after_power_panic(); - // Attempt to lift the print head on the first recovery, so one may remove the excess priming material. - bool raise_z = (eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1); - if(raise_z && (current_position[Z_AXIS]<25)) - enquecommand_P(PSTR("G1 Z25 F800")); + // Lift the print head 25mm, first to avoid collisions with oozed material with the print, + // and second also so one may remove the excess priming material. + if(eeprom_read_byte((uint8_t*)EEPROM_UVLO) == 1) + { + sprintf_P(cmd, PSTR("G1 Z%.3f F800"), current_position[Z_AXIS] + 25); + enquecommand(cmd); + } // Home X and Y axes. Homing just X and Y shall not touch the babystep and the world2machine // transformation status. G28 will not touch Z when MBL is off. From 886c2fdc4ebf18c9ca175068525fa4218c5637e4 Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Thu, 30 Jan 2020 17:24:32 +0200 Subject: [PATCH 24/26] Show correct fixed message --- Firmware/temperature.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 175122548..7517978be 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2003,6 +2003,8 @@ void check_max_temp() //! number of repeating the same state with consecutive step() calls //! used to slow down text switching struct alert_automaton_mintemp { + const char *m2; + alert_automaton_mintemp(const char *m2):m2(m2){} private: enum { ALERT_AUTOMATON_SPEED_DIV = 5 }; enum class States : uint8_t { Init = 0, TempAboveMintemp, ShowPleaseRestart, ShowMintemp }; @@ -2022,7 +2024,6 @@ public: //! @param current_temp current hotend/bed temperature (for computing simple hysteresis) //! @param mintemp minimal temperature including hysteresis to check current_temp against void step(float current_temp, float mintemp){ - static const char m2[] PROGMEM = "MINTEMP fixed"; static const char m1[] PROGMEM = "Please restart"; switch(state){ case States::Init: // initial state - check hysteresis @@ -2050,8 +2051,9 @@ public: } } }; - -static alert_automaton_mintemp alert_automaton_hotend, alert_automaton_bed; +static const char m2hotend[] PROGMEM = "MINTEMP HEATER fixed"; +static const char m2bed[] PROGMEM = "MINTEMP BED fixed"; +static alert_automaton_mintemp alert_automaton_hotend(m2hotend), alert_automaton_bed(m2bed); void check_min_temp_heater0() { From b466dad1d7fb0aaedbe583eb934dc8d4da4c9b3b Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 31 Jan 2020 15:27:19 +0100 Subject: [PATCH 25/26] Fix copy paste issues D2 D5 Fixed copy paste --- Firmware/Dcodes.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index 0a5142629..ee62087d6 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -255,7 +255,7 @@ void dcode_1() ### D2 - Read/Write RAM D3: Read/Write RAM This command can be used without any additional parameters. It will read the entire RAM. - D3 [ A | C | X ] + D2 [ A | C | X ] - `A` - Address (0x0000-0x1fff) - `C` - Count (0x0001-0x2000) @@ -355,7 +355,7 @@ void dcode_4() ### D5 - Read/Write FLASH D5: Read/Write Flash This command can be used without any additional parameters. It will read the 1kb FLASH. - D3 [ A | C | X | E ] + D5 [ A | C | X | E ] - `A` - Address (0x00000-0x3ffff) - `C` - Count (0x0001-0x2000) From a355fdd00d8a3287144d09056c45df94b5043b72 Mon Sep 17 00:00:00 2001 From: 3d-gussner <3d.gussner@gmail.com> Date: Fri, 31 Jan 2020 15:40:07 +0100 Subject: [PATCH 26/26] And another one sorry --- Firmware/Dcodes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/Dcodes.cpp b/Firmware/Dcodes.cpp index ee62087d6..70ffe2c49 100644 --- a/Firmware/Dcodes.cpp +++ b/Firmware/Dcodes.cpp @@ -252,7 +252,7 @@ void dcode_1() /*! * - ### D2 - Read/Write RAM D3: Read/Write RAM + ### D2 - Read/Write RAM D2: Read/Write RAM This command can be used without any additional parameters. It will read the entire RAM. D2 [ A | C | X ]