Skip to content

Commit

Permalink
fixes for good sensorless (props to fbeauKmi and nielsvz)
Browse files Browse the repository at this point in the history
  • Loading branch information
bwnance committed Nov 6, 2023
1 parent 5cccd3b commit 5c1d8bb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
13 changes: 7 additions & 6 deletions klippy/extras/homing.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ def _set_current_homing(self, homing_axes):

for rail in affected_rails:
ch = rail.get_tmc_current_helper()
if ch is not None:
if ch is not None and ch._home_current != ch.run_current:
ch.set_current_for_homing(print_time)
self.toolhead.dwell(0.5)
self.toolhead.dwell(ch.current_change_dwell_time)

def _set_current_post_homing(self, homing_axes):
print_time = self.toolhead.get_last_move_time()
Expand All @@ -254,9 +254,9 @@ def _set_current_post_homing(self, homing_axes):

for rail in affected_rails:
ch = rail.get_tmc_current_helper()
if ch is not None:
if ch is not None and ch._home_current != ch.run_current:
ch.set_current_for_normal(print_time)
self.toolhead.dwell(0.5)
self.toolhead.dwell(ch.current_change_dwell_time)

def home_rails(self, rails, forcepos, movepos):
# Notify of upcoming homing operation
Expand Down Expand Up @@ -284,7 +284,9 @@ def home_rails(self, rails, forcepos, movepos):
# Perform second home
if hi.retract_dist:
needs_rehome = False
if any([dist < hi.retract_dist for dist in homing_axis_distances]):
if any(
[abs(dist) < hi.retract_dist for dist in homing_axis_distances]
):
needs_rehome = True

logging.info("needs rehome: %s", needs_rehome)
Expand All @@ -299,7 +301,6 @@ def home_rails(self, rails, forcepos, movepos):
]
self.toolhead.move(retractpos, hi.retract_speed)
if not hi.use_sensorless_homing or needs_rehome:
self.toolhead.dwell(0.5)
# Home again
startpos = [
rp - ad * retract_r for rp, ad in zip(retractpos, axes_d)
Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2130.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ def __init__(self, config, mcu_tmc):
self._home_current = config.getfloat(
"home_current", self.run_current, above=0.0, maxval=MAX_CURRENT
)
self.current_change_dwell_time = config.getfloat(
"current_change_dwell_time", 0.5, above=0.0
)
self.prev_current = self.run_current
self.req_hold_current = self.hold_current
self.sense_resistor = config.getfloat(
Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2240.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def __init__(self, config, mcu_tmc):
self._home_current = config.getfloat(
"home_current", self.run_current, above=0.0, maxval=self.max_cur
)
self.current_change_dwell_time = config.getfloat(
"current_change_dwell_time", 0.5, above=0.0
)
self.prev_current = self.run_current
self.req_hold_current = self.hold_current
current_range = self._calc_current_range(self.run_current)
Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc2660.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ def __init__(self, config, mcu_tmc):
self._home_current = config.getfloat(
"home_current", self.current, above=0.0, maxval=MAX_CURRENT
)
self.current_change_dwell_time = config.getfloat(
"current_change_dwell_time", 0.5, above=0.0
)
self._prev_current = self.current
self.sense_resistor = config.getfloat("sense_resistor")
vsense, cs = self._calc_current(self.current)
Expand Down
3 changes: 3 additions & 0 deletions klippy/extras/tmc5160.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,9 @@ def __init__(self, config, mcu_tmc):
self._home_current = config.getfloat(
"home_current", self.run_current, above=0.0, maxval=MAX_CURRENT
)
self.current_change_dwell_time = config.getfloat(
"current_change_dwell_time", 0.5, above=0.0
)
self._prev_current = self.run_current
self.req_hold_current = self.hold_current
self.sense_resistor = config.getfloat(
Expand Down

0 comments on commit 5c1d8bb

Please sign in to comment.