From 0271ab364377596073145bd8e52580a4b9dfc9cf Mon Sep 17 00:00:00 2001 From: Robert Pelnar Date: Wed, 25 Apr 2018 16:19:16 +0200 Subject: [PATCH] Meshbedleveling, calibration Z check crash Z (MK3) check deviation of Z-probe (>50um == error, all printers) kill with message "debris on nozzle..." --- Firmware/Marlin_main.cpp | 4 ++-- Firmware/mesh_bed_calibration.cpp | 29 +++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 7db28735..21c5dd6c 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -2076,7 +2076,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); #ifdef TMC2130 - if (READ(Z_TMC2130_DIAG) != 0) return; //Z crash + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) return; //Z crash #endif //TMC2130 current_position[axis] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); @@ -2088,7 +2088,7 @@ void homeaxis(int axis, uint8_t cnt, uint8_t* pstep) plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); #ifdef TMC2130 - if (READ(Z_TMC2130_DIAG) != 0) return; //Z crash + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) return; //Z crash #endif //TMC2130 axis_is_at_home(axis); destination[axis] = current_position[axis]; diff --git a/Firmware/mesh_bed_calibration.cpp b/Firmware/mesh_bed_calibration.cpp index e8ed5cda..946a623e 100644 --- a/Firmware/mesh_bed_calibration.cpp +++ b/Firmware/mesh_bed_calibration.cpp @@ -7,6 +7,10 @@ #include "stepper.h" #include "ultralcd.h" +#ifdef TMC2130 +#include "tmc2130.h" +#endif //TMC2130 + uint8_t world2machine_correction_mode; float world2machine_rotation_and_skew[2][2]; float world2machine_rotation_and_skew_inv[2][2]; @@ -880,8 +884,11 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i update_current_position_z(); if (! endstop_z_hit_on_purpose()) goto error; - - for (uint8_t i = 0; i < n_iter; ++ i) { +#ifdef TMC2130 + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) goto error; //crash Z detected +#endif //TMC2130 + for (uint8_t i = 0; i < n_iter; ++ i) + { // Move up the retract distance. current_position[Z_AXIS] += .5f; go_to_current(homing_feedrate[Z_AXIS]/60); @@ -892,10 +899,16 @@ inline bool find_bed_induction_sensor_point_z(float minimum_z, uint8_t n_iter, i update_current_position_z(); if (! endstop_z_hit_on_purpose()) goto error; +#ifdef TMC2130 + if ((tmc2130_mode == TMC2130_MODE_NORMAL) && (READ(Z_TMC2130_DIAG) != 0)) goto error; //crash Z detected +#endif //TMC2130 // SERIAL_ECHOPGM("Bed find_bed_induction_sensor_point_z low, height: "); // MYSERIAL.print(current_position[Z_AXIS], 5); // SERIAL_ECHOLNPGM(""); + 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)); + if (dz > 0.05) goto error;//deviation > 50um } current_position[Z_AXIS] = z; if (n_iter > 1) @@ -2693,7 +2706,11 @@ bool sample_mesh_and_store_reference() #endif //TMC2130 enable_endstops(false); - find_bed_induction_sensor_point_z(); + if (!find_bed_induction_sensor_point_z()) //Z crash or deviation > 50um + { + kill(MSG_BED_LEVELING_FAILED_POINT_LOW); + return false; + } mbl.set_z(0, 0, current_position[Z_AXIS]); } for (int8_t mesh_point = 1; mesh_point != MESH_MEAS_NUM_X_POINTS * MESH_MEAS_NUM_Y_POINTS; ++ mesh_point) { @@ -2711,7 +2728,11 @@ bool sample_mesh_and_store_reference() lcd_implementation_print_at(0, next_line, mesh_point+1); lcd_printPGM(MSG_MEASURE_BED_REFERENCE_HEIGHT_LINE2); #endif /* MESH_BED_CALIBRATION_SHOW_LCD */ - find_bed_induction_sensor_point_z(); + if (!find_bed_induction_sensor_point_z()) //Z crash or deviation > 50um + { + kill(MSG_BED_LEVELING_FAILED_POINT_LOW); + return false; + } // Get cords of measuring point int8_t ix = mesh_point % MESH_MEAS_NUM_X_POINTS; int8_t iy = mesh_point / MESH_MEAS_NUM_X_POINTS;