예제 #1
0
 def __init__(self, toolhead, config):
     # Setup axis rails
     self.rails = [ stepper.PrinterRail(config.getsection('stepper_x')),
                    stepper.PrinterRail(config.getsection('stepper_y')),
                    stepper.LookupMultiRail(config.getsection('stepper_z')) ]
     self.rails[0].get_endstops()[0][0].add_stepper(
         self.rails[1].get_steppers()[0])
     self.rails[1].get_endstops()[0][0].add_stepper(
         self.rails[0].get_steppers()[0])
     self.rails[0].setup_itersolve('corexy_stepper_alloc', '+')
     self.rails[1].setup_itersolve('corexy_stepper_alloc', '-')
     self.rails[2].setup_itersolve('cartesian_stepper_alloc', 'z')
     for s in self.get_steppers():
         s.set_trapq(toolhead.get_trapq())
         toolhead.register_step_generator(s.generate_steps)
     config.get_printer().register_event_handler("stepper_enable:motor_off",
                                                 self._motor_off)
     # Setup boundary checks
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat(
         'max_z_velocity', max_velocity, above=0., maxval=max_velocity)
     self.max_z_accel = config.getfloat(
         'max_z_accel', max_accel, above=0., maxval=max_accel)
     self.limits = [(1.0, -1.0)] * 3
     # Setup stepper max halt velocity
     max_halt_velocity = toolhead.get_max_axis_halt()
     max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
     max_xy_accel = max_accel * math.sqrt(2.)
     self.rails[0].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
     self.rails[1].set_max_jerk(max_xy_halt_velocity, max_xy_accel)
     self.rails[2].set_max_jerk(
         min(max_halt_velocity, self.max_z_velocity), self.max_z_accel)
예제 #2
0
 def __init__(self, toolhead, config):
     # Setup axis rails
     self.rails = [
         stepper.PrinterRail(config.getsection('stepper_x')),
         stepper.PrinterRail(config.getsection('stepper_y')),
         stepper.PrinterRail(config.getsection('stepper_z'))
     ]
     self.rails[0].get_endstops()[0][0].add_stepper(
         self.rails[2].get_steppers()[0])
     self.rails[2].get_endstops()[0][0].add_stepper(
         self.rails[0].get_steppers()[0])
     self.rails[0].setup_itersolve('corexz_stepper_alloc', b'+')
     self.rails[1].setup_itersolve('cartesian_stepper_alloc', b'y')
     self.rails[2].setup_itersolve('corexz_stepper_alloc', b'-')
     for s in self.get_steppers():
         s.set_trapq(toolhead.get_trapq())
         toolhead.register_step_generator(s.generate_steps)
     config.get_printer().register_event_handler("stepper_enable:motor_off",
                                                 self._motor_off)
     # Setup boundary checks
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat('max_z_velocity',
                                           max_velocity,
                                           above=0.,
                                           maxval=max_velocity)
     self.max_z_accel = config.getfloat('max_z_accel',
                                        max_accel,
                                        above=0.,
                                        maxval=max_accel)
     self.limits = [(1.0, -1.0)] * 3
     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.)
예제 #3
0
 def __init__(self, toolhead, config):
     # Setup axis rails
     self.rails = [
         stepper.PrinterRail(config.getsection('stepper_x')),
         stepper.PrinterRail(config.getsection('stepper_y')),
         stepper.LookupMultiRail(config.getsection('stepper_z'))
     ]
     self.rails[0].add_to_endstop(self.rails[1].get_endstops()[0][0])
     self.rails[1].add_to_endstop(self.rails[0].get_endstops()[0][0])
     self.rails[0].setup_itersolve('corexy_stepper_alloc', '+')
     self.rails[1].setup_itersolve('corexy_stepper_alloc', '-')
     self.rails[2].setup_itersolve('cartesian_stepper_alloc', 'z')
     # Setup boundary checks
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat('max_z_velocity',
                                           max_velocity,
                                           above=0.,
                                           maxval=max_velocity)
     self.max_z_accel = config.getfloat('max_z_accel',
                                        max_accel,
                                        above=0.,
                                        maxval=max_accel)
     self.need_motor_enable = True
     self.limits = [(1.0, -1.0)] * 3
     # Setup stepper max halt velocity
     max_halt_velocity = toolhead.get_max_axis_halt()
     max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
     self.rails[0].set_max_jerk(max_xy_halt_velocity, max_accel)
     self.rails[1].set_max_jerk(max_xy_halt_velocity, max_accel)
     self.rails[2].set_max_jerk(min(max_halt_velocity, self.max_z_velocity),
                                self.max_z_accel)
