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

“Improve Sensorless homing/probing accuracy for G28, G33, M48” #24220

Merged
merged 124 commits into from
Jun 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
124 commits
Select commit Hold shift + click to select a range
58bf83a
Mejora SENSORLESS en DELTA
lujios May 10, 2021
30164ed
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios May 11, 2021
48ca5b2
Update probe.cpp
lujios May 11, 2021
350164d
Error versión actualizada
lujios May 11, 2021
e41f5f0
Error versión actualizada
lujios May 11, 2021
e7db472
DELTA with SENSORLESS_HOMING/PROBING.
lujios May 11, 2021
fc73ae5
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios May 12, 2021
22671e0
Change description.
lujios May 13, 2021
e842e7a
Revert "Change description."
lujios May 13, 2021
30f47bc
Revert "Revert "Change description.""
lujios May 13, 2021
1b6f2b2
Delete Configuration.h
lujios May 13, 2021
49fed0b
Delete Configuration_adv.h
lujios May 13, 2021
f2d2397
Configuration.
lujios May 13, 2021
9b7a34c
Merge branch 'bugfix-2.0.x' of https://github.com/lujios/Marlin into …
lujios May 13, 2021
6ef7d75
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios May 13, 2021
c343ee4
Change Configuration origin
lujios May 13, 2021
dd636ef
Merge branch 'bugfix-2.0.x' of https://github.com/lujios/Marlin into …
lujios May 13, 2021
fc1ec09
Update pins_RAMPS.h
lujios May 13, 2021
84d14c3
Update G28.cpp
lujios May 29, 2021
4041c88
Merge branch 'bugfix-2.0.x' into bugfix-2.0.x
lujios May 29, 2021
9adb045
Update G28.cpp
lujios May 29, 2021
5c31b99
Merge branch 'bugfix-2.0.x' into bugfix-2.0.x
lujios Jun 6, 2021
8a661be
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Jun 17, 2021
909ac8b
Update probe.cpp
lujios Jun 17, 2021
7ec77fc
Update probe.cpp
lujios Jun 17, 2021
4230664
Update probe.cpp
lujios Jun 17, 2021
58a0b19
Update pins_AZSMZ_MINI.h
lujios Jun 17, 2021
2e9bffd
initial review quick fixes
thinkyhead Jun 18, 2021
2824be1
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/21899
thinkyhead Jun 18, 2021
3d15bd3
non-delta slow homing
thinkyhead Jun 18, 2021
876be19
fewer static buffers
thinkyhead Jun 19, 2021
4fcee1e
style tweaks
thinkyhead Jun 19, 2021
0f05cd9
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/21899
thinkyhead Jun 19, 2021
7904673
Update set_homing_current
thinkyhead Jun 19, 2021
742653e
Always trigger MAX on DELTA
thinkyhead Jun 19, 2021
e77ba46
move some to planner
thinkyhead Jun 19, 2021
bb2569f
Update planner.cpp
lujios Jun 20, 2021
8869fa9
Typographic error. debug_current -> debug_current_on
lujios Jun 20, 2021
e59e05b
SENSORLESS_PROBING to SENSORLESS_HOMING
lujios Jun 20, 2021
93a5573
ENABLED(SENSORLESS_PROBING) or ENABLED(SENSORLESS_HOMING)
lujios Jun 20, 2021
f22adf2
ENABLED(SENSORLESS_PROBING) or ENABLED(SENSORLESS_HOMING)
lujios Jun 20, 2021
6deb5e0
Update probe.h
lujios Jun 20, 2021
17c3421
Update probe.cpp
lujios Jun 20, 2021
fa3f66a
Update probe.cpp
lujios Jun 21, 2021
0afa0b0
Update probe.cpp
lujios Jun 21, 2021
e194686
Update probe.cpp
lujios Jun 21, 2021
cccbb23
Update probe.cpp
lujios Jun 21, 2021
6591021
Update probe.cpp
lujios Jun 21, 2021
3ef49e9
Update probe.cpp
lujios Jun 23, 2021
a5960b6
Update probe.cpp
lujios Jun 23, 2021
b39dcc0
Update probe.cpp
lujios Jun 23, 2021
ac1595f
Update probe.cpp
lujios Jun 23, 2021
5598406
Update probe.cpp
lujios Jun 23, 2021
7f8e424
Update tmc_util.h
lujios Jul 10, 2021
46a1943
Update probe.h
lujios Jul 10, 2021
0b04316
Update probe.cpp
lujios Jul 10, 2021
f92fdd2
Update G33.cpp
lujios Jul 10, 2021
181808c
Update planner.h
lujios Jul 10, 2021
e4477b0
Update endstops.cpp
lujios Jul 10, 2021
b8e6477
Update delta.cpp
lujios Jul 10, 2021
f7ee2a2
Update probe.cpp
lujios Jul 10, 2021
8318e7a
Update tmc_util.h
lujios Jul 10, 2021
2b66a40
Update tmc_util.h
lujios Jul 10, 2021
40bda0c
Update tmc_util.h
lujios Jul 10, 2021
a7aa0db
Update tmc_util.h
lujios Jul 10, 2021
3689e97
Update G33.cpp
lujios Jul 10, 2021
0edbd14
Update planner.h
lujios Jul 10, 2021
85015e9
Update planner.cpp
lujios Jul 10, 2021
8762770
Update G28.cpp
lujios Jul 10, 2021
4fa184b
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Jul 10, 2021
6ccff86
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/21899
thinkyhead Jul 12, 2021
db829ea
Use bitfields for test_sensitivity
thinkyhead Jul 12, 2021
fe218b7
motion_state_t
thinkyhead Jul 12, 2021
c1f837b
Tweak some SPI_ENDSTOPS code
thinkyhead Jul 12, 2021
01a7477
Fix warning
thinkyhead Jul 12, 2021
02cb940
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios Feb 25, 2022
b5e9597
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios Feb 25, 2022
d8aec11
Bug G28.cpp
lujios Feb 25, 2022
e41e9e8
Add files via upload
lujios Feb 25, 2022
5fcc713
Add files via upload
lujios Feb 25, 2022
c805c83
Add files via upload
lujios Feb 26, 2022
0a39a08
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Feb 27, 2022
9b75c39
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Feb 28, 2022
ebaca79
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Mar 2, 2022
94db3a3
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Mar 5, 2022
008dcb7
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios Apr 2, 2022
3e170de
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Apr 3, 2022
4138045
Limpiar código
lujios Apr 3, 2022
9e5a46e
Update
lujios Apr 3, 2022
88fce02
Add files via upload
lujios Apr 3, 2022
552c6a0
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Apr 6, 2022
c40982c
Mejora SENSORLESS_PROBING
lujios Apr 6, 2022
e3ff2cf
Add files via upload
lujios Apr 6, 2022
02dce40
Add files via upload
lujios Apr 6, 2022
6010e61
Update .gitignore
lujios Apr 6, 2022
7a7485c
🧑‍💻 Strip #errors in Configurations deployment
thinkyhead Apr 10, 2022
74871ac
Merge branch 'MarlinFirmware:bugfix-2.0.x' into bugfix-2.0.x
lujios Apr 10, 2022
188a979
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios Apr 18, 2022
386b210
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 11, 2022
b85a76c
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 14, 2022
3ee275b
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 17, 2022
d40fdfb
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 21, 2022
267eba6
Update endstops.cpp
lujios May 21, 2022
6fad327
Update Conditionals_adv.h
lujios May 21, 2022
643a308
Update G33.cpp
lujios May 21, 2022
d59a5f6
Update probe.cpp
lujios May 21, 2022
8b89b9a
Better delta sensorless homing/probing accuracy
thinkyhead May 22, 2022
49398e0
cleanup
thinkyhead May 21, 2022
4f41ce3
🩹 Adjust manage_media for slow/late media init (USB FD) (#24015)
robbycandra May 23, 2022
9b128c6
🚸 Firmware upload destination prompt (using Tk) (#24074)
ellensp May 23, 2022
65e38a8
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/24220
thinkyhead May 23, 2022
a15f80d
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into pr/24220
thinkyhead May 23, 2022
08af8a4
use the cond
thinkyhead May 24, 2022
20a4206
Merge branch 'bugfix-2.0.x' of https://github.com/lujios/Marlin into …
lujios May 24, 2022
9eafb1a
probe.cpp
lujios May 24, 2022
ff2e68e
Update G33.cpp
lujios May 24, 2022
a0e8023
Instability in tests.
lujios May 25, 2022
4708317
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 26, 2022
1352004
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 27, 2022
2ab62bf
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios May 29, 2022
91463d8
Merge remote-tracking branch 'upstream/bugfix-2.0.x' into bugfix-2.0.x
lujios Jun 1, 2022
254eef2
clean up
thinkyhead Jun 2, 2022
7de58b9
split up set versus refresh
thinkyhead Jun 3, 2022
e2e81c9
try a lambda
thinkyhead Jun 3, 2022
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: 2 additions & 0 deletions Marlin/src/gcode/calibrate/G28.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ void GcodeSuite::G28() {
stepperW.rms_current(W_CURRENT_HOME);
if (DEBUGGING(LEVELING)) debug_current(F(STR_W), tmc_save_current_W, W_CURRENT_HOME);
#endif
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle
#endif

#if ENABLED(IMPROVE_HOMING_RELIABILITY)
Expand Down Expand Up @@ -576,6 +577,7 @@ void GcodeSuite::G28() {
#if HAS_CURRENT_HOME(W)
stepperW.rms_current(tmc_save_current_W);
#endif
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle
#endif // HAS_HOMING_CURRENT

ui.refresh();
Expand Down
47 changes: 40 additions & 7 deletions Marlin/src/gcode/calibrate/G33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ float lcd_probe_pt(const xy_pos_t &xy);

void ac_home() {
endstops.enable(true);
TERN_(HAS_DELTA_SENSORLESS_PROBING, probe.set_homing_current(true));
TERN_(SENSORLESS_HOMING, endstops.set_homing_current(true));
home_delta();
TERN_(HAS_DELTA_SENSORLESS_PROBING, probe.set_homing_current(false));
TERN_(SENSORLESS_HOMING, endstops.set_homing_current(false));
endstops.not_homing();
}

Expand Down Expand Up @@ -390,6 +390,8 @@ static float auto_tune_a(const float dcr) {
* X Don't activate stallguard on X.
* Y Don't activate stallguard on Y.
* Z Don't activate stallguard on Z.
*
* S Save offset_sensorless_adj
*/
void GcodeSuite::G33() {

Expand All @@ -411,7 +413,8 @@ void GcodeSuite::G33() {
dcr -= probe_at_offset ? _MAX(total_offset, PROBING_MARGIN) : total_offset;
#endif
NOMORE(dcr, DELTA_PRINTABLE_RADIUS);
if (parser.seenval('R')) dcr -= _MAX(parser.value_float(),0);
if (parser.seenval('R')) dcr -= _MAX(parser.value_float(), 0.0f);
TERN_(HAS_DELTA_SENSORLESS_PROBING, dcr *= sensorless_radius_factor);

const float calibration_precision = parser.floatval('C', 0.0f);
if (calibration_precision < 0) {
Expand All @@ -434,9 +437,8 @@ void GcodeSuite::G33() {
const bool stow_after_each = parser.seen_test('E');

#if HAS_DELTA_SENSORLESS_PROBING
probe.test_sensitivity.x = !parser.seen_test('X');
TERN_(HAS_Y_AXIS, probe.test_sensitivity.y = !parser.seen_test('Y'));
TERN_(HAS_Z_AXIS, probe.test_sensitivity.z = !parser.seen_test('Z'));
probe.test_sensitivity.set(!parser.seen_test('X'), !parser.seen_test('Y'), !parser.seen_test('Z'));
const bool do_save_offset_adj = parser.seen_test('S');
#endif

const bool _0p_calibration = probe_points == 0,
Expand Down Expand Up @@ -475,6 +477,25 @@ void GcodeSuite::G33() {

if (!_0p_calibration) ac_home();

#if HAS_DELTA_SENSORLESS_PROBING
if (verbose_level > 0 && do_save_offset_adj) {
offset_sensorless_adj.reset();

auto caltower = [&](Probe::sense_bool_t s){
float z_at_pt[NPP + 1];
LOOP_CAL_ALL(rad) z_at_pt[rad] = 0.0f;
probe.test_sensitivity = s;
if (probe_calibration_points(z_at_pt, 1, dcr, false, false, probe_at_offset))
probe.set_offset_sensorless_adj(z_at_pt[CEN]);
};
caltower({ true, false, false }); // A
caltower({ false, true, false }); // B
caltower({ false, false, true }); // C

probe.test_sensitivity = { true, true, true }; // reset to all
}
#endif

do { // start iterations

float z_at_pt[NPP + 1] = { 0.0f };
Expand Down Expand Up @@ -598,8 +619,17 @@ void GcodeSuite::G33() {

// print report

if (verbose_level == 3 || verbose_level == 0)
if (verbose_level == 3 || verbose_level == 0) {
print_calibration_results(z_at_pt, _tower_results, _opposite_results);
#if HAS_DELTA_SENSORLESS_PROBING
if (verbose_level == 0 && probe_points == 1) {
if (do_save_offset_adj)
probe.set_offset_sensorless_adj(z_at_pt[CEN]);
else
probe.refresh_largest_sensorless_adj();
}
#endif
}

if (verbose_level != 0) { // !dry run
if ((zero_std_dev >= test_precision && iterations > force_iterations) || zero_std_dev <= calibration_precision) { // end iterations
Expand Down Expand Up @@ -660,6 +690,9 @@ void GcodeSuite::G33() {
ac_cleanup(TERN_(HAS_MULTI_HOTEND, old_tool_index));

TERN_(FULL_REPORT_TO_HOST_FEATURE, set_and_report_grblstate(M_IDLE));
#if HAS_DELTA_SENSORLESS_PROBING
probe.test_sensitivity = { true, true, true };
#endif
}

#endif // DELTA_AUTO_CALIBRATION
5 changes: 5 additions & 0 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1048,3 +1048,8 @@
#if ANY(DISABLE_INACTIVE_X, DISABLE_INACTIVE_Y, DISABLE_INACTIVE_Z, DISABLE_INACTIVE_I, DISABLE_INACTIVE_J, DISABLE_INACTIVE_K, DISABLE_INACTIVE_U, DISABLE_INACTIVE_V, DISABLE_INACTIVE_W, DISABLE_INACTIVE_E)
#define HAS_DISABLE_INACTIVE_AXIS 1
#endif

// Delay Sensorless Homing/Probing
#if EITHER(SENSORLESS_HOMING, SENSORLESS_PROBING) && !defined(SENSORLESS_STALLGUARD_DELAY)
#define SENSORLESS_STALLGUARD_DELAY 0
#endif
3 changes: 1 addition & 2 deletions Marlin/src/lcd/extui/dgus/mks/DGUSScreenHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
if (!ExtUI::isPrintingFromMedia()) return; // avoid race condition when user stays in this menu and printer finishes.
switch (swap16(*(uint16_t*)val_ptr)) {
case 0: { // Resume

auto cs = getCurrentScreen();
if (runout_mks.runout_status != RUNOUT_WAITING_STATUS && runout_mks.runout_status != UNRUNOUT_STATUS) {
if (cs == MKSLCD_SCREEN_PRINT || cs == MKSLCD_SCREEN_PAUSE)
Expand All @@ -213,7 +212,6 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
} break;

case 1: // Pause

GotoScreen(MKSLCD_SCREEN_PAUSE);
if (!ExtUI::isPrintingFromMediaPaused()) {
nozzle_park_mks.print_pause_start_flag = 1;
Expand All @@ -222,6 +220,7 @@ void DGUSScreenHandlerMKS::DGUSLCD_SendTMCStepValue(DGUS_VP_Variable &var) {
//ExtUI::mks_pausePrint();
}
break;

case 2: // Abort
HandleUserConfirmationPopUp(VP_SD_AbortPrintConfirmed, nullptr, PSTR("Abort printing"), filelist.filename(), PSTR("?"), true, true, false, true);
break;
Expand Down
8 changes: 7 additions & 1 deletion Marlin/src/lcd/menu/menu_delta_calibrate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@
#include "../extui/ui_api.h"
#endif

#if HAS_PROBE_XY_OFFSET
#include "../../module/probe.h"
#endif

void _man_probe_pt(const xy_pos_t &xy) {
if (!ui.wait_for_move) {
ui.wait_for_move = true;
Expand Down Expand Up @@ -88,7 +92,9 @@ void _man_probe_pt(const xy_pos_t &xy) {
}

void _goto_tower_a(const_float_t a) {
constexpr float dcr = DELTA_PRINTABLE_RADIUS;
float dcr = DELTA_PRINTABLE_RADIUS - PROBING_MARGIN;
TERN_(HAS_PROBE_XY_OFFSET, dcr -= HYPOT(probe.offset_xy.x, probe.offset_xy.y));
TERN_(HAS_DELTA_SENSORLESS_PROBING, dcr *= sensorless_radius_factor);
xy_pos_t tower_vec = { cos(RADIANS(a)), sin(RADIANS(a)) };
_man_probe_pt(tower_vec * dcr);
}
Expand Down
6 changes: 6 additions & 0 deletions Marlin/src/module/delta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ xy_float_t delta_tower[ABC];
abc_float_t delta_diagonal_rod_2_tower;
float delta_clip_start_height = Z_MAX_POS;
abc_float_t delta_diagonal_rod_trim;
#if HAS_DELTA_SENSORLESS_PROBING
abc_float_t offset_sensorless_adj{0};
float largest_sensorless_adj = 0;
#endif

float delta_safe_distance_from_top();

Expand Down Expand Up @@ -236,6 +240,7 @@ void home_delta() {
TERN_(U_SENSORLESS, sensorless_t stealth_states_u = start_sensorless_homing_per_axis(U_AXIS));
TERN_(V_SENSORLESS, sensorless_t stealth_states_v = start_sensorless_homing_per_axis(V_AXIS));
TERN_(W_SENSORLESS, sensorless_t stealth_states_w = start_sensorless_homing_per_axis(W_AXIS));
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle
#endif

// Move all carriages together linearly until an endstop is hit.
Expand All @@ -255,6 +260,7 @@ void home_delta() {
TERN_(U_SENSORLESS, end_sensorless_homing_per_axis(U_AXIS, stealth_states_u));
TERN_(V_SENSORLESS, end_sensorless_homing_per_axis(V_AXIS, stealth_states_v));
TERN_(W_SENSORLESS, end_sensorless_homing_per_axis(W_AXIS, stealth_states_w));
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle
#endif

endstops.validate_homing_move();
Expand Down
11 changes: 11 additions & 0 deletions Marlin/src/module/delta.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,24 @@ extern xy_float_t delta_tower[ABC];
extern abc_float_t delta_diagonal_rod_2_tower;
extern float delta_clip_start_height;
extern abc_float_t delta_diagonal_rod_trim;
#if HAS_DELTA_SENSORLESS_PROBING
extern abc_float_t offset_sensorless_adj;
extern float largest_sensorless_adj;
#endif

/**
* Recalculate factors used for delta kinematics whenever
* settings have been changed (e.g., by M665).
*/
void recalc_delta_settings();

/**
* Get a safe radius for calibration
*/
#if HAS_DELTA_SENSORLESS_PROBING
static constexpr float sensorless_radius_factor = 0.7f;
#endif

/**
* Delta Inverse Kinematics
*
Expand Down
63 changes: 63 additions & 0 deletions Marlin/src/module/endstops.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
#include "temperature.h"
#include "../lcd/marlinui.h"

#define DEBUG_OUT BOTH(USE_SENSORLESS, DEBUG_LEVELING_FEATURE)
#include "../core/debug_out.h"

#if ENABLED(ENDSTOP_INTERRUPTS_FEATURE)
#include HAL_PATH(../HAL, endstop_interrupts.h)
#endif
Expand Down Expand Up @@ -1621,3 +1624,63 @@ void Endstops::update() {
}

#endif // PINS_DEBUGGING

#if USE_SENSORLESS
/**
* Change TMC driver currents to N##_CURRENT_HOME, saving the current configuration of each.
*/
void Endstops::set_homing_current(const bool onoff) {
#define HAS_CURRENT_HOME(N) (defined(N##_CURRENT_HOME) && N##_CURRENT_HOME != N##_CURRENT)
#define HAS_DELTA_X_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(X))
#define HAS_DELTA_Y_CURRENT (ENABLED(DELTA) && HAS_CURRENT_HOME(Y))
#if HAS_DELTA_X_CURRENT || HAS_DELTA_Y_CURRENT || HAS_CURRENT_HOME(Z)
#if HAS_DELTA_X_CURRENT
static int16_t saved_current_x;
#endif
#if HAS_DELTA_Y_CURRENT
static int16_t saved_current_y;
#endif
#if HAS_CURRENT_HOME(Z)
static int16_t saved_current_z;
#endif
auto debug_current_on = [](PGM_P const s, const int16_t a, const int16_t b) {
if (DEBUGGING(LEVELING)) { DEBUG_ECHOPGM_P(s); DEBUG_ECHOLNPGM(" current: ", a, " -> ", b); }
};
if (onoff) {
#if HAS_DELTA_X_CURRENT
saved_current_x = stepperX.getMilliamps();
stepperX.rms_current(X_CURRENT_HOME);
debug_current_on(PSTR("X"), saved_current_x, X_CURRENT_HOME);
#endif
#if HAS_DELTA_Y_CURRENT
saved_current_y = stepperY.getMilliamps();
stepperY.rms_current(Y_CURRENT_HOME);
debug_current_on(PSTR("Y"), saved_current_y, Y_CURRENT_HOME);
#endif
#if HAS_CURRENT_HOME(Z)
saved_current_z = stepperZ.getMilliamps();
stepperZ.rms_current(Z_CURRENT_HOME);
debug_current_on(PSTR("Z"), saved_current_z, Z_CURRENT_HOME);
#endif
}
else {
#if HAS_DELTA_X_CURRENT
stepperX.rms_current(saved_current_x);
debug_current_on(PSTR("X"), X_CURRENT_HOME, saved_current_x);
#endif
#if HAS_DELTA_Y_CURRENT
stepperY.rms_current(saved_current_y);
debug_current_on(PSTR("Y"), Y_CURRENT_HOME, saved_current_y);
#endif
#if HAS_CURRENT_HOME(Z)
stepperZ.rms_current(saved_current_z);
debug_current_on(PSTR("Z"), Z_CURRENT_HOME, saved_current_z);
#endif
}

TERN_(IMPROVE_HOMING_RELIABILITY, planner.enable_stall_prevention(onoff));
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle

#endif // XYZ
}
#endif
5 changes: 5 additions & 0 deletions Marlin/src/module/endstops.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ class Endstops {
static void clear_endstop_state();
static bool tmc_spi_homing_check();
#endif
public:
// Basic functions for Sensorless Homing
#if USE_SENSORLESS
static void set_homing_current(const bool onoff);
#endif
};

extern Endstops endstops;
Expand Down
10 changes: 8 additions & 2 deletions Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,7 +1663,10 @@ void prepare_line_to_destination() {
}

// Disable stealthChop if used. Enable diag1 pin on driver.
TERN_(SENSORLESS_HOMING, stealth_states = start_sensorless_homing_per_axis(axis));
#if ENABLED(SENSORLESS_HOMING)
stealth_states = start_sensorless_homing_per_axis(axis);
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle
#endif
}

#if EITHER(MORGAN_SCARA, MP_SCARA)
Expand Down Expand Up @@ -1699,7 +1702,10 @@ void prepare_line_to_destination() {
endstops.validate_homing_move();

// Re-enable stealthChop if used. Disable diag1 pin on driver.
TERN_(SENSORLESS_HOMING, end_sensorless_homing_per_axis(axis, stealth_states));
#if ENABLED(SENSORLESS_HOMING)
end_sensorless_homing_per_axis(axis, stealth_states);
safe_delay(SENSORLESS_STALLGUARD_DELAY); // Short delay needed to settle
#endif
}
}

Expand Down
5 changes: 1 addition & 4 deletions Marlin/src/module/planner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1663,10 +1663,7 @@ void Planner::quick_stop() {
// forced to empty, there's no risk the ISR will touch this.
delay_before_delivering = BLOCK_DELAY_FOR_1ST_MOVE;

#if HAS_WIRED_LCD
// Clear the accumulated runtime
clear_block_buffer_runtime();
#endif
TERN_(HAS_WIRED_LCD, clear_block_buffer_runtime()); // Clear the accumulated runtime

// Make sure to drop any attempt of queuing moves for 1 second
cleaning_buffer_counter = TEMP_TIMER_FREQUENCY;
Expand Down
Loading