From c594b67c53cc059fdbd1f569f1a06221348b1db8 Mon Sep 17 00:00:00 2001 From: Aaron Tulino <13600347+aaronjamt@users.noreply.github.com> Date: Wed, 22 May 2024 21:49:43 -0700 Subject: [PATCH 1/5] Add option to ignore endstops during startup This is useful for devices where the endstop is pressed while power is off, due to gravity, springs, or otherwise. When the ODrive initially starts up, it sees the limit switch(es) pressed and disarms the motor(s) immediately. With this setting enabled, the limit switch will not cause the motor to disarm during inital startup, making the `odrive.axis*.config.startup_*` flags useful again. --- Firmware/MotorControl/axis.cpp | 4 ++-- Firmware/MotorControl/endstop.hpp | 1 + Firmware/odrive-interface.yaml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index 03735ce0d..fd830c593 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -153,9 +153,9 @@ bool Axis::do_checks(uint32_t timestamp) { motor_.do_checks(timestamp); // Check for endstop presses - if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING)) { + if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED)) { error_ |= ERROR_MIN_ENDSTOP_PRESSED; - } else if (max_endstop_.config_.enabled && max_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING)) { + } 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)) { error_ |= ERROR_MAX_ENDSTOP_PRESSED; } diff --git a/Firmware/MotorControl/endstop.hpp b/Firmware/MotorControl/endstop.hpp index 21a640c27..2df8cba31 100644 --- a/Firmware/MotorControl/endstop.hpp +++ b/Firmware/MotorControl/endstop.hpp @@ -10,6 +10,7 @@ class Endstop { uint16_t gpio_num = 0; bool enabled = false; bool is_active_high = false; + bool ignore_during_startup = false; // custom setters Endstop* parent = nullptr; diff --git a/Firmware/odrive-interface.yaml b/Firmware/odrive-interface.yaml index 34cb09d06..3d2d717d8 100644 --- a/Firmware/odrive-interface.yaml +++ b/Firmware/odrive-interface.yaml @@ -1409,6 +1409,7 @@ interfaces: enabled: {type: bool, c_setter: set_enabled} offset: {type: float32, unit: turns} is_active_high: bool + ignore_during_startup: bool debounce_ms: {type: uint32, c_setter: set_debounce_ms} ODrive.MechanicalBrake: From 304a22adf6d9098b7a87eff6021953be39302bb4 Mon Sep 17 00:00:00 2001 From: Aaron Tulino <13600347+aaronjamt@users.noreply.github.com> Date: Thu, 23 May 2024 13:06:47 -0700 Subject: [PATCH 2/5] x --- Firmware/MotorControl/axis.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index fd830c593..b45f51adf 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -154,6 +154,7 @@ bool Axis::do_checks(uint32_t timestamp) { // Check for endstop presses if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED)) { + if (current_state_ == AXIS_STATE_ENCODER_INDEX_SEARCH) error_ |= ERROR_MAX_ENDSTOP_PRESSED; error_ |= ERROR_MIN_ENDSTOP_PRESSED; } 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)) { error_ |= ERROR_MAX_ENDSTOP_PRESSED; From 41d3c8760cafa35f673e3e7833a1d9d0ba802ef1 Mon Sep 17 00:00:00 2001 From: Aaron Tulino <13600347+aaronjamt@users.noreply.github.com> Date: Thu, 23 May 2024 13:09:07 -0700 Subject: [PATCH 3/5] Update firmware.yaml --- .github/workflows/firmware.yaml | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/.github/workflows/firmware.yaml b/.github/workflows/firmware.yaml index 5f73efd65..1a7fa2757 100644 --- a/.github/workflows/firmware.yaml +++ b/.github/workflows/firmware.yaml @@ -12,20 +12,10 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-latest, windows-latest, macOS-latest] + os: [ubuntu-latest] board_version: [v3.6-56V] - debug: [true] - - include: - - {os: ubuntu-latest, board_version: v3.2, debug: false} - - {os: ubuntu-latest, board_version: v3.3, debug: false} - - {os: ubuntu-latest, board_version: v3.4-24V, debug: false} - - {os: ubuntu-latest, board_version: v3.4-48V, debug: false} - - {os: ubuntu-latest, board_version: v3.5-24V, debug: false} - - {os: ubuntu-latest, board_version: v3.5-48V, debug: false} - - {os: ubuntu-latest, board_version: v3.6-24V, debug: false} - - {os: ubuntu-latest, board_version: v3.6-56V, debug: false} - + debug: [false] + runs-on: ${{ matrix.os }} outputs: channel: ${{ steps.release-info.outputs.channel }} From 93681757b1c79fdaa6a6994bf6d14f228fd6db41 Mon Sep 17 00:00:00 2001 From: Aaron Tulino <13600347+aaronjamt@users.noreply.github.com> Date: Thu, 23 May 2024 13:22:25 -0700 Subject: [PATCH 4/5] x --- Firmware/MotorControl/axis.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index b45f51adf..5e6663b51 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -153,10 +153,9 @@ bool Axis::do_checks(uint32_t timestamp) { motor_.do_checks(timestamp); // Check for endstop presses - if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED)) { - if (current_state_ == AXIS_STATE_ENCODER_INDEX_SEARCH) error_ |= ERROR_MAX_ENDSTOP_PRESSED; + if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED) && !(config_.startup_encoder_index_search && current_state_ == AXIS_STATE_ENCODER_INDEX_SEARCH)) { error_ |= ERROR_MIN_ENDSTOP_PRESSED; - } 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)) { + } 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) && !(config_.startup_encoder_index_search && current_state_ == AXIS_STATE_ENCODER_INDEX_SEARCH)) { error_ |= ERROR_MAX_ENDSTOP_PRESSED; } From a0e958ac7f7bb0948da8462b198c3f9b4ce95301 Mon Sep 17 00:00:00 2001 From: Aaron Tulino <13600347+aaronjamt@users.noreply.github.com> Date: Thu, 23 May 2024 13:50:06 -0700 Subject: [PATCH 5/5] 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 #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. --- Firmware/MotorControl/axis.cpp | 4 ++-- Firmware/MotorControl/endstop.hpp | 1 + Firmware/odrive-interface.yaml | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Firmware/MotorControl/axis.cpp b/Firmware/MotorControl/axis.cpp index fd830c593..f0d8e362d 100644 --- a/Firmware/MotorControl/axis.cpp +++ b/Firmware/MotorControl/axis.cpp @@ -153,9 +153,9 @@ bool Axis::do_checks(uint32_t timestamp) { motor_.do_checks(timestamp); // Check for endstop presses - if (min_endstop_.config_.enabled && min_endstop_.rose() && !(current_state_ == AXIS_STATE_HOMING) && !(min_endstop_.config_.ignore_during_startup && current_state_ == AXIS_STATE_UNDEFINED)) { + 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)) { error_ |= ERROR_MIN_ENDSTOP_PRESSED; - } 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)) { + } 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)) { error_ |= ERROR_MAX_ENDSTOP_PRESSED; } diff --git a/Firmware/MotorControl/endstop.hpp b/Firmware/MotorControl/endstop.hpp index 2df8cba31..b3a6018b1 100644 --- a/Firmware/MotorControl/endstop.hpp +++ b/Firmware/MotorControl/endstop.hpp @@ -11,6 +11,7 @@ class Endstop { bool enabled = false; bool is_active_high = false; bool ignore_during_startup = false; + bool ignore_during_encoder_index_search = false; // custom setters Endstop* parent = nullptr; diff --git a/Firmware/odrive-interface.yaml b/Firmware/odrive-interface.yaml index 3d2d717d8..be98dba1a 100644 --- a/Firmware/odrive-interface.yaml +++ b/Firmware/odrive-interface.yaml @@ -1410,6 +1410,7 @@ interfaces: offset: {type: float32, unit: turns} is_active_high: bool ignore_during_startup: bool + ignore_during_encoder_index_search: bool debounce_ms: {type: uint32, c_setter: set_debounce_ms} ODrive.MechanicalBrake: