Always use deploy/stow for dock_sled

This commit is contained in:
Scott Lahteine 2016-06-20 15:50:51 -07:00
parent 3b457c2dd3
commit f6b09cf465

View File

@ -1655,6 +1655,10 @@ static void setup_for_endstop_move() {
feedrate = old_feedrate; feedrate = old_feedrate;
} }
inline void do_blocking_move_to_x(float x) {
do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
}
inline void do_blocking_move_to_z(float z) { inline void do_blocking_move_to_z(float z) {
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z); do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z);
} }
@ -1684,6 +1688,63 @@ static void setup_for_endstop_move() {
#endif #endif
#if HAS_BED_PROBE
inline void raise_z_after_probing() {
#if Z_RAISE_AFTER_PROBING > 0
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("raise_z_after_probing()");
#endif
do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
#endif
}
#endif
#if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET
#define SLED_DOCKING_OFFSET 0
#endif
/**
* Method to dock/undock a sled designed by Charles Bell.
*
* dock[in] If true, move to MAX_X and engage the electromagnet
* offset[in] The additional distance to move to adjust docking location
*/
static void dock_sled(bool dock, int offset = 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("dock_sled(", dock);
SERIAL_ECHOLNPGM(")");
}
#endif
if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
axis_unhomed_error(true);
return;
}
if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
float oldXpos = current_position[X_AXIS]; // save x position
if (dock) {
raise_z_after_probing(); // raise Z
// Dock sled a bit closer to ensure proper capturing
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
digitalWrite(SLED_PIN, LOW); // turn off magnet
}
else {
float z_loc = current_position[Z_AXIS];
if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
digitalWrite(SLED_PIN, HIGH); // turn on magnet
}
do_blocking_move_to_x(oldXpos); // return to position before docking
}
#endif // Z_PROBE_SLED
#if HAS_BED_PROBE #if HAS_BED_PROBE
static void deploy_z_probe() { static void deploy_z_probe() {
@ -1694,7 +1755,11 @@ static void setup_for_endstop_move() {
if (endstops.z_probe_enabled) return; if (endstops.z_probe_enabled) return;
#if HAS_Z_SERVO_ENDSTOP #if ENABLED(Z_PROBE_SLED)
dock_sled(false);
#elif HAS_Z_SERVO_ENDSTOP
// Make room for Z Servo // Make room for Z Servo
raise_z_for_servo(Z_RAISE_BEFORE_PROBING); raise_z_for_servo(Z_RAISE_BEFORE_PROBING);
@ -1792,7 +1857,11 @@ static void setup_for_endstop_move() {
if (!endstops.z_probe_enabled) return; if (!endstops.z_probe_enabled) return;
#if HAS_Z_SERVO_ENDSTOP #if ENABLED(Z_PROBE_SLED)
dock_sled(true);
#elif HAS_Z_SERVO_ENDSTOP
// Make room for the servo // Make room for the servo
raise_z_for_servo(Z_RAISE_AFTER_PROBING); raise_z_for_servo(Z_RAISE_AFTER_PROBING);
@ -2040,19 +2109,6 @@ static void setup_for_endstop_move() {
do_blocking_move_to(x, y, current_position[Z_AXIS]); do_blocking_move_to(x, y, current_position[Z_AXIS]);
} }
inline void do_blocking_move_to_x(float x) {
do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
}
inline void raise_z_after_probing() {
#if Z_RAISE_AFTER_PROBING > 0
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("raise_z_after_probing()");
#endif
do_blocking_move_to_z(current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING);
#endif
}
static void clean_up_after_endstop_move() { static void clean_up_after_endstop_move() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("clean_up_after_endstop_move > ENDSTOPS_ONLY_FOR_HOMING > endstops.not_homing()"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("clean_up_after_endstop_move > ENDSTOPS_ONLY_FOR_HOMING > endstops.not_homing()");
@ -2229,55 +2285,6 @@ static void setup_for_endstop_move() {
} }
#endif #endif
#if ENABLED(Z_PROBE_SLED)
#ifndef SLED_DOCKING_OFFSET
#define SLED_DOCKING_OFFSET 0
#endif
/**
* Method to dock/undock a sled designed by Charles Bell.
*
* dock[in] If true, move to MAX_X and engage the electromagnet
* offset[in] The additional distance to move to adjust docking location
*/
static void dock_sled(bool dock, int offset = 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("dock_sled(", dock);
SERIAL_ECHOLNPGM(")");
}
#endif
if (!axis_homed[X_AXIS] || !axis_homed[Y_AXIS] || !axis_homed[Z_AXIS]) {
axis_unhomed_error(true);
return;
}
if (endstops.z_probe_enabled == !dock) return; // already docked/undocked?
float oldXpos = current_position[X_AXIS]; // save x position
if (dock) {
raise_z_after_probing(); // raise Z
// Dock sled a bit closer to ensure proper capturing
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
digitalWrite(SLED_PIN, LOW); // turn off magnet
}
else {
float z_loc = current_position[Z_AXIS];
if (z_loc < Z_RAISE_BEFORE_PROBING + 5) z_loc = Z_RAISE_BEFORE_PROBING;
do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], z_loc); // this also updates current_position
digitalWrite(SLED_PIN, HIGH); // turn on magnet
}
do_blocking_move_to_x(oldXpos); // return to position before docking
endstops.enable_z_probe(!dock); // logically disable docked probe
}
#endif // Z_PROBE_SLED
/** /**
* Home an individual axis * Home an individual axis
*/ */
@ -2306,24 +2313,13 @@ static void homeaxis(AxisEnum axis) {
current_position[axis] = 0; current_position[axis] = 0;
sync_plan_position(); sync_plan_position();
#if ENABLED(Z_PROBE_SLED)
#define _Z_DEPLOY (dock_sled(false))
#define _Z_STOW (dock_sled(true))
#elif (ENABLED(AUTO_BED_LEVELING_FEATURE) && HAS_Z_SERVO_ENDSTOP) || ENABLED(FIX_MOUNTED_PROBE)
#define _Z_DEPLOY (deploy_z_probe())
#define _Z_STOW (stow_z_probe())
#elif HAS_Z_SERVO_ENDSTOP
#define _Z_DEPLOY do{ raise_z_for_servo(Z_RAISE_BEFORE_PROBING); DEPLOY_Z_SERVO(); endstops.z_probe_enabled = true; }while(0)
#define _Z_STOW do{ raise_z_for_servo(Z_RAISE_AFTER_PROBING); STOW_Z_SERVO(); endstops.z_probe_enabled = false; }while(0)
#endif
// Homing Z towards the bed? Deploy the Z probe or endstop. // Homing Z towards the bed? Deploy the Z probe or endstop.
#if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED) || ENABLED(FIX_MOUNTED_PROBE) #if HAS_BED_PROBE
if (axis == Z_AXIS && axis_home_dir < 0) { if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > " STRINGIFY(_Z_DEPLOY)); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > deploy_z_probe()");
#endif #endif
_Z_DEPLOY; deploy_z_probe();
} }
#endif #endif
@ -2441,12 +2437,12 @@ static void homeaxis(AxisEnum axis) {
axis_homed[axis] = true; axis_homed[axis] = true;
// Put away the Z probe // Put away the Z probe
#if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED) || ENABLED(FIX_MOUNTED_PROBE) #if HAS_BED_PROBE
if (axis == Z_AXIS && axis_home_dir < 0) { if (axis == Z_AXIS && axis_home_dir < 0) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > " STRINGIFY(_Z_STOW)); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM(" > stow_z_probe()");
#endif #endif
_Z_STOW; stow_z_probe();
} }
#endif #endif
@ -3468,9 +3464,7 @@ inline void gcode_G28() {
#endif // !DELTA #endif // !DELTA
} }
#if ENABLED(Z_PROBE_SLED) #if HAS_BED_PROBE
dock_sled(false); // engage (un-dock) the Z probe
#elif ENABLED(FIX_MOUNTED_PROBE) || ENABLED(MECHANICAL_PROBE) || ENABLED(Z_PROBE_ALLEN_KEY) || (ENABLED(DELTA) && HAS_Z_SERVO_ENDSTOP)
deploy_z_probe(); deploy_z_probe();
#endif #endif
@ -3721,14 +3715,7 @@ inline void gcode_G28() {
#endif // !AUTO_BED_LEVELING_GRID #endif // !AUTO_BED_LEVELING_GRID
#if ENABLED(DELTA) #if DISABLED(DELTA)
// Allen Key Probe for Delta
#if ENABLED(Z_PROBE_ALLEN_KEY) || HAS_Z_SERVO_ENDSTOP
stow_z_probe();
#else
raise_z_after_probing(); // for non Allen Key probes, such as simple mechanical probe
#endif
#else // !DELTA
if (verbose_level > 0) if (verbose_level > 0)
planner.bed_level_matrix.debug(" \n\nBed Level Correction Matrix:"); planner.bed_level_matrix.debug(" \n\nBed Level Correction Matrix:");
@ -3796,18 +3783,13 @@ inline void gcode_G28() {
if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> corrected Z in G29", current_position);
#endif #endif
} }
#endif // !DELTA
// Sled assembly for Cartesian bots #if DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED) && !HAS_Z_SERVO_ENDSTOP
#if ENABLED(Z_PROBE_SLED)
dock_sled(true); // dock the sled
#elif !HAS_Z_SERVO_ENDSTOP && DISABLED(Z_PROBE_ALLEN_KEY) && DISABLED(Z_PROBE_SLED)
// Raise Z axis for non-delta and non servo based probes
raise_z_after_probing(); raise_z_after_probing();
#endif #endif
#endif // !DELTA #if ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) || ENABLED(MECHANICAL_PROBE)
#if ENABLED(MECHANICAL_PROBE)
stow_z_probe(); stow_z_probe();
#endif #endif
@ -3838,13 +3820,15 @@ inline void gcode_G28() {
KEEPALIVE_STATE(IN_HANDLER); KEEPALIVE_STATE(IN_HANDLER);
} }
#if DISABLED(Z_PROBE_SLED) // could be avoided #endif //AUTO_BED_LEVELING_FEATURE
#if HAS_BED_PROBE
/** /**
* G30: Do a single Z probe at the current XY * G30: Do a single Z probe at the current XY
*/ */
inline void gcode_G30() { inline void gcode_G30() {
deploy_z_probe(); // Engage Z Servo endstop if available. Z_PROBE_SLED is missed here. deploy_z_probe();
stepper.synchronize(); stepper.synchronize();
// TODO: clear the leveling matrix or the planner will be set incorrectly // TODO: clear the leveling matrix or the planner will be set incorrectly
@ -3862,14 +3846,12 @@ inline void gcode_G28() {
clean_up_after_endstop_move(); // Too early. must be done after the stowing. clean_up_after_endstop_move(); // Too early. must be done after the stowing.
stow_z_probe(); // Retract Z Servo endstop if available. Z_PROBE_SLED is missed here. stow_z_probe();
report_current_position(); report_current_position();
} }
#endif //!Z_PROBE_SLED #endif // HAS_BED_PROBE
#endif //AUTO_BED_LEVELING_FEATURE
/** /**
* G92: Set current position to given X Y Z E * G92: Set current position to given X Y Z E
@ -6875,24 +6857,24 @@ void process_next_command() {
break; break;
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if HAS_BED_PROBE
#if DISABLED(Z_PROBE_SLED)
case 30: // G30 Single Z probe case 30: // G30 Single Z probe
gcode_G30(); gcode_G30();
break; break;
#else // Z_PROBE_SLED #if ENABLED(Z_PROBE_SLED)
case 31: // G31: dock the sled case 31: // G31: dock the sled
stow_z_probe();
break;
case 32: // G32: undock the sled case 32: // G32: undock the sled
dock_sled(codenum == 31); deploy_z_probe();
break; break;
#endif // Z_PROBE_SLED #endif // Z_PROBE_SLED
#endif // AUTO_BED_LEVELING_FEATURE #endif // HAS_BED_PROBE
case 90: // G90 case 90: // G90
relative_mode = false; relative_mode = false;