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

Sensorless home sanity check #23250

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1a866bd
add flag for home sanity check
Dec 2, 2021
e145976
calculate sanity check on homing routines
Dec 2, 2021
09d193b
simplify time keeping, move const variables to function scope
Dec 2, 2021
9da13ae
even more correct types
Dec 2, 2021
89ea7e7
use more user defined constants in calculation
Dec 2, 2021
c1ffd85
account for different homing direction in home sanity check
Dec 6, 2021
3a7a13c
cleanup
thinkyhead Dec 8, 2021
3f99193
Merge 'bugfix-2.0.x' into pr/23250
thinkyhead Dec 15, 2021
6bd4f25
update, add test
thinkyhead Dec 15, 2021
b607657
Merge branch 'bugfix-2.0.x' into pr/23250
thinkyhead Apr 24, 2022
1a26a59
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Jun 4, 2022
5d7bd37
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Mar 18, 2023
e946a7c
tweaks
thinkyhead Mar 18, 2023
03353bc
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead May 10, 2023
18c7a54
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Jun 2, 2023
182b05e
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Jun 2, 2023
6a24372
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Jun 21, 2023
1aee523
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Aug 3, 2023
29ba27b
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Oct 25, 2023
c49d0fc
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Dec 24, 2023
f558a16
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead Jan 22, 2024
4b9b7ad
merge followup
thinkyhead Jan 22, 2024
f215113
Merge branch 'bugfix-2.1.x' into pr/23250
thinkyhead May 6, 2024
c4d3399
Merge 'bugfix-2.1.x' into pr/23250
thinkyhead Sep 21, 2024
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
7 changes: 7 additions & 0 deletions Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -3451,6 +3451,13 @@
//#define W_STALL_SENSITIVITY 8
//#define SPI_ENDSTOPS // TMC2130/TMC5160 only
//#define IMPROVE_HOMING_RELIABILITY

// When homing a "trusted" axis, verify Stallguard results by timing the move
//#define SENSORLESS_HOMING_VALIDATION
#if ENABLED(SENSORLESS_HOMING_VALIDATION)
#define SHV_STARTUP_COMPENSATION 200 // (ms)
#define SHV_ERROR_MARGIN 50 // (mm)
#endif
#endif

// @section tmc/config
Expand Down
33 changes: 32 additions & 1 deletion Marlin/src/module/motion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2436,8 +2436,30 @@ void prepare_line_to_destination() {
const bool is_home_dir = (axis_home_dir > 0) == (distance > 0);

#if ENABLED(SENSORLESS_HOMING)

sensorless_t stealth_states;
#endif

#if ENABLED(SENSORLESS_HOMING_VALIDATION)

static float expected_distance = 0; // Known coordinates after homing routine sets to 0

if (is_home_dir) {
// Sensorless homing moves by a backoff. This accounts for that distance.
expected_distance += -axis_home_dir * planner.get_axis_position_mm(axis);
}
else {
// In Stallguard context, a backoff distance is done first,
// so this is where the expected printer position is captured.
const float axis_pos = planner.get_axis_position_mm(axis),
expected_distance = axis_home_dir > 0 ? (base_max_pos(axis) - axis_pos) : (base_min_pos(axis) + axis_pos);
}

const millis_t time_to_stop = static_cast<millis_t>((expected_distance / home_fr_mm_s) * 1000.0f),
expected_stop_time = millis() + time_to_stop + SHV_STARTUP_COMPENSATION;

#endif

#endif // SENSORLESS_HOMING

if (is_home_dir) {

Expand Down Expand Up @@ -2490,6 +2512,15 @@ void prepare_line_to_destination() {

if (is_home_dir) {

#if ENABLED(SENSORLESS_HOMING_VALIDATION)
const int32_t time_delta = static_cast<int32_t>(millis() - expected_stop_time);
const bool bad_home = !WITHIN(time_delta, -SHV_ERROR_MARGIN, SHV_ERROR_MARGIN);
if (DEBUGGING(INFO))
SERIAL_ECHOLNPGM("Axis:", C(AXIS_CHAR(axis)), " Distance:", expected_distance, " Feedrate:", home_fr_mm_s, " Expected stop time:", time_to_stop, " Difference:", time_delta);
if (DEBUGGING(ERRORS) && bad_home)
SERIAL_ECHOLNPGM("Homing fault! Time difference: ", time_delta, ", Axis: ", C(AXIS_CHAR(axis)));
#endif

#if HOMING_Z_WITH_PROBE && HAS_QUIET_PROBING
if (axis == Z_AXIS && final_approach) probe.set_probing_paused(false);
#endif
Expand Down
2 changes: 1 addition & 1 deletion buildroot/tests/teensy35
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ opt_set MOTHERBOARD BOARD_TEENSY35_36 \
X_CURRENT_HOME 750 Y_CURRENT_HOME 750 \
X_MIN_ENDSTOP_HIT_STATE LOW Y_MIN_ENDSTOP_HIT_STATE LOW \
X_CS_PIN 46 Y_CS_PIN 47
opt_enable COREXY MONITOR_DRIVER_STATUS SENSORLESS_HOMING X_STALL_SENSITIVITY Y_STALL_SENSITIVITY
opt_enable COREXY MONITOR_DRIVER_STATUS SENSORLESS_HOMING SENSORLESS_HOMING_VALIDATION X_STALL_SENSITIVITY Y_STALL_SENSITIVITY
exec_test $1 $2 "Teensy 3.5/3.6 COREXY" "$3"

#
Expand Down
Loading