static stat_t _homing_axis_search(int8_t axis) // start the search { ritorno(_verify_position(axis)); cm.a[axis].jerk_max = cm.a[axis].jerk_homing; // use the homing jerk for search onward _homing_axis_move(axis, hm.search_travel, hm.search_velocity); return (_set_homing_func(_homing_axis_latch)); }
// Handle an initial switch closure by backing off switches // NOTE: Relies on independent switches per axis (not shared) static stat_t _homing_axis_clear(int8_t axis) // first clear move { //+++++ int8_t homing = read_switch(hm.homing_switch); //+++++ int8_t limit = read_switch(hm.limit_switch); int8_t homing = SW_OPEN; //+++++ int8_t limit = SW_OPEN; //+++++ if ((homing == SW_OPEN) && (limit != SW_CLOSED)) { return (_set_homing_func(_homing_axis_search)); // OK to start the search } if (homing == SW_CLOSED) { _homing_axis_move(axis, hm.latch_backoff, hm.search_velocity); return (_set_homing_func(_homing_axis_backoff_home));// will backoff homing switch some more } _homing_axis_move(axis, -hm.latch_backoff, hm.search_velocity); return (_set_homing_func(_homing_axis_backoff_limit)); // will backoff limit switch some more }
// Handle an initial switch closure by backing off the closed switch // NOTE: Relies on independent switches per axis (not shared) static stat_t _homing_axis_clear(int8_t axis) // first clear move { #ifndef __NEW_SWITCHES if (read_switch(hm.homing_switch) == SW_CLOSED) { _homing_axis_move(axis, hm.latch_backoff, hm.search_velocity); } else if (read_switch(hm.limit_switch) == SW_CLOSED) { _homing_axis_move(axis, -hm.latch_backoff, hm.search_velocity); } else { // no move needed, so target position is same as current position hm.target_position = cm_get_absolute_position(MODEL, axis); } #else if (read_switch(hm.homing_switch_axis, hm.homing_switch_position) == SW_CLOSED) { _homing_axis_move(axis, hm.latch_backoff, hm.search_velocity); } else if (read_switch(hm.limit_switch_axis, hm.limit_switch_position) == SW_CLOSED) { _homing_axis_move(axis, -hm.latch_backoff, hm.search_velocity); } else { // no move needed, so target position is same as current position hm.target_position = cm_get_absolute_position(MODEL, axis); } #endif return (_set_homing_func(_homing_axis_search)); }
static stat_t _homing_axis_latch(int8_t axis) // latch to switch open { /* // Removed this code section because if a NO homing switch opens before the // search deceleration is complete the switch will (correctly) be open. // Therefore the homing cycle should continue -- ASH (build 445.01) // // Still need to figure out how to tell the difference between a rapid switch opening // condition (above) and a user- initiated feedhold during a homing operation. // verify assumption that we arrived here because of homing switch closure // rather than user-initiated feedhold or other disruption #ifndef __NEW_SWITCHES if (read_switch(hm.homing_switch) != SW_CLOSED) return (_set_homing_func(_homing_abort)); #else if (read_switch(hm.homing_switch_axis, hm.homing_switch_position) != SW_CLOSED) return (_set_homing_func(_homing_abort)); #endif */ _homing_axis_move(axis, hm.latch_backoff, hm.latch_velocity); return (_set_homing_func(_homing_axis_zero_backoff)); }
static stat_t _homing_axis_zero_backoff(int8_t axis) // backoff to zero position { _homing_axis_move(axis, hm.zero_backoff, hm.search_velocity); return (_set_homing_func(_homing_axis_set_zero)); }
static stat_t _homing_axis_latch(int8_t axis) // latch to switch open { _homing_axis_move(axis, hm.latch_backoff, hm.latch_velocity); return (_set_homing_func(_homing_axis_zero_backoff)); }
static stat_t _homing_axis_backoff_limit(int8_t axis) // back off cleared limit switch { _homing_axis_move(axis, -hm.latch_backoff, hm.search_velocity); return (_set_homing_func(_homing_axis_search)); }