tmc2660: Add endstop phase detection functionality to TMC2660 extra (#816)
Signed-off-by: Florian Heilmann <Florian.Heilmann@gmx.net>
This commit is contained in:
parent
1a437c1fd1
commit
b6bf455155
|
@ -333,7 +333,7 @@
|
|||
# This specifies the number of phases of the given stepper motor
|
||||
# driver (which is the number of micro-steps multiplied by four).
|
||||
# This setting is automatically determined if one uses TMC2130,
|
||||
# TMC2208, or TMC2224 drivers with run-time configuration.
|
||||
# TMC2208, TMC2224 or TMC2660 drivers with run-time configuration.
|
||||
# Otherwise, this parameter must be provided.
|
||||
#endstop_accuracy: 0.200
|
||||
# Sets the expected accuracy (in mm) of the endstop. This represents
|
||||
|
|
|
@ -26,9 +26,9 @@ the endstop trigger to improve the accuracy of the endstop.
|
|||
|
||||
In order to use this functionality it is necessary to be able to
|
||||
identify the phase of the stepper motor. If one is using Trinamic
|
||||
TMC2130, TMC2208, or TMC2224 drivers in run-time configuration mode
|
||||
(ie, not stand-alone mode) then Klipper can query the stepper phase
|
||||
from the driver. (It is also possible to use this system on
|
||||
TMC2130, TMC2208, TMC2224 or TMC2660 drivers in run-time configuration
|
||||
mode (ie, not stand-alone mode) then Klipper can query the stepper
|
||||
phase from the driver. (It is also possible to use this system on
|
||||
traditional stepper drivers if one can reliably reset the stepper
|
||||
drivers - see below for details.)
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
import math, logging
|
||||
import homing
|
||||
|
||||
TRINAMIC_DRIVERS = ["tmc2130", "tmc2208"]
|
||||
TRINAMIC_DRIVERS = ["tmc2130", "tmc2208", "tmc2660"]
|
||||
|
||||
class EndstopPhase:
|
||||
def __init__(self, config):
|
||||
|
|
|
@ -162,7 +162,7 @@ class TMC2660:
|
|||
self.driver_sdoff = False # since we don't support SPI mode yet, this has to be False
|
||||
vsense = {'low': 0, 'high': 1}
|
||||
self.driver_vsense = config.getchoice('driver_VSENSE', vsense, default='high')
|
||||
self.driver_rdsel = 2 # stallguard2 and coolstep current level
|
||||
self.driver_rdsel = 0 # Microsteps (used by endstop phase)
|
||||
|
||||
|
||||
# Build and send registers
|
||||
|
@ -248,6 +248,17 @@ class TMC2660:
|
|||
self.is_idle = True
|
||||
return eventtime + 0.1
|
||||
|
||||
def get_microsteps(self):
|
||||
return 256 >> self.driver_mres
|
||||
|
||||
def get_phase(self):
|
||||
# Send DRVCTRL to get a response
|
||||
reg_data = [(self.reg_drvctrl >> 16) & 0xff, (self.reg_drvctrl >> 8) & 0xff, self.reg_drvctrl & 0xff]
|
||||
params = self.spi_transfer_cmd.send_with_response([self.oid, reg_data], 'spi_transfer_response', self.oid)
|
||||
pr = bytearray(params['response'])
|
||||
steps = (((pr[0] << 16) | (pr[1] << 8) | pr[2]) & READRSP['MSTEP'][1]) >> READRSP['MSTEP'][0]
|
||||
return steps >> self.driver_mres
|
||||
|
||||
def set_current(self, current):
|
||||
self.driver_cs = current_to_reg(current)
|
||||
reg = self.reg_sgcsconf
|
||||
|
|
Loading…
Reference in New Issue