예제 #4
0
 def __init__(self, toolhead, config):
     self.rails = [
         stepper.PrinterRail(config.getsection('stepper_x')),
         stepper.PrinterRail(config.getsection('stepper_y')),
         stepper.LookupMultiRail(config.getsection('stepper_z'))
     ]
     self.rails[0].add_to_endstop(self.rails[1].get_endstops()[0][0])
     self.rails[1].add_to_endstop(self.rails[0].get_endstops()[0][0])
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat('max_z_velocity',
                                           max_velocity,
                                           above=0.,
                                           maxval=max_velocity)
     self.max_z_accel = config.getfloat('max_z_accel',
                                        max_accel,
                                        above=0.,
                                        maxval=max_accel)
     self.need_motor_enable = True
     self.limits = [(1.0, -1.0)] * 3
     # Setup iterative solver
     ffi_main, ffi_lib = chelper.get_ffi()
     self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
     self.move_fill = ffi_lib.move_fill
     self.rails[0].setup_itersolve(
         ffi_main.gc(ffi_lib.corexy_stepper_alloc('+'), ffi_lib.free))
     self.rails[1].setup_itersolve(
         ffi_main.gc(ffi_lib.corexy_stepper_alloc('-'), ffi_lib.free))
     self.rails[2].setup_cartesian_itersolve('z')
     # Setup stepper max halt velocity
     max_halt_velocity = toolhead.get_max_axis_halt()
     max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
     self.rails[0].set_max_jerk(max_xy_halt_velocity, max_accel)
     self.rails[1].set_max_jerk(max_xy_halt_velocity, max_accel)
     self.rails[2].set_max_jerk(min(max_halt_velocity, self.max_z_velocity),
                                self.max_z_accel)
예제 #5
0
 def __init__(self, toolhead, config):
     # Setup axis steppers
     stepper_bed = stepper.PrinterStepper(config.getsection('stepper_bed'),
                                          units_in_radians=True)
     rail_arm = stepper.PrinterRail(config.getsection('stepper_arm'))
     rail_z = stepper.LookupMultiRail(config.getsection('stepper_z'))
     stepper_bed.setup_itersolve('polar_stepper_alloc', 'a')
     rail_arm.setup_itersolve('polar_stepper_alloc', 'r')
     rail_z.setup_itersolve('cartesian_stepper_alloc', 'z')
     self.rails = [rail_arm, rail_z]
     self.steppers = [stepper_bed
                      ] + [s for r in self.rails for s in r.get_steppers()]
     for s in self.get_steppers():
         s.set_trapq(toolhead.get_trapq())
         toolhead.register_step_generator(s.generate_steps)
     config.get_printer().register_event_handler("stepper_enable:motor_off",
                                                 self._motor_off)
     # Setup boundary checks
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat('max_z_velocity',
                                           max_velocity,
                                           above=0.,
                                           maxval=max_velocity)
     self.max_z_accel = config.getfloat('max_z_accel',
                                        max_accel,
                                        above=0.,
                                        maxval=max_accel)
     self.limit_z = (1.0, -1.0)
     self.limit_xy2 = -1.
     # Setup stepper max halt velocity
     max_halt_velocity = toolhead.get_max_axis_halt()
     stepper_bed.set_max_jerk(max_halt_velocity, max_accel)
     rail_arm.set_max_jerk(max_halt_velocity, max_accel)
     rail_z.set_max_jerk(max_halt_velocity, max_accel)
예제 #6
0
 def __init__(self, config):
     self.printer = config.get_printer()
     if config.get('endstop_pin', None) is not None:
         self.can_home = True
         self.rail = stepper.PrinterRail(config,
                                         need_position_minmax=False,
                                         default_position_endstop=0.)
         self.steppers = self.rail.get_steppers()
     else:
         self.can_home = False
         self.rail = stepper.PrinterStepper(config)
         self.steppers = [self.rail]
     self.velocity = config.getfloat('velocity', 5., above=0.)
     self.accel = config.getfloat('accel', 0., minval=0.)
     self.next_cmd_time = 0.
     # Setup iterative solver
     ffi_main, ffi_lib = chelper.get_ffi()
     self.trapq = ffi_main.gc(ffi_lib.trapq_alloc(), ffi_lib.trapq_free)
     self.trapq_append = ffi_lib.trapq_append
     self.trapq_free_moves = ffi_lib.trapq_free_moves
     self.rail.setup_itersolve('cartesian_stepper_alloc', 'x')
     self.rail.set_trapq(self.trapq)
     self.rail.set_max_jerk(9999999.9, 9999999.9)
     # Register commands
     stepper_name = config.get_name().split()[1]
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_mux_command('MANUAL_STEPPER',
                                     "STEPPER",
                                     stepper_name,
                                     self.cmd_MANUAL_STEPPER,
                                     desc=self.cmd_MANUAL_STEPPER_help)
예제 #7
0
 def __init__(self, toolhead, config):
     # Setup axis steppers
     stepper_bed = stepper.PrinterStepper(config.getsection('stepper_bed'))
     rail_arm = stepper.PrinterRail(config.getsection('stepper_arm'))
     rail_z = stepper.LookupMultiRail(config.getsection('stepper_z'))
     stepper_bed.setup_itersolve('polar_stepper_alloc', 'a')
     rail_arm.setup_itersolve('polar_stepper_alloc', 'r')
     rail_z.setup_itersolve('cartesian_stepper_alloc', 'z')
     self.rails = [rail_arm, rail_z]
     self.steppers = [stepper_bed
                      ] + [s for r in self.rails for s in r.get_steppers()]
     # Setup boundary checks
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat('max_z_velocity',
                                           max_velocity,
                                           above=0.,
                                           maxval=max_velocity)
     self.max_z_accel = config.getfloat('max_z_accel',
                                        max_accel,
                                        above=0.,
                                        maxval=max_accel)
     self.need_motor_enable = True
     self.limit_z = [(1.0, -1.0)]
     self.limit_xy2 = -1.
     # Setup stepper max halt velocity
     max_halt_velocity = toolhead.get_max_axis_halt()
     stepper_bed.set_max_jerk(max_halt_velocity, max_accel)
     rail_arm.set_max_jerk(max_halt_velocity, max_accel)
     rail_z.set_max_jerk(max_halt_velocity, max_accel)
예제 #8
0
 def __init__(self, config):
     self.printer = config.get_printer()
     if config.get('endstop_pin', None) is not None:
         self.can_home = True
         self.stepper = stepper.PrinterRail(config,
                                            need_position_minmax=False,
                                            default_position_endstop=0.)
     else:
         self.can_home = False
         self.stepper = stepper.PrinterStepper(config)
     self.next_cmd_time = 0.
     # Setup iterative solver
     ffi_main, ffi_lib = chelper.get_ffi()
     self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
     self.move_fill = ffi_lib.move_fill
     self.stepper.setup_itersolve('cartesian_stepper_alloc', 'x')
     self.stepper.set_max_jerk(9999999.9, 9999999.9)
     # Register commands
     stepper_name = config.get_name().split()[1]
     self.gcode = self.printer.lookup_object('gcode')
     self.gcode.register_mux_command('MANUAL_STEPPER',
                                     "STEPPER",
                                     stepper_name,
                                     self.cmd_MANUAL_STEPPER,
                                     desc=self.cmd_MANUAL_STEPPER_help)
     self.printer.register_event_handler("toolhead:motor_off",
                                         self.handle_motor_off)
