I still do not really get, what you are up to and the macro seems not suited to achieve proper homing.
I’d suggest the following approach:
- Delete all homing related items from your config, e.g. the above macro, homing overrides, safe z home etc.
- Replace them with the following code:
# Global Variables sensorless homing
[gcode_macro global]
variable_xy_run_current: 0.8
variable_xy_home_current: 0.6
gcode: #intentionally left empty
#### Homing macros for sensorless homing
[gcode_macro _HOME_X]
gcode:
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro global"].xy_home_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro global"].xy_home_current}
# Wait for StallGuard registers to clear
G4 P500
G28 X
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro global"].xy_run_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro global"].xy_run_current}
G91
# Back-off a little
G1 X15 F1200
[gcode_macro _HOME_Y]
gcode:
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro global"].xy_home_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro global"].xy_home_current}
# Wait for StallGuard registers to clear
G4 P500
G28 Y
SET_TMC_CURRENT STEPPER=stepper_x CURRENT={printer["gcode_macro global"].xy_run_current}
SET_TMC_CURRENT STEPPER=stepper_y CURRENT={printer["gcode_macro global"].xy_run_current}
G91
# Back-off a little
G1 Y-15 F1200
[homing_override]
axes: xyz
gcode:
{% set home_all = 'X' not in params and 'Y' not in params and 'Z' not in params %}
# Set a preliminary z-position and get some z-headroom
# Make sure the bed is not fully at z-max
# May or may not be needed
SET_KINEMATIC_POSITION Z=0
G1 Z4 F1200
{% if home_all or 'X' in params %}
_HOME_X
{% endif %}
{% if home_all or 'Y' in params %}
_HOME_Y
{% endif %}
{% if home_all or 'Z' in params %}
G90
G1 X150 Y150 F1200 # <-------- set this to the middle of your bed
G28 Z
G1 Z10 F1200
{% endif %}
Observe the comments and set the values according to your needs.
When it does not work, post a klippy.log