From f47e369b936e1ee435ccc74d24ee14cec60443ee Mon Sep 17 00:00:00 2001 From: HonestBrothers <112437205+HonestBrothers@users.noreply.github.com> Date: Tue, 24 Dec 2024 21:32:23 -0600 Subject: [PATCH] Update tmc5160.py --- klippy/extras/tmc5160.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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