예제 #9
0
 def __init__(self, toolhead, config):
     self.printer = config.get_printer()
     printer_config = config.getsection('printer')
     # 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[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')
         # 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('cartesian_stepper_alloc', b'y')
         dc_rail_0 = idex_modes.DualCarriagesRail(
             self.printer, self.rails[0], axis=0, active=True,
             stepper_alloc_active=('corexy_stepper_alloc', b'-'),
             stepper_alloc_inactive=('cartesian_reverse_stepper_alloc',b'y'))
         dc_rail_1 = idex_modes.DualCarriagesRail(
             self.printer, self.rails[3], axis=0, active=False,
             stepper_alloc_active=('corexy_stepper_alloc', b'+'),
             stepper_alloc_inactive=('cartesian_stepper_alloc', b'y'))
         self.dc_module = idex_modes.DualCarriages(self.printer,
                     dc_rail_0, dc_rail_1, axis=0)
     for s in self.get_steppers():
         s.set_trapq(toolhead.get_trapq())
         toolhead.register_step_generator(s.generate_steps)
     self.printer.register_event_handler("stepper_enable:motor_off",
                                                 self._motor_off)
     # Setup boundary checks
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat(
         'max_z_velocity', max_velocity, above=0., maxval=max_velocity)
     self.max_z_accel = config.getfloat(
         'max_z_accel', max_accel, above=0., maxval=max_accel)
     self.limits = [(1.0, -1.0)] * 3
예제 #10
0
 def __init__(self, toolhead, config, coresign=1.):
     self.toolhead = toolhead
     self.logger = config.get_printer().logger.getChild(self.name)
     self.rails = [ stepper.PrinterRail(config.getsection('stepper_x')),
                    stepper.PrinterRail(config.getsection('stepper_y')),
                    stepper.LookupMultiRail(config.getsection('stepper_z')) ]
     self.combined_endstops = config.getboolean('combined_endstops', False)
     if self.combined_endstops:
         # endstops are always triggered both
         #   => no cross connection necessary
         pass
     else:
         # x/y axes also need to stop on each others endstops
         #   => cross connect endstop and stepper x->y and y->x
         self.rails[0].add_to_endstop(self.rails[1].get_endstops()[0][0])
         self.rails[1].add_to_endstop(self.rails[0].get_endstops()[0][0])
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat(
         'max_z_velocity', max_velocity, above=0., maxval=max_velocity)
     self.max_z_accel = config.getfloat(
         'max_z_accel', max_accel, above=0., maxval=max_accel)
     self.need_motor_enable = True
     if toolhead.allow_move_wo_homing is False:
         self.limits = [(1.0, -1.0)] * 3
     else:
         # Just set min and max values for SW limit
         self.limits = [ rail.get_range() for rail in self.rails ]
     # Setup iterative solver
     ffi_main, ffi_lib = chelper.get_ffi()
     self.cmove = ffi_main.gc(ffi_lib.move_alloc(), ffi_lib.free)
     self.move_fill = ffi_lib.move_fill
     self.rails[0].setup_itersolve(ffi_main.gc(
         ffi_lib.corexy_stepper_alloc('+'), ffi_lib.free))
     self.rails[1].setup_itersolve(ffi_main.gc(
         ffi_lib.corexy_stepper_alloc('-'), ffi_lib.free))
     self.rails[2].setup_cartesian_itersolve('z')
     # Setup stepper max halt velocity
     max_halt_velocity = toolhead.get_max_axis_halt()
     max_xy_halt_velocity = max_halt_velocity * math.sqrt(2.)
     self.rails[0].set_max_jerk(max_xy_halt_velocity, max_accel, max_velocity)
     self.rails[1].set_max_jerk(max_xy_halt_velocity, max_accel, max_velocity)
     self.rails[2].set_max_jerk(
         min(max_halt_velocity, self.max_z_velocity), self.max_z_accel, self.max_z_velocity)
     self.coresign = coresign
     self.experimental = config.getboolean(
         'experimental', False)
예제 #11
0
    def __init__(self, toolhead, config):
        self.printer = config.get_printer()
        # Setup axis rails
        self.rails = [ stepper.PrinterRail(config.getsection('stepper_x')),
                       stepper.PrinterRail(config.getsection('stepper_y')),
                       stepper.LookupMultiRail(config.getsection('stepper_z')) ]
#        self.rails[0].add_to_endstop(self.rails[1].get_endstops()[0][0])
#        self.rails[1].add_to_endstop(self.rails[1].get_endstops()[0][0])
#        self.rails[2].add_to_endstop(self.rails[0].get_endstops()[0][0])
        self.rails[0].setup_itersolve('markforged_stepper_alloc', 'a')
        self.rails[1].setup_itersolve('markforged_stepper_alloc', 'b')
        self.rails[2].setup_itersolve('cartesian_stepper_alloc', 'z')
        # Setup boundary checks
        max_velocity, max_accel = toolhead.get_max_velocity()
        self.max_z_velocity = config.getfloat(
            'max_z_velocity', max_velocity, above=0., maxval=max_velocity)
        self.max_z_accel = config.getfloat(
            'max_z_accel', max_accel, above=0., maxval=max_accel)
        self.need_motor_enable = True
        self.limits = [(1.0, -1.0)] * 3
        # Setup stepper max halt velocity
        max_halt_velocity = toolhead.get_max_axis_halt()
        self.rails[0].set_max_jerk(max_halt_velocity, max_accel) #TODO calc value for markforged value
        self.rails[1].set_max_jerk(max_halt_velocity, max_accel) #TODO calc value for markforged value
        self.rails[2].set_max_jerk(
            min(max_halt_velocity, self.max_z_velocity), self.max_z_accel)

        # Check for dual carriage support
        self.dual_carriage_axis = None
        self.dual_carriage_rails = []
        if config.has_section('dual_carriage'):
            dc_config = config.getsection('dual_carriage')
            dc_axis = dc_config.getchoice('axis', {'x': 'x', 'y': 'y'})
            self.dual_carriage_axis = {'x': 0, 'y': 1}[dc_axis]
            dc_rail = stepper.PrinterRail(dc_config)
            dc_rail.setup_itersolve('markforged_stepper_alloc', dc_axis)
            dc_rail.set_max_jerk(max_halt_velocity, max_accel)
            self.dual_carriage_rails = [
                self.rails[self.dual_carriage_axis], dc_rail]
            self.printer.lookup_object('gcode').register_command(
                'SET_DUAL_CARRIAGE', self.cmd_SET_DUAL_CARRIAGE,
                desc=self.cmd_SET_DUAL_CARRIAGE_help)
예제 #12
0
 def __init__(self, toolhead, config):
     self.printer = config.get_printer()
     self.rails = [
         stepper.PrinterRail(config.getsection('stepper_' + n))
         for n in ['t', 'd', 's']
     ]
     # add additional endstop to drive
     ppins = self.printer.lookup_object('pins')
     extruder_es = config.get('extruder_endstop', None)
     if extruder_es is not None:
         ex_pin = ppins.setup_pin('endstop', extruder_es)
         self.rails[1].add_to_endstop(ex_pin)
     self.drive_endstop = self.rails[1].get_endstops()[0]
     self.need_motor_enable = True
     self.max_velocity, self.max_accel = toolhead.get_max_velocity()
     self.limits = [(1.0, -1.0)] * 3
     for axis, rail in zip('xyz', self.rails):
         rail.setup_itersolve('cartesian_stepper_alloc', axis)
예제 #13
0
파일: delta.py 프로젝트: unnefer1/klipper
    def __init__(self, toolhead, config):
        # Setup tower rails
        stepper_configs = [
            config.getsection('stepper_' + n) for n in ['a', 'b', 'c']
        ]
        rail_a = stepper.PrinterRail(stepper_configs[0],
                                     need_position_minmax=False)
        a_endstop = rail_a.get_homing_info().position_endstop
        rail_b = stepper.PrinterRail(stepper_configs[1],
                                     need_position_minmax=False,
                                     default_position_endstop=a_endstop)
        rail_c = stepper.PrinterRail(stepper_configs[2],
                                     need_position_minmax=False,
                                     default_position_endstop=a_endstop)
        self.rails = [rail_a, rail_b, rail_c]
        # Read radius and arm lengths
        self.radius = radius = config.getfloat('delta_radius', above=0.)
        arm_length_a = stepper_configs[0].getfloat('arm_length', above=radius)
        self.arm_lengths = arm_lengths = [
            sconfig.getfloat('arm_length', arm_length_a, above=radius)
            for sconfig in stepper_configs
        ]
        self.arm2 = [arm**2 for arm in arm_lengths]
        self.endstops = [(rail.get_homing_info().position_endstop +
                          math.sqrt(arm2 - radius**2))
                         for rail, arm2 in zip(self.rails, self.arm2)]
        # Setup boundary checks
        self.need_motor_enable = self.need_home = True
        self.limit_xy2 = -1.
        self.max_z = min(
            [rail.get_homing_info().position_endstop for rail in self.rails])
        self.min_z = config.getfloat('minimum_z_position',
                                     0,
                                     maxval=self.max_z)
        self.limit_z = min(
            [ep - arm for ep, arm in zip(self.endstops, arm_lengths)])
        logging.info(
            "Delta max build height %.2fmm (radius tapered above %.2fmm)" %
            (self.max_z, self.limit_z))
        # Setup stepper max halt velocity
        self.max_velocity, self.max_accel = toolhead.get_max_velocity()
        self.max_z_velocity = config.getfloat('max_z_velocity',
                                              self.max_velocity,
                                              above=0.,
                                              maxval=self.max_velocity)
        max_halt_velocity = toolhead.get_max_axis_halt()
        for rail in self.rails:
            rail.set_max_jerk(max_halt_velocity, self.max_accel)
        # Determine tower locations in cartesian space
        self.angles = [
            sconfig.getfloat('angle', angle)
            for sconfig, angle in zip(stepper_configs, [210., 330., 90.])
        ]
        self.towers = [(math.cos(math.radians(angle)) * radius,
                        math.sin(math.radians(angle)) * radius)
                       for angle in self.angles]
        for r, a, t in zip(self.rails, self.arm2, self.towers):
            r.setup_itersolve('delta_stepper_alloc', a, t[0], t[1])
        # Find the point where an XY move could result in excessive
        # tower movement
        half_min_step_dist = min(
            [r.get_steppers()[0].get_step_dist() for r in self.rails]) * .5
        min_arm_length = min(arm_lengths)

        def ratio_to_dist(ratio):
            return (
                ratio * math.sqrt(min_arm_length**2 /
                                  (ratio**2 + 1.) - half_min_step_dist**2) +
                half_min_step_dist)

        self.slow_xy2 = (ratio_to_dist(SLOW_RATIO) - radius)**2
        self.very_slow_xy2 = (ratio_to_dist(2. * SLOW_RATIO) - radius)**2
        self.max_xy2 = min(radius, min_arm_length - radius,
                           ratio_to_dist(4. * SLOW_RATIO) - radius)**2
        logging.info(
            "Delta max build radius %.2fmm (moves slowed past %.2fmm and %.2fmm)"
            % (math.sqrt(self.max_xy2), math.sqrt(
                self.slow_xy2), math.sqrt(self.very_slow_xy2)))
        self.set_position([0., 0., 0.], ())
예제 #14
0
 def __init__(self, toolhead, config):
     # Setup tower rails
     stepper_configs = [config.getsection('stepper_' + a) for a in 'abc']
     rail_a = stepper.PrinterRail(stepper_configs[0],
                                  need_position_minmax=False,
                                  units_in_radians=True)
     a_endstop = rail_a.get_homing_info().position_endstop
     rail_b = stepper.PrinterRail(stepper_configs[1],
                                  need_position_minmax=False,
                                  default_position_endstop=a_endstop,
                                  units_in_radians=True)
     rail_c = stepper.PrinterRail(stepper_configs[2],
                                  need_position_minmax=False,
                                  default_position_endstop=a_endstop,
                                  units_in_radians=True)
     self.rails = [rail_a, rail_b, rail_c]
     config.get_printer().register_event_handler("stepper_enable:motor_off",
                                                 self._motor_off)
     # Setup stepper max halt velocity
     max_velocity, max_accel = toolhead.get_max_velocity()
     self.max_z_velocity = config.getfloat('max_z_velocity',
                                           max_velocity,
                                           above=0.,
                                           maxval=max_velocity)
     for rail in self.rails:
         rail.set_max_jerk(9999999.9, 9999999.9)
     # Read config
     shoulder_radius = config.getfloat('shoulder_radius', above=0.)
     shoulder_height = config.getfloat('shoulder_height', above=0.)
     a_upper_arm = stepper_configs[0].getfloat('upper_arm_length', above=0.)
     upper_arms = [
         sconfig.getfloat('upper_arm_length', a_upper_arm, above=0.)
         for sconfig in stepper_configs
     ]
     a_lower_arm = stepper_configs[0].getfloat('lower_arm_length', above=0.)
     lower_arms = [
         sconfig.getfloat('lower_arm_length', a_lower_arm, above=0.)
         for sconfig in stepper_configs
     ]
     angles = [
         sconfig.getfloat('angle', angle)
         for sconfig, angle in zip(stepper_configs, [30., 150., 270.])
     ]
     # Setup rotary delta calibration helper
     endstops = [
         rail.get_homing_info().position_endstop for rail in self.rails
     ]
     stepdists = [
         rail.get_steppers()[0].get_step_dist() for rail in self.rails
     ]
     self.calibration = RotaryDeltaCalibration(shoulder_radius,
                                               shoulder_height, angles,
                                               upper_arms, lower_arms,
                                               endstops, stepdists)
     # Setup iterative solver
     for r, a, ua, la in zip(self.rails, angles, upper_arms, lower_arms):
         r.setup_itersolve('rotary_delta_stepper_alloc', shoulder_radius,
                           shoulder_height, math.radians(a), ua, la)
     for s in self.get_steppers():
         s.set_trapq(toolhead.get_trapq())
         toolhead.register_step_generator(s.generate_steps)
     # Setup boundary checks
     self.need_home = True
     self.limit_xy2 = -1.
     eangles = [
         r.calc_position_from_coord([0., 0., ep])
         for r, ep in zip(self.rails, endstops)
     ]
     self.home_position = tuple(
         self.calibration.actuator_to_cartesian(eangles))
     self.max_z = min(endstops)
     self.min_z = config.getfloat('minimum_z_position',
                                  0,
                                  maxval=self.max_z)
     min_ua = min([shoulder_radius + ua for ua in upper_arms])
     min_la = min([la - shoulder_radius for la in lower_arms])
     self.max_xy2 = min(min_ua, min_la)**2
     arm_z = [
         self.calibration.elbow_coord(i, ea)[2]
         for i, ea in enumerate(eangles)
     ]
     self.limit_z = min([az - la for az, la in zip(arm_z, lower_arms)])
     logging.info(
         "Delta max build height %.2fmm (radius tapered above %.2fmm)" %
         (self.max_z, self.limit_z))
     self.set_position([0., 0., 0.], ())
예제 #15
0
파일: delta.py 프로젝트: zhantyzgz/klipper
    def __init__(self, toolhead, config):
        # Setup tower rails
        stepper_configs = [config.getsection('stepper_' + a) for a in 'abc']
        rail_a = stepper.PrinterRail(stepper_configs[0],
                                     need_position_minmax=False)
        a_endstop = rail_a.get_homing_info().position_endstop
        rail_b = stepper.PrinterRail(stepper_configs[1],
                                     need_position_minmax=False,
                                     default_position_endstop=a_endstop)
        rail_c = stepper.PrinterRail(stepper_configs[2],
                                     need_position_minmax=False,
                                     default_position_endstop=a_endstop)
        self.rails = [rail_a, rail_b, rail_c]
        config.get_printer().register_event_handler("stepper_enable:motor_off",
                                                    self._motor_off)
        # Setup max velocity
        self.max_velocity, self.max_accel = toolhead.get_max_velocity()
        self.max_z_velocity = config.getfloat('max_z_velocity',
                                              self.max_velocity,
                                              above=0.,
                                              maxval=self.max_velocity)
        # Read radius and arm lengths
        self.radius = radius = config.getfloat('delta_radius', above=0.)
        print_radius = config.getfloat('print_radius', radius, above=0.)
        arm_length_a = stepper_configs[0].getfloat('arm_length', above=radius)
        self.arm_lengths = arm_lengths = [
            sconfig.getfloat('arm_length', arm_length_a, above=radius)
            for sconfig in stepper_configs
        ]
        self.arm2 = [arm**2 for arm in arm_lengths]
        self.abs_endstops = [(rail.get_homing_info().position_endstop +
                              math.sqrt(arm2 - radius**2))
                             for rail, arm2 in zip(self.rails, self.arm2)]
        # Determine tower locations in cartesian space
        self.angles = [
            sconfig.getfloat('angle', angle)
            for sconfig, angle in zip(stepper_configs, [210., 330., 90.])
        ]
        self.towers = [(math.cos(math.radians(angle)) * radius,
                        math.sin(math.radians(angle)) * radius)
                       for angle in self.angles]
        for r, a, t in zip(self.rails, self.arm2, self.towers):
            r.setup_itersolve('delta_stepper_alloc', a, t[0], t[1])
        for s in self.get_steppers():
            s.set_trapq(toolhead.get_trapq())
            toolhead.register_step_generator(s.generate_steps)
        # Setup boundary checks
        self.need_home = True
        self.limit_xy2 = -1.
        self.home_position = tuple(
            self._actuator_to_cartesian(self.abs_endstops))
        self.max_z = min(
            [rail.get_homing_info().position_endstop for rail in self.rails])
        self.min_z = config.getfloat('minimum_z_position',
                                     0,
                                     maxval=self.max_z)
        self.limit_z = min(
            [ep - arm for ep, arm in zip(self.abs_endstops, arm_lengths)])
        logging.info(
            "Delta max build height %.2fmm (radius tapered above %.2fmm)" %
            (self.max_z, self.limit_z))
        # Find the point where an XY move could result in excessive
        # tower movement
        half_min_step_dist = min(
            [r.get_steppers()[0].get_step_dist() for r in self.rails]) * .5
        min_arm_length = min(arm_lengths)

        def ratio_to_xy(ratio):
            return (
                ratio * math.sqrt(min_arm_length**2 /
                                  (ratio**2 + 1.) - half_min_step_dist**2) +
                half_min_step_dist - radius)

        self.slow_xy2 = ratio_to_xy(SLOW_RATIO)**2
        self.very_slow_xy2 = ratio_to_xy(2. * SLOW_RATIO)**2
        self.max_xy2 = min(print_radius, min_arm_length - radius,
                           ratio_to_xy(4. * SLOW_RATIO))**2
        max_xy = math.sqrt(self.max_xy2)
        logging.info(
            "Delta max build radius %.2fmm (moves slowed past %.2fmm"
            " and %.2fmm)" %
            (max_xy, math.sqrt(self.slow_xy2), math.sqrt(self.very_slow_xy2)))
        self.axes_min = toolhead.Coord(-max_xy, -max_xy, self.min_z, 0.)
        self.axes_max = toolhead.Coord(max_xy, max_xy, self.max_z, 0.)
        self.set_position([0., 0., 0.], ())