Merge pull request #7448 from thinkyhead/bf1_delta_fixes

Prevent damage if DELTA_HEIGHT is set badly
This commit is contained in:
Scott Lahteine 2017-08-15 16:35:09 -05:00 committed by GitHub
commit 06541ec885
4 changed files with 457 additions and 369 deletions

View File

@ -1409,6 +1409,9 @@ bool get_target_extruder_from_command(const uint16_t code) {
soft_endstop_max[axis] = base_max_pos(axis) + offs; soft_endstop_max[axis] = base_max_pos(axis) + offs;
} }
} }
#elif ENABLED(DELTA)
soft_endstop_min[axis] = base_min_pos(axis) + (axis == Z_AXIS ? 0 : offs);
soft_endstop_max[axis] = base_max_pos(axis) + offs;
#else #else
soft_endstop_min[axis] = base_min_pos(axis) + offs; soft_endstop_min[axis] = base_min_pos(axis) + offs;
soft_endstop_max[axis] = base_max_pos(axis) + offs; soft_endstop_max[axis] = base_max_pos(axis) + offs;
@ -1806,13 +1809,9 @@ static void clean_up_after_endstop_or_probe_move() {
} }
#endif #endif
float z_dest = LOGICAL_Z_POSITION(z_raise); float z_dest = z_raise;
if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset; if (zprobe_zoffset < 0) z_dest -= zprobe_zoffset;
#if ENABLED(DELTA)
z_dest -= home_offset[Z_AXIS]; // Account for delta height adjustment
#endif
if (z_dest > current_position[Z_AXIS]) if (z_dest > current_position[Z_AXIS])
do_blocking_move_to_z(z_dest); do_blocking_move_to_z(z_dest);
} }
@ -2106,7 +2105,7 @@ static void clean_up_after_endstop_or_probe_move() {
safe_delay(BLTOUCH_DELAY); safe_delay(BLTOUCH_DELAY);
} }
void set_bltouch_deployed(const bool deploy) { bool set_bltouch_deployed(const bool deploy) {
if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered
bltouch_command(BLTOUCH_RESET); // try to reset it. bltouch_command(BLTOUCH_RESET); // try to reset it.
bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to
@ -2118,6 +2117,7 @@ static void clean_up_after_endstop_or_probe_move() {
SERIAL_ERROR_START(); SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH); SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH);
stop(); // punt! stop(); // punt!
return true;
} }
} }
@ -2130,6 +2130,8 @@ static void clean_up_after_endstop_or_probe_move() {
SERIAL_EOL(); SERIAL_EOL();
} }
#endif #endif
return false;
} }
#endif // BLTOUCH #endif // BLTOUCH
@ -2149,23 +2151,7 @@ static void clean_up_after_endstop_or_probe_move() {
// Make room for probe // Make room for probe
do_probe_raise(_Z_CLEARANCE_DEPLOY_PROBE); do_probe_raise(_Z_CLEARANCE_DEPLOY_PROBE);
// When deploying make sure BLTOUCH is not already triggered #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
#if ENABLED(BLTOUCH)
if (deploy && TEST_BLTOUCH()) { // If BL-Touch says it's triggered
bltouch_command(BLTOUCH_RESET); // try to reset it.
bltouch_command(BLTOUCH_DEPLOY); // Also needs to deploy and stow to
bltouch_command(BLTOUCH_STOW); // clear the triggered condition.
safe_delay(1500); // wait for internal self test to complete
// measured completion time was 0.65 seconds
// after reset, deploy & stow sequence
if (TEST_BLTOUCH()) { // If it still claims to be triggered...
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_STOP_BLTOUCH);
stop(); // punt!
return true;
}
}
#elif ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
#if ENABLED(Z_PROBE_SLED) #if ENABLED(Z_PROBE_SLED)
#define _AUE_ARGS true, false, false #define _AUE_ARGS true, false, false
#else #else
@ -2236,14 +2222,21 @@ static void clean_up_after_endstop_or_probe_move() {
return false; return false;
} }
static void do_probe_move(float z, float fr_mm_m) { /**
* @brief Used by run_z_probe to do a single Z probe move.
*
* @param z Z destination
* @param fr_mm_s Feedrate in mm/s
* @return true to indicate an error
*/
static bool do_probe_move(const float z, const float fr_mm_m) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS(">>> do_probe_move", current_position);
#endif #endif
// Deploy BLTouch at the start of any probe // Deploy BLTouch at the start of any probe
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
set_bltouch_deployed(true); if (set_bltouch_deployed(true)) return true;
#endif #endif
#if QUIET_PROBING #if QUIET_PROBING
@ -2251,15 +2244,24 @@ static void clean_up_after_endstop_or_probe_move() {
#endif #endif
// Move down until probe triggered // Move down until probe triggered
do_blocking_move_to_z(LOGICAL_Z_POSITION(z), MMM_TO_MMS(fr_mm_m)); do_blocking_move_to_z(z, MMM_TO_MMS(fr_mm_m));
// Check to see if the probe was triggered
const bool probe_triggered = TEST(Endstops::endstop_hit_bits,
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
Z_MIN
#else
Z_MIN_PROBE
#endif
);
#if QUIET_PROBING #if QUIET_PROBING
probing_pause(false); probing_pause(false);
#endif #endif
// Retract BLTouch immediately after a probe // Retract BLTouch immediately after a probe if it was triggered
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
set_bltouch_deployed(false); if (probe_triggered && set_bltouch_deployed(false)) return true;
#endif #endif
// Clear endstop flags // Clear endstop flags
@ -2274,11 +2276,18 @@ static void clean_up_after_endstop_or_probe_move() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("<<< do_probe_move", current_position);
#endif #endif
return !probe_triggered;
} }
// Do a single Z probe and return with current_position[Z_AXIS] /**
// at the height where the probe triggered. * @details Used by probe_pt to do a single Z probe.
static float run_z_probe() { * Leaves current_position[Z_AXIS] at the height where the probe triggered.
*
* @param short_move Flag for a shorter probe move towards the bed
* @return The raw Z position where the probe was triggered
*/
static float run_z_probe(const bool short_move=true) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS(">>> run_z_probe", current_position);
@ -2290,34 +2299,33 @@ static void clean_up_after_endstop_or_probe_move() {
#if ENABLED(PROBE_DOUBLE_TOUCH) #if ENABLED(PROBE_DOUBLE_TOUCH)
// Do a first probe at the fast speed // Do a first probe at the fast speed
do_probe_move(-(Z_MAX_LENGTH) - 10, Z_PROBE_SPEED_FAST); if (do_probe_move(-10, Z_PROBE_SPEED_FAST)) return NAN;
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
float first_probe_z = current_position[Z_AXIS]; float first_probe_z = current_position[Z_AXIS];
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("1st Probe Z:", first_probe_z); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPAIR("1st Probe Z:", first_probe_z);
#endif #endif
// move up by the bump distance // move up to make clearance for the probe
do_blocking_move_to_z(current_position[Z_AXIS] + home_bump_mm(Z_AXIS), MMM_TO_MMS(Z_PROBE_SPEED_FAST)); do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
#else #else
// If the nozzle is above the travel height then // If the nozzle is above the travel height then
// move down quickly before doing the slow probe // move down quickly before doing the slow probe
float z = LOGICAL_Z_POSITION(Z_CLEARANCE_BETWEEN_PROBES); float z = Z_CLEARANCE_DEPLOY_PROBE;
if (zprobe_zoffset < 0) z -= zprobe_zoffset; if (zprobe_zoffset < 0) z -= zprobe_zoffset;
#if ENABLED(DELTA) if (z < current_position[Z_AXIS]) {
z -= home_offset[Z_AXIS]; // Account for delta height adjustment
#endif
if (z < current_position[Z_AXIS])
do_blocking_move_to_z(z, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
// If we don't make it to the z position (i.e. the probe triggered), move up to make clearance for the probe
if (!do_probe_move(z, Z_PROBE_SPEED_FAST))
do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
}
#endif #endif
// move down slowly to find bed // move down slowly to find bed
do_probe_move(-(Z_MAX_LENGTH) - 10, Z_PROBE_SPEED_SLOW); if (do_probe_move(-10 + (short_move ? 0 : -(Z_MAX_LENGTH)), Z_PROBE_SPEED_SLOW)) return NAN;
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("<<< run_z_probe", current_position);
@ -2330,6 +2338,7 @@ static void clean_up_after_endstop_or_probe_move() {
SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]); SERIAL_ECHOLNPAIR(" Discrepancy:", first_probe_z - current_position[Z_AXIS]);
} }
#endif #endif
return RAW_CURRENT_POSITION(Z) + zprobe_zoffset return RAW_CURRENT_POSITION(Z) + zprobe_zoffset
#if ENABLED(DELTA) #if ENABLED(DELTA)
+ home_offset[Z_AXIS] // Account for delta height adjustment + home_offset[Z_AXIS] // Account for delta height adjustment
@ -2372,22 +2381,31 @@ static void clean_up_after_endstop_or_probe_move() {
do_blocking_move_to_z(delta_clip_start_height); do_blocking_move_to_z(delta_clip_start_height);
#endif #endif
// Ensure a minimum height before moving the probe #if HAS_SOFTWARE_ENDSTOPS
do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES); // Store the status of the soft endstops and disable if we're probing a non-printable location
static bool enable_soft_endstops = soft_endstops_enabled;
if (!printable) soft_endstops_enabled = false;
#endif
feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S; feedrate_mm_s = XY_PROBE_FEEDRATE_MM_S;
// Move the probe to the given XY // Move the probe to the given XY
do_blocking_move_to_xy(nx, ny); do_blocking_move_to_xy(nx, ny);
if (DEPLOY_PROBE()) return NAN; float measured_z = NAN;
if (!DEPLOY_PROBE()) {
const float measured_z = run_z_probe(); measured_z = run_z_probe(printable);
if (!stow) if (!stow)
do_probe_raise(Z_CLEARANCE_BETWEEN_PROBES); do_blocking_move_to_z(current_position[Z_AXIS] + Z_CLEARANCE_BETWEEN_PROBES, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
else else
if (STOW_PROBE()) return NAN; if (STOW_PROBE()) measured_z = NAN;
}
#if HAS_SOFTWARE_ENDSTOPS
// Restore the soft endstop status
soft_endstops_enabled = enable_soft_endstops;
#endif
if (verbose_level > 2) { if (verbose_level > 2) {
SERIAL_PROTOCOLPGM("Bed X: "); SERIAL_PROTOCOLPGM("Bed X: ");
@ -2405,6 +2423,12 @@ static void clean_up_after_endstop_or_probe_move() {
feedrate_mm_s = old_feedrate_mm_s; feedrate_mm_s = old_feedrate_mm_s;
if (isnan(measured_z)) {
LCD_MESSAGEPGM(MSG_ERR_PROBING_FAILED);
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_ERR_PROBING_FAILED);
}
return measured_z; return measured_z;
} }
@ -3753,7 +3777,7 @@ inline void gcode_G4() {
* A delta can only safely home all axes at the same time * A delta can only safely home all axes at the same time
* This is like quick_home_xy() but for 3 towers. * This is like quick_home_xy() but for 3 towers.
*/ */
inline void home_delta() { inline bool home_delta() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS(">>> home_delta", current_position);
#endif #endif
@ -3762,10 +3786,21 @@ inline void gcode_G4() {
sync_plan_position(); sync_plan_position();
// Move all carriages together linearly until an endstop is hit. // Move all carriages together linearly until an endstop is hit.
current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (Z_MAX_LENGTH + 10); current_position[X_AXIS] = current_position[Y_AXIS] = current_position[Z_AXIS] = (DELTA_HEIGHT + home_offset[Z_AXIS] + 10);
feedrate_mm_s = homing_feedrate(X_AXIS); feedrate_mm_s = homing_feedrate(X_AXIS);
line_to_current_position(); line_to_current_position();
stepper.synchronize(); stepper.synchronize();
// If an endstop was not hit, then damage can occur if homing is continued.
// This can occur if the delta height (DELTA_HEIGHT + home_offset[Z_AXIS]) is
// not set correctly.
if (!(Endstops::endstop_hit_bits & (_BV(X_MAX) | _BV(Y_MAX) | _BV(Z_MAX)))) {
LCD_MESSAGEPGM(MSG_ERR_HOMING_FAILED);
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_ERR_HOMING_FAILED);
return false;
}
endstops.hit_on_purpose(); // clear endstop hit flags endstops.hit_on_purpose(); // clear endstop hit flags
// At least one carriage has reached the top. // At least one carriage has reached the top.
@ -3785,6 +3820,8 @@ inline void gcode_G4() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("<<< home_delta", current_position);
#endif #endif
return true;
} }
#endif // DELTA #endif // DELTA
@ -4641,10 +4678,6 @@ void home_all_axes() { gcode_G28(true); }
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
} }
if (!faux) setup_for_endstop_or_probe_move();
//xProbe = yProbe = measured_z = 0;
#if HAS_BED_PROBE #if HAS_BED_PROBE
// Deploy the probe. Probe will raise if needed. // Deploy the probe. Probe will raise if needed.
if (DEPLOY_PROBE()) { if (DEPLOY_PROBE()) {
@ -4653,6 +4686,8 @@ void home_all_axes() { gcode_G28(true); }
} }
#endif #endif
if (!faux) setup_for_endstop_or_probe_move();
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
@ -4865,7 +4900,7 @@ void home_all_axes() { gcode_G28(true); }
#endif // AUTO_BED_LEVELING_3POINT #endif // AUTO_BED_LEVELING_3POINT
#else // !PROBE_MANUALLY #else // !PROBE_MANUALLY
{
const bool stow_probe_after_each = parser.boolval('E'); const bool stow_probe_after_each = parser.boolval('E');
#if ABL_GRID #if ABL_GRID
@ -4873,7 +4908,7 @@ void home_all_axes() { gcode_G28(true); }
bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION bool zig = PR_OUTER_END & 1; // Always end at RIGHT and BACK_PROBE_BED_POSITION
// Outer loop is Y with PROBE_Y_FIRST disabled // Outer loop is Y with PROBE_Y_FIRST disabled
for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_END; PR_OUTER_VAR++) { for (uint8_t PR_OUTER_VAR = 0; PR_OUTER_VAR < PR_OUTER_END && !isnan(measured_z); PR_OUTER_VAR++) {
int8_t inStart, inStop, inInc; int8_t inStart, inStop, inInc;
@ -4912,7 +4947,7 @@ void home_all_axes() { gcode_G28(true); }
if (isnan(measured_z)) { if (isnan(measured_z)) {
planner.abl_enabled = abl_should_enable; planner.abl_enabled = abl_should_enable;
return; break;
} }
#if ENABLED(AUTO_BED_LEVELING_LINEAR) #if ENABLED(AUTO_BED_LEVELING_LINEAR)
@ -4948,12 +4983,12 @@ void home_all_axes() { gcode_G28(true); }
measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level); measured_z = faux ? 0.001 * random(-100, 101) : probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
if (isnan(measured_z)) { if (isnan(measured_z)) {
planner.abl_enabled = abl_should_enable; planner.abl_enabled = abl_should_enable;
return; break;
} }
points[i].z = measured_z; points[i].z = measured_z;
} }
if (!dryrun) { if (!dryrun && !isnan(measured_z)) {
vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal(); vector_3 planeNormal = vector_3::cross(points[0] - points[1], points[2] - points[1]).get_normal();
if (planeNormal.z < 0) { if (planeNormal.z < 0) {
planeNormal.x *= -1; planeNormal.x *= -1;
@ -4971,9 +5006,9 @@ void home_all_axes() { gcode_G28(true); }
// Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe. // Raise to _Z_CLEARANCE_DEPLOY_PROBE. Stow the probe.
if (STOW_PROBE()) { if (STOW_PROBE()) {
planner.abl_enabled = abl_should_enable; planner.abl_enabled = abl_should_enable;
return; measured_z = NAN;
}
} }
#endif // !PROBE_MANUALLY #endif // !PROBE_MANUALLY
// //
@ -4986,9 +5021,6 @@ void home_all_axes() { gcode_G28(true); }
// return or loop before this point. // return or loop before this point.
// //
// Restore state after probing
if (!faux) clean_up_after_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#endif #endif
@ -5001,6 +5033,7 @@ void home_all_axes() { gcode_G28(true); }
#endif #endif
// Calculate leveling, print reports, correct the position // Calculate leveling, print reports, correct the position
if (!isnan(measured_z)) {
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)
if (!dryrun) extrapolate_unprobed_bed_level(); if (!dryrun) extrapolate_unprobed_bed_level();
@ -5193,6 +5226,13 @@ void home_all_axes() { gcode_G28(true); }
stepper.synchronize(); stepper.synchronize();
#endif #endif
// Auto Bed Leveling is complete! Enable if possible.
planner.abl_enabled = dryrun ? abl_should_enable : true;
} // !isnan(measured_z)
// Restore state after probing
if (!faux) clean_up_after_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
#endif #endif
@ -5201,9 +5241,6 @@ void home_all_axes() { gcode_G28(true); }
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
// Auto Bed Leveling is complete! Enable if possible.
planner.abl_enabled = dryrun ? abl_should_enable : true;
if (planner.abl_enabled) if (planner.abl_enabled)
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
} }
@ -5319,6 +5356,21 @@ void home_all_axes() { gcode_G28(true); }
} }
} }
void G33_cleanup(
#if HOTENDS > 1
const uint8_t old_tool_index
#endif
) {
#if ENABLED(DELTA_HOME_TO_SAFE_ZONE)
do_blocking_move_to_z(delta_clip_start_height);
#endif
STOW_PROBE();
clean_up_after_endstop_or_probe_move();
#if HOTENDS > 1
tool_change(old_tool_index, 0, true);
#endif
}
inline void gcode_G33() { inline void gcode_G33() {
const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS); const int8_t probe_points = parser.intval('P', DELTA_CALIBRATION_DEFAULT_POINTS);
@ -5395,14 +5447,19 @@ void home_all_axes() { gcode_G28(true); }
#if HAS_LEVELING #if HAS_LEVELING
reset_bed_level(); // After calibration bed-level data is no longer valid reset_bed_level(); // After calibration bed-level data is no longer valid
#endif #endif
#if HOTENDS > 1 #if HOTENDS > 1
const uint8_t old_tool_index = active_extruder; const uint8_t old_tool_index = active_extruder;
tool_change(0, 0, true); tool_change(0, 0, true);
#define G33_CLEANUP() G33_cleanup(old_tool_index)
#else
#define G33_CLEANUP() G33_cleanup()
#endif #endif
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
DEPLOY_PROBE();
endstops.enable(true); endstops.enable(true);
home_delta(); if (!home_delta())
return;
endstops.not_homing(); endstops.not_homing();
// print settings // print settings
@ -5416,7 +5473,9 @@ void home_all_axes() { gcode_G28(true); }
print_G33_settings(!_1p_calibration, _7p_calibration && towers_set); print_G33_settings(!_1p_calibration, _7p_calibration && towers_set);
#if DISABLED(PROBE_MANUALLY) #if DISABLED(PROBE_MANUALLY)
home_offset[Z_AXIS] -= probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height const float measured_z = probe_pt(dx, dy, stow_after_each, 1, false); // 1st probe to set height
if (isnan(measured_z)) return G33_CLEANUP();
home_offset[Z_AXIS] -= measured_z;
#endif #endif
do { do {
@ -5434,6 +5493,7 @@ void home_all_axes() { gcode_G28(true); }
z_at_pt[0] += lcd_probe_pt(0, 0); z_at_pt[0] += lcd_probe_pt(0, 0);
#else #else
z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false); z_at_pt[0] += probe_pt(dx, dy, stow_after_each, 1, false);
if (isnan(z_at_pt[0])) return G33_CLEANUP();
#endif #endif
} }
if (_7p_calibration) { // probe extra center points if (_7p_calibration) { // probe extra center points
@ -5442,7 +5502,8 @@ void home_all_axes() { gcode_G28(true); }
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r); z_at_pt[0] += lcd_probe_pt(cos(a) * r, sin(a) * r);
#else #else
z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1, false); z_at_pt[0] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
if (isnan(z_at_pt[0])) return G33_CLEANUP();
#endif #endif
} }
z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points); z_at_pt[0] /= float(_7p_double_circle ? 7 : probe_points);
@ -5462,7 +5523,8 @@ void home_all_axes() { gcode_G28(true); }
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r); z_at_pt[axis] += lcd_probe_pt(cos(a) * r, sin(a) * r);
#else #else
z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1, false); z_at_pt[axis] += probe_pt(cos(a) * r + dx, sin(a) * r + dy, stow_after_each, 1);
if (isnan(z_at_pt[axis])) return G33_CLEANUP();
#endif #endif
} }
zig_zag = !zig_zag; zig_zag = !zig_zag;
@ -5662,14 +5724,7 @@ void home_all_axes() { gcode_G28(true); }
} }
while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations); while ((zero_std_dev < test_precision && zero_std_dev > calibration_precision && iterations < 31) || iterations <= force_iterations);
#if ENABLED(DELTA_HOME_TO_SAFE_ZONE) G33_CLEANUP();
do_blocking_move_to_z(delta_clip_start_height);
#endif
STOW_PROBE();
clean_up_after_endstop_or_probe_move();
#if HOTENDS > 1
tool_change(old_tool_index, 0, true);
#endif
} }
#endif // DELTA_AUTO_CALIBRATION #endif // DELTA_AUTO_CALIBRATION
@ -6980,14 +7035,15 @@ inline void gcode_M42() {
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
double mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
// Move to the first point, deploy, and probe // Move to the first point, deploy, and probe
const float t = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level); const float t = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
if (isnan(t)) return; bool probing_good = !isnan(t);
if (probing_good) {
randomSeed(millis()); randomSeed(millis());
double mean = 0.0, sigma = 0.0, min = 99999.9, max = -99999.9, sample_set[n_samples];
for (uint8_t n = 0; n < n_samples; n++) { for (uint8_t n = 0; n < n_samples; n++) {
if (n_legs) { if (n_legs) {
const int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise const int dir = (random(0, 10) > 5.0) ? -1 : 1; // clockwise or counter clockwise
@ -7060,6 +7116,10 @@ inline void gcode_M42() {
// Probe a single point // Probe a single point
sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0); sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, 0);
// Break the loop if the probe fails
probing_good = !isnan(sample_set[n]);
if (!probing_good) break;
/** /**
* Get the current mean for the data points we have so far * Get the current mean for the data points we have so far
*/ */
@ -7102,12 +7162,13 @@ inline void gcode_M42() {
} }
} }
} // End of probe loop } // n_samples loop
}
if (STOW_PROBE()) return; STOW_PROBE();
SERIAL_PROTOCOLPGM("Finished!"); if (probing_good) {
SERIAL_EOL(); SERIAL_PROTOCOLLNPGM("Finished!");
if (verbose_level > 0) { if (verbose_level > 0) {
SERIAL_PROTOCOLPGM("Mean: "); SERIAL_PROTOCOLPGM("Mean: ");
@ -7125,6 +7186,7 @@ inline void gcode_M42() {
SERIAL_PROTOCOL_F(sigma, 6); SERIAL_PROTOCOL_F(sigma, 6);
SERIAL_EOL(); SERIAL_EOL();
SERIAL_EOL(); SERIAL_EOL();
}
clean_up_after_endstop_or_probe_move(); clean_up_after_endstop_or_probe_move();
@ -11453,19 +11515,22 @@ void ok_to_send() {
// DELTA_PRINTABLE_RADIUS from center of bed, but delta // DELTA_PRINTABLE_RADIUS from center of bed, but delta
// now enforces is_position_reachable for X/Y regardless // now enforces is_position_reachable for X/Y regardless
// of HAS_SOFTWARE_ENDSTOPS, so that enforcement would be // of HAS_SOFTWARE_ENDSTOPS, so that enforcement would be
// redundant here. Probably should #ifdef out the X/Y // redundant here.
// axis clamps here for delta and just leave the Z clamp.
void clamp_to_software_endstops(float target[XYZ]) { void clamp_to_software_endstops(float target[XYZ]) {
if (!soft_endstops_enabled) return; if (!soft_endstops_enabled) return;
#if ENABLED(MIN_SOFTWARE_ENDSTOPS) #if ENABLED(MIN_SOFTWARE_ENDSTOPS)
#if DISABLED(DELTA)
NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]); NOLESS(target[X_AXIS], soft_endstop_min[X_AXIS]);
NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]); NOLESS(target[Y_AXIS], soft_endstop_min[Y_AXIS]);
#endif
NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]); NOLESS(target[Z_AXIS], soft_endstop_min[Z_AXIS]);
#endif #endif
#if ENABLED(MAX_SOFTWARE_ENDSTOPS) #if ENABLED(MAX_SOFTWARE_ENDSTOPS)
#if DISABLED(DELTA)
NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]); NOMORE(target[X_AXIS], soft_endstop_max[X_AXIS]);
NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]); NOMORE(target[Y_AXIS], soft_endstop_max[Y_AXIS]);
#endif
NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]); NOMORE(target[Z_AXIS], soft_endstop_max[Z_AXIS]);
#endif #endif
} }

View File

@ -247,7 +247,7 @@ void Endstops::update() {
#define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX #define _ENDSTOP(AXIS, MINMAX) AXIS ##_## MINMAX
#define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN #define _ENDSTOP_PIN(AXIS, MINMAX) AXIS ##_## MINMAX ##_PIN
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING #define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
#define _ENDSTOP_HIT(AXIS) SBI(endstop_hit_bits, _ENDSTOP(AXIS, MIN)) #define _ENDSTOP_HIT(AXIS, MINMAX) SBI(endstop_hit_bits, _ENDSTOP(AXIS, MINMAX))
// UPDATE_ENDSTOP_BIT: set the current endstop bits for an endstop to its status // UPDATE_ENDSTOP_BIT: set the current endstop bits for an endstop to its status
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX))) #define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT(current_endstop_bits, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
@ -257,7 +257,7 @@ void Endstops::update() {
#define UPDATE_ENDSTOP(AXIS,MINMAX) do { \ #define UPDATE_ENDSTOP(AXIS,MINMAX) do { \
UPDATE_ENDSTOP_BIT(AXIS, MINMAX); \ UPDATE_ENDSTOP_BIT(AXIS, MINMAX); \
if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && stepper.current_block->steps[_AXIS(AXIS)] > 0) { \ if (TEST_ENDSTOP(_ENDSTOP(AXIS, MINMAX)) && stepper.current_block->steps[_AXIS(AXIS)] > 0) { \
_ENDSTOP_HIT(AXIS); \ _ENDSTOP_HIT(AXIS, MINMAX); \
stepper.endstop_triggered(_AXIS(AXIS)); \ stepper.endstop_triggered(_AXIS(AXIS)); \
} \ } \
} while(0) } while(0)
@ -267,9 +267,9 @@ void Endstops::update() {
if (G38_move) { if (G38_move) {
UPDATE_ENDSTOP_BIT(Z, MIN_PROBE); UPDATE_ENDSTOP_BIT(Z, MIN_PROBE);
if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) { if (TEST_ENDSTOP(_ENDSTOP(Z, MIN_PROBE))) {
if (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X); stepper.endstop_triggered(_AXIS(X)); } if (stepper.current_block->steps[_AXIS(X)] > 0) { _ENDSTOP_HIT(X, MIN); stepper.endstop_triggered(_AXIS(X)); }
else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y); stepper.endstop_triggered(_AXIS(Y)); } else if (stepper.current_block->steps[_AXIS(Y)] > 0) { _ENDSTOP_HIT(Y, MIN); stepper.endstop_triggered(_AXIS(Y)); }
else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z); stepper.endstop_triggered(_AXIS(Z)); } else if (stepper.current_block->steps[_AXIS(Z)] > 0) { _ENDSTOP_HIT(Z, MIN); stepper.endstop_triggered(_AXIS(Z)); }
G38_endstop_hit = true; G38_endstop_hit = true;
} }
} }

View File

@ -717,7 +717,7 @@
#define MSG_DELTA_CALIBRATE_CENTER _UxGT("Calibrate Center") #define MSG_DELTA_CALIBRATE_CENTER _UxGT("Calibrate Center")
#endif #endif
#ifndef MSG_DELTA_SETTINGS #ifndef MSG_DELTA_SETTINGS
#define MSG_DELTA_SETTINGS _UxGT("Show Delta Settings") #define MSG_DELTA_SETTINGS _UxGT("Delta Settings")
#endif #endif
#ifndef MSG_DELTA_AUTO_CALIBRATE #ifndef MSG_DELTA_AUTO_CALIBRATE
#define MSG_DELTA_AUTO_CALIBRATE _UxGT("Auto Calibration") #define MSG_DELTA_AUTO_CALIBRATE _UxGT("Auto Calibration")
@ -725,6 +725,15 @@
#ifndef MSG_DELTA_HEIGHT_CALIBRATE #ifndef MSG_DELTA_HEIGHT_CALIBRATE
#define MSG_DELTA_HEIGHT_CALIBRATE _UxGT("Set Delta Height") #define MSG_DELTA_HEIGHT_CALIBRATE _UxGT("Set Delta Height")
#endif #endif
#ifndef MSG_DELTA_DIAG_ROG
#define MSG_DELTA_DIAG_ROG _UxGT("Diag Rod")
#endif
#ifndef MSG_DELTA_HEIGHT
#define MSG_DELTA_HEIGHT _UxGT("Height")
#endif
#ifndef MSG_DELTA_RADIUS
#define MSG_DELTA_RADIUS _UxGT("Radius")
#endif
#ifndef MSG_INFO_MENU #ifndef MSG_INFO_MENU
#define MSG_INFO_MENU _UxGT("About Printer") #define MSG_INFO_MENU _UxGT("About Printer")
#endif #endif
@ -840,6 +849,12 @@
#ifndef MSG_FILAMENT_CHANGE_NOZZLE #ifndef MSG_FILAMENT_CHANGE_NOZZLE
#define MSG_FILAMENT_CHANGE_NOZZLE _UxGT(" Nozzle: ") #define MSG_FILAMENT_CHANGE_NOZZLE _UxGT(" Nozzle: ")
#endif #endif
#ifndef MSG_ERR_HOMING_FAILED
#define MSG_ERR_HOMING_FAILED _UxGT("Homing failed")
#endif
#ifndef MSG_ERR_PROBING_FAILED
#define MSG_ERR_PROBING_FAILED _UxGT("Probing failed")
#endif
// //
// Filament Change screens show up to 3 lines on a 4-line display // Filament Change screens show up to 3 lines on a 4-line display

View File

@ -2537,15 +2537,23 @@ void kill_screen(const char* lcd_msg) {
void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); } void _goto_tower_z() { _man_probe_pt(cos(RADIANS( 90)) * delta_calibration_radius, sin(RADIANS( 90)) * delta_calibration_radius); }
void _goto_center() { _man_probe_pt(0,0); } void _goto_center() { _man_probe_pt(0,0); }
void lcd_delta_G33_settings() { static float _delta_height = DELTA_HEIGHT;
void _lcd_set_delta_height() {
home_offset[Z_AXIS] = _delta_height - DELTA_HEIGHT;
update_software_endstops(Z_AXIS);
}
void lcd_delta_settings() {
START_MENU(); START_MENU();
MENU_BACK(MSG_DELTA_CALIBRATE); MENU_BACK(MSG_DELTA_CALIBRATE);
float delta_height = DELTA_HEIGHT + home_offset[Z_AXIS], Tz = 0.00; float Tz = 0.00;
MENU_ITEM_EDIT(float52, "Height", &delta_height, delta_height, delta_height); MENU_ITEM_EDIT(float52, MSG_DELTA_DIAG_ROG, &delta_diagonal_rod, DELTA_DIAGONAL_ROD - 5.0, DELTA_DIAGONAL_ROD + 5.0);
_delta_height = DELTA_HEIGHT + home_offset[Z_AXIS];
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float52, MSG_DELTA_HEIGHT, &_delta_height, _delta_height - 10.0, _delta_height + 10.0, _lcd_set_delta_height);
MENU_ITEM_EDIT(float43, "Ex", &endstop_adj[A_AXIS], -5.0, 5.0); MENU_ITEM_EDIT(float43, "Ex", &endstop_adj[A_AXIS], -5.0, 5.0);
MENU_ITEM_EDIT(float43, "Ey", &endstop_adj[B_AXIS], -5.0, 5.0); MENU_ITEM_EDIT(float43, "Ey", &endstop_adj[B_AXIS], -5.0, 5.0);
MENU_ITEM_EDIT(float43, "Ez", &endstop_adj[C_AXIS], -5.0, 5.0); MENU_ITEM_EDIT(float43, "Ez", &endstop_adj[C_AXIS], -5.0, 5.0);
MENU_ITEM_EDIT(float52, "Radius", &delta_radius, DELTA_RADIUS - 5.0, DELTA_RADIUS + 5.0); MENU_ITEM_EDIT(float52, MSG_DELTA_RADIUS, &delta_radius, DELTA_RADIUS - 5.0, DELTA_RADIUS + 5.0);
MENU_ITEM_EDIT(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5.0, 5.0); MENU_ITEM_EDIT(float43, "Tx", &delta_tower_angle_trim[A_AXIS], -5.0, 5.0);
MENU_ITEM_EDIT(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5.0, 5.0); MENU_ITEM_EDIT(float43, "Ty", &delta_tower_angle_trim[B_AXIS], -5.0, 5.0);
MENU_ITEM_EDIT(float43, "Tz", &Tz, -5.0, 5.0); MENU_ITEM_EDIT(float43, "Tz", &Tz, -5.0, 5.0);
@ -2556,7 +2564,7 @@ void kill_screen(const char* lcd_msg) {
START_MENU(); START_MENU();
MENU_BACK(MSG_MAIN); MENU_BACK(MSG_MAIN);
#if ENABLED(DELTA_AUTO_CALIBRATION) #if ENABLED(DELTA_AUTO_CALIBRATION)
MENU_ITEM(submenu, MSG_DELTA_SETTINGS, lcd_delta_G33_settings); MENU_ITEM(submenu, MSG_DELTA_SETTINGS, lcd_delta_settings);
MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33")); MENU_ITEM(gcode, MSG_DELTA_AUTO_CALIBRATE, PSTR("G33"));
MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 P1")); MENU_ITEM(gcode, MSG_DELTA_HEIGHT_CALIBRATE, PSTR("G33 P1"));
#if ENABLED(EEPROM_SETTINGS) #if ENABLED(EEPROM_SETTINGS)