From ed8dca8df08924e7df9291d5e4ff88c9fee4ca4e Mon Sep 17 00:00:00 2001 From: Alex Voinea Date: Tue, 14 May 2024 22:23:06 +0200 Subject: tmc: Implement high_velocity_threshold for drivers that support it Signed-off-by: Alex Voinea --- klippy/extras/tmc.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'klippy/extras/tmc.py') diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index e7c0239f..366e00b1 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -632,3 +632,20 @@ def TMCVcoolthrsHelper(config, mcu_tmc): tcoolthrs = TMCtstepHelper(step_dist, mres, mcu_tmc.get_tmc_frequency(), velocity) fields.set_field("tcoolthrs", tcoolthrs) + +# Helper to configure StallGuard and CoolStep maximum velocity and +# SpreadCycle-FullStepping (High velocity) mode threshold. +def TMCVhighHelper(config, mcu_tmc): + fields = mcu_tmc.get_fields() + velocity = config.getfloat('high_velocity_threshold', None, minval=0.) + thigh = 0 + + if velocity is not None: + stepper_name = " ".join(config.get_name().split()[1:]) + sconfig = config.getsection(stepper_name) + rotation_dist, steps_per_rotation = stepper.parse_step_distance(sconfig) + step_dist = rotation_dist / steps_per_rotation + mres = fields.get_field("mres") + thigh = TMCtstepHelper(step_dist, mres, + mcu_tmc.get_tmc_frequency(), velocity) + fields.set_field("thigh", thigh) -- cgit v1.2.3-70-g09d2