Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hybrid_corexy: Fix for inverted hybrid core-xy setups and extended usability #6351

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
6 changes: 6 additions & 0 deletions docs/Config_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -2113,6 +2113,12 @@ axis:
# See the "stepper" section for the definition of the above parameters.
```

```
[hybrid_corexy]
inverted:
# Set to True in case you have a inverted hybrid core-xy setup.
```

### [extruder_stepper]

Support for additional steppers synchronized to the movement of an
Expand Down
66 changes: 53 additions & 13 deletions klippy/kinematics/hybrid_corexy.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,31 @@
class HybridCoreXYKinematics:
def __init__(self, toolhead, config):
self.printer = config.get_printer()
printer_config = config.getsection('printer')
self.inverted = False
if config.has_section('hybrid_corexy'):
hcxy_config = config.getsection('hybrid_corexy')
self.inverted = hcxy_config.getboolean('inverted', False)
# itersolve parameters
self.rails = [ stepper.PrinterRail(config.getsection('stepper_x')),
stepper.LookupMultiRail(config.getsection('stepper_y')),
stepper.LookupMultiRail(config.getsection('stepper_z'))]
self.rails[1].get_endstops()[0][0].add_stepper(
self.rails[0].get_steppers()[0])
self.rails[0].setup_itersolve('corexy_stepper_alloc', b'-')
self.rails = [stepper.LookupMultiRail(config.getsection('stepper_' + n))
for n in 'xyz']
for s in self.rails[0].get_steppers():
self.rails[1].get_endstops()[0][0].add_stepper(s)
if self.inverted == False:
self.rails[0].steppers[0].setup_itersolve(
'corexy_stepper_alloc', b'-')
if len(self.rails[0].steppers)==2:
self.rails[0].steppers[1].setup_itersolve(
'corexy_stepper_alloc', b'+')
if len(self.rails[0].steppers)>2:
raise self.error("Unexpected stepper configuration")
else:
self.rails[0].steppers[0].setup_itersolve(
'corexy_stepper_alloc', b'+')
if len(self.rails[0].steppers)==2:
self.rails[0].steppers[1].setup_itersolve(
'corexy_stepper_alloc', b'-')
if len(self.rails[0].steppers)>2:
raise self.error("Unexpected stepper configuration")
self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y')
self.rails[2].setup_itersolve('cartesian_stepper_alloc', b'z')
ranges = [r.get_range() for r in self.rails]
Expand All @@ -30,10 +47,25 @@ def __init__(self, toolhead, config):
# dummy for cartesian config users
dc_config.getchoice('axis', {'x': 'x'}, default='x')
# setup second dual carriage rail
self.rails.append(stepper.PrinterRail(dc_config))
self.rails[1].get_endstops()[0][0].add_stepper(
self.rails[3].get_steppers()[0])
self.rails[3].setup_itersolve('corexy_stepper_alloc', b'+')
self.rails.append(stepper.LookupMultiRail(dc_config))
for s in self.rails[3].get_steppers():
self.rails[1].get_endstops()[0][0].add_stepper(s)
if self.inverted == False:
self.rails[3].steppers[0].setup_itersolve(
'corexy_stepper_alloc', b'+')
if len(self.rails[3].steppers)==2:
self.rails[3].steppers[1].setup_itersolve(
'corexy_stepper_alloc', b'-')
if len(self.rails[3].steppers)>2:
raise self.error("Unexpected stepper configuration")
else:
self.rails[3].steppers[0].setup_itersolve(
'corexy_stepper_alloc', b'-')
if len(self.rails[3].steppers)==2:
self.rails[3].steppers[1].setup_itersolve(
'corexy_stepper_alloc', b'+')
if len(self.rails[3].steppers)>2:
raise self.error("Unexpected stepper configuration")
dc_rail_0 = idex_modes.DualCarriagesRail(
self.rails[0], axis=0, active=True)
dc_rail_1 = idex_modes.DualCarriagesRail(
Expand All @@ -58,9 +90,17 @@ def calc_position(self, stepper_positions):
pos = [stepper_positions[rail.get_name()] for rail in self.rails]
if (self.dc_module is not None and 'PRIMARY' == \
self.dc_module.get_status()['carriage_1']):
return [pos[0] - pos[1], pos[1], pos[2]]
if self.inverted == False:
return stepper_positions['dual_carriage'] \
- pos[1], pos[1], pos[2]
else:
return stepper_positions['dual_carriage'] \
+ pos[1], pos[1], pos[2]
else:
return [pos[0] + pos[1], pos[1], pos[2]]
if self.inverted == False:
return pos[0] + pos[1], pos[1], pos[2]
else:
return pos[0] - pos[1], pos[1], pos[2]
def update_limits(self, i, range):
l, h = self.limits[i]
# Only update limits if this axis was already homed,
Expand Down
Loading