stepper: Track if using units of radians instead of millimeters
The STEPPER_BUZZ command needs to know if the axis is using radians instead of millimeters so that it can move a more appropriate distance. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
bcf10aa990
commit
97d976fc53
|
@ -6,7 +6,10 @@
|
||||||
import math, logging
|
import math, logging
|
||||||
import chelper
|
import chelper
|
||||||
|
|
||||||
BUZZ_VELOCITY = 4.
|
BUZZ_DISTANCE = 1.
|
||||||
|
BUZZ_VELOCITY = BUZZ_DISTANCE / .250
|
||||||
|
BUZZ_RADIANS_DISTANCE = math.radians(1.)
|
||||||
|
BUZZ_RADIANS_VELOCITY = BUZZ_RADIANS_DISTANCE / .250
|
||||||
STALL_TIME = 0.100
|
STALL_TIME = 0.100
|
||||||
|
|
||||||
# Calculate a move's accel_t, cruise_t, and cruise_v
|
# Calculate a move's accel_t, cruise_t, and cruise_v
|
||||||
|
@ -95,10 +98,13 @@ class ForceMove:
|
||||||
logging.info("Stepper buzz %s", stepper.get_name())
|
logging.info("Stepper buzz %s", stepper.get_name())
|
||||||
was_enable = self.force_enable(stepper)
|
was_enable = self.force_enable(stepper)
|
||||||
toolhead = self.printer.lookup_object('toolhead')
|
toolhead = self.printer.lookup_object('toolhead')
|
||||||
|
dist, speed = BUZZ_DISTANCE, BUZZ_VELOCITY
|
||||||
|
if stepper.units_in_radians():
|
||||||
|
dist, speed = BUZZ_RADIANS_DISTANCE, BUZZ_RADIANS_VELOCITY
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
self.manual_move(stepper, 1., BUZZ_VELOCITY)
|
self.manual_move(stepper, dist, speed)
|
||||||
toolhead.dwell(.050)
|
toolhead.dwell(.050)
|
||||||
self.manual_move(stepper, -1., BUZZ_VELOCITY)
|
self.manual_move(stepper, -dist, speed)
|
||||||
toolhead.dwell(.450)
|
toolhead.dwell(.450)
|
||||||
self.restore_enable(stepper, was_enable)
|
self.restore_enable(stepper, was_enable)
|
||||||
cmd_FORCE_MOVE_help = "Manually move a stepper; invalidates kinematics"
|
cmd_FORCE_MOVE_help = "Manually move a stepper; invalidates kinematics"
|
||||||
|
|
|
@ -9,7 +9,8 @@ import stepper, homing
|
||||||
class PolarKinematics:
|
class PolarKinematics:
|
||||||
def __init__(self, toolhead, config):
|
def __init__(self, toolhead, config):
|
||||||
# Setup axis steppers
|
# Setup axis steppers
|
||||||
stepper_bed = stepper.PrinterStepper(config.getsection('stepper_bed'))
|
stepper_bed = stepper.PrinterStepper(config.getsection('stepper_bed'),
|
||||||
|
units_in_radians=True)
|
||||||
rail_arm = stepper.PrinterRail(config.getsection('stepper_arm'))
|
rail_arm = stepper.PrinterRail(config.getsection('stepper_arm'))
|
||||||
rail_z = stepper.LookupMultiRail(config.getsection('stepper_z'))
|
rail_z = stepper.LookupMultiRail(config.getsection('stepper_z'))
|
||||||
stepper_bed.setup_itersolve('polar_stepper_alloc', 'a')
|
stepper_bed.setup_itersolve('polar_stepper_alloc', 'a')
|
||||||
|
|
|
@ -16,9 +16,11 @@ class error(Exception):
|
||||||
|
|
||||||
# Interface to low-level mcu and chelper code
|
# Interface to low-level mcu and chelper code
|
||||||
class MCU_stepper:
|
class MCU_stepper:
|
||||||
def __init__(self, name, step_pin_params, dir_pin_params, step_dist):
|
def __init__(self, name, step_pin_params, dir_pin_params, step_dist,
|
||||||
|
units_in_radians=False):
|
||||||
self._name = name
|
self._name = name
|
||||||
self._step_dist = step_dist
|
self._step_dist = step_dist
|
||||||
|
self._units_in_radians = units_in_radians
|
||||||
self._mcu = step_pin_params['chip']
|
self._mcu = step_pin_params['chip']
|
||||||
self._oid = oid = self._mcu.create_oid()
|
self._oid = oid = self._mcu.create_oid()
|
||||||
self._mcu.register_config_callback(self._build_config)
|
self._mcu.register_config_callback(self._build_config)
|
||||||
|
@ -47,6 +49,9 @@ class MCU_stepper:
|
||||||
if short and self._name.startswith('stepper_'):
|
if short and self._name.startswith('stepper_'):
|
||||||
return self._name[8:]
|
return self._name[8:]
|
||||||
return self._name
|
return self._name
|
||||||
|
def units_in_radians(self):
|
||||||
|
# Returns true if distances are in radians instead of millimeters
|
||||||
|
return self._units_in_radians
|
||||||
def _dist_to_time(self, dist, start_velocity, accel):
|
def _dist_to_time(self, dist, start_velocity, accel):
|
||||||
# Calculate the time it takes to travel a distance with constant accel
|
# Calculate the time it takes to travel a distance with constant accel
|
||||||
time_offset = start_velocity / accel
|
time_offset = start_velocity / accel
|
||||||
|
@ -159,7 +164,7 @@ class MCU_stepper:
|
||||||
raise error("Internal error in stepcompress")
|
raise error("Internal error in stepcompress")
|
||||||
|
|
||||||
# Helper code to build a stepper object from a config section
|
# Helper code to build a stepper object from a config section
|
||||||
def PrinterStepper(config):
|
def PrinterStepper(config, units_in_radians=False):
|
||||||
printer = config.get_printer()
|
printer = config.get_printer()
|
||||||
name = config.get_name()
|
name = config.get_name()
|
||||||
# Stepper definition
|
# Stepper definition
|
||||||
|
@ -169,7 +174,8 @@ def PrinterStepper(config):
|
||||||
dir_pin = config.get('dir_pin')
|
dir_pin = config.get('dir_pin')
|
||||||
dir_pin_params = ppins.lookup_pin(dir_pin, can_invert=True)
|
dir_pin_params = ppins.lookup_pin(dir_pin, can_invert=True)
|
||||||
step_dist = config.getfloat('step_distance', above=0.)
|
step_dist = config.getfloat('step_distance', above=0.)
|
||||||
mcu_stepper = MCU_stepper(name, step_pin_params, dir_pin_params, step_dist)
|
mcu_stepper = MCU_stepper(name, step_pin_params, dir_pin_params, step_dist,
|
||||||
|
units_in_radians)
|
||||||
# Support for stepper enable pin handling
|
# Support for stepper enable pin handling
|
||||||
stepper_enable = printer.try_load_module(config, 'stepper_enable')
|
stepper_enable = printer.try_load_module(config, 'stepper_enable')
|
||||||
stepper_enable.register_stepper(mcu_stepper, config.get('enable_pin', None))
|
stepper_enable.register_stepper(mcu_stepper, config.get('enable_pin', None))
|
||||||
|
@ -187,8 +193,9 @@ def PrinterStepper(config):
|
||||||
# endstops.
|
# endstops.
|
||||||
class PrinterRail:
|
class PrinterRail:
|
||||||
def __init__(self, config, need_position_minmax=True,
|
def __init__(self, config, need_position_minmax=True,
|
||||||
default_position_endstop=None):
|
default_position_endstop=None, units_in_radians=False):
|
||||||
# Primary stepper and endstop
|
# Primary stepper and endstop
|
||||||
|
self.stepper_units_in_radians = units_in_radians
|
||||||
self.steppers = []
|
self.steppers = []
|
||||||
self.endstops = []
|
self.endstops = []
|
||||||
self.add_extra_stepper(config)
|
self.add_extra_stepper(config)
|
||||||
|
@ -250,7 +257,7 @@ class PrinterRail:
|
||||||
def get_endstops(self):
|
def get_endstops(self):
|
||||||
return list(self.endstops)
|
return list(self.endstops)
|
||||||
def add_extra_stepper(self, config):
|
def add_extra_stepper(self, config):
|
||||||
stepper = PrinterStepper(config)
|
stepper = PrinterStepper(config, self.stepper_units_in_radians)
|
||||||
self.steppers.append(stepper)
|
self.steppers.append(stepper)
|
||||||
if self.endstops and config.get('endstop_pin', None) is None:
|
if self.endstops and config.get('endstop_pin', None) is None:
|
||||||
# No endstop defined - use primary endstop
|
# No endstop defined - use primary endstop
|
||||||
|
|
Loading…
Reference in New Issue