mirror of
https://github.com/Klipper3d/klipper.git
synced 2025-07-24 23:24:01 -06:00
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>
This commit is contained in:
parent
4acfd8d7c8
commit
689231df3a
10 changed files with 77 additions and 12 deletions
|
@ -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(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue