From 51ddbde1a0cf18c84385c78b8c24f4cc4a8a2a90 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Wed, 23 Aug 2023 18:34:21 +0200 Subject: [PATCH 01/12] make inverted belt path work with hybrid_corexy idex --- docs/Config_Reference.md | 2 ++ klippy/kinematics/hybrid_corexy.py | 20 ++++++++++++++++---- klippy/kinematics/idex_modes.py | 2 ++ 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 5b8038f7d332..36c01a150f7d 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2084,6 +2084,8 @@ configuration. axis: # The axis this extra carriage is on (either x or y). This parameter # must be provided. +invert_axis: +# Set to True in case you have a inverted belt path. #safe_distance: # The minimum distance (in mm) to enforce between the dual and the primary # carriages. If a G-Code command is executed that will bring the carriages diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index 26032039c016..3565b19549ae 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -12,28 +12,40 @@ class HybridCoreXYKinematics: def __init__(self, toolhead, config): self.printer = config.get_printer() printer_config = config.getsection('printer') + + dc_config = None + invert_axis = False + if config.has_section('dual_carriage'): + dc_config = config.getsection('dual_carriage') + invert_axis = dc_config.getboolean('invert_axis', 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'-') + if invert_axis == False: + self.rails[0].setup_itersolve('corexy_stepper_alloc', b'-') + else: + self.rails[0].setup_itersolve('corexy_stepper_alloc', b'+') 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] self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) self.dc_module = None - if config.has_section('dual_carriage'): - dc_config = config.getsection('dual_carriage') + if dc_config != None: # 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'+') + if invert_axis == False: + self.rails[3].setup_itersolve('corexy_stepper_alloc', b'+') + else: + self.rails[3].setup_itersolve('corexy_stepper_alloc', b'-') dc_rail_0 = idex_modes.DualCarriagesRail( self.rails[0], axis=0, active=True) dc_rail_1 = idex_modes.DualCarriagesRail( diff --git a/klippy/kinematics/idex_modes.py b/klippy/kinematics/idex_modes.py index b54f96579c9b..eb4fb2ccf7da 100644 --- a/klippy/kinematics/idex_modes.py +++ b/klippy/kinematics/idex_modes.py @@ -20,6 +20,8 @@ def __init__(self, dc_config, rail_0, rail_1, axis): self.dc = (rail_0, rail_1) self.saved_states = {} safe_dist = dc_config.getfloat('safe_distance', None, minval=0.) + invert_axis = dc_config.getboolean('invert_axis', False) + self.invert_axis = invert_axis if safe_dist is None: dc0_rail = rail_0.get_rail() dc1_rail = rail_1.get_rail() From 9332ed63d89335d0340615c13646f2a554c4b830 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Sun, 24 Sep 2023 16:59:10 +0200 Subject: [PATCH 02/12] IDEX --- docs/Config_Reference.md | 4 ++-- klippy/extras/homing.py | 27 ++++++++++++++++++++++++++- klippy/extras/probe.py | 5 +++++ klippy/kinematics/Untitled-1.yml | 15 +++++++++++++++ klippy/kinematics/hybrid_corexy.py | 20 +++++++++++++------- klippy/kinematics/idex_modes.py | 3 +-- 6 files changed, 62 insertions(+), 12 deletions(-) create mode 100644 klippy/kinematics/Untitled-1.yml diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 36c01a150f7d..827c65cd0b74 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2084,8 +2084,8 @@ configuration. axis: # The axis this extra carriage is on (either x or y). This parameter # must be provided. -invert_axis: -# Set to True in case you have a inverted belt path. +inverted: +# Set to True in case you have a inverted hybrid core-xy setup. #safe_distance: # The minimum distance (in mm) to enforce between the dual and the primary # carriages. If a G-Code command is executed that will bring the carriages diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py index 634ad81b74c6..dd689add20a5 100644 --- a/klippy/extras/homing.py +++ b/klippy/extras/homing.py @@ -43,6 +43,7 @@ def __init__(self, printer, endstops, toolhead=None): toolhead = printer.lookup_object('toolhead') self.toolhead = toolhead self.stepper_positions = [] + self.gcode = self.printer.lookup_object('gcode') def get_mcu_endstops(self): return [es for es, name in self.endstops] def _calc_endstop_rate(self, mcu_endstop, movepos, speed): @@ -64,7 +65,21 @@ def calc_toolhead_pos(self, kin_spos, offsets): sname = stepper.get_name() kin_spos[sname] += offsets.get(sname, 0) * stepper.get_step_dist() thpos = self.toolhead.get_position() - return list(kin.calc_position(kin_spos))[:3] + thpos[3:] + + # ################################################## + # self.gcode.respond_info("HomingMove calc_toolhead_pos kin_spos: " + str(kin_spos)) + # self.gcode.respond_info("HomingMove calc_toolhead_pos thpos: " + str(thpos)) + # ################################################## + # # thpos: [150.0, 150.0, 1.57, 0.0] + # # kin_spos: {'stepper_x': 80.5, 'stepper_y': 150.0, 'stepper_y1': 150.0, 'stepper_z': 1.5665625, 'stepper_z1': 1.5665625, 'stepper_z2': 1.5665625, 'dual_carriage': 0.0} + + dc = self.printer.lookup_object('dual_carriage') + if dc is None: + return list(kin.calc_position(kin_spos))[:3] + thpos[3:] + else: + # to do + return list(kin.calc_position(kin_spos))[:3] + thpos[3:] + def homing_move(self, movepos, speed, probe_pos=False, triggered=True, check_triggered=True): # Notify start of homing/probing move @@ -77,6 +92,7 @@ def homing_move(self, movepos, speed, probe_pos=False, self.stepper_positions = [ StepperPosition(s, name) for es, name in self.endstops for s in es.get_steppers() ] + # Start endstop checking print_time = self.toolhead.get_last_move_time() endstop_triggers = [] @@ -126,7 +142,14 @@ def homing_move(self, movepos, speed, probe_pos=False, self.toolhead.set_position(movepos) halt_kin_spos = {s.get_name(): s.get_commanded_position() for s in kin.get_steppers()} + # ################################################## + # self.gcode.respond_info("HomingMove homing_move halt_kin_spos: " + str(halt_kin_spos)) + # self.gcode.respond_info("HomingMove homing_move haltpos A: " + str(haltpos)) + # ################################################## haltpos = self.calc_toolhead_pos(halt_kin_spos, over_steps) + # ################################################## + # self.gcode.respond_info("HomingMove homing_move haltpos B: " + str(haltpos)) + # ################################################## self.toolhead.set_position(haltpos) # Signal homing/probing move complete try: @@ -153,6 +176,8 @@ def __init__(self, printer): self.changed_axes = [] self.trigger_mcu_pos = {} self.adjust_pos = {} + self.gcode = self.printer.lookup_object('gcode') + def set_axes(self, axes): self.changed_axes = axes def get_axes(self): diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index 337c41b13c9d..04ae1a91beed 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -122,6 +122,8 @@ def _probe(self, speed): pos[2] = self.z_position try: epos = phoming.probing_move(self.mcu_probe, pos, speed) + epos[0] = pos[0] + epos[1] = pos[1] except self.printer.command_error as e: reason = str(e) if "Timeout during endstop homing" in reason: @@ -136,6 +138,9 @@ def _probe(self, speed): axis_twist_compensation.get_z_compensation_value(pos)) # add z compensation to probe position epos[2] += z_compensation + # set the position to the correct toolhead in case of a IDEX + if self.printer.lookup_object('dual_carriage') is not None: + toolhead.set_position(epos) self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f" % (epos[0], epos[1], epos[2])) return epos[:3] diff --git a/klippy/kinematics/Untitled-1.yml b/klippy/kinematics/Untitled-1.yml new file mode 100644 index 000000000000..194f57cb98ec --- /dev/null +++ b/klippy/kinematics/Untitled-1.yml @@ -0,0 +1,15 @@ +HomingMove homing_move kin_spos: {'stepper_x': 260.0, 'stepper_y': 260.0, 'stepper_y1': 260.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': -260.0} +HomingMove homing_move kin_spos: {'stepper_x': -153.0, 'stepper_y': -153.0, 'stepper_y1': -153.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 153.0} +G28 Y + + +HomingMove homing_move kin_spos: {'stepper_x': 410.0, 'stepper_y': 260.0, 'stepper_y1': 260.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 112.0} +HomingMove homing_move kin_spos: {'stepper_x': -3.0, 'stepper_y': -153.0, 'stepper_y1': -153.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 525.0} +G28 Y + +HomingMove homing_move kin_spos: {'dual_carriage': 336.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'stepper_x': -73.6875} +HomingMove homing_move kin_spos: {'dual_carriage': -299.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'stepper_x': -73.6875} +HomingMove homing_move kin_spos: {'stepper_x': -34.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 0.0} +HomingMove homing_move kin_spos: {'stepper_x': 601.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 0.0} +DualCarriages home +G28 X \ No newline at end of file diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index 3565b19549ae..a1e7aa6d0ae0 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -11,13 +11,13 @@ class HybridCoreXYKinematics: def __init__(self, toolhead, config): self.printer = config.get_printer() - printer_config = config.getsection('printer') + self.gcode = self.printer.lookup_object('gcode') dc_config = None - invert_axis = False + self.inverted = False if config.has_section('dual_carriage'): dc_config = config.getsection('dual_carriage') - invert_axis = dc_config.getboolean('invert_axis', False) + self.inverted = dc_config.getboolean('inverted', False) # itersolve parameters self.rails = [ stepper.PrinterRail(config.getsection('stepper_x')), @@ -25,7 +25,7 @@ def __init__(self, toolhead, config): stepper.LookupMultiRail(config.getsection('stepper_z'))] self.rails[1].get_endstops()[0][0].add_stepper( self.rails[0].get_steppers()[0]) - if invert_axis == False: + if self.inverted == False: self.rails[0].setup_itersolve('corexy_stepper_alloc', b'-') else: self.rails[0].setup_itersolve('corexy_stepper_alloc', b'+') @@ -42,7 +42,7 @@ def __init__(self, toolhead, config): self.rails.append(stepper.PrinterRail(dc_config)) self.rails[1].get_endstops()[0][0].add_stepper( self.rails[3].get_steppers()[0]) - if invert_axis == False: + if self.inverted == False: self.rails[3].setup_itersolve('corexy_stepper_alloc', b'+') else: self.rails[3].setup_itersolve('corexy_stepper_alloc', b'-') @@ -70,9 +70,15 @@ 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 [pos[0] - pos[1], pos[1], pos[2]] + else: + return [pos[0] + 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, diff --git a/klippy/kinematics/idex_modes.py b/klippy/kinematics/idex_modes.py index eb4fb2ccf7da..b7ce30b8cebb 100644 --- a/klippy/kinematics/idex_modes.py +++ b/klippy/kinematics/idex_modes.py @@ -20,8 +20,7 @@ def __init__(self, dc_config, rail_0, rail_1, axis): self.dc = (rail_0, rail_1) self.saved_states = {} safe_dist = dc_config.getfloat('safe_distance', None, minval=0.) - invert_axis = dc_config.getboolean('invert_axis', False) - self.invert_axis = invert_axis + self.inverted = dc_config.getboolean('inverted', False) if safe_dist is None: dc0_rail = rail_0.get_rail() dc1_rail = rail_1.get_rail() From d48eda7b5cf2451f6182b2654b08ce46c6bb5c0a Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Sun, 24 Sep 2023 17:45:38 +0200 Subject: [PATCH 03/12] Update probe.py --- klippy/extras/probe.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/klippy/extras/probe.py b/klippy/extras/probe.py index 04ae1a91beed..337c41b13c9d 100644 --- a/klippy/extras/probe.py +++ b/klippy/extras/probe.py @@ -122,8 +122,6 @@ def _probe(self, speed): pos[2] = self.z_position try: epos = phoming.probing_move(self.mcu_probe, pos, speed) - epos[0] = pos[0] - epos[1] = pos[1] except self.printer.command_error as e: reason = str(e) if "Timeout during endstop homing" in reason: @@ -138,9 +136,6 @@ def _probe(self, speed): axis_twist_compensation.get_z_compensation_value(pos)) # add z compensation to probe position epos[2] += z_compensation - # set the position to the correct toolhead in case of a IDEX - if self.printer.lookup_object('dual_carriage') is not None: - toolhead.set_position(epos) self.gcode.respond_info("probe at %.3f,%.3f is z=%.6f" % (epos[0], epos[1], epos[2])) return epos[:3] From 18930652ffef7d9465f9ed7b57589b46d9cd59b1 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Sun, 24 Sep 2023 17:46:05 +0200 Subject: [PATCH 04/12] Update homing.py --- klippy/extras/homing.py | 27 +-------------------------- 1 file changed, 1 insertion(+), 26 deletions(-) diff --git a/klippy/extras/homing.py b/klippy/extras/homing.py index dd689add20a5..634ad81b74c6 100644 --- a/klippy/extras/homing.py +++ b/klippy/extras/homing.py @@ -43,7 +43,6 @@ def __init__(self, printer, endstops, toolhead=None): toolhead = printer.lookup_object('toolhead') self.toolhead = toolhead self.stepper_positions = [] - self.gcode = self.printer.lookup_object('gcode') def get_mcu_endstops(self): return [es for es, name in self.endstops] def _calc_endstop_rate(self, mcu_endstop, movepos, speed): @@ -65,21 +64,7 @@ def calc_toolhead_pos(self, kin_spos, offsets): sname = stepper.get_name() kin_spos[sname] += offsets.get(sname, 0) * stepper.get_step_dist() thpos = self.toolhead.get_position() - - # ################################################## - # self.gcode.respond_info("HomingMove calc_toolhead_pos kin_spos: " + str(kin_spos)) - # self.gcode.respond_info("HomingMove calc_toolhead_pos thpos: " + str(thpos)) - # ################################################## - # # thpos: [150.0, 150.0, 1.57, 0.0] - # # kin_spos: {'stepper_x': 80.5, 'stepper_y': 150.0, 'stepper_y1': 150.0, 'stepper_z': 1.5665625, 'stepper_z1': 1.5665625, 'stepper_z2': 1.5665625, 'dual_carriage': 0.0} - - dc = self.printer.lookup_object('dual_carriage') - if dc is None: - return list(kin.calc_position(kin_spos))[:3] + thpos[3:] - else: - # to do - return list(kin.calc_position(kin_spos))[:3] + thpos[3:] - + return list(kin.calc_position(kin_spos))[:3] + thpos[3:] def homing_move(self, movepos, speed, probe_pos=False, triggered=True, check_triggered=True): # Notify start of homing/probing move @@ -92,7 +77,6 @@ def homing_move(self, movepos, speed, probe_pos=False, self.stepper_positions = [ StepperPosition(s, name) for es, name in self.endstops for s in es.get_steppers() ] - # Start endstop checking print_time = self.toolhead.get_last_move_time() endstop_triggers = [] @@ -142,14 +126,7 @@ def homing_move(self, movepos, speed, probe_pos=False, self.toolhead.set_position(movepos) halt_kin_spos = {s.get_name(): s.get_commanded_position() for s in kin.get_steppers()} - # ################################################## - # self.gcode.respond_info("HomingMove homing_move halt_kin_spos: " + str(halt_kin_spos)) - # self.gcode.respond_info("HomingMove homing_move haltpos A: " + str(haltpos)) - # ################################################## haltpos = self.calc_toolhead_pos(halt_kin_spos, over_steps) - # ################################################## - # self.gcode.respond_info("HomingMove homing_move haltpos B: " + str(haltpos)) - # ################################################## self.toolhead.set_position(haltpos) # Signal homing/probing move complete try: @@ -176,8 +153,6 @@ def __init__(self, printer): self.changed_axes = [] self.trigger_mcu_pos = {} self.adjust_pos = {} - self.gcode = self.printer.lookup_object('gcode') - def set_axes(self, axes): self.changed_axes = axes def get_axes(self): From f540d24369af88d4cb5a5b94207114fbb0975dd6 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Sun, 24 Sep 2023 17:54:53 +0200 Subject: [PATCH 05/12] Delete Untitled-1.yml --- klippy/kinematics/Untitled-1.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 klippy/kinematics/Untitled-1.yml diff --git a/klippy/kinematics/Untitled-1.yml b/klippy/kinematics/Untitled-1.yml deleted file mode 100644 index 194f57cb98ec..000000000000 --- a/klippy/kinematics/Untitled-1.yml +++ /dev/null @@ -1,15 +0,0 @@ -HomingMove homing_move kin_spos: {'stepper_x': 260.0, 'stepper_y': 260.0, 'stepper_y1': 260.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': -260.0} -HomingMove homing_move kin_spos: {'stepper_x': -153.0, 'stepper_y': -153.0, 'stepper_y1': -153.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 153.0} -G28 Y - - -HomingMove homing_move kin_spos: {'stepper_x': 410.0, 'stepper_y': 260.0, 'stepper_y1': 260.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 112.0} -HomingMove homing_move kin_spos: {'stepper_x': -3.0, 'stepper_y': -153.0, 'stepper_y1': -153.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 525.0} -G28 Y - -HomingMove homing_move kin_spos: {'dual_carriage': 336.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'stepper_x': -73.6875} -HomingMove homing_move kin_spos: {'dual_carriage': -299.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'stepper_x': -73.6875} -HomingMove homing_move kin_spos: {'stepper_x': -34.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 0.0} -HomingMove homing_move kin_spos: {'stepper_x': 601.0, 'stepper_y': 0.0, 'stepper_y1': 0.0, 'stepper_z': 5.0, 'stepper_z1': 5.0, 'stepper_z2': 5.0, 'dual_carriage': 0.0} -DualCarriages home -G28 X \ No newline at end of file From 9053f6c9d8dc9c43c27fcbee4c5b932c85d4aa32 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Sun, 24 Sep 2023 18:14:07 +0200 Subject: [PATCH 06/12] Update hybrid_corexy.py --- klippy/kinematics/hybrid_corexy.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index a1e7aa6d0ae0..d075f1266d2b 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -11,14 +11,12 @@ class HybridCoreXYKinematics: def __init__(self, toolhead, config): self.printer = config.get_printer() - self.gcode = self.printer.lookup_object('gcode') dc_config = None self.inverted = False if config.has_section('dual_carriage'): dc_config = config.getsection('dual_carriage') self.inverted = dc_config.getboolean('inverted', False) - # itersolve parameters self.rails = [ stepper.PrinterRail(config.getsection('stepper_x')), stepper.LookupMultiRail(config.getsection('stepper_y')), From 57305cde0e68d3cecb640c3c60345db143326fc3 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Wed, 27 Sep 2023 19:37:09 +0200 Subject: [PATCH 07/12] root cause fixed --- klippy/kinematics/hybrid_corexy.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index d075f1266d2b..c267a9f8117f 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -69,14 +69,14 @@ def calc_position(self, stepper_positions): if (self.dc_module is not None and 'PRIMARY' == \ self.dc_module.get_status()['carriage_1']): if self.inverted == False: - return [pos[0] - pos[1], pos[1], pos[2]] + return [stepper_positions['dual_carriage'] - pos[1], pos[1], pos[2]] else: - return [pos[0] + pos[1], pos[1], pos[2]] + return [stepper_positions['dual_carriage'] + pos[1], pos[1], pos[2]] else: if self.inverted == False: - return [pos[0] + pos[1], pos[1], pos[2]] + return [stepper_positions['stepper_x'] + pos[1], pos[1], pos[2]] else: - return [pos[0] - pos[1], pos[1], pos[2]] + return [stepper_positions['stepper_x'] - 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, From ae1d07761a571bae73b8fe20e3bf2f814032fa8c Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Wed, 27 Sep 2023 19:41:36 +0200 Subject: [PATCH 08/12] Update hybrid_corexy.py --- klippy/kinematics/hybrid_corexy.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index c267a9f8117f..2f52d7ead64d 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -69,14 +69,18 @@ def calc_position(self, stepper_positions): if (self.dc_module is not None and 'PRIMARY' == \ self.dc_module.get_status()['carriage_1']): if self.inverted == False: - return [stepper_positions['dual_carriage'] - pos[1], pos[1], pos[2]] + return [stepper_positions['dual_carriage'] \ + - pos[1], pos[1], pos[2]] else: - return [stepper_positions['dual_carriage'] + pos[1], pos[1], pos[2]] + return [stepper_positions['dual_carriage'] \ + + pos[1], pos[1], pos[2]] else: if self.inverted == False: - return [stepper_positions['stepper_x'] + pos[1], pos[1], pos[2]] + return [stepper_positions['stepper_x'] \ + + pos[1], pos[1], pos[2]] else: - return [stepper_positions['stepper_x'] - pos[1], pos[1], pos[2]] + return [stepper_positions['stepper_x'] \ + - 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, From d03d0a3731c4275d25349022d38398ab143f293f Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Wed, 27 Sep 2023 19:43:55 +0200 Subject: [PATCH 09/12] Update hybrid_corexy.py --- klippy/kinematics/hybrid_corexy.py | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index 2f52d7ead64d..49b4f4ba405c 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -69,18 +69,16 @@ def calc_position(self, stepper_positions): if (self.dc_module is not None and 'PRIMARY' == \ self.dc_module.get_status()['carriage_1']): if self.inverted == False: - return [stepper_positions['dual_carriage'] \ - - pos[1], pos[1], pos[2]] + return stepper_positions['dual_carriage'] \ + - pos[1], pos[1], pos[2] else: - return [stepper_positions['dual_carriage'] \ - + pos[1], pos[1], pos[2]] + return stepper_positions['dual_carriage'] \ + + pos[1], pos[1], pos[2] else: if self.inverted == False: - return [stepper_positions['stepper_x'] \ - + pos[1], pos[1], pos[2]] + return pos[0] + pos[1], pos[1], pos[2] else: - return [stepper_positions['stepper_x'] \ - - pos[1], pos[1], pos[2]] + 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, From 7dd13df313646ca2bd5809fe63bc7e7103b8dfbf Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Thu, 2 Nov 2023 20:45:48 +0100 Subject: [PATCH 10/12] extended hybrid corexy kinematics --- docs/Config_Reference.md | 6 ++++ klippy/kinematics/hybrid_corexy.py | 50 +++++++++++++++++++----------- klippy/kinematics/idex_modes.py | 1 - 3 files changed, 38 insertions(+), 19 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index 1e5a7626f682..f46b32220357 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2115,6 +2115,12 @@ inverted: # 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 diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index 49b4f4ba405c..bbb9befd0837 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -11,39 +11,53 @@ class HybridCoreXYKinematics: def __init__(self, toolhead, config): self.printer = config.get_printer() - self.gcode = self.printer.lookup_object('gcode') - dc_config = None self.inverted = False - if config.has_section('dual_carriage'): - dc_config = config.getsection('dual_carriage') - self.inverted = dc_config.getboolean('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 = [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].setup_itersolve('corexy_stepper_alloc', b'-') + 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].setup_itersolve('corexy_stepper_alloc', b'+') + 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] self.axes_min = toolhead.Coord(*[r[0] for r in ranges], e=0.) self.axes_max = toolhead.Coord(*[r[1] for r in ranges], e=0.) self.dc_module = None - if dc_config != None: + if config.has_section('dual_carriage'): + dc_config = config.getsection('dual_carriage') # 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.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].setup_itersolve('corexy_stepper_alloc', b'+') + 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].setup_itersolve('corexy_stepper_alloc', b'-') + 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( diff --git a/klippy/kinematics/idex_modes.py b/klippy/kinematics/idex_modes.py index d11bec341c8e..2ce91afe85a5 100644 --- a/klippy/kinematics/idex_modes.py +++ b/klippy/kinematics/idex_modes.py @@ -20,7 +20,6 @@ def __init__(self, dc_config, rail_0, rail_1, axis): self.dc = (rail_0, rail_1) self.saved_states = {} safe_dist = dc_config.getfloat('safe_distance', None, minval=0.) - self.inverted = dc_config.getboolean('inverted', False) if safe_dist is None: dc0_rail = rail_0.get_rail() dc1_rail = rail_1.get_rail() From 492d60a6cb4d7272bb1a254fe37e2e4c89740747 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Thu, 2 Nov 2023 21:09:27 +0100 Subject: [PATCH 11/12] Update hybrid_corexy.py --- klippy/kinematics/hybrid_corexy.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/klippy/kinematics/hybrid_corexy.py b/klippy/kinematics/hybrid_corexy.py index bbb9befd0837..03a90fb4b29c 100644 --- a/klippy/kinematics/hybrid_corexy.py +++ b/klippy/kinematics/hybrid_corexy.py @@ -21,15 +21,19 @@ def __init__(self, toolhead, config): 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'-') + 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'+') + 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'+') + 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'-') + 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') @@ -47,15 +51,19 @@ def __init__(self, toolhead, 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'+') + 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'-') + 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'-') + 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'+') + 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( From 70b1596cfc99fb4f05a30b1fc48be8af7f03b432 Mon Sep 17 00:00:00 2001 From: HelgeKeck Date: Fri, 3 Nov 2023 02:28:03 +0100 Subject: [PATCH 12/12] Update Config_Reference.md --- docs/Config_Reference.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/docs/Config_Reference.md b/docs/Config_Reference.md index f46b32220357..91fa5592c63b 100644 --- a/docs/Config_Reference.md +++ b/docs/Config_Reference.md @@ -2092,8 +2092,6 @@ configuration. axis: # The axis this extra carriage is on (either x or y). This parameter # must be provided. -inverted: -# Set to True in case you have a inverted hybrid core-xy setup. #safe_distance: # The minimum distance (in mm) to enforce between the dual and the primary # carriages. If a G-Code command is executed that will bring the carriages