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

Make Z Probe options independent of ABL #4093

Merged
merged 2 commits into from
Jun 20, 2016
Merged
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
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,17 @@ script:
- opt_enable PIDTEMPBED
- build_marlin
#
# Test AUTO_BED_LEVELING_FEATURE & DEBUG_LEVELING_FEATURE with a Servo Probe
# Test a Servo Probe without leveling
#
- restore_configs
- opt_enable AUTO_BED_LEVELING_FEATURE DEBUG_LEVELING_FEATURE
- opt_enable NUM_SERVOS Z_ENDSTOP_SERVO_NR Z_SERVO_ANGLES DEACTIVATE_SERVOS_AFTER_MOVE
- build_marlin
#
# Test AUTO_BED_LEVELING_FEATURE & DEBUG_LEVELING_FEATURE with a Servo Probe
#
- opt_enable AUTO_BED_LEVELING_FEATURE DEBUG_LEVELING_FEATURE
- build_marlin
#
# Test MESH_BED_LEVELING feature, with LCD
#
- restore_configs
Expand Down
11 changes: 10 additions & 1 deletion Marlin/Conditionals.h
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,15 @@
#define MAX_PROBE_X (min(X_MAX_POS, X_MAX_POS + X_PROBE_OFFSET_FROM_EXTRUDER))
#define MIN_PROBE_Y (max(Y_MIN_POS, Y_MIN_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))
#define MAX_PROBE_Y (min(Y_MAX_POS, Y_MAX_POS + Y_PROBE_OFFSET_FROM_EXTRUDER))

#ifndef XY_TRAVEL_SPEED
#ifdef HOMING_FEEDRATE_XYZ
#define XY_TRAVEL_SPEED HOMING_FEEDRATE_XYZ
#else
#define XY_TRAVEL_SPEED 4000
#endif
#endif

#endif

#define HAS_Z_SERVO_ENDSTOP (defined(Z_ENDSTOP_SERVO_NR) && Z_ENDSTOP_SERVO_NR >= 0)
Expand Down Expand Up @@ -758,7 +767,7 @@
#define HAS_BED_PROBE (PROBE_SELECTED && PROBE_PIN_CONFIGURED)

/**
* Probe dependencies
* Bed Probe dependencies
*/
#if HAS_BED_PROBE
#ifndef X_PROBE_OFFSET_FROM_EXTRUDER
Expand Down
108 changes: 59 additions & 49 deletions Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,57 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//============================= Z Probe Options =============================
//===========================================================================

//
// Probe Type
// Probes are sensors/switches that are activated / deactivated before/after use.
//
// Allen Key Probes, Servo Probes, Z-Sled Probes, FIX_MOUNTED_PROBE, etc.
// You must activate one of these to use AUTO_BED_LEVELING_FEATURE below.
//
// Use M851 to set the Z probe vertical offset from the nozzle. Store with M500.
//

// A fix mounted probe, like the normal inductive probe, must be deactivated to go
// below Z_PROBE_OFFSET_FROM_EXTRUDER when the hardware endstops are active.
//#define FIX_MOUNTED_PROBE

// Z Servo Probe, such as an endstop switch on a rotating arm.
//#define Z_ENDSTOP_SERVO_NR 0
//#define Z_SERVO_ANGLES {70,0} // Z Servo Deploy and Stow angles

// Enable if you have a Z probe mounted on a sled like those designed by Charles Bell.
//#define Z_PROBE_SLED
//#define SLED_DOCKING_OFFSET 5 // The extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.

// A Mechanical Probe is any probe that either doesn't deploy or needs manual deployment
// For example any setup that uses the nozzle itself as a probe.
//#define MECHANICAL_PROBE

// Z Probe to nozzle (X,Y) offset, relative to (0, 0).
// X and Y offsets must be integers.
//
// In the following example the X and Y offsets are both positive:
// #define X_PROBE_OFFSET_FROM_EXTRUDER 10
// #define Y_PROBE_OFFSET_FROM_EXTRUDER 10
//
// +-- BACK ---+
// | |
// L | (+) P | R <-- probe (20,20)
// E | | I
// F | (-) N (+) | G <-- nozzle (10,10)
// T | | H
// | (-) | T
// | |
// O-- FRONT --+
// (0,0)
#define X_PROBE_OFFSET_FROM_EXTRUDER 10 // X offset: -left +right [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER 10 // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle]

//
// Allen Key Probe is defined in the Delta example configurations.
//

// Enable Z_MIN_PROBE_ENDSTOP to use _both_ a Z Probe and a Z-min-endstop on the same machine.
// With this option the Z_MIN_PROBE_PIN will only be used for probing, never for homing.
//
Expand Down Expand Up @@ -453,12 +504,20 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
// If you're using the Z MIN endstop connector for your Z probe, this has no effect.
//#define DISABLE_Z_MIN_PROBE_ENDSTOP

//
// Probe Raise options provide clearance for the probe to deploy and stow.
//
// For G28 these apply when the probe deploys and stows.
// For G29 these apply before and after the full procedure.
#define Z_RAISE_BEFORE_PROBING 15 // Raise before probe deploy (e.g., the first probe).
#define Z_RAISE_AFTER_PROBING 15 // Raise before probe stow (e.g., the last probe).

//
// For M851 give a range for adjusting the Z probe offset
//
#define Z_PROBE_OFFSET_RANGE_MIN -20
#define Z_PROBE_OFFSET_RANGE_MAX 20

// For Inverting Stepper Enable Pins (Active Low) use 0, Non Inverting (Active High) use 1
// :{0:'Low',1:'High'}
#define X_ENABLE_ON 0
Expand Down Expand Up @@ -606,54 +665,13 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l

#endif // !AUTO_BED_LEVELING_GRID

// Z Probe to nozzle (X,Y) offset, relative to (0, 0).
// X and Y offsets must be integers.
//
// In the following example the X and Y offsets are both positive:
// #define X_PROBE_OFFSET_FROM_EXTRUDER 10
// #define Y_PROBE_OFFSET_FROM_EXTRUDER 10
//
// +-- BACK ---+
// | |
// L | (+) P | R <-- probe (20,20)
// E | | I
// F | (-) N (+) | G <-- nozzle (10,10)
// T | | H
// | (-) | T
// | |
// O-- FRONT --+
// (0,0)
#define X_PROBE_OFFSET_FROM_EXTRUDER 10 // X offset: -left +right [of the nozzle]
#define Y_PROBE_OFFSET_FROM_EXTRUDER 10 // Y offset: -front +behind [the nozzle]
#define Z_PROBE_OFFSET_FROM_EXTRUDER 0 // Z offset: -below +above [the nozzle]

#define XY_TRAVEL_SPEED 8000 // X and Y axis travel speed between probes, in mm/min.

#define Z_RAISE_BETWEEN_PROBINGS 5 // How much the Z axis will be raised when traveling from between next probing points.

//#define Z_PROBE_END_SCRIPT "G1 Z10 F12000\nG1 X15 Y330\nG1 Z0.5\nG1 Z10" // These commands will be executed in the end of G29 routine.
// Useful to retract a deployable Z probe.

// Probes are sensors/switches that need to be activated before they can be used
// and deactivated after their use.
// Allen Key Probes, Servo Probes, Z-Sled Probes, FIX_MOUNTED_PROBE, ... . You have to activate one of these for the AUTO_BED_LEVELING_FEATURE

// A fix mounted probe, like the normal inductive probe, must be deactivated to go below Z_PROBE_OFFSET_FROM_EXTRUDER
// when the hardware endstops are active.
//#define FIX_MOUNTED_PROBE

// A Servo Probe can be defined in the servo section below.

// An Allen Key Probe is currently predefined only in the delta example configurations.

// Enable if you have a Z probe mounted on a sled like those designed by Charles Bell.
//#define Z_PROBE_SLED
//#define SLED_DOCKING_OFFSET 5 // The extra distance the X axis must travel to pickup the sled. 0 should be fine but you can push it further if you'd like.

// A Mechanical Probe is any probe that either doesn't deploy or needs manual deployment
// For example any setup that uses the nozzle itself as a probe.
//#define MECHANICAL_PROBE

// If you've enabled AUTO_BED_LEVELING_FEATURE and are using the Z Probe for Z Homing,
// it is highly recommended you also enable Z_SAFE_HOMING below!

Expand Down Expand Up @@ -1147,14 +1165,6 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
//
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command

// Servo Endstops
//
// This allows for servo actuated endstops, primary usage is for the Z Axis to eliminate calibration or bed height changes.
// Use M851 to set the Z probe vertical offset from the nozzle. Store that setting with M500.
//
//#define Z_ENDSTOP_SERVO_NR 0
//#define Z_SERVO_ANGLES {70,0} // Z Servo Extend and Retract angles

// Servo deactivation
//
// With this option servos are powered only during movement, then turned off to prevent jitter.
Expand Down
154 changes: 85 additions & 69 deletions Marlin/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ static void setup_for_endstop_move() {
endstops.enable();
}

#if ENABLED(AUTO_BED_LEVELING_FEATURE)
#if HAS_BED_PROBE

#if ENABLED(DELTA)
/**
Expand All @@ -1592,6 +1592,71 @@ static void setup_for_endstop_move() {
}
#endif

/**
* Plan a move to (X, Y, Z) and set the current_position
* The final current_position may not be the one that was requested
*/
static void do_blocking_move_to(float x, float y, float z) {
float old_feedrate = feedrate;

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) print_xyz("do_blocking_move_to", x, y, z);
#endif

#if ENABLED(DELTA)

feedrate =
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
xy_travel_speed
#else
min(planner.max_feedrate[X_AXIS], planner.max_feedrate[Y_AXIS]) * 60
#endif
;

