Browse Source

Meshbedleveling, calibration Z
check crash Z (MK3)
check deviation of Z-probe (>50um == error, all printers)
kill with message "debris on nozzle..."

Robert Pelnar 6 years ago
parent
commit
0271ab3643
2 changed files with 27 additions and 6 deletions
  1. 2 2
      Firmware/Marlin_main.cpp
  2. 25 4
      Firmware/mesh_bed_calibration.cpp

+ 2 - 2
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];

+ 25 - 4
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;