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

G28 / G30 probe related changes #25652

Merged
merged 15 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
18 changes: 17 additions & 1 deletion Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@
* L<bool> Force leveling state ON (if possible) or OFF after homing (Requires RESTORE_LEVELING_AFTER_G28 or ENABLE_LEVELING_AFTER_G28)
* O Home only if the position is not known and trusted
* R<linear> Raise by n mm/inches before homing
* H Hold the current X/Y position when executing a home Z, or if
* multiple axes are homed, the position when Z home is executed.
* When using a probe for Z Home, positions close to the edge may
* fail with position unreachable due to probe/nozzle offset. This
* can be used to avoid a model.
*
* Cartesian/SCARA parameters
*
Expand Down Expand Up @@ -486,10 +491,21 @@ void GcodeSuite::G28() {
#endif

#if ENABLED(Z_SAFE_HOMING)
if (TERN1(POWER_LOSS_RECOVERY, !parser.seen_test('H'))) home_z_safely(); else homeaxis(Z_AXIS);
// H means hold the current X/Y position when probing, if not
// specified, move to the define safe X/Y position before homing Z.
if (!parser.seen_test('H'))
home_z_safely();
else
homeaxis(Z_AXIS);
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
#else
homeaxis(Z_AXIS);
#endif

#if ENABLED(BLTOUCH)
// stow() is not automatic in high_speed_mode
if (bltouch.high_speed_mode) probe.stow();
#endif
thinkyhead marked this conversation as resolved.
Show resolved Hide resolved

probe.move_z_after_homing();
}
#endif
Expand Down
25 changes: 20 additions & 5 deletions Marlin/src/gcode/probe/G30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@
/**
* G30: Do a single Z probe at the current XY
*
* If either X or Y are given, the probe is moved to that location.
* that will be the probe location.
* the probe will be moved to
* it will move the probe to that position relative
* to the nozzle, by default it probes the position the probe is at.
*
* Parameters:
*
* X Probe X position (default current X)
Expand All @@ -56,10 +62,18 @@ void GcodeSuite::G30() {
probe.use_probing_tool();

// Convert the given logical position to native position
const xy_pos_t pos = {
parser.seenval('X') ? RAW_X_POSITION(parser.value_linear_units()) : current_position.x,
parser.seenval('Y') ? RAW_Y_POSITION(parser.value_linear_units()) : current_position.y
};
xy_pos_t pos;
const bool seenX = parser.seenval('X');
pos.x = seenX ? RAW_X_POSITION(parser.value_linear_units()) :
current_position.x;
const bool seenY = parser.seenval('Y');
pos.y = seenY ? RAW_Y_POSITION(parser.value_linear_units()) :
current_position.y;
// If X or Y was given, then probe that bed location, which means moving
// the probe over that point, which is accomplished by indicating the point
// is a relative (probe to nozzle) location. False is absolute and no
// movement since it is already at the current location.
const bool probe_relative = seenX || seenY;

if (probe.can_reach(pos)) {
// Disable leveling so the planner won't mess with us
Expand All @@ -74,7 +88,8 @@ void GcodeSuite::G30() {
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;

TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool()));
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
const float measured_z = probe.probe_at_point(pos, raise_after, 1,
probe_relative);
TERN_(HAS_PTC, ptc.set_enabled(true));
if (!isnan(measured_z)) {
SERIAL_ECHOLNPGM("Bed X: ", pos.asLogical().x, " Y: ", pos.asLogical().y, " Z: ", measured_z);
Expand Down
12 changes: 7 additions & 5 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,6 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
DEBUG_POS("", current_position);
}

#if ENABLED(BLTOUCH)
// Reset a BLTouch in HS mode if already triggered
if (bltouch.high_speed_mode && bltouch.triggered()) bltouch._reset();
#endif

thinkyhead marked this conversation as resolved.
Show resolved Hide resolved
// Use a safe Z height for the XY move
const float safe_z = _MAX(current_position.z, Z_PROBE_SAFE_CLEARANCE);

Expand Down Expand Up @@ -952,6 +947,13 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
return current_position.z - bdl.read(); // Difference between Z-home-relative Z and sensor reading
#endif

#if ENABLED(BLTOUCH)
// Now at the safe_z if it is still triggered it may be in an alarm
// condition. Reset to clear alarm has a side effect of stowing the probe,
// which the following deploy will handle.
if (bltouch.triggered()) bltouch._reset();
#endif

float measured_z = NAN;
if (!deploy()) {
measured_z = run_z_probe(sanity_check) + offset.z;
Expand Down