destination[X_AXIS] = x;
destination[Y_AXIS] = y;
destination[Z_AXIS] = z;

if (x == current_position[X_AXIS] && y == current_position[Y_AXIS])
prepare_move_to_destination_raw(); // this will also set_current_to_destination
else
prepare_move_to_destination(); // this will also set_current_to_destination

#else

feedrate = homing_feedrate[Z_AXIS];

current_position[Z_AXIS] = z;
line_to_current_position();
stepper.synchronize();

feedrate =
#if ENABLED(AUTO_BED_LEVELING_FEATURE)
xy_travel_speed
#else
min(planner.max_feedrate[X_AXIS], planner.max_feedrate[Y_AXIS]) * 60
#endif
;

current_position[X_AXIS] = x;
current_position[Y_AXIS] = y;
line_to_current_position();

#endif

stepper.synchronize();

feedrate = old_feedrate;
}

inline void do_blocking_move_to_z(float z) {
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z);
}

#endif //HAS_BED_PROBE

#if ENABLED(AUTO_BED_LEVELING_FEATURE)

#if ENABLED(AUTO_BED_LEVELING_GRID)

#if DISABLED(DELTA)
Expand Down Expand Up @@ -1751,51 +1816,6 @@ static void setup_for_endstop_move() {
feedrate = old_feedrate;
}

/**
* Plan a move to (X, Y, Z) and set the current_position
* The final current_position may not be the one that was requested
*/
static void do_blocking_move_to(float x, float y, float z) {
float old_feedrate = feedrate;

#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) print_xyz("do_blocking_move_to", x, y, z);
#endif

#if ENABLED(DELTA)

feedrate = xy_travel_speed;

destination[X_AXIS] = x;
destination[Y_AXIS] = y;
destination[Z_AXIS] = z;

if (x == current_position[X_AXIS] && y == current_position[Y_AXIS])
prepare_move_to_destination_raw(); // this will also set_current_to_destination
else
prepare_move_to_destination(); // this will also set_current_to_destination

#else

feedrate = homing_feedrate[Z_AXIS];

current_position[Z_AXIS] = z;
line_to_current_position();
stepper.synchronize();

feedrate = xy_travel_speed;

current_position[X_AXIS] = x;
current_position[Y_AXIS] = y;
line_to_current_position();

#endif

stepper.synchronize();

feedrate = old_feedrate;
}

inline void do_blocking_move_to_xy(float x, float y) {
do_blocking_move_to(x, y, current_position[Z_AXIS]);
}
Expand All @@ -1804,10 +1824,6 @@ static void setup_for_endstop_move() {
do_blocking_move_to(x, current_position[Y_AXIS], current_position[Z_AXIS]);
}

inline void do_blocking_move_to_z(float z) {
do_blocking_move_to(current_position[X_AXIS], current_position[Y_AXIS], z);
}

inline void raise_z_after_probing() {
#if Z_RAISE_AFTER_PROBING > 0
#if ENABLED(DEBUG_LEVELING_FEATURE)
Expand Down Expand Up @@ -2171,30 +2187,30 @@ static void setup_for_endstop_move() {

#endif // DELTA

#if HAS_Z_SERVO_ENDSTOP
#endif // AUTO_BED_LEVELING_FEATURE

/**
* Raise Z to a minimum height to make room for a servo to move
*
* zprobe_zoffset: Negative of the Z height where the probe engages
* z_dest: The before / after probing raise distance
*
* The zprobe_zoffset is negative for a switch below the nozzle, so
* multiply by Z_HOME_DIR (-1) to move enough away from the bed.
*/
void raise_z_for_servo(float z_dest) {
z_dest += home_offset[Z_AXIS];
#if HAS_Z_SERVO_ENDSTOP

if ((Z_HOME_DIR) < 0 && zprobe_zoffset < 0)
z_dest -= zprobe_zoffset;
/**
* Raise Z to a minimum height to make room for a servo to move
*
* zprobe_zoffset: Negative of the Z height where the probe engages
* z_dest: The before / after probing raise distance
*
* The zprobe_zoffset is negative for a switch below the nozzle, so
* multiply by Z_HOME_DIR (-1) to move enough away from the bed.
*/
void raise_z_for_servo(float z_dest) {
z_dest += home_offset[Z_AXIS];

if (z_dest > current_position[Z_AXIS])
do_blocking_move_to_z(z_dest); // also updates current_position
}
if ((Z_HOME_DIR) < 0 && zprobe_zoffset < 0)
z_dest -= zprobe_zoffset;

#endif
if (z_dest > current_position[Z_AXIS])
do_blocking_move_to_z(z_dest); // also updates current_position
}

#endif // AUTO_BED_LEVELING_FEATURE
#endif

#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || ENABLED(AUTO_BED_LEVELING_FEATURE)
static void axis_unhomed_error(bool xyz=false) {
Expand Down
Loading