diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index e6a27a43..9e676a5c 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -123,11 +123,13 @@ class TMCCurrentHelper: def _calc_current(self, run_current, hold_current): vsense = False irun = self._calc_current_bits(run_current, vsense) - ihold = self._calc_current_bits(hold_current, vsense) + ihold = self._calc_current_bits(min(hold_current, run_current), + vsense) if irun < 16 and ihold < 16: vsense = True irun = self._calc_current_bits(run_current, vsense) - ihold = self._calc_current_bits(hold_current, vsense) + ihold = self._calc_current_bits(min(hold_current, run_current), + vsense) return vsense, irun, ihold def _calc_current_from_field(self, field_name): bits = self.fields.get_field(field_name) @@ -147,7 +149,7 @@ class TMCCurrentHelper: hold_current = self._calc_current_from_field("IHOLD") if 'CURRENT' in params: run_current = gcode.get_float( - 'CURRENT', params, minval=hold_current, maxval=MAX_CURRENT) + 'CURRENT', params, minval=0., maxval=MAX_CURRENT) else: run_current = self._calc_current_from_field("IRUN") if 'HOLDCURRENT' not in params and 'CURRENT' not in params: diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py index 9102f4b8..fa76c1b2 100644 --- a/klippy/extras/tmc5160.py +++ b/klippy/extras/tmc5160.py @@ -250,7 +250,7 @@ class TMC5160CurrentHelper: return max(0, min(31, cs)) def _calc_current(self, run_current, hold_current): irun = self._calc_current_bits(run_current) - ihold = self._calc_current_bits(hold_current) + ihold = self._calc_current_bits(min(hold_current, run_current)) return irun, ihold def _calc_current_from_field(self, field_name): bits = self.fields.get_field(field_name) @@ -267,7 +267,7 @@ class TMC5160CurrentHelper: hold_current = self._calc_current_from_field("IHOLD") if 'CURRENT' in params: run_current = gcode.get_float( - 'CURRENT', params, minval=hold_current, maxval=MAX_CURRENT) + 'CURRENT', params, minval=0., maxval=MAX_CURRENT) else: run_current = self._calc_current_from_field("IRUN") if 'HOLDCURRENT' not in params and 'CURRENT' not in params: