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

LCD Bed Tramming Probe Loop Fix #26962

Merged
merged 5 commits into from
May 12, 2024
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
2 changes: 1 addition & 1 deletion Marlin/Configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -2218,7 +2218,7 @@
#if ENABLED(LCD_BED_TRAMMING)
#define BED_TRAMMING_INSET_LFRB { 30, 30, 30, 30 } // (mm) Left, Front, Right, Back insets
#define BED_TRAMMING_HEIGHT 0.0 // (mm) Z height of nozzle at tramming points
#define BED_TRAMMING_Z_HOP 4.0 // (mm) Z height of nozzle between tramming points
#define BED_TRAMMING_Z_HOP 4.0 // (mm) Z raise between tramming points
//#define BED_TRAMMING_INCLUDE_CENTER // Move to the center after the last corner
//#define BED_TRAMMING_USE_PROBE
#if ENABLED(BED_TRAMMING_USE_PROBE)
Expand Down
3 changes: 3 additions & 0 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1545,6 +1545,9 @@ static_assert(NUM_SERVOS <= NUM_SERVO_PLUGS, "NUM_SERVOS (or some servo index) i
#error "BED_TRAMMING_USE_PROBE is incompatible with SENSORLESS_PROBING."
#endif
#endif
static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0.");
#elif ANY(DGUS_LCD_UI_RELOADED, DGUS_LCD_UI_E3S1PRO)
#error "LCD_BED_TRAMMING is required for the selected display."
#endif

/**
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/lcd/extui/anycubic_chiron/chiron_tft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,11 @@ void ChironTFT::panelProcess(uint8_t req) {
DEBUG_ECHOLNPGM("Moving to mesh point at x: ", pos.x, " y: ", pos.y, " z: ", pos_z);
#endif
// Go up before moving
setAxisPosition_mm(3.0,Z);
setAxisPosition_mm(3.0f, Z);

setAxisPosition_mm(17 + (93 * pos.x), X);
setAxisPosition_mm(20 + (93 * pos.y), Y);
setAxisPosition_mm(0.0, Z);
setAxisPosition_mm(17.0f + (93.0f * pos.x), X);
setAxisPosition_mm(20.0f + (93.0f * pos.y), Y);
setAxisPosition_mm(0.0f, Z);
#if ACDEBUG(AC_INFO)
DEBUG_ECHOLNPGM("Current Z: ", getAxisPosition_mm(Z));
#endif
Expand Down
13 changes: 6 additions & 7 deletions Marlin/src/lcd/extui/dgus_e3s1pro/DGUSReturnKeyCodeHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,15 +401,14 @@ static void _gotoTrammingPoint(unsigned char point) {
switch (point) {
default: return;
case 1: x = X_CENTER; y = Y_CENTER; break;
case 2: x = X_MIN_POS + lfrb[0]; y = Y_MIN_POS + lfrb[1]; break;
case 3: x = X_MAX_POS - lfrb[2]; y = Y_MIN_POS + lfrb[1]; break;
case 4: x = X_MAX_POS - lfrb[2]; y = Y_MAX_POS - lfrb[3]; break;
case 5: x = X_MIN_POS + lfrb[0]; y = Y_MAX_POS - lfrb[3]; break;
case 2: x = X_MIN_BED + lfrb[0]; y = Y_MIN_BED + lfrb[1]; break;
case 3: x = X_MAX_BED - lfrb[2]; y = Y_MIN_BED + lfrb[1]; break;
case 4: x = X_MAX_BED - lfrb[2]; y = Y_MAX_BED - lfrb[3]; break;
case 5: x = X_MIN_BED + lfrb[0]; y = Y_MAX_BED - lfrb[3]; break;
}

if (ExtUI::getAxisPosition_mm(ExtUI::Z) < (Z_MIN_POS) + (BED_TRAMMING_Z_HOP))
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_Z_HOP), ExtUI::Z);

if (BED_TRAMMING_Z_HOP)
ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z);
ExtUI::setAxisPosition_mm(x, ExtUI::X);
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z);
Expand Down
10 changes: 0 additions & 10 deletions Marlin/src/lcd/extui/dgus_e3s1pro/config/DGUS_Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,3 @@
#ifndef DGUS_STATUS_EXPIRATION_MS
#define DGUS_STATUS_EXPIRATION_MS 30000
#endif

#ifndef BED_TRAMMING_Z_HOP
#define BED_TRAMMING_Z_HOP 4.0
#endif

#ifndef BED_TRAMMING_HEIGHT
#define BED_TRAMMING_HEIGHT 0.0
#endif

static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration.");
23 changes: 11 additions & 12 deletions Marlin/src/lcd/extui/dgus_reloaded/DGUSRxHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -474,29 +474,28 @@ void DGUSRxHandler::moveToPoint(DGUS_VP &vp, void *data_ptr) {
y = DGUS_LEVEL_CENTER_Y;
break;
case 2:
x = X_MIN_POS + lfrb[0];
y = Y_MIN_POS + lfrb[1];
x = X_MIN_BED + lfrb[0];
y = Y_MIN_BED + lfrb[1];
break;
case 3:
x = X_MAX_POS - lfrb[2];
y = Y_MIN_POS + lfrb[1];
x = X_MAX_BED - lfrb[2];
y = Y_MIN_BED + lfrb[1];
break;
case 4:
x = X_MAX_POS - lfrb[2];
y = Y_MAX_POS - lfrb[3];
x = X_MAX_BED - lfrb[2];
y = Y_MAX_BED - lfrb[3];
break;
case 5:
x = X_MIN_POS + lfrb[0];
y = Y_MAX_POS - lfrb[3];
x = X_MIN_BED + lfrb[0];
y = Y_MAX_BED - lfrb[3];
break;
}

if (ExtUI::getAxisPosition_mm(ExtUI::Z) < Z_MIN_POS + BED_TRAMMING_Z_HOP) {
ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_Z_HOP, ExtUI::Z);
}
if (BED_TRAMMING_Z_HOP)
ExtUI::setAxisPosition_mm(ExtUI::getAxisPosition_mm(ExtUI::Z) + (BED_TRAMMING_Z_HOP), ExtUI::Z);
ExtUI::setAxisPosition_mm(x, ExtUI::X);
ExtUI::setAxisPosition_mm(y, ExtUI::Y);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: These manual move methods are not ideal for this usage since they move only one axis at a time. The move to and from the center point ends up taking two moves instead of one. ExtUI should be extended with a method to move XY together (or this code should just use the motion.* functions directly).

ExtUI::setAxisPosition_mm(Z_MIN_POS + BED_TRAMMING_HEIGHT, ExtUI::Z);
ExtUI::setAxisPosition_mm((Z_MIN_POS) + (BED_TRAMMING_HEIGHT), ExtUI::Z);
}

void DGUSRxHandler::probe(DGUS_VP &vp, void *data_ptr) {
Expand Down
10 changes: 0 additions & 10 deletions Marlin/src/lcd/extui/dgus_reloaded/config/DGUS_Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,6 @@
#define DGUS_DEFAULT_FILAMENT_LEN 10
#endif

#ifndef BED_TRAMMING_Z_HOP
#define BED_TRAMMING_Z_HOP 4.0
#endif

#ifndef BED_TRAMMING_HEIGHT
#define BED_TRAMMING_HEIGHT 0.0
#endif

static_assert(BED_TRAMMING_Z_HOP >= 0, "BED_TRAMMING_Z_HOP must be >= 0. Please update your configuration.");

#ifndef DGUS_LEVEL_CENTER_X
#define DGUS_LEVEL_CENTER_X ((X_BED_SIZE) / 2)
#endif
Expand Down
10 changes: 5 additions & 5 deletions Marlin/src/lcd/extui/ia_creality/ia_creality_rts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1162,35 +1162,35 @@ void RTS::handleData() {

#if ENABLED(LCD_BED_TRAMMING)
case 6: // Bed Tramming, Centre 1
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
setAxisPosition_mm(X_CENTER, axis_t(X));
setAxisPosition_mm(Y_CENTER, axis_t(Y));
waitway = 6;
break;

case 7: // Bed Tramming, Front Left 2
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X));
setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y));
waitway = 6;
break;

case 8: // Bed Tramming, Front Right 3
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X));
setAxisPosition_mm(Y_MIN_BED + lfrb[1], axis_t(Y));
waitway = 6;
break;

case 9: // Bed Tramming, Back Right 4
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
setAxisPosition_mm(X_MAX_BED - lfrb[2], axis_t(X));
setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y));
waitway = 6;
break;

case 10: // Bed Tramming, Back Left 5
setAxisPosition_mm(BED_TRAMMING_Z_HOP, axis_t(Z));
if (BED_TRAMMING_Z_HOP) setAxisPosition_mm(current_position.z + (BED_TRAMMING_Z_HOP), axis_t(Z));
setAxisPosition_mm(X_MIN_BED + lfrb[0], axis_t(X));
setAxisPosition_mm(Y_MAX_BED - lfrb[3], axis_t(Y));
waitway = 6;
Expand Down
13 changes: 3 additions & 10 deletions Marlin/src/lcd/menu/menu_bed_tramming.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@
#include "../../feature/bedlevel/bedlevel.h"
#endif

#ifndef BED_TRAMMING_Z_HOP
#define BED_TRAMMING_Z_HOP 4.0
#endif
#ifndef BED_TRAMMING_HEIGHT
#define BED_TRAMMING_HEIGHT 0.0
#endif

#if ALL(HAS_STOWABLE_PROBE, BED_TRAMMING_USE_PROBE) && DISABLED(BLTOUCH)
#define NEEDS_PROBE_DEPLOY 1
#endif
Expand Down Expand Up @@ -151,7 +144,7 @@ static void _lcd_goto_next_corner() {
}
}

float z = BED_TRAMMING_Z_HOP;
float z = current_position.z + (BED_TRAMMING_Z_HOP);
#if ALL(BED_TRAMMING_USE_PROBE, BLTOUCH)
z += bltouch.z_extra_clearance();
#endif
Expand Down Expand Up @@ -235,7 +228,7 @@ static void _lcd_goto_next_corner() {
}

bool _lcd_bed_tramming_probe(const bool verify=false) {
if (verify) line_to_z(BED_TRAMMING_Z_HOP); // do clearance if needed
if (verify) line_to_z(current_position.z + (BED_TRAMMING_Z_HOP)); // do clearance if needed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code like this will need to be tested since it may now need special handling for the first point. We don't want to just raise over the current height before we've moved down to the bed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Upon initial review this change seems to be safe and won't adversely affect behavior.

TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action
do_blocking_move_to_z(last_z - BED_TRAMMING_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance
if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered
Expand All @@ -253,7 +246,7 @@ static void _lcd_goto_next_corner() {

// Raise the probe after the last point to give clearance for stow
if (TERN0(NEEDS_PROBE_DEPLOY, good_points == nr_edge_points - 1))
line_to_z(BED_TRAMMING_Z_HOP);
do_z_clearance(BED_TRAMMING_Z_HOP);

return true; // probe triggered
}
Expand Down
14 changes: 13 additions & 1 deletion Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,14 @@ void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*
fr_mm_s
);
}
/**
* Move Z to a particular height so the nozzle or deployed probe clears the bed.
* (Use do_z_clearance_by for clearance over the current position.)
* - For a probe, add clearance for the probe distance
* - Constrain to the Z max physical position
* - If lowering is not allowed then skip a downward move
* - Execute the move at the probing (or homing) feedrate
*/
void do_z_clearance(const_float_t zclear, const bool with_probe/*=true*/, const bool lower_allowed/*=false*/) {
UNUSED(with_probe);
float zdest = zclear;
Expand All @@ -727,9 +735,13 @@ void do_blocking_move_to(const xyze_pos_t &raw, const_feedRate_t fr_mm_s/*=0.0f*
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("do_z_clearance_by(", zclear, ")");
do_z_clearance(current_position.z + zclear, false);
}
/**
* Move Z to Z_POST_CLEARANCE,
* The axis is allowed to move down.
*/
void do_move_after_z_homing() {
DEBUG_SECTION(mzah, "do_move_after_z_homing", DEBUGGING(LEVELING));
#if defined(Z_AFTER_HOMING) || ALL(DWIN_LCD_PROUI, INDIVIDUAL_AXIS_HOMING_SUBMENU, MESH_BED_LEVELING)
#ifdef Z_POST_CLEARANCE
do_z_clearance(Z_POST_CLEARANCE, true, true);
#elif ENABLED(USE_PROBE_FOR_Z_HOMING)
probe.move_z_after_probing();
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -999,7 +999,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
default: break;
case PROBE_PT_RAISE:
if (raise_after_is_relative)
do_z_clearance(current_position.z + z_clearance, false);
do_z_clearance_by(z_clearance);
else
do_z_clearance(z_clearance);
break;
Expand Down
Loading