Skip to content

Commit a0e958a

Browse files
authored
Add option to ignore endstops during encoder index search
This is useful for devices where the endstop is pressed while power is off, due to gravity, springs, or otherwise. When combined with odriverobotics#747, this allows the ODrive to start up the motors and perform the encoder index search while one of the endstops is pressed. With this setting enabled, the limit switch will not cause the motor to disarm during the encoder index search, making the `odrive.axis*.config.startup_encoder_index_search` flag useful again.
1 parent c594b67 commit a0e958a

3 files changed

Lines changed: 4 additions & 2 deletions

File tree

Firmware/MotorControl/axis.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,9 @@ bool Axis::do_checks(uint32_t timestamp) {
153153
motor_.do_checks(timestamp);
154154

155155
// Check for endstop presses
156-
if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED)) {
156+
if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED) && !(min_endstop_.config_.ignore_during_encoder_index_search && current_state_ == AXIS_STATE_ENCODER_INDEX_SEARCH)) {
157157
error_ |= ERROR_MIN_ENDSTOP_PRESSED;
158-
} else if (max_endstop_.config_.enabled && max_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(max_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED)) {
158+
} else if (max_endstop_.config_.enabled && max_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(max_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED) && !(min_endstop_.config_.ignore_during_encoder_index_search && current_state_ == AXIS_STATE_ENCODER_INDEX_SEARCH)) {
159159
error_ |= ERROR_MAX_ENDSTOP_PRESSED;
160160
}
161161

Firmware/MotorControl/endstop.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ class Endstop {
1111
bool enabled = false;
1212
bool is_active_high = false;
1313
bool ignore_during_startup = false;
14+
bool ignore_during_encoder_index_search = false;
1415

1516
// custom setters
1617
Endstop* parent = nullptr;

Firmware/odrive-interface.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,7 @@ interfaces:
14101410
offset: {type: float32, unit: turns}
14111411
is_active_high: bool
14121412
ignore_during_startup: bool
1413+
ignore_during_encoder_index_search: bool
14131414
debounce_ms: {type: uint32, c_setter: set_debounce_ms}
14141415

14151416
ODrive.MechanicalBrake:

0 commit comments

Comments
 (0)