Skip to content

Commit

Permalink
✨ MAG_MOUNTED_PROBE (#24420)
Browse files Browse the repository at this point in the history
Co-Authored-By: Scott Lahteine <[email protected]>
  • Loading branch information
Farva42 and thinkyhead committed Jul 7, 2022
1 parent 47f6f30 commit 97117d0
Show file tree
Hide file tree
Showing 7 changed files with 105 additions and 9 deletions.
21 changes: 21 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 10 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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."
Expand Down
8 changes: 8 additions & 0 deletions Marlin/src/lcd/menu/menu_motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//
Expand Down
54 changes: 52 additions & 2 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit 97117d0

Please sign in to comment.