Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(stacker): update tpowerdown and hold current delay for motor driver #493

Merged
merged 1 commit into from
Dec 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down Expand Up @@ -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},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<double>(reg) / static_cast<double>(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;
}
Expand Down
Loading