samle z after xyz cal. added, find_point_xy: initial z coordinate after first hit lowered

This commit is contained in:
PavelSindler 2018-03-04 23:49:54 +01:00
parent 8800793dd1
commit f1410a37f2
4 changed files with 48 additions and 31 deletions

View File

@ -2228,9 +2228,12 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize(); st_synchronize();
#ifndef HEATBED_V2
if (result >= 0) if (result >= 0)
{ {
#ifdef HEATBED_V2
sample_z();
#else //HEATBED_V2
point_too_far_mask = 0; point_too_far_mask = 0;
// Second half: The fine adjustment. // Second half: The fine adjustment.
// Let the planner use the uncorrected coordinates. // Let the planner use the uncorrected coordinates.
@ -2245,9 +2248,10 @@ bool gcode_M45(bool onlyZ, int8_t verbosity_level)
current_position[Z_AXIS] = MESH_HOME_Z_SEARCH; current_position[Z_AXIS] = MESH_HOME_Z_SEARCH;
plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder); plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], homing_feedrate[Z_AXIS] / 40, active_extruder);
st_synchronize(); st_synchronize();
// if (result >= 0) babystep_apply(); // if (result >= 0) babystep_apply();
#endif //HEATBED_V2
} }
#endif //HEATBED_V2
lcd_bed_calibration_show_result(result, point_too_far_mask); lcd_bed_calibration_show_result(result, point_too_far_mask);
if (result >= 0) if (result >= 0)
{ {

View File

@ -1038,7 +1038,7 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
MYSERIAL.println(current_position[Z_AXIS]);*/ MYSERIAL.println(current_position[Z_AXIS]);*/
// Slightly lower the Z axis to get a reliable trigger. // Slightly lower the Z axis to get a reliable trigger.
current_position[Z_AXIS] -= 0.05f; current_position[Z_AXIS] -= 0.1f;
go_xyz(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], homing_feedrate[Z_AXIS] / (60 * 10)); go_xyz(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], homing_feedrate[Z_AXIS] / (60 * 10));
SERIAL_ECHOPGM("2 - current_position[Z_AXIS]: "); SERIAL_ECHOPGM("2 - current_position[Z_AXIS]: ");
@ -1050,8 +1050,9 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
for (int iteration = 0; iteration < 8; iteration++) { for (int iteration = 0; iteration < 8; iteration++) {
found = false; found = false;
enable_z_endstop(true, true); invert_z_endstop(true);
go_xy(x0, current_position[Y_AXIS], feedrate / 3); enable_z_endstop(true);
go_xy(x0, current_position[Y_AXIS], feedrate / 5);
update_current_position_xyz(); update_current_position_xyz();
if (!endstop_z_hit_on_purpose()) { if (!endstop_z_hit_on_purpose()) {
// SERIAL_ECHOLN("Search X span 0 - not found"); // SERIAL_ECHOLN("Search X span 0 - not found");
@ -1063,9 +1064,9 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
// SERIAL_ECHOLN("Search X span 0 - found"); // SERIAL_ECHOLN("Search X span 0 - found");
a = current_position[X_AXIS]; a = current_position[X_AXIS];
enable_z_endstop(false); enable_z_endstop(false);
go_xy(init_x_position, current_position[Y_AXIS], feedrate / 3); go_xy(init_x_position, current_position[Y_AXIS], feedrate / 5);
enable_z_endstop(true); enable_z_endstop(true);
go_xy(x1, current_position[Y_AXIS], feedrate / 3); go_xy(x1, current_position[Y_AXIS], feedrate / 5);
update_current_position_xyz(); update_current_position_xyz();
if (!endstop_z_hit_on_purpose()) { if (!endstop_z_hit_on_purpose()) {
// SERIAL_ECHOLN("Search X span 1 - not found"); // SERIAL_ECHOLN("Search X span 1 - not found");
@ -1078,13 +1079,13 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
// Go to the center. // Go to the center.
enable_z_endstop(false); enable_z_endstop(false);
current_position[X_AXIS] = 0.5f * (a + b); current_position[X_AXIS] = 0.5f * (a + b);
go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate / 3); go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate / 5);
found = true; found = true;
// Search in the Y direction along a cross. // Search in the Y direction along a cross.
found = false; found = false;
enable_z_endstop(true); enable_z_endstop(true);
go_xy(current_position[X_AXIS], y0, feedrate / 3); go_xy(current_position[X_AXIS], y0, feedrate / 5);
update_current_position_xyz(); update_current_position_xyz();
if (!endstop_z_hit_on_purpose()) { if (!endstop_z_hit_on_purpose()) {
// SERIAL_ECHOLN("Search Y2 span 0 - not found"); // SERIAL_ECHOLN("Search Y2 span 0 - not found");
@ -1095,9 +1096,9 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
// SERIAL_ECHOLN("Search Y2 span 0 - found"); // SERIAL_ECHOLN("Search Y2 span 0 - found");
a = current_position[Y_AXIS]; a = current_position[Y_AXIS];
enable_z_endstop(false); enable_z_endstop(false);
go_xy(current_position[X_AXIS], init_y_position, feedrate / 3); go_xy(current_position[X_AXIS], init_y_position, feedrate / 5);
enable_z_endstop(true); enable_z_endstop(true);
go_xy(current_position[X_AXIS], y1, feedrate / 3); go_xy(current_position[X_AXIS], y1, feedrate / 5);
update_current_position_xyz(); update_current_position_xyz();
if (!endstop_z_hit_on_purpose()) { if (!endstop_z_hit_on_purpose()) {
// SERIAL_ECHOLN("Search Y2 span 1 - not found"); // SERIAL_ECHOLN("Search Y2 span 1 - not found");
@ -1109,9 +1110,10 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
//lcd_update_enable(true); //lcd_update_enable(true);
// Go to the center. // Go to the center.
enable_z_endstop(false, false); enable_z_endstop(false);
invert_z_endstop(false);
current_position[Y_AXIS] = 0.5f * (a + b); current_position[Y_AXIS] = 0.5f * (a + b);
go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate / 3); go_xy(current_position[X_AXIS], current_position[Y_AXIS], feedrate / 5);
#ifdef SUPPORT_VERBOSITY #ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 20) { if (verbosity_level >= 20) {
@ -1124,17 +1126,20 @@ inline bool find_bed_induction_sensor_point_xy(int verbosity_level)
} }
#endif //SUPPORT_VERBOSITY #endif //SUPPORT_VERBOSITY
if (iteration > 3) { if (iteration > 0) {
// Average the last 4 measurements. // Average the last 7 measurements.
avg[X_AXIS] += current_position[X_AXIS]; avg[X_AXIS] += current_position[X_AXIS];
avg[Y_AXIS] += current_position[Y_AXIS]; avg[Y_AXIS] += current_position[Y_AXIS];
} }
init_x_position = current_position[X_AXIS];
init_y_position = current_position[Y_AXIS];
found = true; found = true;
} }
avg[X_AXIS] *= (1.f / 4.f); avg[X_AXIS] *= (1.f / 7.f);
avg[Y_AXIS] *= (1.f / 4.f); avg[Y_AXIS] *= (1.f / 7.f);
current_position[X_AXIS] = avg[X_AXIS]; current_position[X_AXIS] = avg[X_AXIS];
current_position[Y_AXIS] = avg[Y_AXIS]; current_position[Y_AXIS] = avg[Y_AXIS];
@ -2111,7 +2116,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
#endif // SUPPORT_VERBOSITY #endif // SUPPORT_VERBOSITY
if (!find_bed_induction_sensor_point_xy(verbosity_level)) if (!find_bed_induction_sensor_point_xy(verbosity_level))
return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
#if 1 #ifndef HEATBED_V2
if (k == 0 || k == 1) { if (k == 0 || k == 1) {
// Improve the position of the 1st row sensor points by a zig-zag movement. // Improve the position of the 1st row sensor points by a zig-zag movement.
@ -2132,7 +2137,7 @@ BedSkewOffsetDetectionResultType find_bed_offset_and_skew(int8_t verbosity_level
// not found // not found
return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND; return BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND;
} }
#endif #endif //HEATBED_V2
#ifdef SUPPORT_VERBOSITY #ifdef SUPPORT_VERBOSITY
if (verbosity_level >= 10) if (verbosity_level >= 10)
delay_keep_alive(3000); delay_keep_alive(3000);
@ -2548,16 +2553,7 @@ BedSkewOffsetDetectionResultType improve_bed_offset_and_skew(int8_t method, int8
} }
#endif // SUPPORT_VERBOSITY #endif // SUPPORT_VERBOSITY
//make space if(!sample_z())
current_position[Z_AXIS] += 150;
go_to_current(homing_feedrate[Z_AXIS] / 60);
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder););
lcd_show_fullscreen_message_and_wait_P(MSG_PLACE_STEEL_SHEET);
// Sample Z heights for the mesh bed leveling.
// In addition, store the results into an eeprom, to be used later for verification of the bed leveling process.
if (! sample_mesh_and_store_reference())
goto canceled; goto canceled;
enable_endstops(endstops_enabled); enable_endstops(endstops_enabled);
@ -2579,6 +2575,22 @@ canceled:
return result; return result;
} }
bool sample_z() {
bool sampled = true;
//make space
current_position[Z_AXIS] += 150;
go_to_current(homing_feedrate[Z_AXIS] / 60);
//plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], feedrate, active_extruder););
lcd_show_fullscreen_message_and_wait_P(MSG_PLACE_STEEL_SHEET);
// Sample Z heights for the mesh bed leveling.
// In addition, store the results into an eeprom, to be used later for verification of the bed leveling process.
if (!sample_mesh_and_store_reference()) sampled = false;
return sampled;
}
void go_home_with_z_lift() void go_home_with_z_lift()
{ {
// Don't let the manage_inactivity() function remove power from the motors. // Don't let the manage_inactivity() function remove power from the motors.

View File

@ -187,5 +187,6 @@ extern void babystep_undo();
// Reset the current babystep counter without moving the axes. // Reset the current babystep counter without moving the axes.
extern void babystep_reset(); extern void babystep_reset();
extern void count_xyz_details(); extern void count_xyz_details();
extern bool sample_z();
#endif /* MESH_BED_CALIBRATION_H */ #endif /* MESH_BED_CALIBRATION_H */

View File

@ -611,7 +611,7 @@ void isr() {
// Stall guard homing turned on // Stall guard homing turned on
z_min_endstop = (READ(Z_MIN_PIN) != z_endstop_invert) || (READ(Z_TMC2130_DIAG) != 0); z_min_endstop = (READ(Z_MIN_PIN) != z_endstop_invert) || (READ(Z_TMC2130_DIAG) != 0);
#else #else
z_min_endstop = (READ(Z_MIN_PIN) != z_endstop_invert); z_min_endstop = (READ(Z_MIN_PIN) != z_endstop_invert);
#endif //TMC2130_SG_HOMING #endif //TMC2130_SG_HOMING
if(z_min_endstop && old_z_min_endstop) { if(z_min_endstop && old_z_min_endstop) {
endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];