aboutsummaryrefslogtreecommitdiffstats
path: root/klippy
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2021-10-27 19:10:36 -0400
committerKevin O'Connor <kevin@koconnor.net>2021-11-04 12:06:27 -0400
commit4acfd8d7c8973f6cc7b8a3eaa8ea9e82a92b018b (patch)
tree8e9e494c4fe21f2a96010ed23962e5efa6696af4 /klippy
parent913d099261399ba737b35752f3c3be6da618bb6a (diff)
downloadkutter-4acfd8d7c8973f6cc7b8a3eaa8ea9e82a92b018b.tar.gz
kutter-4acfd8d7c8973f6cc7b8a3eaa8ea9e82a92b018b.tar.xz
kutter-4acfd8d7c8973f6cc7b8a3eaa8ea9e82a92b018b.zip
stepper: Make step pulse duration customizable at run-time
Remove the STEP_DELAY Kconfig option and replace it with a per-stepper step_pulse_duration printer.cfg config option. The AVR code will continue to have optimized code to step and "unstep" in the same function (which is automatically activated when the step delay is 40 ticks or less). This change removes the Kconfig option for single function step/unstep on 32bit processors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy')
-rw-r--r--klippy/stepper.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/klippy/stepper.py b/klippy/stepper.py
index 013d667b..c5f81382 100644
--- a/klippy/stepper.py
+++ b/klippy/stepper.py
@@ -17,9 +17,10 @@ class error(Exception):
# Interface to low-level mcu and chelper code
class MCU_stepper:
def __init__(self, name, step_pin_params, dir_pin_params, step_dist,
- units_in_radians=False):
+ step_pulse_duration=None, units_in_radians=False):
self._name = name
self._step_dist = step_dist
+ self._step_pulse_duration = step_pulse_duration
self._units_in_radians = units_in_radians
self._mcu = step_pin_params['chip']
self._oid = oid = self._mcu.create_oid()
@@ -58,9 +59,13 @@ class MCU_stepper:
sk = ffi_main.gc(getattr(ffi_lib, alloc_func)(*params), ffi_lib.free)
self.set_stepper_kinematics(sk)
def _build_config(self):
+ if self._step_pulse_duration is None:
+ self._step_pulse_duration = .000002
+ step_pulse_ticks = self._mcu.seconds_to_clock(self._step_pulse_duration)
self._mcu.add_config_cmd(
"config_stepper oid=%d step_pin=%s dir_pin=%s invert_step=%d"
- % (self._oid, self._step_pin, self._dir_pin, self._invert_step))
+ " step_pulse_ticks=%u" % (self._oid, self._step_pin, self._dir_pin,
+ self._invert_step, step_pulse_ticks))
self._mcu.add_config_cmd("reset_step_clock oid=%d clock=0"
% (self._oid,), on_restart=True)
step_cmd_tag = self._mcu.lookup_command_tag(
@@ -73,9 +78,9 @@ class MCU_stepper:
"stepper_get_position oid=%c",
"stepper_position oid=%c pos=%i", oid=self._oid)
max_error = self._mcu.get_max_stepper_error()
+ max_error_ticks = self._mcu.seconds_to_clock(max_error)
ffi_main, ffi_lib = chelper.get_ffi()
- ffi_lib.stepcompress_fill(self._stepqueue,
- self._mcu.seconds_to_clock(max_error),
+ ffi_lib.stepcompress_fill(self._stepqueue, max_error_ticks,
self._invert_dir, step_cmd_tag, dir_cmd_tag)
def get_oid(self):
return self._oid
@@ -201,8 +206,10 @@ def PrinterStepper(config, units_in_radians=False):
dir_pin = config.get('dir_pin')
dir_pin_params = ppins.lookup_pin(dir_pin, can_invert=True)
step_dist = parse_step_distance(config, units_in_radians, True)
+ step_pulse_duration = config.getfloat('step_pulse_duration', None,
+ minval=0., maxval=.001)
mcu_stepper = MCU_stepper(name, step_pin_params, dir_pin_params, step_dist,
- units_in_radians)
+ step_pulse_duration, units_in_radians)
# Register with helper modules
for mname in ['stepper_enable', 'force_move', 'motion_report']:
m = printer.load_object(config, mname)