Skip to content

Commit 1db4ebe

Browse files
authored
Merge pull request #4200 from grandixximo/fix/joint-index-enable-edge
motion: drive joint.N.index-enable only on edges (fix #3556)
2 parents 057ecf6 + 168a470 commit 1db4ebe

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)