diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2021-10-28 17:10:10 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2021-11-04 12:06:27 -0400 |
commit | 689231df3a6c1ed606d227cce7115703b153193b (patch) | |
tree | 28c550dfb5d9140403ee3b5b13e081d8906ad873 /klippy/stepper.py | |
parent | 4acfd8d7c8973f6cc7b8a3eaa8ea9e82a92b018b (diff) | |
download | kutter-689231df3a6c1ed606d227cce7115703b153193b.tar.gz kutter-689231df3a6c1ed606d227cce7115703b153193b.tar.xz kutter-689231df3a6c1ed606d227cce7115703b153193b.zip |
stepper: Add support for stepping on both edges of a step pulse
Add an optimized step function for drivers that support stepping on
both rising and falling edges of the step pin. Enable this
optimization on 32bit ARM micro-controllers. Automatically detect
this capability in the host code and enable on TMC drivers running in
SPI/UART mode.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'klippy/stepper.py')
-rw-r--r-- | klippy/stepper.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/klippy/stepper.py b/klippy/stepper.py index c5f81382..2e6655ef 100644 --- a/klippy/stepper.py +++ b/klippy/stepper.py @@ -32,6 +32,7 @@ class MCU_stepper: "Stepper dir pin must be on same mcu as step pin") self._dir_pin = dir_pin_params['pin'] self._invert_dir = dir_pin_params['invert'] + self._step_both_edge = self._req_step_both_edge = False self._mcu_position_offset = 0. self._reset_cmd_tag = self._get_position_cmd = None self._active_callbacks = [] @@ -54,6 +55,12 @@ class MCU_stepper: def units_in_radians(self): # Returns true if distances are in radians instead of millimeters return self._units_in_radians + def get_pulse_duration(self): + return self._step_pulse_duration, self._step_both_edge + def setup_default_pulse_duration(self, pulse_duration, step_both_edge): + if self._step_pulse_duration is None: + self._step_pulse_duration = pulse_duration + self._req_step_both_edge = step_both_edge def setup_itersolve(self, alloc_func, *params): ffi_main, ffi_lib = chelper.get_ffi() sk = ffi_main.gc(getattr(ffi_lib, alloc_func)(*params), ffi_lib.free) @@ -61,11 +68,18 @@ class MCU_stepper: def _build_config(self): if self._step_pulse_duration is None: self._step_pulse_duration = .000002 + invert_step = self._invert_step + sbe = int(self._mcu.get_constants().get('STEPPER_BOTH_EDGE', '0')) + if self._req_step_both_edge and sbe: + # Enable stepper optimized step on both edges + self._step_both_edge = True + self._step_pulse_duration = 0. + invert_step = -1 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" " step_pulse_ticks=%u" % (self._oid, self._step_pin, self._dir_pin, - self._invert_step, step_pulse_ticks)) + 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( |