Merge pull request #4134 from thinkyhead/rc_followup_4021

Additional cleanup to probing/leveling
This commit is contained in:
Scott Lahteine 2016-06-23 20:55:49 -07:00 committed by GitHub
commit de0e6d5f13
24 changed files with 262 additions and 421 deletions

View file

@ -1173,18 +1173,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1592,9 +1592,6 @@ inline void set_destination_to_current() { memcpy(destination, current_position,
// - Reset the command timeout // - Reset the command timeout
// - Enable the endstops (for endstop moves) // - Enable the endstops (for endstop moves)
// //
// clean_up_after_endstop_move() restores
// feedrates, sets endstops back to global state.
//
static void setup_for_endstop_or_probe_move() { static void setup_for_endstop_or_probe_move() {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("setup_for_endstop_or_probe_move", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("setup_for_endstop_or_probe_move", current_position);
@ -1619,12 +1616,6 @@ static void clean_up_after_endstop_or_probe_move() {
} }
#if HAS_BED_PROBE #if HAS_BED_PROBE
static void clean_up_after_endstop_move() {
clean_up_after_endstop_or_probe_move();
endstops.not_homing();
}
#if ENABLED(DELTA) #if ENABLED(DELTA)
/** /**
* Calculate delta, start a line, and set current_position to destination * Calculate delta, start a line, and set current_position to destination
@ -1666,18 +1657,25 @@ static void clean_up_after_endstop_or_probe_move() {
#else #else
// If Z needs to raise, do it before moving XY
if (current_position[Z_AXIS] < z) {
feedrate = homing_feedrate[Z_AXIS]; feedrate = homing_feedrate[Z_AXIS];
current_position[Z_AXIS] = z; current_position[Z_AXIS] = z;
line_to_current_position(); line_to_current_position();
stepper.synchronize(); }
feedrate = XY_PROBE_FEEDRATE; feedrate = XY_PROBE_FEEDRATE;
current_position[X_AXIS] = x; current_position[X_AXIS] = x;
current_position[Y_AXIS] = y; current_position[Y_AXIS] = y;
line_to_current_position(); line_to_current_position();
// If Z needs to lower, do it after moving XY
if (current_position[Z_AXIS] > z) {
feedrate = homing_feedrate[Z_AXIS];
current_position[Z_AXIS] = z;
line_to_current_position();
}
#endif #endif
stepper.synchronize(); stepper.synchronize();
@ -1722,11 +1720,6 @@ static void clean_up_after_endstop_or_probe_move() {
} }
} }
inline void raise_z_after_probing() {
#if Z_RAISE_AFTER_PROBING > 0
do_probe_raise(Z_RAISE_AFTER_PROBING);
#endif
}
#endif //HAS_BED_PROBE #endif //HAS_BED_PROBE
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_SAFE_HOMING) || HAS_PROBING_PROCEDURE
@ -1774,7 +1767,9 @@ static void clean_up_after_endstop_or_probe_move() {
float oldXpos = current_position[X_AXIS]; // save x position float oldXpos = current_position[X_AXIS]; // save x position
float old_feedrate = feedrate; float old_feedrate = feedrate;
if (dock) { if (dock) {
raise_z_after_probing(); // raise Z #if Z_RAISE_AFTER_PROBING > 0
do_probe_raise(Z_RAISE_AFTER_PROBING);
#endif
// Dock sled a bit closer to ensure proper capturing // Dock sled a bit closer to ensure proper capturing
feedrate = XY_PROBE_FEEDRATE; feedrate = XY_PROBE_FEEDRATE;
do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1); do_blocking_move_to_x(X_MAX_POS + SLED_DOCKING_OFFSET + offset - 1);
@ -1804,15 +1799,17 @@ static void clean_up_after_endstop_or_probe_move() {
if (endstops.z_probe_enabled) return; if (endstops.z_probe_enabled) return;
// Make room for probe
#if Z_RAISE_BEFORE_PROBING > 0
do_probe_raise(Z_RAISE_BEFORE_PROBING);
#endif
#if ENABLED(Z_PROBE_SLED) #if ENABLED(Z_PROBE_SLED)
dock_sled(false); dock_sled(false);
#elif HAS_Z_SERVO_ENDSTOP #elif HAS_Z_SERVO_ENDSTOP
// Make room for Z Servo
do_probe_raise(Z_RAISE_BEFORE_PROBING);
// Engage Z Servo endstop if enabled // Engage Z Servo endstop if enabled
DEPLOY_Z_SERVO(); DEPLOY_Z_SERVO();
@ -1906,15 +1903,17 @@ static void clean_up_after_endstop_or_probe_move() {
if (!endstops.z_probe_enabled) return; if (!endstops.z_probe_enabled) return;
// Make more room for the servo
#if Z_RAISE_AFTER_PROBING > 0
do_probe_raise(Z_RAISE_AFTER_PROBING);
#endif
#if ENABLED(Z_PROBE_SLED) #if ENABLED(Z_PROBE_SLED)
dock_sled(true); dock_sled(true);
#elif HAS_Z_SERVO_ENDSTOP #elif HAS_Z_SERVO_ENDSTOP
// Make room for the servo
do_probe_raise(Z_RAISE_AFTER_PROBING);
// Change the Z servo angle // Change the Z servo angle
STOW_Z_SERVO(); STOW_Z_SERVO();
@ -2080,27 +2079,24 @@ static void clean_up_after_endstop_or_probe_move() {
return current_position[Z_AXIS]; return current_position[Z_AXIS];
} }
#endif // HAS_BED_PROBE
#if HAS_PROBING_PROCEDURE
inline void do_blocking_move_to_xy(float x, float y) { inline void do_blocking_move_to_xy(float x, float y) {
do_blocking_move_to(x, y, current_position[Z_AXIS]); do_blocking_move_to(x, y, current_position[Z_AXIS]);
} }
enum ProbeAction { //
ProbeStay = 0, // - Move to the given XY
ProbeDeploy = _BV(0), // - Deploy the probe, if not already deployed
ProbeStow = _BV(1), // - Probe the bed, get the Z position
ProbeDeployAndStow = (ProbeDeploy | ProbeStow) // - Depending on the 'stow' flag
}; // - Stow the probe, or
// - Raise to the BETWEEN height
// Probe bed height at position (x,y), returns the measured z value // - Return the probed Z position
static float probe_pt(float x, float y, float z_raise, ProbeAction probe_action = ProbeDeployAndStow, int verbose_level = 1) { //
static float probe_pt(float x, float y, bool stow = true, int verbose_level = 1) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOLNPGM("probe_pt >>>"); SERIAL_ECHOLNPGM("probe_pt >>>");
SERIAL_ECHOPAIR("> ProbeAction:", probe_action); SERIAL_ECHOPAIR("> stow:", stow);
SERIAL_EOL; SERIAL_EOL;
DEBUG_POS("", current_position); DEBUG_POS("", current_position);
} }
@ -2111,39 +2107,37 @@ static void clean_up_after_endstop_or_probe_move() {
// Raise by z_raise, then move the Z probe to the given XY // Raise by z_raise, then move the Z probe to the given XY
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("Z Raise by z_raise ", z_raise); SERIAL_ECHOPAIR("> do_blocking_move_to ", x - (X_PROBE_OFFSET_FROM_EXTRUDER));
SERIAL_EOL;
}
#endif
do_probe_raise(z_raise); // this also updates current_position
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> do_blocking_move_to_xy ", x - (X_PROBE_OFFSET_FROM_EXTRUDER));
SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); SERIAL_ECHOPAIR(", ", y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
SERIAL_ECHOPAIR(", ", max(current_position[Z_AXIS], Z_RAISE_BETWEEN_PROBINGS));
SERIAL_EOL; SERIAL_EOL;
} }
#endif #endif
// this also updates current_position
feedrate = XY_PROBE_FEEDRATE; feedrate = XY_PROBE_FEEDRATE;
do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER)); do_blocking_move_to_xy(x - (X_PROBE_OFFSET_FROM_EXTRUDER), y - (Y_PROBE_OFFSET_FROM_EXTRUDER));
if (probe_action & ProbeDeploy) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeDeploy"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> deploy_z_probe");
#endif #endif
deploy_z_probe(); deploy_z_probe();
}
float measured_z = run_z_probe(); float measured_z = run_z_probe();
if (probe_action & ProbeStow) { if (stow) {
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> ProbeStow (stow_z_probe will do Z Raise)"); if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> stow_z_probe");
#endif #endif
stow_z_probe(); stow_z_probe();
} }
#if Z_RAISE_BETWEEN_PROBINGS > 0
else {
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> do_probe_raise");
#endif
do_probe_raise(Z_RAISE_BETWEEN_PROBINGS);
}
#endif
if (verbose_level > 2) { if (verbose_level > 2) {
SERIAL_PROTOCOLPGM("Bed X: "); SERIAL_PROTOCOLPGM("Bed X: ");
@ -2164,7 +2158,7 @@ static void clean_up_after_endstop_or_probe_move() {
return measured_z; return measured_z;
} }
#endif // AUTO_BED_LEVELING_FEATURE || Z_MIN_PROBE_REPEATABILITY_TEST #endif // HAS_BED_PROBE
#if ENABLED(AUTO_BED_LEVELING_FEATURE) #if ENABLED(AUTO_BED_LEVELING_FEATURE)
@ -3383,8 +3377,10 @@ inline void gcode_G28() {
bool dryrun = code_seen('D'); bool dryrun = code_seen('D');
#if DISABLED(Z_PROBE_SLED) && DISABLED(Z_PROBE_ALLEN_KEY) #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
bool deploy_probe_for_each_reading = code_seen('E'); const bool stow_probe_after_each = false;
#else
bool stow_probe_after_each = code_seen('E');
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_GRID) #if ENABLED(AUTO_BED_LEVELING_GRID)
@ -3541,42 +3537,13 @@ inline void gcode_G28() {
for (int xCount = xStart; xCount != xStop; xCount += xInc) { for (int xCount = xStart; xCount != xStop; xCount += xInc) {
double xProbe = left_probe_bed_position + xGridSpacing * xCount; double xProbe = left_probe_bed_position + xGridSpacing * xCount;
// raise extruder
float measured_z,
z_raise = probePointCounter ? Z_RAISE_BETWEEN_PROBINGS : Z_RAISE_BEFORE_PROBING;
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPGM("z_raise = (");
if (probePointCounter)
SERIAL_ECHOPGM("between) ");
else
SERIAL_ECHOPGM("before) ");
SERIAL_ECHOLN(z_raise);
}
#endif
#if ENABLED(DELTA) #if ENABLED(DELTA)
// Avoid probing the corners (outside the round or hexagon print surface) on a delta printer. // Avoid probing the corners (outside the round or hexagon print surface) on a delta printer.
float distance_from_center = sqrt(xProbe * xProbe + yProbe * yProbe); float distance_from_center = sqrt(xProbe * xProbe + yProbe * yProbe);
if (distance_from_center > DELTA_PROBEABLE_RADIUS) continue; if (distance_from_center > DELTA_PROBEABLE_RADIUS) continue;
#endif //DELTA #endif //DELTA
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) float measured_z = probe_pt(xProbe, yProbe, stow_probe_after_each, verbose_level);
const ProbeAction act = ProbeStay;
#else
ProbeAction act;
if (deploy_probe_for_each_reading) // G29 E - Stow between probes
act = ProbeDeployAndStow;
else if (yCount == 0 && xCount == xStart)
act = ProbeDeploy;
else if (yCount == auto_bed_leveling_grid_points - 1 && xCount == xStop - xInc)
act = ProbeStow;
else
act = ProbeStay;
#endif
measured_z = probe_pt(xProbe, yProbe, z_raise, act, verbose_level);
#if DISABLED(DELTA) #if DISABLED(DELTA)
mean += measured_z; mean += measured_z;
@ -3597,10 +3564,39 @@ inline void gcode_G28() {
} //xProbe } //xProbe
} //yProbe } //yProbe
#else // !AUTO_BED_LEVELING_GRID
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
#endif
// Probe at 3 arbitrary points
float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
stow_probe_after_each, verbose_level),
z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
stow_probe_after_each, verbose_level),
z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
stow_probe_after_each, verbose_level);
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
#endif // !AUTO_BED_LEVELING_GRID
// Raise to Z_RAISE_AFTER_PROBING. Stow the probe.
stow_z_probe();
// Restore state after probing
clean_up_after_endstop_or_probe_move();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#endif #endif
// Calculate leveling, print reports, correct the position
#if ENABLED(AUTO_BED_LEVELING_GRID)
#if ENABLED(DELTA) #if ENABLED(DELTA)
if (!dryrun) extrapolate_unprobed_bed_level(); if (!dryrun) extrapolate_unprobed_bed_level();
@ -3696,41 +3692,7 @@ inline void gcode_G28() {
} }
} //do_topography_map } //do_topography_map
#endif //!DELTA #endif //!DELTA
#endif // AUTO_BED_LEVELING_GRID
#else // !AUTO_BED_LEVELING_GRID
#if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("> 3-point Leveling");
#endif
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
const ProbeAction p1 = ProbeStay, p2 = ProbeStay, p3 = ProbeStay;
#else
// Actions for each probe
ProbeAction p1, p2, p3;
if (deploy_probe_for_each_reading)
p1 = p2 = p3 = ProbeDeployAndStow;
else
p1 = ProbeDeploy, p2 = ProbeStay, p3 = ProbeStow;
#endif
// Probe at 3 arbitrary points
float z_at_pt_1 = probe_pt( ABL_PROBE_PT_1_X + home_offset[X_AXIS],
ABL_PROBE_PT_1_Y + home_offset[Y_AXIS],
Z_RAISE_BEFORE_PROBING,
p1, verbose_level),
z_at_pt_2 = probe_pt( ABL_PROBE_PT_2_X + home_offset[X_AXIS],
ABL_PROBE_PT_2_Y + home_offset[Y_AXIS],
Z_RAISE_BETWEEN_PROBINGS,
p2, verbose_level),
z_at_pt_3 = probe_pt( ABL_PROBE_PT_3_X + home_offset[X_AXIS],
ABL_PROBE_PT_3_Y + home_offset[Y_AXIS],
Z_RAISE_BETWEEN_PROBINGS,
p3, verbose_level);
if (!dryrun) set_bed_level_equation_3pts(z_at_pt_1, z_at_pt_2, z_at_pt_3);
#endif // !AUTO_BED_LEVELING_GRID
#if DISABLED(DELTA) #if DISABLED(DELTA)
if (verbose_level > 0) if (verbose_level > 0)
@ -3745,13 +3707,12 @@ inline void gcode_G28() {
float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER, float x_tmp = current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER, y_tmp = current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
z_tmp = current_position[Z_AXIS], z_tmp = current_position[Z_AXIS],
real_z = stepper.get_axis_position_mm(Z_AXIS); //get the real Z (since planner.adjusted_position is now correcting the plane) stepper_z = stepper.get_axis_position_mm(Z_AXIS); //get the real Z (since planner.adjusted_position is now correcting the plane)
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > z_tmp = ", z_tmp); SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > stepper_z = ", stepper_z);
SERIAL_EOL; SERIAL_ECHOPAIR(" ... z_tmp = ", z_tmp);
SERIAL_ECHOPAIR("> BEFORE apply_rotation_xyz > real_z = ", real_z);
SERIAL_EOL; SERIAL_EOL;
} }
#endif #endif
@ -3759,28 +3720,6 @@ inline void gcode_G28() {
// Apply the correction sending the Z probe offset // Apply the correction sending the Z probe offset
apply_rotation_xyz(planner.bed_level_matrix, x_tmp, y_tmp, z_tmp); apply_rotation_xyz(planner.bed_level_matrix, x_tmp, y_tmp, z_tmp);
/*
* Get the current Z position and send it to the planner.
*
* >> (z_tmp - real_z) : The rotated current Z minus the uncorrected Z
* (most recent planner.set_position_mm/sync_plan_position)
*
* >> zprobe_zoffset : Z distance from nozzle to Z probe
* (set by default, M851, EEPROM, or Menu)
*
* >> Z_RAISE_AFTER_PROBING : The distance the Z probe will have lifted
* after the last probe
*
* >> Should home_offset[Z_AXIS] be included?
*
*
* Discussion: home_offset[Z_AXIS] was applied in G28 to set the
* starting Z. If Z is not tweaked in G29 -and- the Z probe in G29 is
* not actually "homing" Z... then perhaps it should not be included
* here. The purpose of home_offset[] is to adjust for inaccurate
* endstops, not for reasonably accurate probes. If it were added
* here, it could be seen as a compensating factor for the Z probe.
*/
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
SERIAL_ECHOPAIR("> AFTER apply_rotation_xyz > z_tmp = ", z_tmp); SERIAL_ECHOPAIR("> AFTER apply_rotation_xyz > z_tmp = ", z_tmp);
@ -3788,30 +3727,16 @@ inline void gcode_G28() {
} }
#endif #endif
current_position[Z_AXIS] = -zprobe_zoffset + (z_tmp - real_z) // Adjust the current Z and send it to the planner.
#if HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_ALLEN_KEY) || ENABLED(Z_PROBE_SLED) current_position[Z_AXIS] += z_tmp - stepper_z;
+ Z_RAISE_AFTER_PROBING
#endif
;
// current_position[Z_AXIS] += home_offset[Z_AXIS]; // The Z probe determines Z=0, not "Z home"
SYNC_PLAN_POSITION_KINEMATIC(); SYNC_PLAN_POSITION_KINEMATIC();
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
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 #endif // !DELTA
// Final raise of Z axis after probing.
raise_z_after_probing();
// Stow the probe. Servo will raise if needed.
stow_z_probe();
// Restore state after probing
clean_up_after_endstop_or_probe_move();
#ifdef Z_PROBE_END_SCRIPT #ifdef Z_PROBE_END_SCRIPT
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) {
@ -3824,9 +3749,7 @@ inline void gcode_G28() {
#endif #endif
#if ENABLED(DEBUG_LEVELING_FEATURE) #if ENABLED(DEBUG_LEVELING_FEATURE)
if (DEBUGGING(LEVELING)) { if (DEBUGGING(LEVELING)) SERIAL_ECHOLNPGM("<<< gcode_G29");
SERIAL_ECHOLNPGM("<<< gcode_G29");
}
#endif #endif
bed_leveling_in_progress = false; bed_leveling_in_progress = false;
@ -3847,12 +3770,10 @@ inline void gcode_G28() {
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
deploy_z_probe();
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
float measured_z = run_z_probe(); // clears the ABL non-delta matrix only float measured_z = probe_pt(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER,
current_position[Y_AXIS] + Y_PROBE_OFFSET_FROM_EXTRUDER,
true, 1);
SERIAL_PROTOCOLPGM("Bed X: "); SERIAL_PROTOCOLPGM("Bed X: ");
SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001); SERIAL_PROTOCOL(current_position[X_AXIS] + X_PROBE_OFFSET_FROM_EXTRUDER + 0.0001);
@ -3862,13 +3783,25 @@ inline void gcode_G28() {
SERIAL_PROTOCOL(measured_z + 0.0001); SERIAL_PROTOCOL(measured_z + 0.0001);
SERIAL_EOL; SERIAL_EOL;
stow_z_probe();
clean_up_after_endstop_or_probe_move(); clean_up_after_endstop_or_probe_move();
report_current_position(); report_current_position();
} }
#if ENABLED(Z_PROBE_SLED)
/**
* G31: Deploy the Z probe
*/
inline void gcode_G31() { deploy_z_probe(); }
/**
* G32: Stow the Z probe
*/
inline void gcode_G32() { stow_z_probe(); }
#endif // Z_PROBE_SLED
#endif // HAS_BED_PROBE #endif // HAS_BED_PROBE
/** /**
@ -4210,9 +4143,9 @@ inline void gcode_M42() {
Y_current = current_position[Y_AXIS]; Y_current = current_position[Y_AXIS];
#if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY) #if ENABLED(Z_PROBE_SLED) || ENABLED(Z_PROBE_ALLEN_KEY)
const bool deploy_probe_for_each_reading = false; const bool stow_probe_after_each = false;
#else #else
bool deploy_probe_for_each_reading = code_seen('E'); bool stow_probe_after_each = code_seen('E');
#endif #endif
float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER; float X_probe_location = code_seen('X') ? code_value_axis_units(X_AXIS) : X_current + X_PROBE_OFFSET_FROM_EXTRUDER;
@ -4265,24 +4198,8 @@ inline void gcode_M42() {
setup_for_endstop_or_probe_move(); setup_for_endstop_or_probe_move();
do_probe_raise(Z_RAISE_BEFORE_PROBING); // Move to the first point, deploy, and probe
probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
feedrate = XY_PROBE_FEEDRATE;
do_blocking_move_to_xy(X_probe_location - (X_PROBE_OFFSET_FROM_EXTRUDER), Y_probe_location - (Y_PROBE_OFFSET_FROM_EXTRUDER));
/**
* OK, do the initial probe to get us close to the bed.
* Then retrace the right amount and use that in subsequent probes
*/
// Height before each probe (except the first)
float z_between = deploy_probe_for_each_reading ? Z_RAISE_BEFORE_PROBING : Z_RAISE_BETWEEN_PROBINGS;
// Deploy the probe and probe the first point
probe_pt(X_probe_location, Y_probe_location,
Z_RAISE_BEFORE_PROBING,
deploy_probe_for_each_reading ? ProbeDeployAndStow : ProbeDeploy,
verbose_level);
randomSeed(millis()); randomSeed(millis());
@ -4302,12 +4219,9 @@ inline void gcode_M42() {
if (verbose_level > 3) { if (verbose_level > 3) {
SERIAL_ECHOPAIR("Starting radius: ", radius); SERIAL_ECHOPAIR("Starting radius: ", radius);
SERIAL_ECHOPAIR(" angle: ", angle); SERIAL_ECHOPAIR(" angle: ", angle);
delay(100); SERIAL_ECHO(" Direction: ");
if (dir > 0) if (dir > 0) SERIAL_ECHO("Counter ");
SERIAL_ECHO(" Direction: Counter Clockwise \n"); SERIAL_ECHOLN("Clockwise");
else
SERIAL_ECHO(" Direction: Clockwise \n");
delay(100);
} }
for (uint8_t l = 0; l < n_legs - 1; l++) { for (uint8_t l = 0; l < n_legs - 1; l++) {
@ -4346,7 +4260,6 @@ inline void gcode_M42() {
SERIAL_ECHOPAIR("Pulling point towards center:", X_current); SERIAL_ECHOPAIR("Pulling point towards center:", X_current);
SERIAL_ECHOPAIR(", ", Y_current); SERIAL_ECHOPAIR(", ", Y_current);
SERIAL_EOL; SERIAL_EOL;
delay(50);
} }
} }
#endif #endif
@ -4356,22 +4269,13 @@ inline void gcode_M42() {
SERIAL_ECHOPAIR("y: ", Y_current); SERIAL_ECHOPAIR("y: ", Y_current);
SERIAL_ECHOPAIR(" z: ", current_position[Z_AXIS]); SERIAL_ECHOPAIR(" z: ", current_position[Z_AXIS]);
SERIAL_EOL; SERIAL_EOL;
delay(55);
} }
do_blocking_move_to_xy(X_current, Y_current); do_blocking_move_to_xy(X_current, Y_current);
} // n_legs loop } // n_legs loop
} // n_legs } // n_legs
// The last probe will differ
bool last_probe = (n == n_samples - 1);
// Probe a single point // Probe a single point
sample_set[n] = probe_pt( sample_set[n] = probe_pt(X_probe_location, Y_probe_location, stow_probe_after_each, verbose_level);
X_probe_location, Y_probe_location,
z_between,
deploy_probe_for_each_reading ? ProbeDeployAndStow : last_probe ? ProbeStow : ProbeStay,
verbose_level
);
/** /**
* Get the current mean for the data points we have so far * Get the current mean for the data points we have so far
@ -4397,7 +4301,6 @@ inline void gcode_M42() {
SERIAL_PROTOCOL((int)n_samples); SERIAL_PROTOCOL((int)n_samples);
SERIAL_PROTOCOLPGM(" z: "); SERIAL_PROTOCOLPGM(" z: ");
SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6); SERIAL_PROTOCOL_F(current_position[Z_AXIS], 6);
delay(50);
if (verbose_level > 2) { if (verbose_level > 2) {
SERIAL_PROTOCOLPGM(" mean: "); SERIAL_PROTOCOLPGM(" mean: ");
SERIAL_PROTOCOL_F(mean, 6); SERIAL_PROTOCOL_F(mean, 6);
@ -4408,17 +4311,10 @@ inline void gcode_M42() {
SERIAL_EOL; SERIAL_EOL;
} }
// Raise before the next loop for the legs,
// or do the final raise after the last probe
if (last_probe)
do_probe_raise(Z_RAISE_AFTER_PROBING);
else if (n_legs) {
do_probe_raise(z_between);
if (!last_probe) delay(500);
}
} // End of probe loop } // End of probe loop
stow_z_probe();
if (verbose_level > 0) { if (verbose_level > 0) {
SERIAL_PROTOCOLPGM("Mean: "); SERIAL_PROTOCOLPGM("Mean: ");
SERIAL_PROTOCOL_F(mean, 6); SERIAL_PROTOCOL_F(mean, 6);
@ -5967,16 +5863,12 @@ inline void gcode_M400() { stepper.synchronize(); }
/** /**
* M401: Engage Z Servo endstop if available * M401: Engage Z Servo endstop if available
*/ */
inline void gcode_M401() { inline void gcode_M401() { deploy_z_probe(); }
deploy_z_probe();
}
/** /**
* M402: Retract Z Servo endstop if enabled * M402: Retract Z Servo endstop if enabled
*/ */
inline void gcode_M402() { inline void gcode_M402() { stow_z_probe(); }
stow_z_probe();
}
#endif // HAS_BED_PROBE #endif // HAS_BED_PROBE
@ -6858,10 +6750,11 @@ void process_next_command() {
#if ENABLED(Z_PROBE_SLED) #if ENABLED(Z_PROBE_SLED)
case 31: // G31: dock the sled case 31: // G31: dock the sled
stow_z_probe(); gcode_G31();
break; break;
case 32: // G32: undock the sled case 32: // G32: undock the sled
deploy_z_probe(); gcode_G32();
break; break;
#endif // Z_PROBE_SLED #endif // Z_PROBE_SLED

View file

@ -593,8 +593,6 @@
#error "Z_LATE_ENABLE can't be used with COREXZ." #error "Z_LATE_ENABLE can't be used with COREXZ."
#elif defined(X_HOME_RETRACT_MM) #elif defined(X_HOME_RETRACT_MM)
#error "[XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM." #error "[XYZ]_HOME_RETRACT_MM settings have been renamed [XYZ]_HOME_BUMP_MM."
#elif defined(PROBE_SERVO_DEACTIVATION_DELAY)
#error "PROBE_SERVO_DEACTIVATION_DELAY has been replaced with DEACTIVATE_SERVOS_AFTER_MOVE and SERVO_DEACTIVATION_DELAY."
#elif defined(BEEPER) #elif defined(BEEPER)
#error "BEEPER is now BEEPER_PIN. Please update your pins definitions." #error "BEEPER is now BEEPER_PIN. Please update your pins definitions."
#elif defined(SDCARDDETECT) #elif defined(SDCARDDETECT)
@ -635,6 +633,10 @@
#error "X_ENDSTOP_SERVO_NR and Y_ENDSTOP_SERVO_NR are deprecated and should be removed." #error "X_ENDSTOP_SERVO_NR and Y_ENDSTOP_SERVO_NR are deprecated and should be removed."
#elif defined(XY_TRAVEL_SPEED) #elif defined(XY_TRAVEL_SPEED)
#error "XY_TRAVEL_SPEED is deprecated. Use XY_PROBE_SPEED instead." #error "XY_TRAVEL_SPEED is deprecated. Use XY_PROBE_SPEED instead."
#elif defined(PROBE_SERVO_DEACTIVATION_DELAY)
#error "PROBE_SERVO_DEACTIVATION_DELAY is deprecated. Use DEACTIVATE_SERVOS_AFTER_MOVE instead."
#elif defined(SERVO_DEACTIVATION_DELAY)
#error "SERVO_DEACTIVATION_DELAY is deprecated. Use SERVO_DELAY instead."
#endif #endif
#endif //SANITYCHECK_H #endif //SANITYCHECK_H

View file

@ -1172,18 +1172,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1156,18 +1156,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1154,18 +1154,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1165,18 +1165,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// //
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1167,18 +1167,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1190,18 +1190,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1173,18 +1173,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1170,18 +1170,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = false; // set to true to invert the l
// //
#define NUM_SERVOS 0 // DGlass3D - Servo index starts with 0 for M280 command #define NUM_SERVOS 0 // DGlass3D - Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1181,18 +1181,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1194,18 +1194,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1165,18 +1165,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// //
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1173,18 +1173,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1258,18 +1258,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// //
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1252,18 +1252,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// //
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1255,18 +1255,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1255,18 +1255,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1257,18 +1257,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1176,18 +1176,16 @@ 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 //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -1167,18 +1167,16 @@ const bool Z_MIN_PROBE_ENDSTOP_INVERTING = true; // set to true to invert the lo
// //
//#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command //#define NUM_SERVOS 3 // Servo index starts with 0 for M280 command
// Delay (in microseconds) before the next move will start, to give the servo time to reach its target angle.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DELAY 300
// Servo deactivation // Servo deactivation
// //
// With this option servos are powered only during movement, then turned off to prevent jitter. // With this option servos are powered only during movement, then turned off to prevent jitter.
//#define DEACTIVATE_SERVOS_AFTER_MOVE //#define DEACTIVATE_SERVOS_AFTER_MOVE
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
// Delay (in microseconds) before turning the servo off. This depends on the servo speed.
// 300ms is a good value but you can try less delay.
// If the servo can't reach the requested position, increase it.
#define SERVO_DEACTIVATION_DELAY 300
#endif
/**********************************************************************\ /**********************************************************************\
* Support for a filament diameter sensor * Support for a filament diameter sensor
* Also allows adjustment of diameter at print time (vs at slicing) * Also allows adjustment of diameter at print time (vs at slicing)

View file

@ -21,49 +21,34 @@
*/ */
/** /**
servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2 * servo.cpp - Interrupt driven Servo library for Arduino using 16 bit timers- Version 2
Copyright (c) 2009 Michael Margolis. All right reserved. * Copyright (c) 2009 Michael Margolis. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
/** /**
* A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method.
A servo is activated by creating an instance of the Servo class passing the desired pin to the attach() method. * The servos are pulsed in the background using the value most recently written using the write() method
The servos are pulsed in the background using the value most recently written using the write() method *
* Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached.
Note that analogWrite of PWM on pins associated with the timer are disabled when the first servo is attached. * Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four.
Timers are seized as needed in groups of 12 servos - 24 servos use two timers, 48 servos will use four. *
* The methods are:
The methods are: *
* Servo - Class for manipulating servo motors connected to Arduino pins.
Servo - Class for manipulating servo motors connected to Arduino pins. *
* attach(pin) - Attach a servo motor to an i/o pin.
attach(pin ) - Attaches a servo motor to an i/o pin. * attach(pin, min, max) - Attach to a pin, setting min and max values in microseconds
attach(pin, min, max ) - Attaches to a pin setting min and max values in microseconds * Default min is 544, max is 2400
default min is 544, max is 2400 *
* write() - Set the servo angle in degrees. (Invalid angles over MIN_PULSE_WIDTH are treated as µs.)
write() - Sets the servo angle in degrees. (invalid angle that is valid as pulse in microseconds is treated as microseconds) * writeMicroseconds() - Set the servo pulse width in microseconds.
writeMicroseconds() - Sets the servo pulse width in microseconds * move(pin, angle) - Sequence of attach(pin), write(angle), delay(SERVO_DELAY).
move(pin, angle) - Sequence of attach(pin), write(angle). * With DEACTIVATE_SERVOS_AFTER_MOVE it detaches after SERVO_DELAY.
With DEACTIVATE_SERVOS_AFTER_MOVE it waits SERVO_DEACTIVATION_DELAY and detaches. * read() - Get the last-written servo pulse width as an angle between 0 and 180.
read() - Gets the last written servo pulse width as an angle between 0 and 180. * readMicroseconds() - Get the last-written servo pulse width in microseconds.
readMicroseconds() - Gets the last written servo pulse width in microseconds. (was read_us() in first release) * attached() - Return true if a servo is attached.
attached() - Returns true if there is a servo attached. * detach() - Stop an attached servo from pulsing its i/o pin.
detach() - Stops an attached servos from pulsing its i/o pin. *
*/ */
#include "Configuration.h" #include "Configuration.h"
@ -238,6 +223,7 @@ static void finISR(timer16_Sequence_t timer) {
} }
#else //!WIRING #else //!WIRING
// For arduino - in future: call here to a currently undefined function to reset the timer // For arduino - in future: call here to a currently undefined function to reset the timer
UNUSED(timer);
#endif #endif
} }
@ -324,8 +310,8 @@ bool Servo::attached() { return servo_info[this->servoIndex].Pin.isActive; }
void Servo::move(int value) { void Servo::move(int value) {
if (this->attach(0) >= 0) { if (this->attach(0) >= 0) {
this->write(value); this->write(value);
delay(SERVO_DELAY);
#if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE) #if ENABLED(DEACTIVATE_SERVOS_AFTER_MOVE)
delay(SERVO_DEACTIVATION_DELAY);
this->detach(); this->detach();
#endif #endif
} }

View file

@ -63,7 +63,7 @@
attached() - Returns true if there is a servo attached. attached() - Returns true if there is a servo attached.
detach() - Stops an attached servos from pulsing its i/o pin. detach() - Stops an attached servos from pulsing its i/o pin.
move(angle) - Sequence of attach(0), write(angle), move(angle) - Sequence of attach(0), write(angle),
With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY and detach. With DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY and detach.
*/ */
#ifndef servo_h #ifndef servo_h
@ -147,7 +147,7 @@ class Servo {
void writeMicroseconds(int value); // write pulse width in microseconds void writeMicroseconds(int value); // write pulse width in microseconds
void move(int value); // attach the servo, then move to value void move(int value); // attach the servo, then move to value
// if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds // if value is < 200 it is treated as an angle, otherwise as pulse width in microseconds
// if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DEACTIVATION_DELAY, then detach // if DEACTIVATE_SERVOS_AFTER_MOVE wait SERVO_DELAY, then detach
int read(); // returns current pulse width as an angle between 0 and 180 degrees int read(); // returns current pulse width as an angle between 0 and 180 degrees
int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release) int readMicroseconds(); // returns current pulse width in microseconds for this servo (was read_us() in first release)
bool attached(); // return true if this servo is attached, otherwise false bool attached(); // return true if this servo is attached, otherwise false