From 010ceceff969e406b6e1e11370de50ea3992335b Mon Sep 17 00:00:00 2001 From: PavelSindler Date: Tue, 24 Apr 2018 13:43:51 +0200 Subject: [PATCH] add another homing after steel sheet is removed; added timeout for pinda cooling; if PINDA doesn't trigger before reaching Z = -1mm, temp. calibration fails --- Firmware/Marlin_main.cpp | 478 +++++++++++++++++++------------------- Firmware/language_all.cpp | 7 + Firmware/language_all.h | 2 + Firmware/language_cz.h | 1 + Firmware/language_en.h | 3 +- Firmware/ultralcd.cpp | 45 +++- Firmware/ultralcd.h | 5 +- 7 files changed, 299 insertions(+), 242 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index c3e561cb7..33ad82956 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2959,254 +2959,254 @@ void process_commands() #endif //FWRETRACT case 28: //G28 Home all Axis one at a time { - st_synchronize(); + st_synchronize(); #if 0 - SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, initial "); print_physical_coordinates(); #endif - // Flag for the display update routine and to disable the print cancelation during homing. - homing_flag = true; - - // Which axes should be homed? - bool home_x = code_seen(axis_codes[X_AXIS]); - bool home_y = code_seen(axis_codes[Y_AXIS]); - bool home_z = code_seen(axis_codes[Z_AXIS]); - // calibrate? - bool calib = code_seen('C'); - // Either all X,Y,Z codes are present, or none of them. - bool home_all_axes = home_x == home_y && home_x == home_z; - if (home_all_axes) - // No X/Y/Z code provided means to home all axes. - home_x = home_y = home_z = true; + // Flag for the display update routine and to disable the print cancelation during homing. + homing_flag = true; + + // Which axes should be homed? + bool home_x = code_seen(axis_codes[X_AXIS]); + bool home_y = code_seen(axis_codes[Y_AXIS]); + bool home_z = code_seen(axis_codes[Z_AXIS]); + // calibrate? + bool calib = code_seen('C'); + // Either all X,Y,Z codes are present, or none of them. + bool home_all_axes = home_x == home_y && home_x == home_z; + if (home_all_axes) + // No X/Y/Z code provided means to home all axes. + home_x = home_y = home_z = true; #ifdef ENABLE_AUTO_BED_LEVELING - plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) + plan_bed_level_matrix.set_to_identity(); //Reset the plane ("erase" all leveling data) #endif //ENABLE_AUTO_BED_LEVELING - - // Reset world2machine_rotation_and_skew and world2machine_shift, therefore - // the planner will not perform any adjustments in the XY plane. - // Wait for the motors to stop and update the current position with the absolute values. - world2machine_revert_to_uncorrected(); - // For mesh bed leveling deactivate the matrix temporarily. - // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed - // in a single axis only. - // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. + // Reset world2machine_rotation_and_skew and world2machine_shift, therefore + // the planner will not perform any adjustments in the XY plane. + // Wait for the motors to stop and update the current position with the absolute values. + world2machine_revert_to_uncorrected(); + + // For mesh bed leveling deactivate the matrix temporarily. + // It is necessary to disable the bed leveling for the X and Y homing moves, so that the move is performed + // in a single axis only. + // In case of re-homing the X or Y axes only, the mesh bed leveling is restored after G28. #ifdef MESH_BED_LEVELING - uint8_t mbl_was_active = mbl.active; - mbl.active = 0; - current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); + uint8_t mbl_was_active = mbl.active; + mbl.active = 0; + current_position[Z_AXIS] = st_get_position_mm(Z_AXIS); #endif - // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be - // consumed during the first movements following this statement. - if (home_z) - babystep_undo(); + // Reset baby stepping to zero, if the babystepping has already been loaded before. The babystepsTodo value will be + // consumed during the first movements following this statement. + if (home_z) + babystep_undo(); - saved_feedrate = feedrate; - saved_feedmultiply = feedmultiply; - feedmultiply = 100; - previous_millis_cmd = millis(); + saved_feedrate = feedrate; + saved_feedmultiply = feedmultiply; + feedmultiply = 100; + previous_millis_cmd = millis(); - enable_endstops(true); + enable_endstops(true); - memcpy(destination, current_position, sizeof(destination)); - feedrate = 0.0; + memcpy(destination, current_position, sizeof(destination)); + feedrate = 0.0; - #if Z_HOME_DIR > 0 // If homing away from BED do Z first - if(home_z) - homeaxis(Z_AXIS); - #endif +#if Z_HOME_DIR > 0 // If homing away from BED do Z first + if(home_z) + homeaxis(Z_AXIS); +#endif - #ifdef QUICK_HOME - // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. - if(home_x && home_y) //first diagonal move - { - current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; +#ifdef QUICK_HOME + // In the quick mode, if both x and y are to be homed, a diagonal move will be performed initially. + if(home_x && home_y) //first diagonal move + { + current_position[X_AXIS] = 0;current_position[Y_AXIS] = 0; - int x_axis_home_dir = home_dir(X_AXIS); + int x_axis_home_dir = home_dir(X_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); - feedrate = homing_feedrate[X_AXIS]; - if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { - feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); - } else { - feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); - } - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - st_synchronize(); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = 1.5 * max_length(X_AXIS) * x_axis_home_dir;destination[Y_AXIS] = 1.5 * max_length(Y_AXIS) * home_dir(Y_AXIS); + feedrate = homing_feedrate[X_AXIS]; + if(homing_feedrate[Y_AXIS] max_length(Y_AXIS)) { + feedrate *= sqrt(pow(max_length(Y_AXIS) / max_length(X_AXIS), 2) + 1); + } else { + feedrate *= sqrt(pow(max_length(X_AXIS) / max_length(Y_AXIS), 2) + 1); + } + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + st_synchronize(); - axis_is_at_home(X_AXIS); - axis_is_at_home(Y_AXIS); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[X_AXIS] = current_position[X_AXIS]; - destination[Y_AXIS] = current_position[Y_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); - feedrate = 0.0; - st_synchronize(); - endstops_hit_on_purpose(); + axis_is_at_home(X_AXIS); + axis_is_at_home(Y_AXIS); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[X_AXIS] = current_position[X_AXIS]; + destination[Y_AXIS] = current_position[Y_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); + feedrate = 0.0; + st_synchronize(); + endstops_hit_on_purpose(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - current_position[Z_AXIS] = destination[Z_AXIS]; - } - #endif /* QUICK_HOME */ + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + current_position[Z_AXIS] = destination[Z_AXIS]; + } +#endif /* QUICK_HOME */ #ifdef TMC2130 - if(home_x) - { - if (!calib) - homeaxis(X_AXIS); - else - tmc2130_home_calibrate(X_AXIS); - } + if(home_x) + { + if (!calib) + homeaxis(X_AXIS); + else + tmc2130_home_calibrate(X_AXIS); + } - if(home_y) - { - if (!calib) - homeaxis(Y_AXIS); - else - tmc2130_home_calibrate(Y_AXIS); - } + if(home_y) + { + if (!calib) + homeaxis(Y_AXIS); + else + tmc2130_home_calibrate(Y_AXIS); + } #endif //TMC2130 - if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) - current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; + if(code_seen(axis_codes[X_AXIS]) && code_value_long() != 0) + current_position[X_AXIS]=code_value()+add_homing[X_AXIS]; - if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) - current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; + if(code_seen(axis_codes[Y_AXIS]) && code_value_long() != 0) + current_position[Y_AXIS]=code_value()+add_homing[Y_AXIS]; - #if Z_HOME_DIR < 0 // If homing towards BED do Z last - #ifndef Z_SAFE_HOMING - if(home_z) { - #if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - #endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) - #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home - if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) - { - homeaxis(X_AXIS); - homeaxis(Y_AXIS); - } - // 1st mesh bed leveling measurement point, corrected. - world2machine_initialize(); - world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); - world2machine_reset(); - if (destination[Y_AXIS] < Y_MIN_POS) - destination[Y_AXIS] = Y_MIN_POS; - destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed - feedrate = homing_feedrate[Z_AXIS]/10; - current_position[Z_AXIS] = 0; - enable_endstops(false); - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; - enable_endstops(true); - endstops_hit_on_purpose(); - homeaxis(Z_AXIS); - #else // MESH_BED_LEVELING - homeaxis(Z_AXIS); - #endif // MESH_BED_LEVELING - } - #else // defined(Z_SAFE_HOMING): Z Safe mode activated. - if(home_all_axes) { - destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); - destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = XY_TRAVEL_SPEED/60; - current_position[Z_AXIS] = 0; +#if Z_HOME_DIR < 0 // If homing towards BED do Z last +#ifndef Z_SAFE_HOMING + if(home_z) { +#if defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); +#endif // defined (Z_RAISE_BEFORE_HOMING) && (Z_RAISE_BEFORE_HOMING > 0) +#if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) // If Mesh bed leveling, moxve X&Y to safe position for home + if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] )) + { + homeaxis(X_AXIS); + homeaxis(Y_AXIS); + } + // 1st mesh bed leveling measurement point, corrected. + world2machine_initialize(); + world2machine(pgm_read_float(bed_ref_points), pgm_read_float(bed_ref_points+1), destination[X_AXIS], destination[Y_AXIS]); + world2machine_reset(); + if (destination[Y_AXIS] < Y_MIN_POS) + destination[Y_AXIS] = Y_MIN_POS; + destination[Z_AXIS] = MESH_HOME_Z_SEARCH; // Set destination away from bed + feedrate = homing_feedrate[Z_AXIS]/10; + current_position[Z_AXIS] = 0; + enable_endstops(false); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; + enable_endstops(true); + endstops_hit_on_purpose(); + homeaxis(Z_AXIS); +#else // MESH_BED_LEVELING + homeaxis(Z_AXIS); +#endif // MESH_BED_LEVELING + } +#else // defined(Z_SAFE_HOMING): Z Safe mode activated. + if(home_all_axes) { + destination[X_AXIS] = round(Z_SAFE_HOMING_X_POINT - X_PROBE_OFFSET_FROM_EXTRUDER); + destination[Y_AXIS] = round(Z_SAFE_HOMING_Y_POINT - Y_PROBE_OFFSET_FROM_EXTRUDER); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = XY_TRAVEL_SPEED/60; + current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); - current_position[X_AXIS] = destination[X_AXIS]; - current_position[Y_AXIS] = destination[Y_AXIS]; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); + current_position[X_AXIS] = destination[X_AXIS]; + current_position[Y_AXIS] = destination[Y_AXIS]; - homeaxis(Z_AXIS); - } - // Let's see if X and Y are homed and probe is inside bed area. - if(home_z) { - if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ - && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ - && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { + homeaxis(Z_AXIS); + } + // Let's see if X and Y are homed and probe is inside bed area. + if(home_z) { + if ( (axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER >= X_MIN_POS) \ + && (current_position[X_AXIS]+X_PROBE_OFFSET_FROM_EXTRUDER <= X_MAX_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER >= Y_MIN_POS) \ + && (current_position[Y_AXIS]+Y_PROBE_OFFSET_FROM_EXTRUDER <= Y_MAX_POS)) { - current_position[Z_AXIS] = 0; - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed - feedrate = max_feedrate[Z_AXIS]; - plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); - st_synchronize(); + current_position[Z_AXIS] = 0; + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + destination[Z_AXIS] = Z_RAISE_BEFORE_HOMING * home_dir(Z_AXIS) * (-1); // Set destination away from bed + feedrate = max_feedrate[Z_AXIS]; + plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate, active_extruder); + st_synchronize(); - homeaxis(Z_AXIS); - } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { - LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); - SERIAL_ECHO_START; - SERIAL_ECHOLNRPGM(MSG_POSITION_UNKNOWN); - } else { - LCD_MESSAGERPGM(MSG_ZPROBE_OUT); - SERIAL_ECHO_START; - SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); - } - } - #endif // Z_SAFE_HOMING - #endif // Z_HOME_DIR < 0 + homeaxis(Z_AXIS); + } else if (!((axis_known_position[X_AXIS]) && (axis_known_position[Y_AXIS]))) { + LCD_MESSAGERPGM(MSG_POSITION_UNKNOWN); + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(MSG_POSITION_UNKNOWN); + } else { + LCD_MESSAGERPGM(MSG_ZPROBE_OUT); + SERIAL_ECHO_START; + SERIAL_ECHOLNRPGM(MSG_ZPROBE_OUT); + } + } +#endif // Z_SAFE_HOMING +#endif // Z_HOME_DIR < 0 - if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) - current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; - #ifdef ENABLE_AUTO_BED_LEVELING - if(home_z) - current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) - #endif - - // Set the planner and stepper routine positions. - // At this point the mesh bed leveling and world2machine corrections are disabled and current_position - // contains the machine coordinates. - plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); - - #ifdef ENDSTOPS_ONLY_FOR_HOMING - enable_endstops(false); - #endif - - feedrate = saved_feedrate; - feedmultiply = saved_feedmultiply; - previous_millis_cmd = millis(); - endstops_hit_on_purpose(); -#ifndef MESH_BED_LEVELING - // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. - // Offer the user to load the baby step value, which has been adjusted at the previous print session. - if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) - lcd_adjust_z(); + if(code_seen(axis_codes[Z_AXIS]) && code_value_long() != 0) + current_position[Z_AXIS]=code_value()+add_homing[Z_AXIS]; +#ifdef ENABLE_AUTO_BED_LEVELING + if(home_z) + current_position[Z_AXIS] += zprobe_zoffset; //Add Z_Probe offset (the distance is negative) #endif - // Load the machine correction matrix - world2machine_initialize(); - // and correct the current_position XY axes to match the transformed coordinate system. - world2machine_update_current(); + // Set the planner and stepper routine positions. + // At this point the mesh bed leveling and world2machine corrections are disabled and current_position + // contains the machine coordinates. + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + +#ifdef ENDSTOPS_ONLY_FOR_HOMING + enable_endstops(false); +#endif + + feedrate = saved_feedrate; + feedmultiply = saved_feedmultiply; + previous_millis_cmd = millis(); + endstops_hit_on_purpose(); +#ifndef MESH_BED_LEVELING + // If MESH_BED_LEVELING is not active, then it is the original Prusa i3. + // Offer the user to load the baby step value, which has been adjusted at the previous print session. + if(card.sdprinting && eeprom_read_word((uint16_t *)EEPROM_BABYSTEP_Z)) + lcd_adjust_z(); +#endif + + // Load the machine correction matrix + world2machine_initialize(); + // and correct the current_position XY axes to match the transformed coordinate system. + world2machine_update_current(); #if (defined(MESH_BED_LEVELING) && !defined(MK1BP)) - if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) + if (code_seen(axis_codes[X_AXIS]) || code_seen(axis_codes[Y_AXIS]) || code_seen('W') || code_seen(axis_codes[Z_AXIS])) { - if (! home_z && mbl_was_active) { - // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. - mbl.active = true; - // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. - current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); - } + if (! home_z && mbl_was_active) { + // Re-enable the mesh bed leveling if only the X and Y axes were re-homed. + mbl.active = true; + // and re-adjust the current logical Z axis with the bed leveling offset applicable at the current XY position. + current_position[Z_AXIS] -= mbl.get_z(st_get_position_mm(X_AXIS), st_get_position_mm(Y_AXIS)); + } } - else + else { st_synchronize(); homing_flag = false; @@ -3214,18 +3214,18 @@ void process_commands() // There shall be always enough space reserved for these commands. // enquecommand_front_P((PSTR("G80"))); goto case_G80; - } + } #endif - if (farm_mode) { prusa_statistics(20); }; + if (farm_mode) { prusa_statistics(20); }; - homing_flag = false; + homing_flag = false; #if 0 - SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); - SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); + SERIAL_ECHOPGM("G28, final "); print_world_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_physical_coordinates(); + SERIAL_ECHOPGM("G28, final "); print_mesh_bed_leveling_table(); #endif - break; + break; } #ifdef ENABLE_AUTO_BED_LEVELING case 29: // G29 Detailed Z-Probe, probes the bed at 3 or more points. @@ -3451,17 +3451,32 @@ void process_commands() } lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CAL_WARNING); bool result = lcd_show_fullscreen_message_yes_no_and_wait_P(MSG_STEEL_SHEET_CHECK, false, false); + if (result) { current_position[Z_AXIS] = 50; - current_position[Y_AXIS] = 190; + current_position[Y_AXIS] += 180; plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); lcd_show_fullscreen_message_and_wait_P(MSG_REMOVE_STEEL_SHEET); + current_position[Y_AXIS] -= 180; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + st_synchronize(); + feedrate = homing_feedrate[Z_AXIS] / 10; + enable_endstops(true); + endstops_hit_on_purpose(); + homeaxis(Z_AXIS); + plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); + enable_endstops(false); } if ((current_temperature_pinda > 35) && (farm_mode == false)) { //waiting for PIDNA probe to cool down in case that we are not in farm mode - lcd_wait_for_pinda(35); + current_position[Z_AXIS] = 100; + plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); + if (lcd_wait_for_pinda(35) == false) { //waiting for PINDA probe to cool, if this takes more then time expected, temp. cal. fails + lcd_temp_cal_show_result(false); + break; + } } lcd_update_enable(true); KEEPALIVE_STATE(NOT_BUSY); //no need to print busy messages as we print current temperatures periodicaly @@ -3504,7 +3519,9 @@ void process_commands() plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); - find_bed_induction_sensor_point_z(-1.f); + bool find_z_result = find_bed_induction_sensor_point_z(-1.f); + if(find_z_result == false) lcd_temp_cal_show_result(find_z_result); + zero_z = current_position[Z_AXIS]; //current_position[Z_AXIS] @@ -3553,7 +3570,9 @@ void process_commands() current_position[Y_AXIS] = pgm_read_float(bed_ref_points + 1); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 3000 / 60, active_extruder); st_synchronize(); - find_bed_induction_sensor_point_z(-1.f); + find_z_result = find_bed_induction_sensor_point_z(-1.f); + if (find_z_result == false) lcd_temp_cal_show_result(find_z_result); + z_shift = (int)((current_position[Z_AXIS] - zero_z)*axis_steps_per_unit[Z_AXIS]); SERIAL_ECHOLNPGM(""); @@ -3566,25 +3585,8 @@ void process_commands() EEPROM_save_B(EEPROM_PROBE_TEMP_SHIFT + i * 2, &z_shift); } - custom_message_type = 0; - custom_message = false; + lcd_temp_cal_show_result(true); - eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); - SERIAL_ECHOLNPGM("Temperature calibration done. Continue with pressing the knob."); - disable_x(); - disable_y(); - disable_z(); - disable_e0(); - disable_e1(); - disable_e2(); - setTargetBed(0); //set bed target temperature back to 0 -// setTargetHotend(0,0); //set hotend target temperature back to 0 - lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); - temp_cal_active = true; - eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); - - lcd_update_enable(true); - lcd_update(2); break; } #endif //PINDA_THERMISTOR diff --git a/Firmware/language_all.cpp b/Firmware/language_all.cpp index 98ee8ec62..18f742bfb 100644 --- a/Firmware/language_all.cpp +++ b/Firmware/language_all.cpp @@ -2218,6 +2218,13 @@ const char * const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM] PROGMEM = { MSG_TEMP_CALIBRATION_ON_CZ }; +const char MSG_TEMP_CAL_FAILED_EN[] PROGMEM = "Temperature calibration failed"; +const char MSG_TEMP_CAL_FAILED_CZ[] PROGMEM = "Teplotni kalibrace selhala"; +const char * const MSG_TEMP_CAL_FAILED_LANG_TABLE[LANG_NUM] PROGMEM = { + MSG_TEMP_CAL_FAILED_EN, + MSG_TEMP_CAL_FAILED_CZ +}; + const char MSG_TEMP_CAL_WARNING_EN[] PROGMEM = "Stable ambient temperature 21-26C is needed a rigid stand is required."; const char * const MSG_TEMP_CAL_WARNING_LANG_TABLE[1] PROGMEM = { MSG_TEMP_CAL_WARNING_EN diff --git a/Firmware/language_all.h b/Firmware/language_all.h index ae8278732..e4711773e 100644 --- a/Firmware/language_all.h +++ b/Firmware/language_all.h @@ -726,6 +726,8 @@ extern const char* const MSG_TEMP_CALIBRATION_OFF_LANG_TABLE[LANG_NUM]; #define MSG_TEMP_CALIBRATION_OFF LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_OFF_LANG_TABLE) extern const char* const MSG_TEMP_CALIBRATION_ON_LANG_TABLE[LANG_NUM]; #define MSG_TEMP_CALIBRATION_ON LANG_TABLE_SELECT(MSG_TEMP_CALIBRATION_ON_LANG_TABLE) +extern const char* const MSG_TEMP_CAL_FAILED_LANG_TABLE[LANG_NUM]; +#define MSG_TEMP_CAL_FAILED LANG_TABLE_SELECT(MSG_TEMP_CAL_FAILED_LANG_TABLE) extern const char* const MSG_TEMP_CAL_WARNING_LANG_TABLE[1]; #define MSG_TEMP_CAL_WARNING LANG_TABLE_SELECT_EXPLICIT(MSG_TEMP_CAL_WARNING_LANG_TABLE, 0) extern const char* const MSG_TOSHIBA_FLASH_AIR_COMPATIBILITY_OFF_LANG_TABLE[1]; diff --git a/Firmware/language_cz.h b/Firmware/language_cz.h index f7eb4f1b5..5069d8020 100644 --- a/Firmware/language_cz.h +++ b/Firmware/language_cz.h @@ -415,3 +415,4 @@ #define MSG_CHANGED_PRINTER "Varovani: doslo ke zmene typu tiskarny." #define MSG_CHANGED_BOTH "Varovani: doslo ke zmene typu tiskarny a motherboardu." #define MSG_WAITING_TEMP_PINDA "Cekani na zchladnuti PINDA" +#define MSG_TEMP_CAL_FAILED "Teplotni kalibrace selhala" \ No newline at end of file diff --git a/Firmware/language_en.h b/Firmware/language_en.h index 4cb5b20c4..84d58e664 100644 --- a/Firmware/language_en.h +++ b/Firmware/language_en.h @@ -422,4 +422,5 @@ #define(length=20, lines=4) MSG_CHANGED_MOTHERBOARD "Warning: motherboard type changed." #define(length=20, lines=4) MSG_CHANGED_PRINTER "Warning: printer type changed." #define(length=20, lines=4) MSG_CHANGED_BOTH "Warning: both printer type and motherboard type changed." -#define(length=20, lines=3) MSG_WAITING_TEMP_PINDA "Waiting for PINDA probe cooling" \ No newline at end of file +#define(length=20, lines=3) MSG_WAITING_TEMP_PINDA "Waiting for PINDA probe cooling" +#define(length=20, lines=8) MSG_TEMP_CAL_FAILED "Temperature calibration failed" \ No newline at end of file diff --git a/Firmware/ultralcd.cpp b/Firmware/ultralcd.cpp index 5996272b3..25d65d74b 100644 --- a/Firmware/ultralcd.cpp +++ b/Firmware/ultralcd.cpp @@ -9,6 +9,7 @@ #include "stepper.h" #include "ConfigurationStore.h" #include +#include "Timer.h" #include "util.h" #include "mesh_bed_leveling.h" @@ -2600,23 +2601,33 @@ void lcd_adjust_z() { } -void lcd_wait_for_pinda(uint8_t temp) { +bool lcd_wait_for_pinda(float temp) { lcd_set_custom_characters_degree(); setTargetHotend(0, 0); setTargetBed(0); + Timer pinda_timeout; + pinda_timeout.start(); + bool target_temp_reached = true; + while (current_temperature_pinda > temp){ lcd_display_message_fullscreen_P(MSG_WAITING_TEMP_PINDA); lcd.setCursor(0, 4); lcd.print(LCD_STR_THERMOMETER[0]); lcd.print(ftostr3(current_temperature_pinda)); - lcd.print("/35"); + lcd.print("/"); + lcd.print(ftostr3(temp)); lcd.print(LCD_STR_DEGREE); delay_keep_alive(1000); serialecho_temperatures(); + if (pinda_timeout.expired(8 * 60 * 1000ul)) { //PINDA cooling from 60 C to 35 C takes about 7 minutes + target_temp_reached = false; + break; + } } lcd_set_custom_characters_arrows(); lcd_update_enable(true); + return(target_temp_reached); } void lcd_wait_for_heater() { @@ -3063,6 +3074,36 @@ void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, ui } } +void lcd_temp_cal_show_result(bool result) { + + custom_message_type = 0; + custom_message = false; + disable_x(); + disable_y(); + disable_z(); + disable_e0(); + disable_e1(); + disable_e2(); + setTargetBed(0); //set bed target temperature back to 0 + + if (result == true) { + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 1); + SERIAL_ECHOLNPGM("Temperature calibration done. Continue with pressing the knob."); + lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CALIBRATION_DONE); + temp_cal_active = true; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 1); + } + else { + eeprom_update_byte((uint8_t*)EEPROM_CALIBRATION_STATUS_PINDA, 0); + SERIAL_ECHOLNPGM("Temperature calibration failed. Continue with pressing the knob."); + lcd_show_fullscreen_message_and_wait_P(MSG_TEMP_CAL_FAILED); + temp_cal_active = false; + eeprom_update_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE, 0); + } + lcd_update_enable(true); + lcd_update(2); +} + static void lcd_show_end_stops() { lcd.setCursor(0, 0); lcd_printPGM((PSTR("End stops diag"))); diff --git a/Firmware/ultralcd.h b/Firmware/ultralcd.h index c53ac8b93..79fc70d41 100644 --- a/Firmware/ultralcd.h +++ b/Firmware/ultralcd.h @@ -267,10 +267,13 @@ void lcd_farm_sdcard_menu_w(); void lcd_wait_for_heater(); void lcd_wait_for_cool_down(); -void lcd_wait_for_pinda(uint8_t temp); void adjust_bed_reset(); void lcd_extr_cal_reset(); +void lcd_temp_cal_show_result(bool result); +bool lcd_wait_for_pinda(float temp); + + union MenuData; void bowden_menu();