Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 WIP: Relieve pressure after a nozzle crash #4618

Draft
wants to merge 1 commit into
base: MK3
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2192,16 +2192,29 @@ bool calibrate_z_auto()
}
#endif //TMC2130

static void nozzle_crash_handler() {
// Exit whatever homing or endstop mode was enabled
#ifdef TMC2130
FORCE_HIGH_POWER_END;
tmc2130_home_exit();
#endif
enable_endstops(false);
enable_z_endstop(false);
// Fix the planner position to a known value
current_position[Z_AXIS] = 0;
plan_set_position_curposXYZE();
// Raize Z to release pressure on bed after nozzle crash
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS]);
st_synchronize();
}

#ifdef TMC2130
void check_Z_crash(void)
{
if (!READ(Z_TMC2130_DIAG)) { //Z crash
FORCE_HIGH_POWER_END;
current_position[Z_AXIS] = 0;
plan_set_position_curposXYZE();
current_position[Z_AXIS] += MESH_HOME_Z_SEARCH;
plan_buffer_line_curposXYZE(max_feedrate[Z_AXIS]);
st_synchronize();
nozzle_crash_handler();
// throw unrecoverable error
kill(_T(MSG_BED_LEVELING_FAILED_POINT_LOW));
}
}
Expand Down Expand Up @@ -3281,6 +3294,7 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
}
else
{
nozzle_crash_handler();
lcd_show_fullscreen_message_and_wait_P(PSTR("Calibration failed! Check the axes and run again."));
final_result = false;
}
Expand Down
26 changes: 9 additions & 17 deletions Firmware/mesh_bed_calibration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
#endif //SUPPORT_VERBOSITY
)
{
bool result = false;
bool high_deviation_occured = false;
bedPWMDisabled = 1;
#ifdef TMC2130
Expand Down Expand Up @@ -974,13 +975,13 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
if (! endstop_z_hit_on_purpose())
{
//printf_P(PSTR("endstop not hit 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
goto error;
goto end;
}
#ifdef TMC2130
if (!READ(Z_TMC2130_DIAG))
{
//printf_P(PSTR("crash detected 1, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
goto error; //crash Z detected
goto end; //crash Z detected
}
#endif //TMC2130
for (uint8_t i = 0; i < n_iter; ++ i)
Expand Down Expand Up @@ -1010,12 +1011,12 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
if (!endstop_z_hit_on_purpose())
{
//printf_P(PSTR("i = %d, endstop not hit 2, current_pos[Z]: %f \n"), i, current_position[Z_AXIS]);
goto error;
goto end;
}
#ifdef TMC2130
if (!READ(Z_TMC2130_DIAG)) {
//printf_P(PSTR("crash detected 2, current_pos[Z]: %f \n"), current_position[Z_AXIS]);
goto error; //crash Z detected
goto end; //crash Z detected
}
#endif //TMC2130
// SERIAL_ECHOPGM("Bed find_bed_induction_sensor_point_z low, height: ");
Expand All @@ -1035,7 +1036,7 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
z = 0;
}
else {
goto error;
goto end;
}
}
//printf_P(PSTR("PINDA triggered at %f\n"), current_position[Z_AXIS]);
Expand All @@ -1044,25 +1045,16 @@ bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, int
if (n_iter > 1)
current_position[Z_AXIS] /= float(n_iter);


result = true; //success
end:
enable_endstops(endstops_enabled);
enable_z_endstop(endstop_z_enabled);
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 3");
#ifdef TMC2130
if (bHighPowerForced) FORCE_HIGH_POWER_END;
#endif
bedPWMDisabled = 0;
return true;

error:
// SERIAL_ECHOLNPGM("find_bed_induction_sensor_point_z 4");
enable_endstops(endstops_enabled);
enable_z_endstop(endstop_z_enabled);
#ifdef TMC2130
if (bHighPowerForced) FORCE_HIGH_POWER_END;
#endif
bedPWMDisabled = 0;
return false;
return result;
}

#ifdef NEW_XYZCAL
Expand Down
Loading