From 527fe2496af924c47411c7aa3c3622b22d04b42e Mon Sep 17 00:00:00 2001 From: Farva42 <100859196+Farva42@users.noreply.github.com> Date: Wed, 6 Jul 2022 19:40:09 -0600 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20MAG=5FMOUNTED=5FPROBE=20(#24420)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Scott Lahteine --- Marlin/Configuration.h | 21 +++++++++++ Marlin/Configuration_adv.h | 3 ++ Marlin/src/inc/Conditionals_LCD.h | 11 +++--- Marlin/src/inc/Conditionals_adv.h | 4 +++ Marlin/src/inc/SanityCheck.h | 13 +++++-- Marlin/src/lcd/menu/menu_motion.cpp | 8 +++++ Marlin/src/module/probe.cpp | 54 +++++++++++++++++++++++++++-- 7 files changed, 105 insertions(+), 9 deletions(-) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 788bd64075..e05428ad08 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -1343,6 +1343,27 @@ #define Z_PROBE_RETRACT_X X_MAX_POS #endif +/** + * Magnetically Mounted Probe + * For probes such as Euclid, Klicky, Klackender, etc. + */ +//#define MAG_MOUNTED_PROBE +#if ENABLED(MAG_MOUNTED_PROBE) + #define PROBE_DEPLOY_FEEDRATE (133*60) // (mm/min) Probe deploy speed + #define PROBE_STOW_FEEDRATE (133*60) // (mm/min) Probe stow speed + + #define MAG_MOUNTED_DEPLOY_1 { PROBE_DEPLOY_FEEDRATE, { 245, 114, 30 } } // Move to side Dock & Attach probe + #define MAG_MOUNTED_DEPLOY_2 { PROBE_DEPLOY_FEEDRATE, { 210, 114, 30 } } // Move probe off dock + #define MAG_MOUNTED_DEPLOY_3 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_4 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_DEPLOY_5 { PROBE_DEPLOY_FEEDRATE, { 0, 0, 0 } } // Extra move if needed + #define MAG_MOUNTED_STOW_1 { PROBE_STOW_FEEDRATE, { 245, 114, 20 } } // Move to dock + #define MAG_MOUNTED_STOW_2 { PROBE_STOW_FEEDRATE, { 245, 114, 0 } } // Place probe beside remover + #define MAG_MOUNTED_STOW_3 { PROBE_STOW_FEEDRATE, { 230, 114, 0 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_4 { PROBE_STOW_FEEDRATE, { 210, 114, 20 } } // Side move to remove probe + #define MAG_MOUNTED_STOW_5 { PROBE_STOW_FEEDRATE, { 0, 0, 0 } } // Extra move if needed +#endif + // Duet Smart Effector (for delta printers) - https://bit.ly/2ul5U7J // When the pin is defined you can use M672 to set/reset the probe sensitivity. //#define DUET_SMART_EFFECTOR diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index b4627a9830..7f85b241a2 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -1319,6 +1319,9 @@ #define XATC_Y_POSITION Y_CENTER // (mm) Y position to probe #define XATC_Z_OFFSETS { 0, 0, 0 } // Z offsets for X axis sample points #endif + + // Show Deploy / Stow Probe options in the Motion menu. + #define PROBE_DEPLOY_STOW_MENU #endif // Include a page of printer information in the LCD Main Menu diff --git a/Marlin/src/inc/Conditionals_LCD.h b/Marlin/src/inc/Conditionals_LCD.h index b8cf66c8c4..fc66f5359c 100644 --- a/Marlin/src/inc/Conditionals_LCD.h +++ b/Marlin/src/inc/Conditionals_LCD.h @@ -1047,9 +1047,12 @@ #endif /** - * Set a flag for any type of bed probe, including the paper-test + * Set flags for any form of bed probe */ -#if ANY(HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, SOLENOID_PROBE, SENSORLESS_PROBING, RACK_AND_PINION_PROBE, MAGLEV4) +#if ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, SOLENOID_PROBE, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #define HAS_STOWABLE_PROBE 1 +#endif +#if ANY(HAS_STOWABLE_PROBE, HAS_Z_SERVO_PROBE, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE) #define HAS_BED_PROBE 1 #endif @@ -1207,13 +1210,13 @@ #if NONE(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN, HAS_DELTA_SENSORLESS_PROBING) #define USES_Z_MIN_PROBE_PIN 1 #endif - #if Z_HOME_TO_MIN && TERN1(USES_Z_MIN_PROBE_PIN, ENABLED(USE_PROBE_FOR_Z_HOMING)) + #if Z_HOME_TO_MIN && (DISABLED(USES_Z_MIN_PROBE_PIN) || USE_PROBE_FOR_Z_HOMING) #define HOMING_Z_WITH_PROBE 1 #endif #ifndef Z_PROBE_LOW_POINT #define Z_PROBE_LOW_POINT -5 #endif - #if ENABLED(Z_PROBE_ALLEN_KEY) + #if EITHER(Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) #define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe #endif #if MULTIPLE_PROBING > 1 diff --git a/Marlin/src/inc/Conditionals_adv.h b/Marlin/src/inc/Conditionals_adv.h index 2a204c6cf3..9931409976 100644 --- a/Marlin/src/inc/Conditionals_adv.h +++ b/Marlin/src/inc/Conditionals_adv.h @@ -79,6 +79,10 @@ #define SERVO_DELAY { 50 } #endif +#if !HAS_STOWABLE_PROBE + #undef PROBE_DEPLOY_STOW_MENU +#endif + #if !HAS_EXTRUDERS #define NO_VOLUMETRICS #undef TEMP_SENSOR_0 diff --git a/Marlin/src/inc/SanityCheck.h b/Marlin/src/inc/SanityCheck.h index f75a59b9b4..4412fbb41e 100644 --- a/Marlin/src/inc/SanityCheck.h +++ b/Marlin/src/inc/SanityCheck.h @@ -1627,8 +1627,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS */ #if 1 < 0 \ + (DISABLED(BLTOUCH) && HAS_Z_SERVO_PROBE) \ - + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4) - #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, or Z Servo." + + COUNT_ENABLED(PROBE_MANUALLY, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, RACK_AND_PINION_PROBE, SENSORLESS_PROBING, MAGLEV4, MAG_MOUNTED_PROBE) + #error "Please enable only one probe option: PROBE_MANUALLY, SENSORLESS_PROBING, BLTOUCH, FIX_MOUNTED_PROBE, NOZZLE_AS_PROBE, TOUCH_MI_PROBE, SOLENOID_PROBE, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, MAGLEV4, MAG_MOUNTED_PROBE or Z Servo." #endif #if HAS_BED_PROBE @@ -1734,13 +1734,20 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS #endif #endif + /** + * Mag mounted probe requirements + */ + #if BOTH(MAG_MOUNTED_PROBE, USE_PROBE_FOR_Z_HOMING) && DISABLED(Z_SAFE_HOMING) + #error "MAG_MOUNTED_PROBE requires Z_SAFE_HOMING if it's being used to home Z." + #endif + /** * MagLev V4 probe requirements */ #if ENABLED(MAGLEV4) #if !PIN_EXISTS(MAGLEV_TRIGGER) #error "MAGLEV4 requires MAGLEV_TRIGGER_PIN to be defined." - #elif DISABLED(Z_SAFE_HOMING) + #elif ENABLED(HOMING_Z_WITH_PROBE) && DISABLED(Z_SAFE_HOMING) #error "MAGLEV4 requires Z_SAFE_HOMING." #elif MAGLEV_TRIGGER_DELAY != 15 #error "MAGLEV_TRIGGER_DELAY should not be changed. Comment out this line to continue." diff --git a/Marlin/src/lcd/menu/menu_motion.cpp b/Marlin/src/lcd/menu/menu_motion.cpp index cebc2eb317..3765fe1e4a 100644 --- a/Marlin/src/lcd/menu/menu_motion.cpp +++ b/Marlin/src/lcd/menu/menu_motion.cpp @@ -348,6 +348,14 @@ void menu_motion() { GCODES_ITEM(MSG_AUTO_Z_ALIGN, F("G34")); #endif + // + // Probe Deploy/Stow + // + #if ENABLED(PROBE_DEPLOY_STOW_MENU) + GCODES_ITEM(MSG_MANUAL_DEPLOY, F("M401")); + GCODES_ITEM(MSG_MANUAL_STOW, F("M402")); + #endif + // // Assisted Bed Tramming // diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index ed8d4a1429..afe5ba7a74 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -264,7 +264,57 @@ xyz_pos_t Probe::offset; // Initialized by settings.load() #endif } -#endif // Z_PROBE_ALLEN_KEY +#elif ENABLED(MAG_MOUNTED_PROBE) + + typedef struct { float fr_mm_min; xyz_pos_t where; } mag_probe_move_t; + + inline void run_deploy_moves_script() { + #ifdef MAG_MOUNTED_DEPLOY_1 + constexpr mag_probe_move_t deploy_1 = MAG_MOUNTED_DEPLOY_1; + do_blocking_move_to(deploy_1.where, MMM_TO_MMS(deploy_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_2 + constexpr mag_probe_move_t deploy_2 = MAG_MOUNTED_DEPLOY_2; + do_blocking_move_to(deploy_2.where, MMM_TO_MMS(deploy_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_3 + constexpr mag_probe_move_t deploy_3 = MAG_MOUNTED_DEPLOY_3; + do_blocking_move_to(deploy_3.where, MMM_TO_MMS(deploy_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_4 + constexpr mag_probe_move_t deploy_4 = MAG_MOUNTED_DEPLOY_4; + do_blocking_move_to(deploy_4.where, MMM_TO_MMS(deploy_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_DEPLOY_5 + constexpr mag_probe_move_t deploy_5 = MAG_MOUNTED_DEPLOY_5; + do_blocking_move_to(deploy_5.where, MMM_TO_MMS(deploy_5.fr_mm_min)); + #endif + } + + inline void run_stow_moves_script() { + #ifdef MAG_MOUNTED_STOW_1 + constexpr mag_probe_move_t stow_1 = MAG_MOUNTED_STOW_1; + do_blocking_move_to(stow_1.where, MMM_TO_MMS(stow_1.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_2 + constexpr mag_probe_move_t stow_2 = MAG_MOUNTED_STOW_2; + do_blocking_move_to(stow_2.where, MMM_TO_MMS(stow_2.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_3 + constexpr mag_probe_move_t stow_3 = MAG_MOUNTED_STOW_3; + do_blocking_move_to(stow_3.where, MMM_TO_MMS(stow_3.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_4 + constexpr mag_probe_move_t stow_4 = MAG_MOUNTED_STOW_4; + do_blocking_move_to(stow_4.where, MMM_TO_MMS(stow_4.fr_mm_min)); + #endif + #ifdef MAG_MOUNTED_STOW_5 + constexpr mag_probe_move_t stow_5 = MAG_MOUNTED_STOW_5; + do_blocking_move_to(stow_5.where, MMM_TO_MMS(stow_5.fr_mm_min)); + #endif + } + +#endif // MAG_MOUNTED_PROBE #if HAS_QUIET_PROBING @@ -350,7 +400,7 @@ FORCE_INLINE void probe_specific_action(const bool deploy) { servo[Z_PROBE_SERVO_NR].move(servo_angles[Z_PROBE_SERVO_NR][deploy ? 0 : 1]); - #elif EITHER(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY) + #elif ANY(TOUCH_MI_PROBE, Z_PROBE_ALLEN_KEY, MAG_MOUNTED_PROBE) deploy ? run_deploy_moves_script() : run_stow_moves_script();