From 388db0f32e7c59f6a903735e97aef6520c0434b4 Mon Sep 17 00:00:00 2001 From: Luca Toniolo <10792599+grandixximo@users.noreply.github.com> Date: Fri, 26 Jun 2026 21:48:20 +0800 Subject: [PATCH] motion: drive joint.N.index-enable only on edges joint.N.index-enable is a HAL_IO pin: homing writes 1 to arm an index search, the encoder driver writes 0 to clear it on the index pulse. base_write_homing_out_pins wrote it every servo cycle, clamping a pin homing does not exclusively own and holding it low after homing finished. That fights any other writer on the signal. Netting it to spindle.N.index-enable breaks G33/G33.1: idle homing overwrites the spindle's sync request low and the move rapids instead of waiting for the index. Drive the pin only on homing's own edges (arm on rising, release on falling) and otherwise leave it for the encoder to clear. --- src/emc/motion/homing.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/emc/motion/homing.c b/src/emc/motion/homing.c index 13f74f43a11..050ed612c13 100644 --- a/src/emc/motion/homing.c +++ b/src/emc/motion/homing.c @@ -110,6 +110,7 @@ typedef struct { bool homed; // OUT pin bool home_sw; // IN pin bool index_enable; // IO pin + bool index_enable_prev; // last value driven onto index_enable pin bool joint_in_sequence; int pause_timer; double home_offset; // intfc, updateable @@ -546,7 +547,16 @@ static void base_write_homing_out_pins(int njoints) *(addr->homing) = H[jno].homing; // OUT *(addr->homed) = H[jno].homed; // OUT *(addr->home_state) = H[jno].home_state; // OUT - *(addr->index_enable) = H[jno].index_enable; // IO + // index_enable is a HAL_IO pin: the encoder driver also writes it + // (clears it on the index pulse). We do not own it, so we must not + // clamp it every cycle; drive it only on our own edges and otherwise + // leave it to whoever else is on the signal. + if (H[jno].index_enable && !H[jno].index_enable_prev) { + *(addr->index_enable) = 1; // arm the index search + } else if (!H[jno].index_enable && H[jno].index_enable_prev) { + *(addr->index_enable) = 0; // release if aborted while armed + } + H[jno].index_enable_prev = H[jno].index_enable; } }