diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py index c1bde0d5c175..87c8030fef76 100644 --- a/klippy/extras/tmc5160.py +++ b/klippy/extras/tmc5160.py @@ -284,9 +284,9 @@ def __init__(self, config, mcu_tmc): self.fields.set_field("irun", irun) def _calc_globalscaler(self, current): cs = self._calc_current_bits(current) - globalscaler = int( + globalscaler = int(math.ceil( (current * 256.0 * math.sqrt(2.0) * self.sense_resistor * 32 / ( - VREF * (1 + cs))) + 0.5) + VREF * (1 + cs))))) globalscaler = max(32, globalscaler) if globalscaler >= 256: globalscaler = 0