Skip to content

Commit 168a470

Browse files
committed
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.
1 parent 057ecf6 commit 168a470

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

src/emc/motion/homing.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ typedef struct {
111111
bool homed; // OUT pin
112112
bool home_sw; // IN pin
113113
bool index_enable; // IO pin
114+
bool index_enable_prev; // last value driven onto index_enable pin
114115
bool joint_in_sequence;
115116
int pause_timer;
116117
double home_offset; // intfc, updateable
@@ -559,7 +560,16 @@ static void base_write_homing_out_pins(int njoints)
559560
*(addr->homing) = H[jno].homing; // OUT
560561
*(addr->homed) = H[jno].homed; // OUT
561562
*(addr->home_state) = H[jno].home_state; // OUT
562-
*(addr->index_enable) = H[jno].index_enable; // IO
563+
// index_enable is a HAL_IO pin: the encoder driver also writes it
564+
// (clears it on the index pulse). We do not own it, so we must not
565+
// clamp it every cycle; drive it only on our own edges and otherwise
566+
// leave it to whoever else is on the signal.
567+
if (H[jno].index_enable && !H[jno].index_enable_prev) {
568+
*(addr->index_enable) = 1; // arm the index search
569+
} else if (!H[jno].index_enable && H[jno].index_enable_prev) {
570+
*(addr->index_enable) = 0; // release if aborted while armed
571+
}
572+
H[jno].index_enable_prev = H[jno].index_enable;
563573
}
564574
}
565575

0 commit comments

Comments
 (0)