aboutsummaryrefslogtreecommitdiffstats
path: root/klippy/stepper.py
diff options
context:
space:
mode:
Diffstat (limited to 'klippy/stepper.py')
-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)