Skip to content

Commit

Permalink
bugfix: restore run_current after sensorless homing (#233)
Browse files Browse the repository at this point in the history
When utilizing home_current + sensorless homing the run_current is not being restored after homing was completed.

- The needs_home_current_change check will be fales because run_current at that time is equal to home_current
- The short circuit code in most drivers is triggering falsely because it's comparing the previous run current to the requested run_current and not looking at the currently set run current, thus never setting this even after switch to a `needs_run_current_change` helper in the condition.
  • Loading branch information
mjonuschat authored May 10, 2024
1 parent 0777365 commit a478116
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 4 deletions.
2 changes: 1 addition & 1 deletion klippy/extras/homing.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def _set_current_post_homing(self, homing_axes):
chs = rail.get_tmc_current_helpers()
dwell_time = None
for ch in chs:
if ch is not None and ch.needs_home_current_change():
if ch is not None and ch.needs_run_current_change():
if dwell_time is None:
dwell_time = ch.current_change_dwell_time
ch.set_current_for_normal(print_time)
Expand Down
5 changes: 4 additions & 1 deletion klippy/extras/tmc2130.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ def __init__(self, config, mcu_tmc):
def needs_home_current_change(self):
return self._home_current != self.run_current

def needs_run_current_change(self):
return self._prev_current != self.run_current

def set_home_current(self, new_home_current):
self._home_current = min(MAX_CURRENT, new_home_current)

Expand Down Expand Up @@ -281,7 +284,7 @@ def get_current(self):

def set_current(self, run_current, hold_current, print_time, force=False):
if (
run_current == self._prev_current
run_current == self.run_current
and hold_current == self.req_hold_current
and not force
):
Expand Down
5 changes: 4 additions & 1 deletion klippy/extras/tmc2240.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ def __init__(self, config, mcu_tmc):
def needs_home_current_change(self):
return self._home_current != self.run_current

def needs_run_current_change(self):
return self._prev_current != self.run_current

def set_home_current(self, new_home_current):
self._home_current = min(self.max_cur, new_home_current)

Expand Down Expand Up @@ -360,7 +363,7 @@ def get_current(self):

def set_current(self, run_current, hold_current, print_time, force=False):
if (
run_current == self._prev_current
run_current == self.run_current
and hold_current == self.req_hold_current
and not force
):
Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2660.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@ def __init__(self, config, mcu_tmc):
def needs_home_current_change(self):
return self._home_current != self.current

def needs_run_current_change(self):
return self._prev_current != self.current

def set_home_current(self, new_home_current):
self._home_current = min(MAX_CURRENT, new_home_current)

Expand Down
5 changes: 4 additions & 1 deletion klippy/extras/tmc5160.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,9 @@ def __init__(self, config, mcu_tmc):
def needs_home_current_change(self):
return self._home_current != self.run_current

def needs_run_current_change(self):
return self._prev_current != self.run_current

def set_home_current(self, new_home_current):
self._home_current = min(MAX_CURRENT, new_home_current)

Expand Down Expand Up @@ -338,7 +341,7 @@ def get_current(self):

def set_current(self, run_current, hold_current, print_time, force=False):
if (
run_current == self._prev_current
run_current == self.run_current
and hold_current == self.req_hold_current
and not force
):
Expand Down

0 comments on commit a478116

Please sign in to comment.