🎨 Misc. probe-related cleanup

This commit is contained in:
Scott Lahteine 2023-03-30 15:12:56 -05:00
parent 182497fc39
commit 266786406c
8 changed files with 34 additions and 25 deletions

View file

@ -153,7 +153,7 @@ void GcodeSuite::G34() {
const xy_pos_t diff = z_stepper_align.xy[i] - z_stepper_align.xy[j]; const xy_pos_t diff = z_stepper_align.xy[i] - z_stepper_align.xy[j];
return HYPOT2(diff.x, diff.y); return HYPOT2(diff.x, diff.y);
}; };
float z_probe = Z_PROBE_SAFE_CLEARANCE + (G34_MAX_GRADE) * 0.01f * SQRT(_MAX(0, magnitude2(0, 1) float z_probe = (Z_PROBE_SAFE_CLEARANCE) + (G34_MAX_GRADE) * 0.01f * SQRT(_MAX(0, magnitude2(0, 1)
#if TRIPLE_Z #if TRIPLE_Z
, magnitude2(2, 1), magnitude2(2, 0) , magnitude2(2, 1), magnitude2(2, 0)
#if QUAD_Z #if QUAD_Z
@ -234,7 +234,7 @@ void GcodeSuite::G34() {
// Add height to each value, to provide a more useful target height for // Add height to each value, to provide a more useful target height for
// the next iteration of probing. This allows adjustments to be made away from the bed. // the next iteration of probing. This allows adjustments to be made away from the bed.
z_measured[iprobe] = z_probed_height + Z_CLEARANCE_BETWEEN_PROBES; z_measured[iprobe] = z_probed_height + (Z_CLEARANCE_BETWEEN_PROBES);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Z", iprobe + 1, " measured position is ", z_measured[iprobe]); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Z", iprobe + 1, " measured position is ", z_measured[iprobe]);
@ -248,7 +248,7 @@ void GcodeSuite::G34() {
// Adapt the next probe clearance height based on the new measurements. // Adapt the next probe clearance height based on the new measurements.
// Safe_height = lowest distance to bed (= highest measurement) plus highest measured misalignment. // Safe_height = lowest distance to bed (= highest measurement) plus highest measured misalignment.
z_maxdiff = z_measured_max - z_measured_min; z_maxdiff = z_measured_max - z_measured_min;
z_probe = Z_PROBE_SAFE_CLEARANCE + z_measured_max + z_maxdiff; z_probe = (Z_PROBE_SAFE_CLEARANCE) + z_measured_max + z_maxdiff;
#if HAS_Z_STEPPER_ALIGN_STEPPER_XY #if HAS_Z_STEPPER_ALIGN_STEPPER_XY
// Replace the initial values in z_measured with calculated heights at // Replace the initial values in z_measured with calculated heights at
@ -436,7 +436,7 @@ void GcodeSuite::G34() {
// Use the probed height from the last iteration to determine the Z height. // Use the probed height from the last iteration to determine the Z height.
// z_measured_min is used, because all steppers are aligned to z_measured_min. // z_measured_min is used, because all steppers are aligned to z_measured_min.
// Ideally, this would be equal to the 'z_probe * 0.5f' which was added earlier. // Ideally, this would be equal to the 'z_probe * 0.5f' which was added earlier.
current_position.z -= z_measured_min - (float)Z_CLEARANCE_BETWEEN_PROBES; current_position.z -= z_measured_min - float(Z_CLEARANCE_BETWEEN_PROBES);
sync_plan_position(); sync_plan_position();
#endif #endif

View file

@ -65,7 +65,9 @@ void GcodeSuite::M401() {
*/ */
void GcodeSuite::M402() { void GcodeSuite::M402() {
probe.stow(parser.boolval('R')); probe.stow(parser.boolval('R'));
probe.move_z_after_probing(); #ifdef Z_AFTER_PROBING
do_z_clearance(Z_AFTER_PROBING);
#endif
report_current_position(); report_current_position();
} }

View file

@ -152,7 +152,7 @@ namespace Anycubic {
// Enable levelling and Disable end stops during print // Enable levelling and Disable end stops during print
// as Z home places nozzle above the bed so we need to allow it past the end stops // as Z home places nozzle above the bed so we need to allow it past the end stops
injectCommands_P(AC_cmnd_enable_levelling); injectCommands(AC_cmnd_enable_leveling);
// Startup tunes are defined in Tunes.h // Startup tunes are defined in Tunes.h
//PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1); //PlayTune(BEEPER_PIN, Anycubic_PowerOn, 1);
@ -1299,7 +1299,7 @@ namespace Anycubic {
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
if (printer_state == AC_printer_resuming_from_power_outage) { if (printer_state == AC_printer_resuming_from_power_outage) {
// Need to home here to restore the Z position // Need to home here to restore the Z position
//injectCommands_P(AC_cmnd_power_loss_recovery); //injectCommands(AC_cmnd_power_loss_recovery);
//SERIAL_ECHOLNPGM("start resuming from power outage: ", AC_cmnd_power_loss_recovery); //SERIAL_ECHOLNPGM("start resuming from power outage: ", AC_cmnd_power_loss_recovery);
ChangePageOfTFT(PAGE_STATUS2); // show pause ChangePageOfTFT(PAGE_STATUS2); // show pause
injectCommands(F("M1000")); // home and start recovery injectCommands(F("M1000")); // home and start recovery
@ -2280,11 +2280,11 @@ namespace Anycubic {
if (!isPrinting()) { if (!isPrinting()) {
if (filament_status == 1) { if (filament_status == 1) {
if (canMove(E0) && !commandsInQueue()) if (canMove(E0) && !commandsInQueue())
injectCommands_P(AC_cmnd_manual_load_filament); injectCommands(AC_cmnd_manual_load_filament);
} }
else if (filament_status == 2) { else if (filament_status == 2) {
if (canMove(E0) && !commandsInQueue()) if (canMove(E0) && !commandsInQueue())
injectCommands_P(AC_cmnd_manual_unload_filament); injectCommands(AC_cmnd_manual_unload_filament);
} }
} }
} }

View file

@ -104,13 +104,14 @@
#define MARLIN_msg_filament_purging PSTR("Filament Purging...") #define MARLIN_msg_filament_purging PSTR("Filament Purging...")
#define MARLIN_msg_media_removed PSTR("Media Removed") #define MARLIN_msg_media_removed PSTR("Media Removed")
#define MARLIN_msg_special_pause PSTR("PB") #define MARLIN_msg_special_pause PSTR("PB")
#define AC_cmnd_auto_unload_filament PSTR("M701") // Use Marlin unload routine
#define AC_cmnd_auto_load_filament PSTR("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle
#define AC_cmnd_manual_load_filament PSTR("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster #define AC_cmnd_auto_unload_filament F("M701") // Use Marlin unload routine
#define AC_cmnd_manual_unload_filament PSTR("M83\nG1 E-50 F1200\nM82") #define AC_cmnd_auto_load_filament F("M702 M0 PB") // Use Marlin load routing then pause for user to clean nozzle
#define AC_cmnd_enable_levelling PSTR("M420 S1 V1")
#define AC_cmnd_power_loss_recovery PSTR("G28 R5 X Y\nG28 Z") // Lift, home X and Y then home Z when in 'safe' position #define AC_cmnd_manual_load_filament F("M83\nG1 E50 F700\nM82") // replace the manual panel commands with something a little faster
#define AC_cmnd_manual_unload_filament F("M83\nG1 E-50 F1200\nM82")
#define AC_cmnd_enable_leveling F("M420SV")
#define AC_cmnd_power_loss_recovery F("G28XYR5\nG28Z") // Lift, home X and Y then home Z when in 'safe' position
namespace Anycubic { namespace Anycubic {
enum heater_state_t : uint8_t { enum heater_state_t : uint8_t {

View file

@ -798,6 +798,10 @@ void do_blocking_move_to_x(const_float_t rx, const_feedRate_t fr_mm_s/*=0.0*/) {
if (zdest == current_position.z || (!lower_allowed && zdest < current_position.z)) return; if (zdest == current_position.z || (!lower_allowed && zdest < current_position.z)) return;
do_blocking_move_to_z(zdest, TERN(HAS_BED_PROBE, z_probe_fast_mm_s, homing_feedrate(Z_AXIS))); do_blocking_move_to_z(zdest, TERN(HAS_BED_PROBE, z_probe_fast_mm_s, homing_feedrate(Z_AXIS)));
} }
void do_z_clearance_by(const_float_t zclear) {
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance_by(", zclear, ")");
do_z_clearance(current_position.z + zclear);
}
#endif #endif
// //
@ -2458,15 +2462,10 @@ void set_axis_is_at_home(const AxisEnum axis) {
#if HAS_BED_PROBE && Z_HOME_TO_MIN #if HAS_BED_PROBE && Z_HOME_TO_MIN
if (axis == Z_AXIS) { if (axis == Z_AXIS) {
#if HOMING_Z_WITH_PROBE #if HOMING_Z_WITH_PROBE
current_position.z -= probe.offset.z; current_position.z -= probe.offset.z;
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED WITH PROBE (Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) ***\n> probe.offset.z = ", probe.offset.z);
#else #else
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***"); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("*** Z HOMED TO ENDSTOP ***");
#endif #endif
} }
#endif #endif

View file

@ -404,8 +404,10 @@ void restore_feedrate_and_scaling();
#if HAS_Z_AXIS #if HAS_Z_AXIS
void do_z_clearance(const_float_t zclear, const bool lower_allowed=false); void do_z_clearance(const_float_t zclear, const bool lower_allowed=false);
void do_z_clearance_by(const_float_t zclear);
#else #else
inline void do_z_clearance(float, bool=false) {} inline void do_z_clearance(float, bool=false) {}
inline void do_z_clearance_by(float) {}
#endif #endif
/** /**

View file

@ -757,8 +757,8 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s, if (try_to_probe(PSTR("FAST"), z_probe_low_point, z_probe_fast_mm_s,
sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN; sanity_check, Z_CLEARANCE_BETWEEN_PROBES) ) return NAN;
const float first_probe_z = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj); const float z1 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", first_probe_z); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("1st Probe Z:", z1);
// Raise to give the probe clearance // Raise to give the probe clearance
do_z_clearance(Z_CLEARANCE_MULTI_PROBE); do_z_clearance(Z_CLEARANCE_MULTI_PROBE);
@ -767,7 +767,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
// If the nozzle is well over the travel height then // If the nozzle is well over the travel height then
// move down quickly before doing the slow probe // move down quickly before doing the slow probe
const float z = Z_CLEARANCE_DEPLOY_PROBE + 5.0f + _MAX(zoffs, 0.0f); const float z = (Z_CLEARANCE_DEPLOY_PROBE) + 5.0f + _MAX(zoffs, 0.0f);
if (current_position.z > z) { if (current_position.z > z) {
// Probe down fast. If the probe never triggered, raise for probe clearance // Probe down fast. If the probe never triggered, raise for probe clearance
if (!probe_down_to_z(z, z_probe_fast_mm_s)) if (!probe_down_to_z(z, z_probe_fast_mm_s))
@ -853,10 +853,10 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
const float z2 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj); const float z2 = DIFF_TERN(HAS_DELTA_SENSORLESS_PROBING, current_position.z, largest_sensorless_adj);
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("2nd Probe Z:", z2, " Discrepancy:", first_probe_z - z2); if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("2nd Probe Z:", z2, " Discrepancy:", z1 - z2);
// Return a weighted average of the fast and slow probes // Return a weighted average of the fast and slow probes
const float measured_z = (z2 * 3.0f + first_probe_z * 2.0f) * 0.2f; const float measured_z = (z2 * 3.0f + z1 * 2.0f) * 0.2f;
#else #else

View file

@ -33,6 +33,9 @@
#include "../lcd/e3v2/proui/dwin.h" #include "../lcd/e3v2/proui/dwin.h"
#endif #endif
#define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"
#if HAS_BED_PROBE #if HAS_BED_PROBE
enum ProbePtRaise : uint8_t { enum ProbePtRaise : uint8_t {
PROBE_PT_NONE, // No raise or stow after run_z_probe PROBE_PT_NONE, // No raise or stow after run_z_probe
@ -171,6 +174,7 @@ public:
#endif // !IS_KINEMATIC #endif // !IS_KINEMATIC
static void move_z_after_probing() { static void move_z_after_probing() {
DEBUG_SECTION(mzah, "move_z_after_probing", DEBUGGING(LEVELING));
#ifdef Z_AFTER_PROBING #ifdef Z_AFTER_PROBING
do_z_clearance(Z_AFTER_PROBING, true); // Move down still permitted do_z_clearance(Z_AFTER_PROBING, true); // Move down still permitted
#endif #endif
@ -193,6 +197,7 @@ public:
static void use_probing_tool(const bool=true) IF_DISABLED(DO_TOOLCHANGE_FOR_PROBING, {}); static void use_probing_tool(const bool=true) IF_DISABLED(DO_TOOLCHANGE_FOR_PROBING, {});
static void move_z_after_homing() { static void move_z_after_homing() {
DEBUG_SECTION(mzah, "move_z_after_homing", DEBUGGING(LEVELING));
#if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) || defined(Z_AFTER_HOMING) #if ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING) || defined(Z_AFTER_HOMING)
do_z_clearance(Z_POST_CLEARANCE, true); do_z_clearance(Z_POST_CLEARANCE, true);
#elif HAS_BED_PROBE #elif HAS_BED_PROBE