Skip to content

Commit

Permalink
added purge front parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
LandonPatmore committed Nov 16, 2023
1 parent 3eca87b commit cb1a0e5
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 17 deletions.
1 change: 1 addition & 0 deletions Configuration/KAMP_Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ variable_tip_distance: 0 # Distance between tip of filament a
variable_purge_margin: 10 # Distance the purge will be in front of the print area, default is 10.
variable_purge_amount: 30 # Amount of filament to be purged prior to printing.
variable_flow_rate: 12 # Flow rate of purge in mm3/s. Default is 12.
variable_purge_front: True # Whether to purge at the front or rear of the bed. Useful if you have a purge bucket/nozzle scrubber in the rear.

# The following variables are for adjusting the Smart Park feature for KAMP, which will park the printhead near the print area at a specified height.
variable_smart_park_height: 10 # Z position for Smart Park, default is 10.
Expand Down
14 changes: 10 additions & 4 deletions Configuration/Line_Purge.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ gcode:
{% set purge_margin = printer["gcode_macro _KAMP_Settings"].purge_margin | float %}
{% set purge_amount = printer["gcode_macro _KAMP_Settings"].purge_amount | float %}
{% set flow_rate = printer["gcode_macro _KAMP_Settings"].flow_rate | float %}
{% set purge_front = printer["gcode_macro _KAMP_Settings"].purge_front | int %}


# Calculate purge origins and centers from objects
Expand All @@ -33,8 +34,13 @@ gcode:
{% set purge_x_center = ([((purge_x_max + purge_x_min) / 2) - (purge_amount / 2), 0] | max) %} # Create center point of purge line relative to print on X axis
{% set purge_y_center = ([((purge_y_max + purge_y_min) / 2) - (purge_amount / 2), 0] | max) %} # Create center point of purge line relative to print on Y axis

{% set purge_x_origin = ([purge_x_min - purge_margin, 0] | max) %} # Add margin to x min, compare to 0, and choose the larger
{% set purge_y_origin = ([purge_y_min - purge_margin, 0] | max) %} # Add margin to y min, compare to 0, and choose the larger
{% if purge_front %}
{% set purge_x_origin = ([purge_x_min - purge_margin, 0] | max) %} # Add margin to x min, compare to 0, and choose the larger
{% set purge_y_origin = ([purge_y_min - purge_margin, 0] | max) %} # Add margin to y min, compare to 0, and choose the larger
{% else %}
{% set purge_x_origin = ([purge_x_max + purge_margin, printer.toolhead.axis_maximum.x] | min) %} # Add margin to x max, compare to x max, and choose the smaller
{% set purge_y_origin = ([purge_y_max + purge_margin, printer.toolhead.axis_maximum.x] | min) %} # Add margin to y max, compare to y max, and choose the smaller
{% endif %}

# Calculate purge speed
{% set purge_move_speed = (flow_rate / 5.0) * 60 | float %}
Expand Down Expand Up @@ -80,7 +86,7 @@ gcode:

SAVE_GCODE_STATE NAME=Prepurge_State # Create gcode state

{% if purge_y_origin > 0 %} # If there's room on Y, purge along X axis in front of print area
{% if purge_y_origin > 0 %} # If there's room on Y, purge along X axis

G92 E0 # Reset extruder
G0 F{travel_speed} # Set travel speed
Expand All @@ -96,7 +102,7 @@ gcode:
M82 # Absolute extrusion mode
G0 Z{purge_height * 2} F{travel_speed} # Z hop

{% else %} # If there's room on X, purge along Y axis to the left of print area
{% else %} # If there's room on X, purge along Y axis

G92 E0 # Reset extruder
G0 F{travel_speed} # Set travel speed
Expand Down
39 changes: 28 additions & 11 deletions Configuration/Smart_Park.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,51 @@ gcode:
{% set z_height = kamp_settings.smart_park_height | float %} # Set Z height variable
{% set purge_margin = kamp_settings.purge_margin | float %} # Set purge margin variable
{% set verbose_enable = kamp_settings.verbose_enable | abs %} # Set verbosity
{% set center_x = printer.toolhead.axis_maximum.x / 2 | float %} # Create center point of x for fallback
{% set center_y = printer.toolhead.axis_maximum.y / 2 | float %} # Create center point of y for fallback
{% set axis_minimum_x = printer.toolhead.axis_minimum.x | float %}
{% set axis_minimum_y = printer.toolhead.axis_minimum.y | float %}
{% set axis_maximum_x = printer.toolhead.axis_maximum.x | float %}
{% set axis_maximum_y = printer.toolhead.axis_maximum.y | float %}
{% set center_x = axis_maximum_x / 2 | float %} # Create center point of x for fallback
{% set center_y = axis_maximum_y / 2 | float %} # Create center point of y for fallback
{% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Gather all object points
{% set x_min = all_points | map(attribute=0) | min | default(center_x) %} # Set x_min from smallest object x point
{% set y_min = all_points | map(attribute=1) | min | default(center_y) %} # Set y_min from smallest object y point
{% set x_max = all_points | map(attribute=0) | max | default(center_x) %} # Set x_max from largest object x point
{% set y_max = all_points | map(attribute=1) | max | default(center_y) %} # Set y_max from largest object y point
{% set travel_speed = (printer.toolhead.max_velocity) * 60 | float %} # Set travel speed from config
{% set purge_front = kamp_settings.purge_front | int %} # Set whether to park at the front or back of object


{% if purge_margin > 0 and x_min != center_x and y_min != center_y %} # If objects are detected and purge margin
{% set x_min = [ x_min - purge_margin , x_min ] | min %} # value is greater than 0, move
{% set y_min = [ y_min - purge_margin , y_min ] | min %} # to purge location + margin
{% set x_min = [ x_min , axis_minimum_x ] | max %}
{% set y_min = [ y_min , axis_minimum_y ] | max %}
# If objects are detected and purge margin value is greater than 0, move to purge location + margin
{% if purge_margin > 0 %}
{% if purge_front %}
{% if x_min != center_x and y_min != center_y %}
{% set x_point = [ x_min - purge_margin , x_min ] | min %}
{% set y_point = [ y_min - purge_margin , y_min ] | min %}
{% set x_point = [ x_point , axis_minimum_x ] | max %}
{% set y_point = [ y_point , axis_minimum_y ] | max %}
{% endif %}
{% else %}
{% if x_max != center_x and y_max != center_y %}
{% set x_point = [ x_max + purge_margin , x_max ] | max %}
{% set y_point = [ y_max + purge_margin , y_max ] | max %}
{% set x_point = [ x_point , axis_maximum_x ] | min %}
{% set y_point = [ y_point , axis_maximum_y ] | min %}
{% endif %}
{% endif %}
{% endif %}

# Verbose park location
{% if verbose_enable == True %}

{ action_respond_info("Smart Park location: {},{}.".format(
(x_min),
(y_min),
(x_point),
(y_point),
)) }

{% endif %}

{% if printer.toolhead.position.z < z_height %}
G0 Z{z_height} # Move Z to park height if current Z position is lower than z_height
{% endif %}
G0 X{x_min} Y{y_min} F{travel_speed} # Move near object area
G0 X{x_point} Y{y_point} F{travel_speed} # Move near object area
G0 Z{z_height} # Move Z to park height
10 changes: 8 additions & 2 deletions Configuration/Voron_Purge.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ gcode:
{% set purge_amount = kamp_settings.purge_amount | float %}
{% set flow_rate = kamp_settings.flow_rate | float %}
{% set size = 10 | float %}
{% set purge_front = kamp_settings.purge_front | int %}

# Calculate purge origins and centers from objects
{% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Get all object points
Expand All @@ -34,8 +35,13 @@ gcode:
{% set purge_x_center = ([((purge_x_max + purge_x_min) / 2) - (purge_amount / 2), 0] | max) %} # Create center point of purge line relative to print on X axis
{% set purge_y_center = ([((purge_y_max + purge_y_min) / 2) - (purge_amount / 2), 0] | max) %} # Create center point of purge line relative to print on Y axis

{% set purge_x_origin = ([purge_x_min - purge_margin, 0] | max) %} # Add margin to x min, compare to 0, and choose the larger
{% set purge_y_origin = ([purge_y_min - purge_margin, 0] | max) %} # Add margin to y min, compare to 0, and choose the larger
{% if purge_front %}
{% set purge_x_origin = ([purge_x_min - purge_margin, 0] | max) %} # Add margin to x min, compare to 0, and choose the larger
{% set purge_y_origin = ([purge_y_min - purge_margin, 0] | max) %} # Add margin to y min, compare to 0, and choose the larger
{% else %}
{% set purge_x_origin = ([purge_x_max + purge_margin, printer.toolhead.axis_maximum.x] | min) %} # Add margin to x max, compare to x max, and choose the smaller
{% set purge_y_origin = ([purge_y_max + purge_margin, printer.toolhead.axis_maximum.x] | min) %} # Add margin to y max, compare to y max, and choose the smaller
{% endif %}

# Calculate purge speed
{% set purge_move_speed = (flow_rate / 5.0) * 60 | float %}
Expand Down

0 comments on commit cb1a0e5

Please sign in to comment.