From 5cd9e09192ab1784723ebd93f43adda118fb2d39 Mon Sep 17 00:00:00 2001 From: zkk <1007518571@qq.com> Date: Sat, 21 Jun 2025 14:13:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=89=93=E5=8D=B0=E4=B8=AD?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=96=B7=E5=A4=B4=20babystep=E5=80=BC?= =?UTF-8?q?=E4=B8=A2=E5=A4=B1=E9=97=AE=E9=A2=98=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E6=9C=80=E5=B0=8F=E6=8C=A4=E5=87=BA=E6=B8=A9=E5=BA=A6=E4=B8=BA?= =?UTF-8?q?100=E2=84=83=20=E4=BD=8E=E4=BA=8E=E6=97=B6=E5=8F=AA=E8=AD=A6?= =?UTF-8?q?=E5=91=8A=E4=B8=8D=E5=81=9C=E6=AD=A2=20=E4=BF=AE=E6=94=B9F430NX?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E5=96=B7=E5=A4=B4=E6=97=B6=E5=80=99=E9=99=8D?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=20=E4=BC=98=E5=8C=96=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E4=B8=AD=E5=88=87=E6=8D=A2=E5=96=B7=E5=A4=B4=E4=B8=8D=E9=87=8D?= =?UTF-8?q?=E7=BD=AE=E6=8C=A4=E5=87=BA=E9=87=8F=EF=BC=8C=E6=89=93=E5=8D=B0?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E6=97=B6=E9=87=8D=E7=BD=AE=E6=8C=A4=E5=87=BA?= =?UTF-8?q?=E9=87=8F=E5=92=8C=E9=80=9F=E5=BA=A6=20=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E6=94=AF=E6=8C=81P800?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Squashed commit of the following: commit 617b5bd632590bb66e6186952d895fe1a8343f0d Merge: 530470a41 434e023f3 Author: zkk <1007518571@qq.com> Date: Sat Jun 21 14:03:49 2025 +0800 # Conflicts: # config/CreatBot_D1000/base.cfg resolved by 617b5bd632590bb66e6186952d895fe1a8343f0d version # config/CreatBot_D1000_V0/base.cfg resolved by 617b5bd632590bb66e6186952d895fe1a8343f0d version # config/CreatBot_D600Pro2/base.cfg resolved by 617b5bd632590bb66e6186952d895fe1a8343f0d version # config/CreatBot_D600Pro2_V0/base.cfg resolved by 617b5bd632590bb66e6186952d895fe1a8343f0d version # config/CreatBot_F430NX/base.cfg resolved by 617b5bd632590bb66e6186952d895fe1a8343f0d version # scripts/graph_mesh.py resolved by master version --- config/CreatBot_D1000/base.cfg | 152 +---- config/CreatBot_D1000_V0/base.cfg | 152 +---- config/CreatBot_D600Pro2/base.cfg | 154 +---- config/CreatBot_D600Pro2_V0/base.cfg | 156 +---- config/CreatBot_F430NX/base.cfg | 140 +---- config/CreatBot_P800/1.1/door_detect.cfg | 1 + config/CreatBot_P800/base.cfg | 701 +++++++++++++++++++++++ config/CreatBot_P800/printer.cfg | 39 ++ klippy/extras/filament_airpump_sensor.py | 142 +++++ klippy/extras/filament_switch_sensor.py | 3 + klippy/extras/gcode_move.py | 2 +- klippy/extras/state_led.py | 116 ++++ klippy/kinematics/extruder.py | 29 +- 13 files changed, 1169 insertions(+), 618 deletions(-) create mode 100644 config/CreatBot_P800/1.1/door_detect.cfg create mode 100644 config/CreatBot_P800/base.cfg create mode 100644 config/CreatBot_P800/printer.cfg create mode 100644 klippy/extras/filament_airpump_sensor.py create mode 100644 klippy/extras/state_led.py diff --git a/config/CreatBot_D1000/base.cfg b/config/CreatBot_D1000/base.cfg index 8178a6d73..30af13834 100644 --- a/config/CreatBot_D1000/base.cfg +++ b/config/CreatBot_D1000/base.cfg @@ -257,7 +257,7 @@ max_power: 1.0 min_temp: -20 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.03 pressure_advance_smooth_time:0.040 # control = pid @@ -307,7 +307,7 @@ max_power: 1.0 min_temp: -20 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.032 pressure_advance_smooth_time:0.040 # control = pid @@ -373,6 +373,9 @@ gcode: [gcode_macro T0] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + {% set z_offset = -z_offset %} {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} {% set filament_insert = True if client.filament_sensor|default("") == "" else True if not printer[client.filament_sensor].enabled @@ -381,10 +384,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z=0 MOVE=1 - {% else %} - SET_GCODE_OFFSET Z=0 + {% if printer.toolhead.extruder != 'extruder' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y=0 SET_GCODE_OFFSET X=0 @@ -411,10 +416,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z={z_offset} MOVE=1 - {% else %} - SET_GCODE_OFFSET Z={z_offset} + {% if printer.toolhead.extruder != 'extruder1' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y={y_offset} SET_GCODE_OFFSET X={x_offset} @@ -445,7 +452,8 @@ gcode: [gcode_macro _CANCEL_PRINT_BASE] description: Call when cancelled to print gcode: - # Nothing + M220 S100 + M221 S100 [gcode_macro START_PRINT] gcode: @@ -489,6 +497,8 @@ gcode: [gcode_macro END_PRINT] gcode: M400 + M220 S100 + M221 S100 G92 E0 G1 E-10.0 F3600 G91 @@ -535,10 +545,14 @@ gcode: [gcode_macro _ACTIVATE_DEFAULT_EXTRUDER] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + SET_GCODE_OFFSET Z=0 {% if printer.toolhead.extruder == 'extruder' %} T0 {% elif printer.toolhead.extruder == 'extruder1' %} T1 + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 {% endif %} ######################################## @@ -1046,15 +1060,11 @@ gcode: {% endif %} {% if adaptive_mesh|lower == 'true' %} - {% if printer.exclude_object.objects != [] %} - {% if idex_mode %} - BED_MESH_CLEAR - {% else %} - BED_MESH_CALIBRATE PROFILE=adaptive - {% endif %} + {% if idex_mode %} + BED_MESH_CLEAR {% else %} - {% if idex_mode %} - BED_MESH_CLEAR + {% if printer.exclude_object.objects != [] %} + BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 {% else %} {% if 'default' in profiles %} BED_MESH_PROFILE LOAD=default @@ -1066,110 +1076,6 @@ gcode: {% endif %} {% endif %} -[gcode_macro BED_MESH_CALIBRATE] -rename_existing: _BED_MESH_CALIBRATE -gcode: - {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points - {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %} # Get bed mesh min from printer.cfg - {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %} # Get bed mesh max from printer.cfg - {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %} # Get probe count from printer.cfg - {% set kamp_settings = printer["gcode_macro Adaptive_Mesh"] %} # Pull variables from _KAMP_Settings - {% set verbose_enable = kamp_settings.verbose_enable | abs %} # Pull verbose setting from _KAMP_Settings - {% set mesh_margin = kamp_settings.mesh_margin | float %} # Pull mesh margin setting from _KAMP_Settings - {% set fuzz_amount = kamp_settings.fuzz_amount | float %} # Pull fuzz amount setting from _KAMP_Settings - {% set default_profile = params.PROFILE | default("default") %} # get default mesh profile - {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %} # If probe count is only a single number, convert it to 2. E.g. probe_count:7 = 7,7 - {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %} # Determine max probe point distance - {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %} # Determine max probe point distance - {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %} # Set x_min from smallest object x point - {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %} # Set y_min from smallest object y point - {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %} # Set x_max from largest object x point - {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %} # Set y_max from largest object y point - - {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %} # Set fuzz_range between 0 and fuzz_amount - {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt x_min to margin and fuzz constraints - {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt y_min to margin and fuzz constraints - {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints - {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt y_max to margin and fuzz constraints - - {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %} # Compare adjustments to defaults and choose min - {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %} # Compare adjustments to defaults and choose min - - {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %} # Define probe_count's x point count and round up - {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %} # Define probe_count's y point count and round up - - {% if (([points_x, points_y]|max) > 6) %} # - {% set algorithm = "bicubic" %} # - {% set min_points = 4 %} # - {% else %} # Calculate if algorithm should be bicubic or lagrange - {% set algorithm = "lagrange" %} # - {% set min_points = 3 %} # - {% endif %} # - - {% set points_x = [points_x , min_points]|max %} # Set probe_count's x points to fit the calculated algorithm - {% set points_y = [points_y , min_points]|max %} # Set probe_count's y points to fit the calculated algorithm - {% set points_x = [points_x , probe_count[0]]|min %} - {% set points_y = [points_y , probe_count[1]]|min %} - - {% if verbose_enable == True %} # If verbose is enabled, print information about KAMP's calculations - {% if printer.exclude_object.objects != [] %} - - { action_respond_info( "Algorithm: {}.".format( - (algorithm), - )) } - - { action_respond_info("Default probe count: {},{}.".format( - (probe_count[0]), - (probe_count[1]), - )) } - - { action_respond_info("Adapted probe count: {},{}.".format( - (points_x), - (points_y), - )) } - - {action_respond_info("Default mesh bounds: {}, {}.".format( - (bed_mesh_min[0],bed_mesh_min[1]), - (bed_mesh_max[0],bed_mesh_max[1]), - )) } - - {% if mesh_margin > 0 %} - {action_respond_info("Mesh margin is {}, mesh bounds extended by {}mm.".format( - (mesh_margin), - (mesh_margin), - )) } - {% else %} - {action_respond_info("Mesh margin is 0, margin not increased.")} - {% endif %} - - {% if fuzz_amount > 0 %} - {action_respond_info("Mesh point fuzzing enabled, points fuzzed up to {}mm.".format( - (fuzz_amount), - )) } - {% else %} - {action_respond_info("Fuzz amount is 0, mesh points not fuzzed.")} - {% endif %} - - { action_respond_info("Adapted mesh bounds: {}, {}.".format( - (adapted_x_min, adapted_y_min), - (adapted_x_max, adapted_y_max), - )) } - - {action_respond_info("KAMP adjustments successful. Happy KAMPing!")} - - {% else %} - - {action_respond_info("No objects detected! Check your gcode and make sure that EXCLUDE_OBJECT_DEFINE is happening before BED_MESH_CALIBRATE is called. Defaulting to regular meshing.")} - G4 P5000 # Wait 5 seconds to make error more visible - {% endif %} - - {% endif %} - - _BED_MESH_CALIBRATE PROFILE={default_profile} mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} # End of verbose - BED_MESH_PROFILE LOAD={default_profile} - ######################################## # Nozzle Calibrate ######################################## diff --git a/config/CreatBot_D1000_V0/base.cfg b/config/CreatBot_D1000_V0/base.cfg index 9ed9a8543..e34b97629 100644 --- a/config/CreatBot_D1000_V0/base.cfg +++ b/config/CreatBot_D1000_V0/base.cfg @@ -210,7 +210,7 @@ max_power: 1.0 min_temp: -1 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.03 pressure_advance_smooth_time:0.040 # control = pid @@ -248,7 +248,7 @@ max_power: 1.0 min_temp: -1 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.032 pressure_advance_smooth_time:0.040 # control = pid @@ -305,6 +305,9 @@ gcode: [gcode_macro T0] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + {% set z_offset = -z_offset %} {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} {% set filament_insert = True if client.filament_sensor|default("") == "" else True if not printer[client.filament_sensor].enabled @@ -313,10 +316,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z=0 MOVE=1 - {% else %} - SET_GCODE_OFFSET Z=0 + {% if printer.toolhead.extruder != 'extruder' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y=0 SET_GCODE_OFFSET X=0 @@ -343,10 +348,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z={z_offset} MOVE=1 - {% else %} - SET_GCODE_OFFSET Z={z_offset} + {% if printer.toolhead.extruder != 'extruder1' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y={y_offset} SET_GCODE_OFFSET X={x_offset} @@ -377,7 +384,8 @@ gcode: [gcode_macro _CANCEL_PRINT_BASE] description: Call when cancelled to print gcode: - # Nothing + M220 S100 + M221 S100 [gcode_macro START_PRINT] gcode: @@ -421,6 +429,8 @@ gcode: [gcode_macro END_PRINT] gcode: M400 + M220 S100 + M221 S100 G92 E0 G1 E-10.0 F3600 G91 @@ -467,10 +477,14 @@ gcode: [gcode_macro _ACTIVATE_DEFAULT_EXTRUDER] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + SET_GCODE_OFFSET Z=0 {% if printer.toolhead.extruder == 'extruder' %} T0 {% elif printer.toolhead.extruder == 'extruder1' %} T1 + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 {% endif %} ######################################## @@ -959,15 +973,11 @@ gcode: {% endif %} {% if adaptive_mesh|lower == 'true' %} - {% if printer.exclude_object.objects != [] %} - {% if idex_mode %} - BED_MESH_CLEAR - {% else %} - BED_MESH_CALIBRATE PROFILE=adaptive - {% endif %} + {% if idex_mode %} + BED_MESH_CLEAR {% else %} - {% if idex_mode %} - BED_MESH_CLEAR + {% if printer.exclude_object.objects != [] %} + BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 {% else %} {% if 'default' in profiles %} BED_MESH_PROFILE LOAD=default @@ -979,110 +989,6 @@ gcode: {% endif %} {% endif %} -[gcode_macro BED_MESH_CALIBRATE] -rename_existing: _BED_MESH_CALIBRATE -gcode: - {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points - {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %} # Get bed mesh min from printer.cfg - {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %} # Get bed mesh max from printer.cfg - {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %} # Get probe count from printer.cfg - {% set kamp_settings = printer["gcode_macro Adaptive_Mesh"] %} # Pull variables from _KAMP_Settings - {% set verbose_enable = kamp_settings.verbose_enable | abs %} # Pull verbose setting from _KAMP_Settings - {% set mesh_margin = kamp_settings.mesh_margin | float %} # Pull mesh margin setting from _KAMP_Settings - {% set fuzz_amount = kamp_settings.fuzz_amount | float %} # Pull fuzz amount setting from _KAMP_Settings - {% set default_profile = params.PROFILE | default("default") %} # get default mesh profile - {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %} # If probe count is only a single number, convert it to 2. E.g. probe_count:7 = 7,7 - {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %} # Determine max probe point distance - {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %} # Determine max probe point distance - {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %} # Set x_min from smallest object x point - {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %} # Set y_min from smallest object y point - {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %} # Set x_max from largest object x point - {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %} # Set y_max from largest object y point - - {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %} # Set fuzz_range between 0 and fuzz_amount - {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt x_min to margin and fuzz constraints - {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt y_min to margin and fuzz constraints - {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints - {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt y_max to margin and fuzz constraints - - {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %} # Compare adjustments to defaults and choose min - {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %} # Compare adjustments to defaults and choose min - - {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %} # Define probe_count's x point count and round up - {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %} # Define probe_count's y point count and round up - - {% if (([points_x, points_y]|max) > 6) %} # - {% set algorithm = "bicubic" %} # - {% set min_points = 4 %} # - {% else %} # Calculate if algorithm should be bicubic or lagrange - {% set algorithm = "lagrange" %} # - {% set min_points = 3 %} # - {% endif %} # - - {% set points_x = [points_x , min_points]|max %} # Set probe_count's x points to fit the calculated algorithm - {% set points_y = [points_y , min_points]|max %} # Set probe_count's y points to fit the calculated algorithm - {% set points_x = [points_x , probe_count[0]]|min %} - {% set points_y = [points_y , probe_count[1]]|min %} - - {% if verbose_enable == True %} # If verbose is enabled, print information about KAMP's calculations - {% if printer.exclude_object.objects != [] %} - - { action_respond_info( "Algorithm: {}.".format( - (algorithm), - )) } - - { action_respond_info("Default probe count: {},{}.".format( - (probe_count[0]), - (probe_count[1]), - )) } - - { action_respond_info("Adapted probe count: {},{}.".format( - (points_x), - (points_y), - )) } - - {action_respond_info("Default mesh bounds: {}, {}.".format( - (bed_mesh_min[0],bed_mesh_min[1]), - (bed_mesh_max[0],bed_mesh_max[1]), - )) } - - {% if mesh_margin > 0 %} - {action_respond_info("Mesh margin is {}, mesh bounds extended by {}mm.".format( - (mesh_margin), - (mesh_margin), - )) } - {% else %} - {action_respond_info("Mesh margin is 0, margin not increased.")} - {% endif %} - - {% if fuzz_amount > 0 %} - {action_respond_info("Mesh point fuzzing enabled, points fuzzed up to {}mm.".format( - (fuzz_amount), - )) } - {% else %} - {action_respond_info("Fuzz amount is 0, mesh points not fuzzed.")} - {% endif %} - - { action_respond_info("Adapted mesh bounds: {}, {}.".format( - (adapted_x_min, adapted_y_min), - (adapted_x_max, adapted_y_max), - )) } - - {action_respond_info("KAMP adjustments successful. Happy KAMPing!")} - - {% else %} - - {action_respond_info("No objects detected! Check your gcode and make sure that EXCLUDE_OBJECT_DEFINE is happening before BED_MESH_CALIBRATE is called. Defaulting to regular meshing.")} - G4 P5000 # Wait 5 seconds to make error more visible - {% endif %} - - {% endif %} - - _BED_MESH_CALIBRATE PROFILE={default_profile} mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} # End of verbose - BED_MESH_PROFILE LOAD={default_profile} - ######################################## # Nozzle Calibrate ######################################## diff --git a/config/CreatBot_D600Pro2/base.cfg b/config/CreatBot_D600Pro2/base.cfg index e5c6e4d91..a5e7a6bac 100644 --- a/config/CreatBot_D600Pro2/base.cfg +++ b/config/CreatBot_D600Pro2/base.cfg @@ -257,7 +257,7 @@ max_power: 1.0 min_temp: -20 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.03 pressure_advance_smooth_time:0.040 # control = pid @@ -307,7 +307,7 @@ max_power: 1.0 min_temp: -20 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.032 pressure_advance_smooth_time:0.040 # control = pid @@ -345,7 +345,7 @@ pin: tool:PC8 maximum_servo_angle: 180 minimum_pulse_width: 0.000900 maximum_pulse_width: 0.002100 -initial_angle: 130 +initial_angle: 170 steps_decomposed: 60 signal_duration: 0.1 # initial_pulse_width: @@ -373,6 +373,9 @@ gcode: [gcode_macro T0] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + {% set z_offset = -z_offset %} {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} {% set filament_insert = True if client.filament_sensor|default("") == "" else True if not printer[client.filament_sensor].enabled @@ -381,10 +384,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z=0 MOVE=1 - {% else %} - SET_GCODE_OFFSET Z=0 + {% if printer.toolhead.extruder != 'extruder' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y=0 SET_GCODE_OFFSET X=0 @@ -411,10 +416,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z={z_offset} MOVE=1 - {% else %} - SET_GCODE_OFFSET Z={z_offset} + {% if printer.toolhead.extruder != 'extruder1' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y={y_offset} SET_GCODE_OFFSET X={x_offset} @@ -445,7 +452,8 @@ gcode: [gcode_macro _CANCEL_PRINT_BASE] description: Call when cancelled to print gcode: - # Nothing + M220 S100 + M221 S100 [gcode_macro START_PRINT] gcode: @@ -489,6 +497,8 @@ gcode: [gcode_macro END_PRINT] gcode: M400 + M220 S100 + M221 S100 G92 E0 G1 E-10.0 F3600 G91 @@ -535,10 +545,14 @@ gcode: [gcode_macro _ACTIVATE_DEFAULT_EXTRUDER] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + SET_GCODE_OFFSET Z=0 {% if printer.toolhead.extruder == 'extruder' %} T0 {% elif printer.toolhead.extruder == 'extruder1' %} T1 + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 {% endif %} ######################################## @@ -1047,15 +1061,11 @@ gcode: {% endif %} {% if adaptive_mesh|lower == 'true' %} - {% if printer.exclude_object.objects != [] %} - {% if idex_mode %} - BED_MESH_CLEAR - {% else %} - BED_MESH_CALIBRATE PROFILE=adaptive - {% endif %} + {% if idex_mode %} + BED_MESH_CLEAR {% else %} - {% if idex_mode %} - BED_MESH_CLEAR + {% if printer.exclude_object.objects != [] %} + BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 {% else %} {% if 'default' in profiles %} BED_MESH_PROFILE LOAD=default @@ -1067,110 +1077,6 @@ gcode: {% endif %} {% endif %} -[gcode_macro BED_MESH_CALIBRATE] -rename_existing: _BED_MESH_CALIBRATE -gcode: - {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points - {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %} # Get bed mesh min from printer.cfg - {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %} # Get bed mesh max from printer.cfg - {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %} # Get probe count from printer.cfg - {% set kamp_settings = printer["gcode_macro Adaptive_Mesh"] %} # Pull variables from _KAMP_Settings - {% set verbose_enable = kamp_settings.verbose_enable | abs %} # Pull verbose setting from _KAMP_Settings - {% set mesh_margin = kamp_settings.mesh_margin | float %} # Pull mesh margin setting from _KAMP_Settings - {% set fuzz_amount = kamp_settings.fuzz_amount | float %} # Pull fuzz amount setting from _KAMP_Settings - {% set default_profile = params.PROFILE | default("default") %} # get default mesh profile - {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %} # If probe count is only a single number, convert it to 2. E.g. probe_count:7 = 7,7 - {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %} # Determine max probe point distance - {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %} # Determine max probe point distance - {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %} # Set x_min from smallest object x point - {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %} # Set y_min from smallest object y point - {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %} # Set x_max from largest object x point - {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %} # Set y_max from largest object y point - - {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %} # Set fuzz_range between 0 and fuzz_amount - {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt x_min to margin and fuzz constraints - {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt y_min to margin and fuzz constraints - {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints - {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt y_max to margin and fuzz constraints - - {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %} # Compare adjustments to defaults and choose min - {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %} # Compare adjustments to defaults and choose min - - {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %} # Define probe_count's x point count and round up - {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %} # Define probe_count's y point count and round up - - {% if (([points_x, points_y]|max) > 6) %} # - {% set algorithm = "bicubic" %} # - {% set min_points = 4 %} # - {% else %} # Calculate if algorithm should be bicubic or lagrange - {% set algorithm = "lagrange" %} # - {% set min_points = 3 %} # - {% endif %} # - - {% set points_x = [points_x , min_points]|max %} # Set probe_count's x points to fit the calculated algorithm - {% set points_y = [points_y , min_points]|max %} # Set probe_count's y points to fit the calculated algorithm - {% set points_x = [points_x , probe_count[0]]|min %} - {% set points_y = [points_y , probe_count[1]]|min %} - - {% if verbose_enable == True %} # If verbose is enabled, print information about KAMP's calculations - {% if printer.exclude_object.objects != [] %} - - { action_respond_info( "Algorithm: {}.".format( - (algorithm), - )) } - - { action_respond_info("Default probe count: {},{}.".format( - (probe_count[0]), - (probe_count[1]), - )) } - - { action_respond_info("Adapted probe count: {},{}.".format( - (points_x), - (points_y), - )) } - - {action_respond_info("Default mesh bounds: {}, {}.".format( - (bed_mesh_min[0],bed_mesh_min[1]), - (bed_mesh_max[0],bed_mesh_max[1]), - )) } - - {% if mesh_margin > 0 %} - {action_respond_info("Mesh margin is {}, mesh bounds extended by {}mm.".format( - (mesh_margin), - (mesh_margin), - )) } - {% else %} - {action_respond_info("Mesh margin is 0, margin not increased.")} - {% endif %} - - {% if fuzz_amount > 0 %} - {action_respond_info("Mesh point fuzzing enabled, points fuzzed up to {}mm.".format( - (fuzz_amount), - )) } - {% else %} - {action_respond_info("Fuzz amount is 0, mesh points not fuzzed.")} - {% endif %} - - { action_respond_info("Adapted mesh bounds: {}, {}.".format( - (adapted_x_min, adapted_y_min), - (adapted_x_max, adapted_y_max), - )) } - - {action_respond_info("KAMP adjustments successful. Happy KAMPing!")} - - {% else %} - - {action_respond_info("No objects detected! Check your gcode and make sure that EXCLUDE_OBJECT_DEFINE is happening before BED_MESH_CALIBRATE is called. Defaulting to regular meshing.")} - G4 P5000 # Wait 5 seconds to make error more visible - {% endif %} - - {% endif %} - - _BED_MESH_CALIBRATE PROFILE={default_profile} mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} # End of verbose - BED_MESH_PROFILE LOAD={default_profile} - ######################################## # Nozzle Calibrate ######################################## diff --git a/config/CreatBot_D600Pro2_V0/base.cfg b/config/CreatBot_D600Pro2_V0/base.cfg index 4f10bf87a..af0786ab4 100644 --- a/config/CreatBot_D600Pro2_V0/base.cfg +++ b/config/CreatBot_D600Pro2_V0/base.cfg @@ -211,7 +211,7 @@ max_power: 1.0 min_temp: -1 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.03 pressure_advance_smooth_time:0.040 # control = pid @@ -249,7 +249,7 @@ max_power: 1.0 min_temp: -1 max_temp: 420 overshoot: 20 -min_extrude_temp: 180 +min_extrude_temp: 100 pressure_advance: 0.032 pressure_advance_smooth_time:0.040 # control = pid @@ -278,7 +278,7 @@ pin: PE5 maximum_servo_angle: 180 minimum_pulse_width: 0.000900 maximum_pulse_width: 0.002100 -initial_angle: 130 +initial_angle: 170 steps_decomposed: 60 signal_duration: 0.1 # initial_pulse_width: @@ -306,6 +306,9 @@ gcode: [gcode_macro T0] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + {% set z_offset = -z_offset %} {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} {% set filament_insert = True if client.filament_sensor|default("") == "" else True if not printer[client.filament_sensor].enabled @@ -314,10 +317,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z=0 MOVE=1 - {% else %} - SET_GCODE_OFFSET Z=0 + {% if printer.toolhead.extruder != 'extruder' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y=0 SET_GCODE_OFFSET X=0 @@ -344,10 +349,12 @@ gcode: {% if filament_insert or printing == False %} SET_SERVO SERVO=switch_nozzle angle=135 G4 P500 - {% if "z" in printer.toolhead.homed_axes | lower %} - SET_GCODE_OFFSET Z={z_offset} MOVE=1 - {% else %} - SET_GCODE_OFFSET Z={z_offset} + {% if printer.toolhead.extruder != 'extruder1' %} + {% if "z" in printer.toolhead.homed_axes | lower %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 + {% else %} + SET_GCODE_OFFSET Z_ADJUST={z_offset} + {% endif %} {% endif %} SET_GCODE_OFFSET Y={y_offset} SET_GCODE_OFFSET X={x_offset} @@ -366,7 +373,7 @@ gcode: [gcode_macro PROBE_SERVO_CLOSE] gcode: - SET_SERVO SERVO=probe_servo angle=130 + SET_SERVO SERVO=probe_servo angle=170 G4 P2000 [gcode_macro _START_PRINT_BASE] @@ -378,7 +385,8 @@ gcode: [gcode_macro _CANCEL_PRINT_BASE] description: Call when cancelled to print gcode: - # Nothing + M220 S100 + M221 S100 [gcode_macro START_PRINT] gcode: @@ -422,6 +430,8 @@ gcode: [gcode_macro END_PRINT] gcode: M400 + M220 S100 + M221 S100 G92 E0 G1 E-10.0 F3600 G91 @@ -468,10 +478,14 @@ gcode: [gcode_macro _ACTIVATE_DEFAULT_EXTRUDER] gcode: + {% set sv = printer.save_variables.variables %} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + SET_GCODE_OFFSET Z=0 {% if printer.toolhead.extruder == 'extruder' %} T0 {% elif printer.toolhead.extruder == 'extruder1' %} T1 + SET_GCODE_OFFSET Z_ADJUST={z_offset} MOVE=1 {% endif %} ######################################## @@ -954,15 +968,11 @@ gcode: {% endif %} {% if adaptive_mesh|lower == 'true' %} - {% if printer.exclude_object.objects != [] %} - {% if idex_mode %} - BED_MESH_CLEAR - {% else %} - BED_MESH_CALIBRATE PROFILE=adaptive - {% endif %} + {% if idex_mode %} + BED_MESH_CLEAR {% else %} - {% if idex_mode %} - BED_MESH_CLEAR + {% if printer.exclude_object.objects != [] %} + BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 {% else %} {% if 'default' in profiles %} BED_MESH_PROFILE LOAD=default @@ -974,110 +984,6 @@ gcode: {% endif %} {% endif %} -[gcode_macro BED_MESH_CALIBRATE] -rename_existing: _BED_MESH_CALIBRATE -gcode: - {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points - {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %} # Get bed mesh min from printer.cfg - {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %} # Get bed mesh max from printer.cfg - {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %} # Get probe count from printer.cfg - {% set kamp_settings = printer["gcode_macro Adaptive_Mesh"] %} # Pull variables from _KAMP_Settings - {% set verbose_enable = kamp_settings.verbose_enable | abs %} # Pull verbose setting from _KAMP_Settings - {% set mesh_margin = kamp_settings.mesh_margin | float %} # Pull mesh margin setting from _KAMP_Settings - {% set fuzz_amount = kamp_settings.fuzz_amount | float %} # Pull fuzz amount setting from _KAMP_Settings - {% set default_profile = params.PROFILE | default("default") %} # get default mesh profile - {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %} # If probe count is only a single number, convert it to 2. E.g. probe_count:7 = 7,7 - {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %} # Determine max probe point distance - {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %} # Determine max probe point distance - {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %} # Set x_min from smallest object x point - {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %} # Set y_min from smallest object y point - {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %} # Set x_max from largest object x point - {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %} # Set y_max from largest object y point - - {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %} # Set fuzz_range between 0 and fuzz_amount - {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt x_min to margin and fuzz constraints - {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt y_min to margin and fuzz constraints - {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints - {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt y_max to margin and fuzz constraints - - {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %} # Compare adjustments to defaults and choose min - {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %} # Compare adjustments to defaults and choose min - - {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %} # Define probe_count's x point count and round up - {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %} # Define probe_count's y point count and round up - - {% if (([points_x, points_y]|max) > 6) %} # - {% set algorithm = "bicubic" %} # - {% set min_points = 4 %} # - {% else %} # Calculate if algorithm should be bicubic or lagrange - {% set algorithm = "lagrange" %} # - {% set min_points = 3 %} # - {% endif %} # - - {% set points_x = [points_x , min_points]|max %} # Set probe_count's x points to fit the calculated algorithm - {% set points_y = [points_y , min_points]|max %} # Set probe_count's y points to fit the calculated algorithm - {% set points_x = [points_x , probe_count[0]]|min %} - {% set points_y = [points_y , probe_count[1]]|min %} - - {% if verbose_enable == True %} # If verbose is enabled, print information about KAMP's calculations - {% if printer.exclude_object.objects != [] %} - - { action_respond_info( "Algorithm: {}.".format( - (algorithm), - )) } - - { action_respond_info("Default probe count: {},{}.".format( - (probe_count[0]), - (probe_count[1]), - )) } - - { action_respond_info("Adapted probe count: {},{}.".format( - (points_x), - (points_y), - )) } - - {action_respond_info("Default mesh bounds: {}, {}.".format( - (bed_mesh_min[0],bed_mesh_min[1]), - (bed_mesh_max[0],bed_mesh_max[1]), - )) } - - {% if mesh_margin > 0 %} - {action_respond_info("Mesh margin is {}, mesh bounds extended by {}mm.".format( - (mesh_margin), - (mesh_margin), - )) } - {% else %} - {action_respond_info("Mesh margin is 0, margin not increased.")} - {% endif %} - - {% if fuzz_amount > 0 %} - {action_respond_info("Mesh point fuzzing enabled, points fuzzed up to {}mm.".format( - (fuzz_amount), - )) } - {% else %} - {action_respond_info("Fuzz amount is 0, mesh points not fuzzed.")} - {% endif %} - - { action_respond_info("Adapted mesh bounds: {}, {}.".format( - (adapted_x_min, adapted_y_min), - (adapted_x_max, adapted_y_max), - )) } - - {action_respond_info("KAMP adjustments successful. Happy KAMPing!")} - - {% else %} - - {action_respond_info("No objects detected! Check your gcode and make sure that EXCLUDE_OBJECT_DEFINE is happening before BED_MESH_CALIBRATE is called. Defaulting to regular meshing.")} - G4 P5000 # Wait 5 seconds to make error more visible - {% endif %} - - {% endif %} - - _BED_MESH_CALIBRATE PROFILE={default_profile} mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} # End of verbose - BED_MESH_PROFILE LOAD={default_profile} - ######################################## # Nozzle Calibrate ######################################## diff --git a/config/CreatBot_F430NX/base.cfg b/config/CreatBot_F430NX/base.cfg index f40c2d214..922e744cf 100644 --- a/config/CreatBot_F430NX/base.cfg +++ b/config/CreatBot_F430NX/base.cfg @@ -304,7 +304,7 @@ max_power: 1.0 min_temp: -20 max_temp: 450 overshoot: 20 -min_extrude_temp: 150 +min_extrude_temp: 100 pressure_advance: 0.032 pressure_advance_smooth_time:0.040 # control = pid @@ -398,7 +398,7 @@ max_power: 1.0 min_temp: -20 max_temp: 450 overshoot: 20 -min_extrude_temp: 150 +min_extrude_temp: 100 pressure_advance: 0.032 pressure_advance_smooth_time:0.040 # control = pid @@ -436,6 +436,18 @@ gcode: ACTIVATE_EXTRUDER EXTRUDER=extruder SET_DUAL_CARRIAGE CARRIAGE=0 +[gcode_macro _PLATFORM_LIFT] +gcode: + {% set distance = params.DISTANCE|default(0) %} + {% set speed = params.SPEED|default(300) %} + + {% if "z" in printer.toolhead.homed_axes %} + SAVE_GCODE_STATE NAME=platform_lift_state + G91 + G1 Z{distance} F{speed} + RESTORE_GCODE_STATE NAME=platform_lift_state + {% endif %} + [gcode_macro _PARK_extruder] gcode: ACTIVATE_EXTRUDER EXTRUDER=extruder @@ -458,6 +470,7 @@ gcode: {% set x_home = true %} {% endif %} {% if printer.toolhead.extruder != 'extruder' or x_home %} + _PLATFORM_LIFT DISTANCE=1 _PARK_{printer.toolhead.extruder} ACTIVATE_EXTRUDER EXTRUDER=extruder SET_DUAL_CARRIAGE CARRIAGE=0 @@ -472,6 +485,7 @@ gcode: G90 G1 X0 F6000 RESTORE_GCODE_STATE NAME=park0 + _PLATFORM_LIFT DISTANCE=-1 {% endif %} {% else %} PAUSE @@ -510,6 +524,7 @@ gcode: {% endif %} {% if printer.toolhead.extruder != 'extruder1' or x_home %} + _PLATFORM_LIFT DISTANCE=1 _PARK_{printer.toolhead.extruder} ACTIVATE_EXTRUDER EXTRUDER=extruder1 SET_DUAL_CARRIAGE CARRIAGE=1 @@ -525,6 +540,7 @@ gcode: {% endif %} SET_GCODE_OFFSET Y={y_offset} SET_GCODE_OFFSET X={x_offset} + _PLATFORM_LIFT DISTANCE=-1 {% endif %} {% else %} PAUSE @@ -592,6 +608,8 @@ gcode: [gcode_macro _CANCEL_PRINT_BASE] description: Call when cancelled to print gcode: + M220 S100 + M221 S100 _ACTIVATE_PRIMARY_MODE [gcode_macro START_PRINT] @@ -638,6 +656,8 @@ gcode: {% set svv = printer.save_variables.variables %} {% set y_offset = svv.nozzle_y_offset_val|default(0)|float %} M400 + M220 S100 + M221 S100 G92 E0 G1 E-10.0 F3600 G91 @@ -1229,15 +1249,11 @@ gcode: {% endif %} {% if adaptive_mesh|lower == 'true' %} - {% if printer.exclude_object.objects != [] %} - {% if idex_mode %} - BED_MESH_CLEAR - {% else %} - BED_MESH_CALIBRATE PROFILE=adaptive - {% endif %} + {% if idex_mode %} + BED_MESH_CLEAR {% else %} - {% if idex_mode %} - BED_MESH_CLEAR + {% if printer.exclude_object.objects != [] %} + BED_MESH_CALIBRATE PROFILE=adaptive ADAPTIVE=1 {% else %} {% if 'default' in profiles %} BED_MESH_PROFILE LOAD=default @@ -1249,110 +1265,6 @@ gcode: {% endif %} {% endif %} -[gcode_macro BED_MESH_CALIBRATE] -rename_existing: _BED_MESH_CALIBRATE -gcode: - {% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points - {% set bed_mesh_min = printer.configfile.settings.bed_mesh.mesh_min %} # Get bed mesh min from printer.cfg - {% set bed_mesh_max = printer.configfile.settings.bed_mesh.mesh_max %} # Get bed mesh max from printer.cfg - {% set probe_count = printer.configfile.settings.bed_mesh.probe_count %} # Get probe count from printer.cfg - {% set kamp_settings = printer["gcode_macro Adaptive_Mesh"] %} # Pull variables from _KAMP_Settings - {% set verbose_enable = kamp_settings.verbose_enable | abs %} # Pull verbose setting from _KAMP_Settings - {% set mesh_margin = kamp_settings.mesh_margin | float %} # Pull mesh margin setting from _KAMP_Settings - {% set fuzz_amount = kamp_settings.fuzz_amount | float %} # Pull fuzz amount setting from _KAMP_Settings - {% set default_profile = params.PROFILE | default("default") %} # get default mesh profile - {% set probe_count = probe_count if probe_count|length > 1 else probe_count * 2 %} # If probe count is only a single number, convert it to 2. E.g. probe_count:7 = 7,7 - {% set max_probe_point_distance_x = ( bed_mesh_max[0] - bed_mesh_min[0] ) / (probe_count[0] - 1) %} # Determine max probe point distance - {% set max_probe_point_distance_y = ( bed_mesh_max[1] - bed_mesh_min[1] ) / (probe_count[1] - 1) %} # Determine max probe point distance - {% set x_min = all_points | map(attribute=0) | min | default(bed_mesh_min[0]) %} # Set x_min from smallest object x point - {% set y_min = all_points | map(attribute=1) | min | default(bed_mesh_min[1]) %} # Set y_min from smallest object y point - {% set x_max = all_points | map(attribute=0) | max | default(bed_mesh_max[0]) %} # Set x_max from largest object x point - {% set y_max = all_points | map(attribute=1) | max | default(bed_mesh_max[1]) %} # Set y_max from largest object y point - - {% set fuzz_range = range((0) | int, (fuzz_amount * 100) | int + 1) %} # Set fuzz_range between 0 and fuzz_amount - {% set adapted_x_min = x_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt x_min to margin and fuzz constraints - {% set adapted_y_min = y_min - mesh_margin - (fuzz_range | random / 100.0) %} # Adapt y_min to margin and fuzz constraints - {% set adapted_x_max = x_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints - {% set adapted_y_max = y_max + mesh_margin + (fuzz_range | random / 100.0) %} # Adapt y_max to margin and fuzz constraints - - {% set adapted_x_min = [adapted_x_min , bed_mesh_min[0]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_y_min = [adapted_y_min , bed_mesh_min[1]] | max %} # Compare adjustments to defaults and choose max - {% set adapted_x_max = [adapted_x_max , bed_mesh_max[0]] | min %} # Compare adjustments to defaults and choose min - {% set adapted_y_max = [adapted_y_max , bed_mesh_max[1]] | min %} # Compare adjustments to defaults and choose min - - {% set points_x = (((adapted_x_max - adapted_x_min) / max_probe_point_distance_x) | round(method='ceil') | int) + 1 %} # Define probe_count's x point count and round up - {% set points_y = (((adapted_y_max - adapted_y_min) / max_probe_point_distance_y) | round(method='ceil') | int) + 1 %} # Define probe_count's y point count and round up - - {% if (([points_x, points_y]|max) > 6) %} # - {% set algorithm = "bicubic" %} # - {% set min_points = 4 %} # - {% else %} # Calculate if algorithm should be bicubic or lagrange - {% set algorithm = "lagrange" %} # - {% set min_points = 3 %} # - {% endif %} # - - {% set points_x = [points_x , min_points]|max %} # Set probe_count's x points to fit the calculated algorithm - {% set points_y = [points_y , min_points]|max %} # Set probe_count's y points to fit the calculated algorithm - {% set points_x = [points_x , probe_count[0]]|min %} - {% set points_y = [points_y , probe_count[1]]|min %} - - {% if verbose_enable == True %} # If verbose is enabled, print information about KAMP's calculations - {% if printer.exclude_object.objects != [] %} - - { action_respond_info( "Algorithm: {}.".format( - (algorithm), - )) } - - { action_respond_info("Default probe count: {},{}.".format( - (probe_count[0]), - (probe_count[1]), - )) } - - { action_respond_info("Adapted probe count: {},{}.".format( - (points_x), - (points_y), - )) } - - {action_respond_info("Default mesh bounds: {}, {}.".format( - (bed_mesh_min[0],bed_mesh_min[1]), - (bed_mesh_max[0],bed_mesh_max[1]), - )) } - - {% if mesh_margin > 0 %} - {action_respond_info("Mesh margin is {}, mesh bounds extended by {}mm.".format( - (mesh_margin), - (mesh_margin), - )) } - {% else %} - {action_respond_info("Mesh margin is 0, margin not increased.")} - {% endif %} - - {% if fuzz_amount > 0 %} - {action_respond_info("Mesh point fuzzing enabled, points fuzzed up to {}mm.".format( - (fuzz_amount), - )) } - {% else %} - {action_respond_info("Fuzz amount is 0, mesh points not fuzzed.")} - {% endif %} - - { action_respond_info("Adapted mesh bounds: {}, {}.".format( - (adapted_x_min, adapted_y_min), - (adapted_x_max, adapted_y_max), - )) } - - {action_respond_info("KAMP adjustments successful. Happy KAMPing!")} - - {% else %} - - {action_respond_info("No objects detected! Check your gcode and make sure that EXCLUDE_OBJECT_DEFINE is happening before BED_MESH_CALIBRATE is called. Defaulting to regular meshing.")} - G4 P5000 # Wait 5 seconds to make error more visible - {% endif %} - - {% endif %} - - _BED_MESH_CALIBRATE PROFILE={default_profile} mesh_min={adapted_x_min},{adapted_y_min} mesh_max={adapted_x_max},{adapted_y_max} ALGORITHM={algorithm} PROBE_COUNT={points_x},{points_y} # End of verbose - BED_MESH_PROFILE LOAD={default_profile} - ######################################## # Nozzle Calibrate ######################################## diff --git a/config/CreatBot_P800/1.1/door_detect.cfg b/config/CreatBot_P800/1.1/door_detect.cfg new file mode 100644 index 000000000..7f384b926 --- /dev/null +++ b/config/CreatBot_P800/1.1/door_detect.cfg @@ -0,0 +1 @@ +../../module/door_detect.cfg \ No newline at end of file diff --git a/config/CreatBot_P800/base.cfg b/config/CreatBot_P800/base.cfg new file mode 100644 index 000000000..bb309622f --- /dev/null +++ b/config/CreatBot_P800/base.cfg @@ -0,0 +1,701 @@ +# This is a configuration file for the Creatbot P800. +[include mainsail.cfg] + +[virtual_sdcard] +path: ~/printer_data/gcodes +on_error_gcode: CANCEL_PRINT + +[save_variables] +filename: ~/printer_data/config/config_variables.cfg + +[exclude_object] + +[gcode_arcs] +resolution: 1.0 + +[force_move] +enable_force_move: True + +[idle_timeout] +gcode: + {% if printer.webhooks.state|lower == 'ready' %} + {% if printer.pause_resume.is_paused %} + {% set heaters = ["extruder", "pre-heater", "mid-heater"] %} + {% for heater in heaters %} + {% if printer["%s" % heater] is defined %} + SET_HEATER_TEMPERATURE HEATER={heater} + {% endif %} + {% endfor %} + {% else %} + TURN_OFF_HEATERS + {% endif %} + {% endif %} +timeout: 1800 # 0.5 hour timeout + +[mcu] +canbus_uuid: 000000000010 +canbus_interface: can0 + +[printer] +kinematics: cartesian +max_velocity: 100 +max_accel: 100 +max_z_velocity: 5 +max_z_accel: 5 +square_corner_velocity: 5.0 + +[stepper_x] +step_pin: PD1 +dir_pin: PD0 +enable_pin: !PA15 +rotation_distance: 53.3 +microsteps: 16 +full_steps_per_rotation: 200 +gear_ratio:4:3 +endstop_pin: PE10 +position_min: 0 +position_endstop: 0 +position_max: 800 +homing_speed: 120 +homing_retract_dist: 5 + +[stepper_y] +step_pin: PD4 +dir_pin: PD3 +enable_pin: !PD2 +rotation_distance: 60 +microsteps: 8 +full_steps_per_rotation: 200 +gear_ratio: 2:1 +endstop_pin: PE11 +position_min: 0 +position_endstop: 0 +position_max: 800 +homing_speed: 80 +homing_retract_dist: 5 +step_pulse_duration: 0.000005 + +[stepper_z] +step_pin: PD7 +dir_pin: !PD6 +enable_pin: !PD5 +rotation_distance: 5 +gear_ratio: 3:1 +microsteps: 16 +full_steps_per_rotation: 200 +endstop_pin:PE12 +position_endstop: 0 +position_min:-20 +position_max: 800 +homing_speed: 5 +second_homing_speed: 4 +homing_retract_speed: 5 +homing_retract_dist: 2.0 +step_pulse_duration: 0.000005 + +[heater_generic pre-heater] +heater_pin: PD15 +sensor_type: AD8495 +adc_voltage: 3.3 +sensor_pin: PC3 +max_power: 1.0 +min_temp: -235 +max_temp: 300 + + +[verify_heater pre-heater] +max_error: 120 +hysteresis: 100 +check_gain_time: 36000 +heating_gain: 0.01 + + +[heater_generic mid-heater] +heater_pin: PD14 +sensor_type: AD8495 +adc_voltage: 3.3 +sensor_pin: PC2 +max_power: 1.0 +min_temp: -235 +max_temp: 300 + +[verify_heater mid-heater] +max_error: 120 +hysteresis: 100 +check_gain_time: 3600 +heating_gain: 0.01 + +[extruder] +step_pin: PE1 +dir_pin: !PE0 +enable_pin: !PB9 +microsteps: 16 +full_steps_per_rotation: 200 +rotation_distance: 233.4 +gear_ratio: 10:1 +nozzle_diameter: 1 +filament_diameter: 1.750 +max_extrude_only_distance: 3000.0 +max_extrude_only_velocity: 5000.0 +max_extrude_only_accel: 300.0 +max_extrude_cross_section: 100.0 +heater_pin: PD13 +sensor_type: AD8495 +adc_voltage: 3.3 +sensor_pin: PC1 +max_power: 1.0 +min_temp: -235 +max_temp: 500 +min_extrude_temp: 100 +pressure_advance: 0.032 +pressure_advance_smooth_time:0.040 +step_pulse_duration: 0.000005 + +[heater_bed] +heater_pin: PD12 +sensor_type: Generic 3950 +sensor_pin: PC0 +max_power: 1.0 +min_temp: -235 +max_temp: 500 +control: pid +pid_kp: 74.000 +pid_ki: 1.965 +pid_kd: 696.525 + +[verify_heater heater_bed] +max_error: 120 +hysteresis: 100 +check_gain_time: 36000 +heating_gain: 0.01 + +[heater_generic chamber] +heater_pin:PB14 +max_power:1.0 +sensor_type:Generic 3950 +sensor_pin:PB1 +min_temp:-50 +max_temp:100 + +[verify_heater chamber] +max_error: 120 +hysteresis: 100 +check_gain_time: 36000 +heating_gain: 0.01 + +[fan_generic Air_filter_fan] +pin: PC8 +max_power: 1.0 +shutdown_speed: 0.0 +kick_start_time: 1.0 +off_below: 0.10 + +[filament_airpump_sensor extruder] +switch_pin: !PE13 +airpump_pin: PE2 +pause_on_runout: False +runout_gcode: _RUNOUT_HANDLE +max_run_time: 30 +insert_delay_time: 15.0 +debounce_delay: 3.0 +event_delay: 0.01 + +[state_led led] +red_pin: PD8 +green_pin: PD9 +blue_pin: PD10 +initial_RED: 0.0 +initial_GREEN: 0.0 +initial_BLUE: 0.0 +idle: 0.0, 1.0, 0.5 +printing: 0.0, 1.0, 0.0 +paused: 1.0, 1.0, 0.0 +error: 1.0, 0.0, 0.0 +heating: 0.0, 0.0, 1.0 + +[led Interior_lighting] +white_pin: PC13 +cycle_time: 0.010 +initial_WHITE: 1 + +[fan] +pin:PC7 +kick_start_time: 0.5 +off_below: 0.10 +max_power: 1.0 + +[heater_fan Sink_fan] +pin:PC6 +max_power: 1.0 +kick_start_time: 0.5 +heater: extruder +heater_temp: 100 +fan_speed: 1.0 + +[safe_z_home] +home_xy_position:390,400 +z_hop_speed: 5 +speed: 150 +z_hop: 5 + +[gcode_macro ENABLE_MOTOR] +gcode: + SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=1 + SET_STEPPER_ENABLE STEPPER=stepper_y ENABLE=1 + SET_KINEMATIC_POSITION X=400 Y=400 Z=0 + +[gcode_macro LOAD_FILAMENT] +variable_load_distance: 2500 +variable_purge_distance: 25 +gcode: + {% set speed = params.SPEED|default(200) %} + {% set max_velocity = printer.configfile.settings['extruder'].max_extrude_only_velocity * 10 %} + SAVE_GCODE_STATE NAME=load_state + G91 + G92 E0 + G1 E{load_distance} F{max_velocity} # fast-load + RESTORE_GCODE_STATE NAME=load_state + +######################################## +# GCODE +######################################## + +[gcode_macro _START_PRINT_BASE] +description: Call when starting to print +variable_door_can_start: True +variable_filament_can_start: True +gcode: + {% if printer['gcode_button _door_detection'] %} + _DOOR_START_PRINT_RESPOND + {% endif %} + _CLEAR_LAST_FILE + _START_FILAMENT_HANDLE + +[gcode_macro _CANCEL_PRINT_BASE] +description: Call when cancelled to print +gcode: + M220 S100 + M221 S100 + +[gcode_macro START_PRINT] +gcode: + {% set BED_TEMP = params.BED|default(0)|float %} + {% set EXTRUDER_TEMP = params.EXTRUDER|default(0)|float %} + {% set EXTRUDER_TEMP1 = params.EXTRUDER1|default(0)|float %} + {% set CHAMBER_TEMP = params.CHAMBER|default(0)|float %} + {% if params.BED is defined %} + M140 S{BED_TEMP} + {% endif %} + {% if params.EXTRUDER is defined %} + M104 T0 S{EXTRUDER_TEMP} + {% endif %} + {% if params.EXTRUDER1 is defined %} + M104 T1 S{EXTRUDER_TEMP1} + {% endif %} + {% if params.CHAMBER is defined %} + M141 S{CHAMBER_TEMP} + {% endif %} + G28 + _START_PRINT_BED_MESH + {% if BED_TEMP != 0 %} + M190 S{BED_TEMP} + {% endif %} + {% if EXTRUDER_TEMP != 0 %} + M109 T0 S{EXTRUDER_TEMP} + {% endif %} + {% if EXTRUDER_TEMP1 != 0 %} + M109 T1 S{EXTRUDER_TEMP1} + {% endif %} + {% if CHAMBER_TEMP != 0 %} + M191 S{CHAMBER_TEMP} + {% endif %} + G92 E0 + M117 Printing start... + +[gcode_macro PRINT_START] +gcode: + START_PRINT + +[gcode_macro END_PRINT] +gcode: + M400 + G92 E0 + G1 E-10.0 F3600 + G91 + G0 Z1.00 X20.0 Y20.0 F6000 + TURN_OFF_HEATERS + M107 + G1 Z2 F3000 + G90 + G0 X590 Y590 F3600 + # BED_MESH_CLEAR + +[gcode_macro PRINT_END] +gcode: + END_PRINT + +######################################## +# GCODE +######################################## + +[gcode_macro G28] +rename_existing: C28 +gcode: + {% set homing_cmd = ''%} + {% set do_x = 'X' in params|string %} + {% set do_y = 'Y' in params|string %} + {% set do_z = 'Z' in params|string %} + + {% if do_x %} + SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=1 + G4 P300 + {% set homing_cmd = 'X ' %} + {% endif %} + {% if do_y %} + SET_STEPPER_ENABLE STEPPER=stepper_y ENABLE=1 + G4 P300 + {% set homing_cmd = homing_cmd + 'Y ' %} + {% endif %} + {% if do_z %} + {% if 'x' not in printer.toolhead.homed_axes|lower or 'y' not in printer.toolhead.homed_axes|lower %} + {% set homing_cmd = 'X Y Z' %} + {% else %} + {% set homing_cmd = homing_cmd + 'Z' %} + {% endif %} + {% endif %} + {% if not homing_cmd %} + SET_STEPPER_ENABLE STEPPER=stepper_x ENABLE=1 + SET_STEPPER_ENABLE STEPPER=stepper_y ENABLE=1 + G4 P300 + C28 + {% else %} + C28 {homing_cmd} + {% endif %} + +[gcode_macro M104] +rename_existing: C104 +gcode: + {% set hotend = printer.toolhead.extruder %} + {% set s = params.S|default(0)|float %} + {% set t = params.T|default(0)|int %} + {% if params.S is defined %} + {% if params.T is defined %} + {% set heater_mapping = {1: "pre-heater", 2: "mid-heater",} %} + {% set hotend = heater_mapping.get(t, "extruder") %} + {% endif %} + SET_HEATER_TEMPERATURE HEATER={hotend} TARGET={s} + {% endif %} + +[gcode_macro M109] +rename_existing: C109 +gcode: + {% set hotend = printer.toolhead.extruder %} + {% set s = params.S|default(0)|float %} + {% set t = params.T|default(0)|int %} + M104 {rawparams} + {% if s != 0 %} + {% if params.T is defined %} + {% set heater_mapping = {1: "'heater_generic pre-heater'", 2: "'heater_generic mid-heater'",} %} + {% set hotend =heater_mapping.get(t, "'extruder'") %} + {% endif %} + TEMPERATURE_WAIT SENSOR={hotend} MINIMUM={s-3} MAXIMUM={s+3} + {% endif %} + +[gcode_macro M141] +gcode: + {% set s = params.S|default(0)|float %} + {% if params.S is defined %} + SET_HEATER_TEMPERATURE HEATER=chamber target={s|int} + {% endif %} + +[gcode_macro M190] +rename_existing: C190 +gcode: + {% set s = params.S|default(0)|float %} + {% if params.S is defined %} + SET_HEATER_TEMPERATURE HEATER="heater_bed" TARGET={s} + {% if s != 0 %} + TEMPERATURE_WAIT SENSOR="heater_bed" MINIMUM={s-3} MAXIMUM={s+3} + {% endif %} + {% endif %} + +[gcode_macro M191] +gcode: + {% set s = params.S|default(0)|float %} + {% if params.S is defined %} + M141 S{s} + {% if s != 0 %} + TEMPERATURE_WAIT SENSOR="heater_generic chamber" MINIMUM={s-3} MAXIMUM={s+3} + {% endif %} + {% endif %} + +[gcode_macro M84] +rename_existing: C84 +gcode: + C84 + SET_STEPPER_ENABLE STEPPER=stepper_z enable=1 + +######################################## +# CANCEL_PRINT/PAUSE/RESUME/ +######################################## + +[gcode_macro _CLIENT_VARIABLE] +variable_use_custom_pos : True +variable_custom_park_x : 400.0 +variable_custom_park_y : 300.0 +variable_custom_park_dz : 20.0 +variable_retract : 2.0 +variable_cancel_retract : 10.0 +variable_speed_retract : 60.0 +variable_unretract : 20.0 +variable_speed_unretract : 6.0 +variable_speed_hop : 4.0 +variable_speed_move : 100.0 +variable_park_at_cancel : False +variable_park_at_cancel_x : None +variable_park_at_cancel_y : None +variable_use_fw_retract : False +variable_idle_timeout : 600 +variable_filament_sensor : "filament_airpump_sensor extruder" +variable_user_temp_macro : "_USER_TEMP_RESUME" +variable_user_pause_macro : "_USER_PAUSE" +variable_user_cancel_macro: "_USER_CANCEL" +gcode: + # Nothing + +[gcode_macro _USER_PAUSE] +gcode: + {% set extruderTools = [('extruder', 'last_extruder_temp'), + ('heater_generic pre-heater', 'last_perheater_temp'), + ('heater_generic mid-heater', 'last_midheater_temp')] %} + {% set act = printer.gcode_move.gcode_position %} + SAVE_VARIABLE VARIABLE=power_resume_z VALUE={act.z} + {% for extruder_name, name in extruderTools %} + {% set temp = printer[extruder_name].target if extruder_name in printer else 0 %} + {% set restore = False if printer[extruder_name] == '' + else True if params.RESTORE|default(1)|int == 1 else False %} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE={name} VALUE="{{'restore': restore, 'temp': temp}}" + {% endfor %} + +[gcode_macro _USER_TEMP_RESUME] +gcode: + {% set extruder_info = [ + {'index': 0, 'name': 'last_extruder_temp'}, + {'index': 1, 'name': 'last_perheater_temp'}, + {'index': 2, 'name': 'last_midheater_temp'}] %} + {% for info in extruder_info %} + {% set variable = printer["gcode_macro RESUME"][info.name] %} + {% if variable.restore %} + M104 T{ info.index } S{ variable.temp } + {% endif %} + {% endfor %} + {% for info in extruder_info %} + {% set variable = printer["gcode_macro RESUME"][info.name] %} + {% if variable.restore %} + {% set heater_mapping = {1: "heater_generic pre-heater", + 2: "heater_generic mid-heater"} %} + {% set tool = heater_mapping.get(info.index, "extruder") %} + {% set needwait = True if printer[tool].temperature < variable.temp else False %} + {% if needwait %} + RESPOND TYPE=echo MSG='{"Restoring heater temperature, this may take some time."}' + M109 T{info.index} S{variable.temp} + {% endif %} + {% endif %} + {% endfor %} + +[gcode_macro _USER_CANCEL] +gcode: + {% if 'z' in printer.toolhead.homed_axes %} + G91 + G1 Z30 F600 ; lift nozzle + {% endif %} + M84 + +[gcode_macro _CLIENT_EXTRUDE] +description: Extrudes, if the extruder is hot enough +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set use_fw_retract = (client.use_fw_retract|default(false)|lower == 'true') and (printer.firmware_retraction is defined) %} + {% set length = params.LENGTH|default(client.unretract)|default(1.0)|float %} + {% set speed = params.SPEED|default(client.speed_unretract)|default(35) %} + {% set absolute_extrude = printer.gcode_move.absolute_extrude %} + ##### end of definitions ##### + {% if printer.toolhead.extruder != '' %} + {% if printer[printer.toolhead.extruder].can_extrude %} + {% if use_fw_retract %} + {% if length < 0 %} + G10 + {% else %} + G11 + {% endif %} + {% else %} + M83 + G1 E{length} F{(speed|float|abs) * 60} + {% if absolute_extrude %} + M82 + {% endif %} + {% endif %} + {% endif %} + {% endif %} + +[gcode_macro RESUME] +description: Resume the actual running print +rename_existing: RESUME_BASE +variable_last_extruder_temp: {'restore': False, 'temp': 0} +variable_last_perheater_temp: {'restore': False, 'temp': 0} +variable_last_midheater_temp: {'restore': False, 'temp': 0} +variable_restore_idle_timeout: 0 +variable_idle_state: False +variable_filament_state: False +gcode: + _FILAMENT_UPDATE + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set do_resume = False %} + {% set can_extrude = True if printer.toolhead.extruder == '' # no extruder defined in config + else printer[printer.toolhead.extruder].can_extrude %} # status of active extruder + #### Printer comming from timeout idle state #### + {% if printer.idle_timeout.state|upper == "IDLE" or idle_state %} + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=idle_state VALUE=False + {% endif %} + {% if last_extruder_temp.restore or last_perheater_temp.restore or last_midheater_temp.restore %} + {client.user_temp_macro|default("")} + {% set do_resume = True %} + {% elif can_extrude %} + {% set do_resume = True %} + {% endif %} + _ACT_RESUME DO_RESUME={do_resume} + +[gcode_macro _ACT_RESUME] +gcode: + ##### get user parameters or use default ##### + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set velocity = printer.configfile.settings.pause_resume.recover_velocity %} + {% set sp_move = client.speed_move|default(velocity) %} + {% set filament_state = printer['gcode_macro RESUME'].filament_state|default(False)|lower %} + {% set restore_idle_timeout = printer['gcode_macro RESUME'].restore_idle_timeout|default(0) %} + + {% if filament_state == "false" %} + AIR_PUMP_ON + {% endif %} + {% if printer[printer.toolhead.extruder].can_extrude %} + {% if restore_idle_timeout > 0 %} SET_IDLE_TIMEOUT TIMEOUT={restore_idle_timeout} {% endif %} + _CLIENT_EXTRUDE + RESUME_BASE VELOCITY={params.VELOCITY|default(sp_move)} + {% else %} + RESPOND TYPE=error MSG='{"extruder not hot enough, Please confirm whether the temperature is normal."}' + {% endif %} + +######################################## +# filament_runout +######################################## + +[gcode_macro AIR_PUMP_ON] +gcode: + SET_AIRPUMP AIRPUMP=extruder VALUE=1 RUN_TIME=20 + +[gcode_macro AIR_PUMP_OFF] +gcode: + SET_AIRPUMP AIRPUMP=extruder VALUE=0 + +[gcode_macro _START_FILAMENT_HANDLE] +gcode: + {% set runout = True if not printer['filament_airpump_sensor extruder'].enabled + else printer['filament_airpump_sensor extruder'].filament_detected %} + {% if not runout %} + SET_AIRPUMP AIRPUMP=extruder VALUE=1 RUN_TIME=10 + {% endif %} + G4 P5000 + _RUNOUT_HANDLE + +[gcode_macro _FILAMENT_UPDATE] +gcode: + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set runout = True if client.filament_sensor|default("") == "" # no runout + else True if not printer[client.filament_sensor].enabled # sensor is disabled + else printer[client.filament_sensor].filament_detected %} # sensor status + SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=filament_state VALUE="{runout}" + +[gcode_macro _RUNOUT_HANDLE] +description: filament state update +gcode: + _FILAMENT_UPDATE + {% if printer.print_stats.state == "printing" %} + _RUNOUT_PAUSE + {% endif %} + +[gcode_macro _RUNOUT_PAUSE] +gcode: + {% set filament_state = printer['gcode_macro RESUME'].filament_state.runout|default(False) %} + {% if not filament_state %} + PAUSE + M118 "Nothing! granular material in the silo has been run out." + {% endif %} + +######################################## +# power loss recovery +######################################## + +[delayed_gcode _CHECK_POWER_LOSS_RECOVERY] +initial_duration: 1 +gcode: + {% set was_interrupted = printer.save_variables.variables.was_interrupted | default(False) | string %} + {% set enable_recovery = printer.save_variables.variables.power_loss_recovery | default(Ture) | string %} + {% if enable_recovery != "False" and was_interrupted == "True" %} + RESPOND TYPE=command MSG="action:prompt_begin " + RESPOND TYPE=command MSG="action:prompt_text The last print job was not completed continue printing?" + RESPOND TYPE=command MSG="action:prompt_footer_button Continue|_RESUME_INTERRUPTED" + RESPOND TYPE=command MSG="action:prompt_footer_button Cancel|_ABORT_INTERRUPTED|error" + RESPOND TYPE=command MSG="action:prompt_show" + {% endif %} + +[gcode_shell_command _CLEAR_PLR] +command: sh /home/klipper/klipper/scripts/clear_plr.sh +timeout: 5. +verbose: False + +[gcode_macro _CLEAR_LAST_FILE] +gcode: + {% set filename = '' %} + {% set filepath = '' %} + RUN_SHELL_COMMAND CMD=_CLEAR_PLR + SAVE_VARIABLE VARIABLE=last_file VALUE='"{ filename }"' + SAVE_VARIABLE VARIABLE=filepath VALUE='"{ filepath }"' + {% set zero_vars = ['power_resume_x', 'power_resume_y', 'power_resume_z'] %} + {% for var in zero_vars %} + SAVE_VARIABLE VARIABLE={var} VALUE=0 + {% endfor %} + SAVE_VARIABLE VARIABLE=was_interrupted VALUE=False + +[gcode_shell_command _POWER_LOSS_RECOVERY] +command: /home/klipper/klipper/scripts/plr.sh +timeout: 420. +verbose: False + +[gcode_macro _RESUME_INTERRUPTED] +gcode: + {% set sv = printer.save_variables.variables %} + {% set client = printer['gcode_macro _CLIENT_VARIABLE']|default({}) %} + {% set park_dz = client.custom_park_dz|default(2.0)|abs %} + RESPOND TYPE=command MSG="action:prompt_end" + SET_GCODE_OFFSET Z=0 MOVE=0 + {% set z_height = params.Z_HEIGHT|default(sv.power_resume_z)|float %} + {% set is_paused = sv.power_loss_paused|default(False) %} + {% set last_file = params.GCODE_FILE|default(sv.last_file)|string %} + {% set hotend = sv.power_resume_extruder|default("extruder")%} + {% set z_offset = sv.nozzle_z_offset_val|default(0)|float %} + {% set z_offset_total = park_dz if is_paused else 0 %} + {% if hotend == "extruder1" %} + {% set z_offset_total = z_offset_total + z_offset %} + {% endif %} + M118 Recovery in progress, please wait + RUN_SHELL_COMMAND CMD=_POWER_LOSS_RECOVERY PARAMS="{z_height} \"{last_file}\" \"{z_offset_total}\"" + SDCARD_PRINT_FILE FILENAME=.plr/"{last_file}" + SAVE_VARIABLE VARIABLE=was_interrupted VALUE=False + +[gcode_macro _ABORT_INTERRUPTED] +gcode: + RESPOND TYPE=command MSG="action:prompt_end" + _CLEAR_LAST_FILE + +[include module/*.cfg] diff --git a/config/CreatBot_P800/printer.cfg b/config/CreatBot_P800/printer.cfg new file mode 100644 index 000000000..04df54673 --- /dev/null +++ b/config/CreatBot_P800/printer.cfg @@ -0,0 +1,39 @@ +[include base.cfg] + +[printer] +kinematics: cartesian +max_velocity: 100 +max_accel: 100 +max_z_velocity: 5 +max_z_accel: 5 +square_corner_velocity: 5 + +[extruder] +control: pid +pid_kp: 44.910 +pid_ki: 3.481 +pid_kd: 144.835 + +[heater_bed] +control: pid +pid_kp: 53.939 +pid_ki: 1.456 +pid_kd: 499.607 + +[heater_generic pre-heater] +control: pid +pid_kp: 44.075 +pid_ki: 2.332 +pid_kd: 208.253 + +[heater_generic mid-heater] +control: pid +pid_kp: 44.497 +pid_ki: 2.535 +pid_kd: 195.229 + +[heater_generic chamber] +control: pid +pid_kp: 30.68 +pid_ki: 0.21 +pid_kd: 0 diff --git a/klippy/extras/filament_airpump_sensor.py b/klippy/extras/filament_airpump_sensor.py new file mode 100644 index 000000000..4cb2d6ed4 --- /dev/null +++ b/klippy/extras/filament_airpump_sensor.py @@ -0,0 +1,142 @@ +# Filament air pump load Module +# +# Copyright (C) 2025 Creatbot +# +# This file may be distributed under the terms of the GNU GPLv3 license. +import logging +from . import output_pin, filament_switch_sensor + +class AirPump: + def __init__(self, config, timeout_event_handler): + self.printer = config.get_printer() + self.name = config.get_name() + self.reactor = self.printer.get_reactor() + self.max_run_time = config.getfloat('max_run_time', 10., minval=0.) + self.insert_delay_time = config.getfloat('insert_delay_time', 2., minval=0.) + self.start_time = None + self.is_running = False + self.timeout_timer = None + + ppins = self.printer.lookup_object('pins') + self.airpump_pin = None + airpump_pin = config.get('airpump_pin') + self.airpump_pin = ppins.setup_pin('digital_out', airpump_pin) + self.airpump_pin.setup_max_duration(0.) + self.airpump_mcu = self.airpump_pin.get_mcu() + self.timeout_event_handler = timeout_event_handler + + def set_power(self, power, eventtime): + print_time = self.airpump_mcu.estimated_print_time(eventtime + 0.1) + logging.info(f"set air pump to {power} at {print_time}") + if power > 0: + if not self.is_running: + self.start_time = self.reactor.monotonic() + self.is_running = True + self.timeout_timer = self.reactor.register_timer( + self._check_timeout, self.start_time + self.max_run_time) + self.airpump_pin.set_digital(print_time, 1) + else: + if self.timeout_timer is not None: + self.reactor.unregister_timer(self.timeout_timer) + self.timeout_timer = None + self.is_running = False + self.start_time = None + self.airpump_pin.set_digital(print_time, 0) + + def _check_timeout(self, eventtime): + if self.is_running and (eventtime - self.start_time >= self.max_run_time): + if self.timeout_event_handler: + self.timeout_event_handler(eventtime) + logging.info(f"Air pump '{self.name}' timed out after {self.max_run_time}s") + return self.reactor.NEVER + +class AirPump_Helper(filament_switch_sensor.RunoutHelper): + def __init__(self, config): + super().__init__(config) + self.airpump = AirPump(config, self._timeout_event_handler) + self.retry_count = 0 + + def set_airpump_state(self, power, eventtime=None): + if eventtime is None: + eventtime = self.reactor.monotonic() + self.airpump.set_power(power, eventtime) + + def _runout_event_handler(self, eventtime): + self.set_airpump_state(1, eventtime) + self.min_event_systime = self.reactor.monotonic() + self.event_delay + + def _insert_pump_event_handler(self, eventtime): + delay = self.airpump.insert_delay_time + target_time = eventtime + delay + def delayed_action(eventtime): + self.set_airpump_state(0, eventtime) + self.min_event_systime = self.reactor.monotonic() + self.event_delay + return self.reactor.NEVER + self.reactor.register_callback(delayed_action, target_time) + self.retry_count = 0 + + def _timeout_event_handler(self, eventtime): + self.retry_count += 1 + self.set_airpump_state(0, eventtime) + if self.retry_count < 3: + target_time = eventtime + 30 + def retry_action(eventtime): + self._runout_event_handler(eventtime) + return self.reactor.NEVER + self.reactor.register_callback(retry_action, target_time) + else: + super()._runout_event_handler(eventtime) + self.retry_count = 0 + +class AirPumpLoad: + def __init__(self, config): + self.cmd_SET_AIRPUMP_help = "Sets the state of the filament airpump" + self.printer = config.get_printer() + buttons = self.printer.load_object(config, 'buttons') + switch_pin = config.get('switch_pin') + + buttons.register_debounce_button(switch_pin, self._pump_status_handler, config) + self.airpump_helper = AirPump_Helper(config) + self.get_status = self.airpump_helper.get_status + + self.name = config.get_name().split()[-1] + self.template_eval = output_pin.lookup_template_eval(config) + gcode = self.printer.lookup_object('gcode') + gcode.register_mux_command("SET_AIRPUMP", "AIRPUMP", + self.name, + self.cmd_SET_AIRPUMP, + desc=self.cmd_SET_AIRPUMP_help) + + def _pump_status_handler(self, eventtime, state): + self.airpump_helper.note_filament_present(eventtime, state) + + def _template_update(self, text): + try: + value = float(text) + except ValueError as e: + logging.exception("Airpump template render error") + value = 0. + self.airpump_helper.set_airpump_state(value) + + def cmd_SET_AIRPUMP(self, gcmd): + value = gcmd.get_float('VALUE', None, minval=0., maxval=1.) + template = gcmd.get('TEMPLATE', None) + run_time = gcmd.get_float('RUN_TIME', None, minval=0.) + + if (value is None) == (template is None): + raise gcmd.error("SET_AIRPUMP must specify VALUE or TEMPLATE") + if template is not None: + self.template_eval.set_template(gcmd, self._template_update) + return + self.airpump_helper.set_airpump_state(value) + gcmd.respond_info(f"{self.name} airpump set to: {value}") + + if value > 0 and run_time is not None: + eventtime = self.airpump_helper.reactor.monotonic() + def turn_off_pump(eventtime): + self.airpump_helper.set_airpump_state(0, eventtime) + return self.airpump_helper.reactor.NEVER + self.airpump_helper.reactor.register_timer(turn_off_pump, eventtime + run_time) + +def load_config_prefix(config): + return AirPumpLoad(config) diff --git a/klippy/extras/filament_switch_sensor.py b/klippy/extras/filament_switch_sensor.py index d1acadd59..d5ca57cbe 100644 --- a/klippy/extras/filament_switch_sensor.py +++ b/klippy/extras/filament_switch_sensor.py @@ -76,6 +76,9 @@ class RunoutHelper: is_printing = idle_timeout.get_status(now)["state"] == "Printing" # Perform filament action associated with status change (if any) if is_filament_present: + if hasattr(self, 'airpump'): + self.min_event_systime = self.reactor.NEVER + self.reactor.register_callback(self._insert_pump_event_handler) if not is_printing and self.insert_gcode is not None: # insert detected self.min_event_systime = self.reactor.NEVER diff --git a/klippy/extras/gcode_move.py b/klippy/extras/gcode_move.py index 098b0b3b6..4e3e7b144 100644 --- a/klippy/extras/gcode_move.py +++ b/klippy/extras/gcode_move.py @@ -69,7 +69,7 @@ class GCodeMove: self.extrude_factor, self.speed) def _handle_activate_extruder(self): self.reset_last_position() - self.extrude_factor = 1. + # self.extrude_factor = 1. self.base_position[3] = self.last_position[3] def _handle_home_rails_end(self, homing_state, rails): self.reset_last_position() diff --git a/klippy/extras/state_led.py b/klippy/extras/state_led.py new file mode 100644 index 000000000..5a4e1a108 --- /dev/null +++ b/klippy/extras/state_led.py @@ -0,0 +1,116 @@ +from . import led +import logging + +class LEDStateHandler: + def __init__(self, config): + self.printer = config.get_printer() + self.led_name = config.get_name().split()[-1] + self.color_map = {} + states = ['idle', 'printing', 'paused', 'error', 'heating'] + for state in states: + color_str = config.get(state, None) + if color_str: + r, g, b = [float(v.strip()) for v in color_str.split(',')] + self.color_map[state] = (r, g, b) + + default_colors = { + 'idle': (0.0, 0.0, 0.0), + 'printing': (0.0, 1.0, 0.0), + 'paused': (1.0, 1.0, 0.0), + 'error': (1.0, 0.0, 0.0), + 'heating': (1.0, 0.5, 0.0), + } + for state, color in default_colors.items(): + if state not in self.color_map: + self.color_map[state] = color + + self.led = led.PrinterPWMLED(config) + self.hot_targets = {} + self.is_ready = False + self.last_color = None + + self.reactor = self.printer.get_reactor() + self.timer = None + + self.print_stats = self.printer.lookup_object('print_stats') + self.heaters = self.printer.lookup_object('heaters') + self.printer.register_event_handler('klippy:ready', self._handle_ready) + + def _handle_ready(self): + self.heaters = self.printer.lookup_object('heaters') + self.display_status = self.printer.lookup_object('display_status', None) + + for heater_name in self.heaters.get_all_heaters(): + self.hot_targets[heater_name] = 0.0 + + self.is_ready = True + self.timer = self.reactor.register_timer( + self._update_callback, self.reactor.NOW) + + def _update_callback(self, eventtime): + if not self.is_ready: + return eventtime + 1.0 + + status = self.print_stats.get_status(eventtime) + current_state = status.get('state', 'standby') + message = status.get('message', '') + try: + hot_targets_copy = self.hot_targets.copy() + for heater_name in hot_targets_copy.keys(): + try: + if heater_name.startswith('heater_generic '): + heater_name = heater_name.split(' ')[-1] + heater = self.heaters.lookup_heater(heater_name) + _, target = heater.get_temp(eventtime) + self.hot_targets[heater_name] = target + except Exception: + pass + except Exception as e: + logging.error("Error updating heater targets: %s", str(e)) + return eventtime + 1.0 + + max_hot_target = max(self.hot_targets.values()) if self.hot_targets else 0 + + if current_state == 'standby': + color_name = 'heating' if max_hot_target > 0 else 'idle' + elif current_state == 'printing': + color_name = 'printing' + elif current_state == 'paused': + color_name = 'paused' + elif current_state == 'cancelled': + color_name = 'paused' if message else 'idle' + elif current_state == 'error': + color_name = 'error' + else: + color_name = 'idle' + + try: + r, g, b = self.color_map[color_name] + except KeyError: + logging.error("Missing color definition for state: %s", color_name) + r, g, b = (1.0, 0.0, 0.0) + + if self.last_color != (r, g, b): + try: + color = (r, g, b, 0.0) + toolhead = self.printer.lookup_object('toolhead') + toolhead.register_lookahead_callback( + lambda pt: self._update_led_color(color, pt) + ) + logging.info('LED %s: %s %s', self.led_name, current_state, (r, g, b)) + self.last_color = (r, g, b) + except Exception as e: + logging.error("Error updating LED color: %s", str(e)) + + return eventtime + 0.5 + + def _update_led_color(self, color, print_time): + try: + if self.led.led_helper.led_state[0] != color: + self.led.led_helper._set_color(None, color) + self.led.led_helper._check_transmit(print_time) + except Exception as e: + logging.error("Error in LED transmission: %s", str(e)) + +def load_config_prefix(config): + return LEDStateHandler(config) \ No newline at end of file diff --git a/klippy/kinematics/extruder.py b/klippy/kinematics/extruder.py index cfe046b18..a427f36f2 100644 --- a/klippy/kinematics/extruder.py +++ b/klippy/kinematics/extruder.py @@ -136,6 +136,7 @@ class PrinterExtruder: def __init__(self, config, extruder_num): self.printer = config.get_printer() self.name = config.get_name() + self.err_count = 0 self.last_position = 0. # Setup hotend heater pheaters = self.printer.load_object(config, 'heaters') @@ -177,12 +178,12 @@ class PrinterExtruder: self.extruder_stepper = ExtruderStepper(config) self.extruder_stepper.stepper.set_trapq(self.trapq) # Register commands - gcode = self.printer.lookup_object('gcode') + self.gcode = self.printer.lookup_object('gcode') if self.name == 'extruder': toolhead.set_extruder(self, 0.) - gcode.register_command("M104", self.cmd_M104) - gcode.register_command("M109", self.cmd_M109) - gcode.register_mux_command("ACTIVATE_EXTRUDER", "EXTRUDER", + self.gcode.register_command("M104", self.cmd_M104) + self.gcode.register_command("M109", self.cmd_M109) + self.gcode.register_mux_command("ACTIVATE_EXTRUDER", "EXTRUDER", self.name, self.cmd_ACTIVATE_EXTRUDER, desc=self.cmd_ACTIVATE_EXTRUDER_help) def update_move_time(self, flush_time, clear_history_time): @@ -204,16 +205,28 @@ class PrinterExtruder: def check_move(self, move): axis_r = move.axes_r[3] if not self.heater.can_extrude: - raise self.printer.command_error( - "Extrude below minimum temp\n" - "See the 'min_extrude_temp' config option for details") + msg = (f"Extrude below minimum extrude temp of {self.heater.min_extrude_temp}℃") + if self.printer.is_printing(): + self.err_count += 1 + if self.err_count > 100: + self.err_count = 0 + self.gcode._respond_error(msg) + else: + raise self.printer.command_error(f"Extrude below minimum extrude temp of {self.heater.min_extrude_temp}℃") if (not move.axes_d[0] and not move.axes_d[1]) or axis_r < 0.: # Extrude only move (or retraction move) - limit accel and velocity if abs(move.axes_d[3]) > self.max_e_dist: - raise self.printer.command_error( + msg = ( "Extrude only move too long (%.3fmm vs %.3fmm)\n" "See the 'max_extrude_only_distance' config" " option for details" % (move.axes_d[3], self.max_e_dist)) + if self.printer.is_printing(): + self.err_count += 1 + if self.err_count > 100: + self.err_count = 0 + self.gcode._respond_error(msg) + else: + raise self.printer.command_error(msg) inv_extrude_r = 1. / abs(axis_r) move.limit_speed(self.max_e_velocity * inv_extrude_r, self.max_e_accel * inv_extrude_r)