Skip to content

Commit

Permalink
Merge pull request kyleisah#105 from kyleisah/voron-logo-purge
Browse files Browse the repository at this point in the history
Voron logo purge and Smart Park feature added
  • Loading branch information
kyleisah authored Jul 8, 2023
2 parents 991a4e1 + 2e54f3f commit 16a0d15
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 6 deletions.
7 changes: 6 additions & 1 deletion Configuration/KAMP_Settings.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

# [include ./KAMP/Adaptive_Meshing.cfg] # Include to enable adaptive meshing configuration.
# [include ./KAMP/Line_Purge.cfg] # Include to enable adaptive line purging configuration.
# [include ./KAMP/Voron_Purge.cfg] # Include to enable adaptive Voron logo purging configuration.
# [include ./KAMP/Smart_Park.cfg] # Include to enable the Smart Park function, which parks the printhead near the print area for final heating.

[gcode_macro _KAMP_Settings]
description: This macro contains all adjustable settings for KAMP
Expand All @@ -26,6 +28,9 @@ variable_purge_margin: 10 # Distance the purge will be in fron
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.

# 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.

gcode: # Gcode section left intentionally blank. Do not disturb.

{action_respond_info(" Running the KAMP_Settings macro does nothing, it is only used for storing KAMP settings. ")}
{action_respond_info(" Running the KAMP_Settings macro does nothing, it is only used for storing KAMP settings. ")}
8 changes: 4 additions & 4 deletions Configuration/Line_Purge.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ gcode:
{% set purge_y_origin = ([purge_y_min - purge_margin, 0] | max) %} # Add margin to y min, compare to 0, and choose the larger

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

{% if cross_section != 5 %}
{% if cross_section < 5 %}

{action_respond_info("[Extruder] max_extrude_cross_section is not configured correctly, please set it to 5. Purge skipped.")}
{action_respond_info("[Extruder] max_extrude_cross_section is insufficient for purge, please set it to 5 or greater. Purge skipped.")}

{% else %}

Expand Down Expand Up @@ -110,4 +110,4 @@ gcode:

{% endif %}

{% endif %}
{% endif %}
14 changes: 14 additions & 0 deletions Configuration/Smart_Park.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[gcode_macro Smart_Park]
description: Parks your printhead near the print area for pre-print hotend heating.
gcode:

{% set z_height = printer["gcode_macro _KAMP_Settings"].smart_park_height | float %} # Pull park height value from _KAMP_Settings
{% 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 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 travel_speed = (printer.toolhead.max_velocity) * 60 | float %} # Set travel speed from config

G0 X{x_min} Y{y_min} F{travel_speed} # Move near object area
G0 Z{z_height} # Move Z to park height
86 changes: 86 additions & 0 deletions Configuration/Voron_Purge.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
[gcode_macro VORON_PURGE]
description: A purge macro that adapts to be near your actual printed objects
gcode:
# Get relevant printer params
{% set travel_speed = (printer.toolhead.max_velocity) * 60 | float %}
{% set cross_section = printer.configfile.settings.extruder.max_extrude_cross_section | float %}

# Use firmware retraction if it is defined
{% if printer.firmware_retraction is defined %}
{% set RETRACT = G10 | string %}
{% set UNRETRACT = G11 | string %}
{% else %}
{% set RETRACT = 'G1 E-.5 F2100' | string %}
{% set UNRETRACT = 'G1 E.5 F2100' | string %}
{% endif %}

# Get purge settings from _Kamp_Settings
{% set verbose_enable = printer["gcode_macro _KAMP_Settings"].verbose_enable | abs %}
{% set purge_height = printer["gcode_macro _KAMP_Settings"].purge_height | float %}
{% set tip_distance = printer["gcode_macro _KAMP_Settings"].tip_distance | float %}
{% 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 size = 10 | float %}

# Calculate purge origins and centers from objects
{% set all_points = printer.exclude_object.objects | map(attribute='polygon') | sum(start=[]) %} # Get all object points
{% set purge_x_min = (all_points | map(attribute=0) | min | default(0)) %} # Object x min
{% set purge_x_max = (all_points | map(attribute=0) | max | default(0)) %} # Object x max
{% set purge_y_min = (all_points | map(attribute=1) | min | default(0)) %} # Object y min
{% set purge_y_max = (all_points | map(attribute=1) | max | default(0)) %} # Object y max

