Skip to content

position sync when hardware endstops are hit#28388

Open
DerAndere1 wants to merge 1 commit into
MarlinFirmware:bugfix-2.1.xfrom
DerAndere1:fix_hw_endstop
Open

position sync when hardware endstops are hit#28388
DerAndere1 wants to merge 1 commit into
MarlinFirmware:bugfix-2.1.xfrom
DerAndere1:fix_hw_endstop

Conversation

@DerAndere1
Copy link
Copy Markdown
Contributor

@DerAndere1 DerAndere1 commented Apr 12, 2026

Description

Position was corrupted after trying to move beyond enabled hardware endstops. Repeated move commands beyond the hardware endstop were still stopped, but position stayed corrupted. When later move commands continued motion within axis limits. that caused wrong toolhead positions in real life. If one axis end had no endstops, this could lead to a crash.

Steps to reproduce:

; limit switch at Z_MAX_POS = 255
G28
M211 S0 ; disable soft endstops
M121; disable hardware endstops
G1 X10 Y10 Z6 ; move within axis limits
M120; ensable hardware endstops
G1 Z258; motion stops at Z_MAX_POS 255
M114; Shows Z258
G1 Z6; observe nozzle is 3 mm above bed
M114; Shows Z6

With this fix: When moving into a hardware endstop, motion.position is set to the axis limit (e.g. Z_MIN_POS or Z_MAX_POS) to keep position synchronized with actual nozzle position. I still prefer the alternative solution to call kill() when hitting any endstop (hardware or software) because such an event means that positions are wrong, either due to user error or due to a firmware bug.

Requirements

none. The bug could happen with any config, but occurance is propably higher / more obvious with one or more of these:

#define Z_HOME_DIR 1
//#define USE_PROBE_FOR_Z_HOMING // disabled
#define ENDSTOPS_ALWAYS_ON_DEFAULT
//#define ENABLE_LEVELING_FADE_HEIGHT // disabled

Benefits

less risk of wrong positions and crashes

Configurations

https://github.com/DerAndere1/Marlin2ForPipetBot/tree/Marlin2ForPipetBot/config/examples/DerAndere/bugfix_test

Related Issues

Possibly some of the reported issues dealing with wrong "z-offset", and problems with bed leveling compensation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant