sled improvements

- create sled pin definition
- G28 Works with sled
This commit is contained in:
Christian Bohn 2015-05-11 23:22:19 +02:00
parent 8a0dc4d54a
commit fb44b53ae3
3 changed files with 72 additions and 38 deletions

View file

@ -276,6 +276,13 @@
#define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#endif
/**
* Sled Options
*/
#ifdef Z_PROBE_SLED
#define Z_SAFE_HOMING
#endif
/**
* MAX_STEP_FREQUENCY differs for TOSHIBA
*/

View file

@ -650,8 +650,8 @@ void setup() {
#endif
#ifdef Z_PROBE_SLED
pinMode(SERVO0_PIN, OUTPUT);
digitalWrite(SERVO0_PIN, LOW); // turn it off
pinMode(SLED_PIN, OUTPUT);
digitalWrite(SLED_PIN, LOW); // turn it off
#endif // Z_PROBE_SLED
setup_homepin();
@ -1516,6 +1516,48 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
#endif // ENABLE_AUTO_BED_LEVELING
#ifdef 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 (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
return;
}
if (dock) {
float oldXpos = current_position[X_AXIS]; // save x position
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] + Z_RAISE_AFTER_PROBING); // rise Z
do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1, current_position[Y_AXIS], current_position[Z_AXIS]); // Dock sled a bit closer to ensure proper capturing
digitalWrite(SLED_PIN, LOW); // turn off magnet
do_blocking_move_to(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS] - Z_RAISE_AFTER_PROBING);
} else {
float oldXpos = current_position[X_AXIS]; // save x position
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(oldXpos, current_position[Y_AXIS], current_position[Z_AXIS]); // return to position before docking
}
}
#endif // Z_PROBE_SLED
/**
* Home an individual axis
*/
@ -1538,6 +1580,13 @@ static void homeaxis(AxisEnum axis) {
current_position[axis] = 0;
sync_plan_position();
#ifdef Z_PROBE_SLED
// Get Probe
if (axis == Z_AXIS) {
if (axis_home_dir < 0) dock_sled(false);
}
#endif
#if SERVO_LEVELING && !defined(Z_PROBE_SLED)
// Deploy a probe if there is one, and homing towards the bed
@ -1634,6 +1683,13 @@ static void homeaxis(AxisEnum axis) {
endstops_hit_on_purpose(); // clear endstop hit flags
axis_known_position[axis] = true;
#ifdef Z_PROBE_SLED
// bring probe back
if (axis == Z_AXIS) {
if (axis_home_dir < 0) dock_sled(true);
}
#endif
#if SERVO_LEVELING && !defined(Z_PROBE_SLED)
// Deploy a probe if there is one, and homing towards the bed
@ -1708,39 +1764,6 @@ static void homeaxis(AxisEnum axis) {
#endif // FWRETRACT
#ifdef 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 (!axis_known_position[X_AXIS] || !axis_known_position[Y_AXIS]) {
LCD_MESSAGEPGM(MSG_POSITION_UNKNOWN);
SERIAL_ECHO_START;
SERIAL_ECHOLNPGM(MSG_POSITION_UNKNOWN);
return;
}
if (dock) {
do_blocking_move_to(X_MAX_POS + SLED_DOCKING_OFFSET + offset, current_position[Y_AXIS], current_position[Z_AXIS]); // this also updates current_position
digitalWrite(SERVO0_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, Y_PROBE_OFFSET_FROM_EXTRUDER, z_loc); // this also updates current_position
digitalWrite(SERVO0_PIN, HIGH); // turn on magnet
}
}
#endif // Z_PROBE_SLED
/**
*
* G-Code Handler functions
@ -2000,12 +2023,12 @@ inline void gcode_G28() {
if (home_all_axis || homeZ) {
#ifdef Z_SAFE_HOMING
#ifdef Z_SAFE_HOMING
if (home_all_axis) {
current_position[Z_AXIS] = 0;
sync_plan_position();
sync_plan_position();
//
// Set the probe (or just the nozzle) destination to the safe homing point
@ -2586,7 +2609,7 @@ inline void gcode_G28() {
#endif // !DELTA
#ifdef Z_PROBE_SLED
dock_sled(true, -SLED_DOCKING_OFFSET); // dock the probe, correcting for over-travel
dock_sled(true); // dock the probe
#elif defined(Z_PROBE_ALLEN_KEY) //|| defined(SERVO_LEVELING)
stow_z_probe();
#endif

View file

@ -44,6 +44,10 @@
#define FAN_PIN 4
#endif
#ifdef Z_PROBE_SLED
#define SLED_PIN 27
#endif
#ifdef NUM_SERVOS
#define SERVO0_PIN -1