From d8ed0fad92b5ffe1cc3c01d4fcee78c713fb6f76 Mon Sep 17 00:00:00 2001 From: ahiuchingau <20424172+ahiuchingau@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:34:17 -0500 Subject: [PATCH] update tpowerdown and hold current delay --- .../flex-stacker/flex-stacker/motor_driver_task.hpp | 9 ++++++--- .../flex-stacker/flex-stacker/tmc2160_registers.hpp | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/stm32-modules/include/flex-stacker/flex-stacker/motor_driver_task.hpp b/stm32-modules/include/flex-stacker/flex-stacker/motor_driver_task.hpp index dc156a056..82ca48d81 100644 --- a/stm32-modules/include/flex-stacker/flex-stacker/motor_driver_task.hpp +++ b/stm32-modules/include/flex-stacker/flex-stacker/motor_driver_task.hpp @@ -35,7 +35,8 @@ static constexpr tmc2160::TMC2160RegisterMap motor_z_config{ .glob_scale = {.global_scaler = 0x0}, .ihold_irun = {.hold_current = 10, .run_current = 31, - .hold_current_delay = 15}, + .hold_current_delay = 1}, + .tpowerdown = {.time = tmc2160::PowerDownDelay::seconds_to_reg(0.1)}, .tpwmthrs = {.threshold = 0x80000}, .tcoolthrs = {.threshold = 0x2FF}, .thigh = {.threshold = 0x1}, @@ -63,7 +64,8 @@ static constexpr tmc2160::TMC2160RegisterMap motor_x_config{ .glob_scale = {.global_scaler = 0x0}, .ihold_irun = {.hold_current = 12, .run_current = 31, - .hold_current_delay = 7}, + .hold_current_delay = 1}, + .tpowerdown = {.time = tmc2160::PowerDownDelay::seconds_to_reg(0.1)}, .tpwmthrs = {.threshold = 0x80000}, .tcoolthrs = {.threshold = 0x2FF}, .thigh = {.threshold = 0x1}, @@ -91,7 +93,8 @@ static constexpr tmc2160::TMC2160RegisterMap motor_l_config{ .glob_scale = {.global_scaler = 0x0}, .ihold_irun = {.hold_current = 7, .run_current = 8, - .hold_current_delay = 7}, + .hold_current_delay = 1}, + .tpowerdown = {.time = tmc2160::PowerDownDelay::seconds_to_reg(0.1)}, .tpwmthrs = {.threshold = 0x80000}, .tcoolthrs = {.threshold = 0x2FF}, .thigh = {.threshold = 0x1}, diff --git a/stm32-modules/include/flex-stacker/flex-stacker/tmc2160_registers.hpp b/stm32-modules/include/flex-stacker/flex-stacker/tmc2160_registers.hpp index f7bbf885c..a78b85d98 100644 --- a/stm32-modules/include/flex-stacker/flex-stacker/tmc2160_registers.hpp +++ b/stm32-modules/include/flex-stacker/flex-stacker/tmc2160_registers.hpp @@ -261,11 +261,11 @@ struct __attribute__((packed, __may_alias__)) PowerDownDelay { static constexpr uint32_t max_val = 0xFF; static constexpr uint32_t reset = 10; - [[nodiscard]] static auto reg_to_seconds(uint8_t reg) -> double { + [[nodiscard]] static constexpr auto reg_to_seconds(uint8_t reg) -> double { return (static_cast(reg) / static_cast(max_val)) * max_time; } - static auto seconds_to_reg(double seconds) -> uint8_t { + static constexpr auto seconds_to_reg(double seconds) -> uint8_t { if (seconds > max_time) { return max_val; }