{% 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

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

{% if cross_section < 5 %}

{action_respond_info("[Extruder] max_extrude_cross_section is insufficient for purge, please set it to 5 or greater. Purge skipped.")}

{% else %}

{% if verbose_enable == True %}

{action_respond_info("Moving filament tip {}mms".format(
(tip_distance),
)) }
{% endif %}

{% if printer.firmware_retraction is defined %}
{action_respond_info("KAMP purge is using firmware retraction.")}
{% else %}
{action_respond_info("KAMP purge is not using firmware retraction, it is recommended to configure it.")}
{% endif %}

G92 E0 # Reset extruder
G0 F{travel_speed} # Set travel speed
G90 # Absolute positioning
G0 X{purge_x_origin} Y{purge_y_origin+size/2} # Move to purge position
G0 Z{purge_height} # Move to purge Z height
M83 # Relative extrusion mode
G1 E{tip_distance} F{purge_move_speed} # Move tip of filament to nozzle
G1 X{purge_x_origin+size*0.289} Y{purge_y_origin+size} E{purge_amount/4} F{purge_move_speed}# Purge first line of logo
G1 E-.5 F2100 # Retract
G0 Z{purge_height*2} # Z hop
G0 X{purge_x_origin+size*0.789} Y{purge_y_origin+size} # Move to second purge line origin
G0 Z{purge_height} # Move to purge Z height
G1 E.5 F2100 # Recover
G1 X{purge_x_origin+size*0.211} Y{purge_y_origin} E{purge_amount/2} F{purge_move_speed} # Purge second line of logo
G1 E-.5 F2100 # Retract
G0 Z{purge_height*2} # Z hop
G0 X{purge_x_origin+size*0.711} Y{purge_y_origin} # Move to third purge line origin
G0 Z{purge_height} # Move to purge Z height
G1 E.5 F2100 # Recover
G1 X{purge_x_origin+size} Y{purge_y_origin+size/2} E{purge_amount/4} F{purge_move_speed} # Purge third line of logo
G1 E-.5 F2100 # Retract
G92 E0 # Reset extruder distance
M82 # Absolute extrusion mode
G0 Z{purge_height*2} F{travel_speed}

{% endif %}
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,18 @@ The cleanest and easiest way to get started with KAMP is to use Moonraker's Upda
# This file enables the use of adaptive line purging.
[include ./KAMP/Line_Purge.cfg]
# This file enables the use of the adaptive Voron logo purge.
[include ./KAMP/Voron_Purge.cfg]
# This file enables the use of KAMP's Smart Park feature.
[include ./KAMP/Smart_Park.cfg]
```

>**Note:**
The KAMP configuration files are broken up like this to allow those who do not use bed probes to benefit from adaptive purging.
The KAMP configuration files are broken up like this to allow those who do not use bed probes to benefit from adaptive purging, and other features.

4. After you `[include]` the features you want, be sure to restart your firmware so those inclusions take effect.

Expand Down Expand Up @@ -192,6 +200,12 @@ The cleanest and easiest way to get started with KAMP is to use Moonraker's Upda
>**Note:**
It is required to add `max_extrude_cross_section: 5` to your `[extruder]` config to allow effective purging to be possible. KAMP will warn you if you forget to set this value, and skip the purge so the printer will not be halted. It is also recommended to set up [firmware_retraction](https://www.klipper3d.org/Config_Reference.html?h=retract#firmware_retraction) inside of klipper so KAMP can use the correct retration settings for your machine. If this is not found, KAMP will warn you, and use reasonable direct-drive extruder values to complete the purge.

## Smart Park:

* These settings are used for adjusting KAMP's Smart Park function, which is helpful to move the printhead near the print area to do your final heating.

* `smart_park_height:` This is the height at which you'd like your printhead to be when calling the `Smart_Park` macro. **Don't forget to add this near the end of your `Print_Start` macro, *before* the final heating command is called.**

## Troubleshooting:
*

Expand Down

0 comments on commit 16a0d15

Please sign in to comment.