Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add servo support to MAG_MOUNTED_PROBE #27551

Open
wants to merge 2 commits into
base: bugfix-2.1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -1534,6 +1534,17 @@
#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
/**
* Magnetically mounted probe is on a servo
* On both deploy and stow the folloing sequence is followed:
* 1) The servo is set to deploy position
* 2) The apropriate X,Y,Z moves are executed for a deploy or stow operation
* 3) The servo is set to the stowed position
*/
//#define MAG_MOUNTED_PROBE_SERVO_NR 0 // Set to servo number to use
#ifdef MAG_MOUNTED_PROBE_SERVO_NR
#define MAG_MOUNTED_PROBE_SERVO_ANGLES { 90, 0 } // Mag servo Deploy and Stow angles
#endif

#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
Expand Down
5 changes: 4 additions & 1 deletion Marlin/src/inc/Conditionals-3-etc.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,10 @@
#ifdef Z_PROBE_SERVO_NR
#define HAS_Z_SERVO_PROBE 1
#endif
#if ANY(HAS_Z_SERVO_PROBE, SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
#ifdef MAG_MOUNTED_PROBE_SERVO_NR
#define HAS_MAG_MOUNTED_SERVO_PROBE 1
#endif
#if ANY(HAS_Z_SERVO_PROBE, HAS_MAG_MOUNTED_SERVO_PROBE, SWITCHING_EXTRUDER, SWITCHING_NOZZLE)
#define HAS_SERVO_ANGLES 1
#endif
#if !HAS_SERVO_ANGLES
Expand Down
14 changes: 13 additions & 1 deletion Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
#include "../feature/host_actions.h" // for PROMPT_USER_CONTINUE
#endif

#if HAS_Z_SERVO_PROBE
#if HAS_Z_SERVO_PROBE || HAS_MAG_MOUNTED_SERVO_PROBE
#include "servo.h"
#endif

Expand Down Expand Up @@ -272,6 +272,9 @@ xyz_pos_t Probe::offset; // Initialized by settings.load
typedef struct { float fr_mm_min; xyz_pos_t where; } mag_probe_move_t;

inline void run_deploy_moves() {
#if HAS_MAG_MOUNTED_SERVO_PROBE
servo[MAG_MOUNTED_PROBE_SERVO_NR].move(servo_angles[MAG_MOUNTED_PROBE_SERVO_NR][0]);
#endif
#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));
Expand All @@ -292,9 +295,15 @@ xyz_pos_t Probe::offset; // Initialized by settings.load
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
#if HAS_MAG_MOUNTED_SERVO_PROBE
servo[MAG_MOUNTED_PROBE_SERVO_NR].move(servo_angles[MAG_MOUNTED_PROBE_SERVO_NR][1]);
#endif
}

inline void run_stow_moves() {
#if HAS_MAG_MOUNTED_SERVO_PROBE
servo[MAG_MOUNTED_PROBE_SERVO_NR].move(servo_angles[MAG_MOUNTED_PROBE_SERVO_NR][0]);
#endif
#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));
Expand All @@ -315,6 +324,9 @@ xyz_pos_t Probe::offset; // Initialized by settings.load
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
#if HAS_MAG_MOUNTED_SERVO_PROBE
servo[MAG_MOUNTED_PROBE_SERVO_NR].move(servo_angles[MAG_MOUNTED_PROBE_SERVO_NR][1]);
#endif
}

#endif // MAG_MOUNTED_PROBE
Expand Down
7 changes: 7 additions & 0 deletions Marlin/src/module/servo.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@
#endif
constexpr uint16_t sazp[] = Z_SERVO_ANGLES;
static_assert(COUNT(sazp) == 2, "Z_SERVO_ANGLES needs 2 angles.");
#elif defined(MAG_MOUNTED_PROBE_SERVO_ANGLES)
constexpr uint16_t sazp[] = MAG_MOUNTED_PROBE_SERVO_ANGLES;
static_assert(COUNT(sazp) == 2, "MAG_MOUNTED_PROBE_SERVO_ANGLES needs 2 angles.");
#else
constexpr uint16_t sazp[2] = { 0 };
#endif
Expand All @@ -79,6 +82,9 @@
#ifndef Z_PROBE_SERVO_NR
#define Z_PROBE_SERVO_NR -1
#endif
#ifndef MAG_MOUNTED_PROBE_SERVO_NR
#define MAG_MOUNTED_PROBE_SERVO_NR -1
#endif

#define SASN(J,I) TERN(SWITCHING_NOZZLE_TWO_SERVOS, sasn[J][I], sasn[I])

Expand All @@ -88,6 +94,7 @@
: N == SWITCHING_NOZZLE_SERVO_NR ? SASN(0,I) \
TERN_(SWITCHING_NOZZLE_TWO_SERVOS, : N == SWITCHING_NOZZLE_E1_SERVO_NR ? SASN(1,I)) \
: N == Z_PROBE_SERVO_NR ? sazp[I] \
: N == MAG_MOUNTED_PROBE_SERVO_NR ? sazp[I] \
: 0 )

#if ENABLED(EDITABLE_SERVO_ANGLES)
Expand Down