File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments