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

Bring over all the updates I had on main #57

Merged
merged 8 commits into from
Oct 6, 2024
41 changes: 31 additions & 10 deletions AFC.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __init__(self, config):
self.cooling_tube_length = config.getfloat("cooling_tube_length", 10)
self.initial_cooling_speed = config.getfloat("initial_cooling_speed", 10)
self.final_cooling_speed = config.getfloat("final_cooling_speed", 50)
self.cooling_moves = config.getfloat("cooling_moves", 4)
self.cooling_moves = config.getint("cooling_moves", 4)
self.use_skinnydip = config.getboolean("use_skinnydip", False)
self.skinnydip_distance = config.getfloat("skinnydip_distance", 4)
self.dip_insertion_speed = config.getfloat("dip_insertion_speed", 4)
Expand Down Expand Up @@ -103,6 +103,7 @@ def __init__(self, config):
self.short_move_dis = config.getfloat("short_move_dis", 10)
self.tool_unload_speed =config.getfloat("tool_unload_speed", 10)
self.tool_load_speed =config.getfloat("tool_load_speed", 10)
self.tool_max_unload_attempts = config.getint('tool_max_unload_attempts', 2)
self.z_hop =config.getfloat("z_hop", 0)


Expand All @@ -127,9 +128,9 @@ def __init__(self, config):
cmd_LANE_MOVE_help = "Lane Manual Movements"
def cmd_LANE_MOVE(self, gcmd):
lane = gcmd.get('LANE', None)
distance = gcmd.get('DISTANCE', 0)
distance = gcmd.get_float('DISTANCE', 0)
CUR_LANE = self.printer.lookup_object('AFC_stepper ' + lane)
CUR_LANE.move(int(distance), self.short_moves_speed, self.short_moves_accel)
CUR_LANE.move(distance, self.short_moves_speed, self.short_moves_accel)

def respond_info(self, msg):
"""
Expand Down Expand Up @@ -183,8 +184,16 @@ def handle_connect(self):
cmd_TEST_help = "Test Assist Motors"
def cmd_TEST(self, gcmd):
lane = gcmd.get('LANE', None)
if lane == None:
self.respond_error('Must select LANE')
return

self.gcode.respond_info('TEST ROUTINE')
CUR_LANE = self.printer.lookup_object('AFC_stepper '+lane)
try:
CUR_LANE = self.printer.lookup_object('AFC_stepper '+lane)
except error as e:
self.respond_error(str(e))
return
self.gcode.respond_info('Testing at full speed')
CUR_LANE.assist(-1)
self.reactor.pause(self.reactor.monotonic() + 1)
Expand Down Expand Up @@ -491,8 +500,12 @@ def cmd_TOOL_LOAD(self, gcmd):
if self.hub_cut_active:
self.hub_cut(CUR_LANE.name)
if not self.heater.can_extrude: #Heat extruder if not at min temp
self.gcode.respond_info('Extruder below min_extrude_temp, heating to 5 degrees above min')
self.gcode.run_script_from_command('M109 S' + str((self.heater.min_extrude_temp) + 5))
if self.heater.target_temp >= self.heater.min_extrude_temp:
self.gcode.respond_info('Extruder temp is still below min_extrude_temp, waiting for it to finish heating.')
self.gcode.run_script_from_command('M109 S' + str((self.heater.target_temp)))
else:
self.gcode.respond_info('Extruder below min_extrude_temp, heating to 5 degrees above min')
self.gcode.run_script_from_command('M109 S' + str((self.heater.min_extrude_temp) + 5))
CUR_LANE.do_enable(True)
if CUR_LANE.hub_load == False:
CUR_LANE.move(CUR_LANE.dist_hub, self.short_moves_speed, self.short_moves_accel)
Expand Down Expand Up @@ -626,7 +639,15 @@ def cmd_TOOL_UNLOAD(self, gcmd):
else:
self.gcode.run_script_from_command(self.form_tip_cmd)

num_tries = 0
while self.tool.filament_present == True:
num_tries += 1
if num_tries > self.tool_max_unload_attempts:
self.pause_print()
msg = ('FAILED TO UNLOAD ' + CUR_LANE.name.upper() + '. FILAMENT STUCK IN TOOLHEAD.\n||=====||====||====|x|\nTRG LOAD HUB TOOL')
self.respond_error(msg, raise_error=False)
self.afc_led(self.led_fault, CUR_LANE.led_index)
return
pos = self.toolhead.get_position()
pos[3] += self.tool_stn_unload * -1
self.toolhead.manual_move(pos, self.tool_unload_speed)
Expand Down Expand Up @@ -776,10 +797,10 @@ def afc_tip_form(self):
self.gcode.respond_info('AFC-TIP-FORM: Step ' + str(step) + ': Retraction & Nozzle Separation')
total_retraction_distance = self.cooling_tube_position + self.cooling_tube_length - 15
self.afc_extrude(-15, self.unloading_speed_start * 60)
if self.total_retraction_dis > 0:
self.afc_extrude(.7 * total_retraction_distance, 1.0 * self.unloading_speed)
self.afc_extrude(.2 * total_retraction_distance, 0.5 * self.unloading_speed)
self.afc_extrude(.1 * total_retraction_distance, 0.3 * self.unloading_speed)
if total_retraction_distance > 0:
self.afc_extrude(-.7 * total_retraction_distance, 1.0 * self.unloading_speed * 60)
self.afc_extrude(-.2 * total_retraction_distance, 0.5 * self.unloading_speed * 60)
self.afc_extrude(-.1 * total_retraction_distance, 0.3 * self.unloading_speed * 60)

if self.toolchange_temp > 0:
if self.use_skinnydip:
Expand Down
3 changes: 1 addition & 2 deletions AFC_stepper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import math
import chelper
import time
from kinematics import extruder
from . import AFC_assist

Expand Down Expand Up @@ -213,7 +212,7 @@ def prep_callback(self, eventtime, state):
x += 1
self.do_enable(True)
self.move(10,500,400)
time.sleep(0.1)
self.reactor.pause(self.reactor.monotonic() + 0.1)
if x> 20:
msg = (' FAILED TO LOAD, CHECK FILAMENT AT TRIGGER\n||==>--||----||------||\nTRG LOAD HUB TOOL')
self.AFC.respond_error(msg, raise_error=False)
Expand Down
4 changes: 2 additions & 2 deletions Klipper_cfg_example/AFC/AFC.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ use_skinnydip: False # Enable skinny dip moves (for burning off filam
skinnydip_distance: 30 # Distance to reinsert the filament, starting at the end of the cooling tube in mm.
dip_insertion_speed: 30 # Insertion speed for burning off filament hairs in mm/s.
dip_extraction_speed: 70 # Extraction speed (set to around 2x the insertion speed) in mm/s.
melt_zone_pause: 0 # Pause time in the melt zone in ms.
cooling_zone_pause: 0 # Pause time in the cooling zone after the dip in ms.
melt_zone_pause: 0 # Pause time in the melt zone in seconds.
cooling_zone_pause: 0 # Pause time in the cooling zone after the dip in seconds.


#--=================================================================================--#
Expand Down