Safe Z homing for Power Loss Recovery (#16909)
This commit is contained in:
parent
854ab04ee4
commit
c8cd824be2
@ -1256,7 +1256,6 @@
|
|||||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
|
#define PLR_ENABLED_DEFAULT false // Power Loss Recovery enabled by default. (Set with 'M413 Sn' & M500)
|
||||||
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
|
//#define BACKUP_POWER_SUPPLY // Backup power / UPS to move the steppers on power loss
|
||||||
//#define POWER_LOSS_RECOVER_ZHOME // Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
|
|
||||||
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS)
|
//#define POWER_LOSS_ZRAISE 2 // (mm) Z axis raise on resume (on power loss with UPS)
|
||||||
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
|
//#define POWER_LOSS_PIN 44 // Pin to detect power loss. Set to -1 to disable default pin on boards without module.
|
||||||
//#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
|
//#define POWER_LOSS_STATE HIGH // State of pin indicating power loss
|
||||||
@ -1268,6 +1267,12 @@
|
|||||||
// Without a POWER_LOSS_PIN the following option helps reduce wear on the SD card,
|
// Without a POWER_LOSS_PIN the following option helps reduce wear on the SD card,
|
||||||
// especially with "vase mode" printing. Set too high and vases cannot be continued.
|
// especially with "vase mode" printing. Set too high and vases cannot be continued.
|
||||||
#define POWER_LOSS_MIN_Z_CHANGE 0.05 // (mm) Minimum Z change before saving power-loss data
|
#define POWER_LOSS_MIN_Z_CHANGE 0.05 // (mm) Minimum Z change before saving power-loss data
|
||||||
|
|
||||||
|
// Enable if Z homing is needed for proper recovery. 99.9% of the time this should be disabled!
|
||||||
|
//#define POWER_LOSS_RECOVER_ZHOME
|
||||||
|
#if ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
||||||
|
//#define POWER_LOSS_ZHOME_POS { 0, 0 } // Safe XY position to home Z while avoiding objects on the bed
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -384,18 +384,25 @@ void PrintJobRecovery::resume() {
|
|||||||
// Home safely with no Z raise
|
// Home safely with no Z raise
|
||||||
gcode.process_subcommands_now_P(PSTR(
|
gcode.process_subcommands_now_P(PSTR(
|
||||||
"G28R0" // No raise during G28
|
"G28R0" // No raise during G28
|
||||||
#if IS_CARTESIAN && DISABLED(POWER_LOSS_RECOVER_ZHOME)
|
#if IS_CARTESIAN && (DISABLED(POWER_LOSS_RECOVER_ZHOME) || defined(POWER_LOSS_ZHOME_POS))
|
||||||
"XY" // Don't home Z on Cartesian unless overridden
|
"XY" // Don't home Z on Cartesian unless overridden
|
||||||
#endif
|
#endif
|
||||||
));
|
));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Pretend that all axes are homed
|
#ifdef POWER_LOSS_ZHOME_POS
|
||||||
|
// If defined move to a safe Z homing position that avoids the print
|
||||||
|
constexpr xy_pos_t homepos = POWER_LOSS_ZHOME_POS;
|
||||||
|
sprintf_P(cmd, PSTR("G1 X%s Y%s F1000\nG28Z", dtostrf(homepos.x, 1, 3, str_1), dtostrf(homepos.y, 1, 3, str_2)));
|
||||||
|
gcode.process_subcommands_now(cmd);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// Ensure that all axes are marked as homed
|
||||||
set_all_homed();
|
set_all_homed();
|
||||||
|
|
||||||
#if ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
#if ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
||||||
// Z has been homed so restore Z to ZsavedPos + POWER_LOSS_ZRAISE
|
// Now move to ZsavedPos + POWER_LOSS_ZRAISE
|
||||||
sprintf_P(cmd, PSTR("G1 F500 Z%s"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
|
sprintf_P(cmd, PSTR("G1 F500 Z%s"), dtostrf(info.current_position.z + POWER_LOSS_ZRAISE, 1, 3, str_1));
|
||||||
gcode.process_subcommands_now(cmd);
|
gcode.process_subcommands_now(cmd);
|
||||||
#endif
|
#endif
|
||||||
@ -467,7 +474,7 @@ void PrintJobRecovery::resume() {
|
|||||||
|
|
||||||
// Additional purge if configured
|
// Additional purge if configured
|
||||||
#if POWER_LOSS_PURGE_LEN
|
#if POWER_LOSS_PURGE_LEN
|
||||||
sprintf_P(cmd, PSTR("G1 E%d F200"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN));
|
sprintf_P(cmd, PSTR("G1 E%d F3000"), (POWER_LOSS_PURGE_LEN) + (POWER_LOSS_RETRACT_LEN));
|
||||||
gcode.process_subcommands_now(cmd);
|
gcode.process_subcommands_now(cmd);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -485,7 +492,7 @@ void PrintJobRecovery::resume() {
|
|||||||
// Move back to the saved Z
|
// Move back to the saved Z
|
||||||
dtostrf(info.current_position.z, 1, 3, str_1);
|
dtostrf(info.current_position.z, 1, 3, str_1);
|
||||||
#if Z_HOME_DIR > 0 || ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
#if Z_HOME_DIR > 0 || ENABLED(POWER_LOSS_RECOVER_ZHOME)
|
||||||
sprintf_P(cmd, PSTR("G1 Z%s F200"), str_1);
|
sprintf_P(cmd, PSTR("G1 Z%s F500"), str_1);
|
||||||
#else
|
#else
|
||||||
gcode.process_subcommands_now_P(PSTR("G1 Z0 F200"));
|
gcode.process_subcommands_now_P(PSTR("G1 Z0 F200"));
|
||||||
sprintf_P(cmd, PSTR("G92.9 Z%s"), str_1);
|
sprintf_P(cmd, PSTR("G92.9 Z%s"), str_1);
|
||||||
|
@ -1641,7 +1641,7 @@ static_assert(hbm[Z_AXIS] >= 0, "HOMING_BUMP_MM.Z must be greater than or equal
|
|||||||
* Allen Key
|
* Allen Key
|
||||||
* Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis.
|
* Deploying the Allen Key probe uses big moves in z direction. Too dangerous for an unhomed z-axis.
|
||||||
*/
|
*/
|
||||||
#if BOTH(Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && (Z_HOME_DIR < 0)
|
#if BOTH(Z_PROBE_ALLEN_KEY, Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) && Z_HOME_DIR < 0
|
||||||
#error "You can't home to a Z min endstop with a Z_PROBE_ALLEN_KEY."
|
#error "You can't home to a Z min endstop with a Z_PROBE_ALLEN_KEY."
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -2913,12 +2913,16 @@ static_assert( _ARR_TEST(3,0) && _ARR_TEST(3,1) && _ARR_TEST(3,2)
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(BACKUP_POWER_SUPPLY) && !PIN_EXISTS(POWER_LOSS)
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||||
|
#if ENABLED(BACKUP_POWER_SUPPLY) && !PIN_EXISTS(POWER_LOSS)
|
||||||
#error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN."
|
#error "BACKUP_POWER_SUPPLY requires a POWER_LOSS_PIN."
|
||||||
#endif
|
#elif BOTH(POWER_LOSS_RECOVER_ZHOME, Z_SAFE_HOMING)
|
||||||
|
#error "POWER_LOSS_RECOVER_ZHOME cannot be used with Z_SAFE_HOMING."
|
||||||
#if BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
|
#elif BOTH(POWER_LOSS_PULLUP, POWER_LOSS_PULLDOWN)
|
||||||
#error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
|
#error "You can't enable POWER_LOSS_PULLUP and POWER_LOSS_PULLDOWN at the same time."
|
||||||
|
#elif BOTH(IS_CARTESIAN, POWER_LOSS_RECOVER_ZHOME) && Z_HOME_DIR < 0 && !defined(POWER_LOSS_ZHOME_POS)
|
||||||
|
#error "POWER_LOSS_RECOVER_ZHOME requires POWER_LOSS_ZHOME_POS for a Cartesian that homes to ZMIN."
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
|
#if ENABLED(Z_STEPPER_AUTO_ALIGN)
|
||||||
|
@ -340,7 +340,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
|
|||||||
* - If a preheat input is higher than the current target, raise the target temperature.
|
* - If a preheat input is higher than the current target, raise the target temperature.
|
||||||
* - If a preheat input is higher than the current temperature, wait for stabilization.
|
* - If a preheat input is higher than the current temperature, wait for stabilization.
|
||||||
*/
|
*/
|
||||||
void Probe::preheat_for_probing(const uint16_t hotend_temp, const uint16_t bed_temp) {
|
void Probe::preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp) {
|
||||||
#if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP)
|
#if HAS_HOTEND && (PROBING_NOZZLE_TEMP || LEVELING_NOZZLE_TEMP)
|
||||||
#define WAIT_FOR_NOZZLE_HEAT
|
#define WAIT_FOR_NOZZLE_HEAT
|
||||||
#endif
|
#endif
|
||||||
@ -351,17 +351,17 @@ FORCE_INLINE void probe_specific_action(const bool deploy) {
|
|||||||
DEBUG_ECHOPGM("Preheating ");
|
DEBUG_ECHOPGM("Preheating ");
|
||||||
|
|
||||||
#if ENABLED(WAIT_FOR_NOZZLE_HEAT)
|
#if ENABLED(WAIT_FOR_NOZZLE_HEAT)
|
||||||
const uint16_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0;
|
const int16_t hotendPreheat = hotend_temp > thermalManager.degTargetHotend(0) ? hotend_temp : 0;
|
||||||
if (hotendPreheat) {
|
if (hotendPreheat) {
|
||||||
DEBUG_ECHOPAIR("hotend (", hotendPreheat, ")");
|
DEBUG_ECHOPAIR("hotend (", hotendPreheat, ")");
|
||||||
thermalManager.setTargetHotend(hotendPreheat, 0);
|
thermalManager.setTargetHotend(hotendPreheat, 0);
|
||||||
}
|
}
|
||||||
#elif ENABLED(WAIT_FOR_BED_HEAT)
|
#elif ENABLED(WAIT_FOR_BED_HEAT)
|
||||||
constexpr uint16_t hotendPreheat = 0;
|
constexpr int16_t hotendPreheat = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(WAIT_FOR_BED_HEAT)
|
#if ENABLED(WAIT_FOR_BED_HEAT)
|
||||||
const uint16_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
|
const int16_t bedPreheat = bed_temp > thermalManager.degTargetBed() ? bed_temp : 0;
|
||||||
if (bedPreheat) {
|
if (bedPreheat) {
|
||||||
if (hotendPreheat) DEBUG_ECHOPGM(" and ");
|
if (hotendPreheat) DEBUG_ECHOPGM(" and ");
|
||||||
DEBUG_ECHOPAIR("bed (", bedPreheat, ")");
|
DEBUG_ECHOPAIR("bed (", bedPreheat, ")");
|
||||||
|
@ -61,7 +61,7 @@ public:
|
|||||||
static xyz_pos_t offset;
|
static xyz_pos_t offset;
|
||||||
|
|
||||||
#if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
|
#if EITHER(PREHEAT_BEFORE_PROBING, PREHEAT_BEFORE_LEVELING)
|
||||||
static void preheat_for_probing(const uint16_t hotend_temp, const uint16_t bed_temp);
|
static void preheat_for_probing(const int16_t hotend_temp, const int16_t bed_temp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static bool set_deployed(const bool deploy);
|
static bool set_deployed(const bool deploy);
|
||||||
|
@ -22,9 +22,11 @@ opt_add TEMP_CHAMBER_PIN 3
|
|||||||
opt_add HEATER_CHAMBER_PIN 45
|
opt_add HEATER_CHAMBER_PIN 45
|
||||||
opt_set GRID_MAX_POINTS_X 16
|
opt_set GRID_MAX_POINTS_X 16
|
||||||
opt_set FANMUX0_PIN 53
|
opt_set FANMUX0_PIN 53
|
||||||
opt_disable USE_WATCHDOG
|
opt_set Z_HOME_DIR 1
|
||||||
|
opt_enable USE_ZMAX_PLUG
|
||||||
|
opt_disable USE_ZMIN_PLUG Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN USE_WATCHDOG
|
||||||
opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \
|
opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TEST \
|
||||||
FIX_MOUNTED_PROBE Z_SAFE_HOMING CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \
|
FIX_MOUNTED_PROBE CODEPENDENT_XY_HOMING PIDTEMPBED PROBE_TEMP_COMPENSATION \
|
||||||
PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
|
PREHEAT_BEFORE_PROBING PROBING_HEATERS_OFF PROBING_FANS_OFF PROBING_STEPPERS_OFF WAIT_FOR_BED_HEATER \
|
||||||
EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \
|
EEPROM_SETTINGS SDSUPPORT SD_REPRINT_LAST_SELECTED_FILE BINARY_FILE_TRANSFER \
|
||||||
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
|
BLINKM PCA9533 PCA9632 RGB_LED RGB_LED_R_PIN RGB_LED_G_PIN RGB_LED_B_PIN LED_CONTROL_MENU \
|
||||||
@ -38,7 +40,7 @@ opt_enable REPRAP_DISCOUNT_SMART_CONTROLLER LCD_PROGRESS_BAR LCD_PROGRESS_BAR_TE
|
|||||||
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
|
SKEW_CORRECTION SKEW_CORRECTION_FOR_Z SKEW_CORRECTION_GCODE \
|
||||||
BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \
|
BACKLASH_COMPENSATION BACKLASH_GCODE BAUD_RATE_GCODE BEZIER_CURVE_SUPPORT \
|
||||||
FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
|
FWRETRACT ARC_P_CIRCLES CNC_WORKSPACE_PLANES CNC_COORDINATE_SYSTEMS \
|
||||||
PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE \
|
PSU_CONTROL AUTO_POWER_CONTROL POWER_LOSS_RECOVERY POWER_LOSS_PIN POWER_LOSS_STATE POWER_LOSS_RECOVER_ZHOME \
|
||||||
SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
|
SLOW_PWM_HEATERS THERMAL_PROTECTION_CHAMBER LIN_ADVANCE EXTRA_LIN_ADVANCE_K \
|
||||||
HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL
|
HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT PINS_DEBUGGING MAX7219_DEBUG M114_DETAIL
|
||||||
opt_add DEBUG_POWER_LOSS_RECOVERY
|
opt_add DEBUG_POWER_LOSS_RECOVERY
|
||||||
|
Loading…
Reference in New Issue
Block a user