Skip to content

Commit

Permalink
Minor fixes (#160)
Browse files Browse the repository at this point in the history
* Update Line_Purge.cfg

- Added 10mm rapid move at the end of the purge line to break any stringing and move nozzle to less likely area to collide with purged line.

- Added gcode state save and restore to finally fix issues with slicer profiles that do not use relative extrusion mode.

* Update Voron_Purge.cfg

- Added gcode state save and restore to finally fix issues with slicer profiles that do not use relative extrusion mode.

* Update Smart_Park.cfg

Update smart park to account for purge margin if it is present, and if there are objects detected.

* Update Smart_Park.cfg

Sometimes with a full buildplate, the park will fail. Smart park will now compare the purge+margin point with the minimum point of the printed area and choose the bigger of the two points.

* Update Adaptive_Meshing.cfg

If KAMP adjustments exceed printer configured default bounds, remove adjustments and verbose message

* fix spelling error for moonraker.conf

* fix for calculated mesh exceeding bounds

* fix readme, add common issue to troubleshooting
  • Loading branch information
kyleisah committed Aug 20, 2023
1 parent 23bee5b commit 7399a37
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 10 deletions.
13 changes: 9 additions & 4 deletions Configuration/Adaptive_Meshing.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ gcode:
{% set adapted_x_max = (bed_mesh_max[0] - fuzz_amount + mesh_margin, x_max) | min + (fuzz_range | random / 100.0) %} # Adapt x_max to margin and fuzz constraints
{% set adapted_y_max = (bed_mesh_max[1] - fuzz_amount + mesh_margin, y_max) | min + (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

Expand All @@ -44,10 +49,10 @@ gcode:
{% 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 %}
{% 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

Expand Down
6 changes: 6 additions & 0 deletions Configuration/Line_Purge.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ gcode:

{% endif %}

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

G92 E0 # Reset extruder
Expand All @@ -89,6 +91,7 @@ gcode:
G1 E{tip_distance} F{purge_move_speed} # Move filament tip
G1 X{purge_x_center + purge_amount} E{purge_amount} F{purge_move_speed} # Purge line
{RETRACT} # Retract
G0 X{purge_x_center + purge_amount + 10} F{travel_speed} # Rapid move to break string
G92 E0 # Reset extruder distance
M82 # Absolute extrusion mode
G0 Z{purge_height * 2} F{travel_speed} # Z hop
Expand All @@ -104,10 +107,13 @@ gcode:
G1 E{tip_distance} F{purge_move_speed} # Move filament tip
G1 Y{purge_y_center + purge_amount} E{purge_amount} F{purge_move_speed} # Purge line
{RETRACT} # Retract
G0 Y{purge_y_center + purge_amount + 10} F{travel_speed} # Rapid move to break string
G92 E0 # Reset extruder distance
M82 # Absolute extrusion mode
G0 Z{purge_height * 2} F{travel_speed} # Z hop

{% endif %}

RESTORE_GCODE_STATE NAME=Prepurge_State # Restore gcode state

{% endif %}
22 changes: 20 additions & 2 deletions Configuration/Smart_Park.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,31 @@
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 kamp_settings = printer["gcode_macro _KAMP_Settings"] %} # Pull all variables from _KAMP_Settings
{% 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 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

{% 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 ] | max %} # value is greater than 0, move
{% set y_min = [ y_min - purge_margin , y_min ] | max %} # to purge location + margin
{% endif %}

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

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

{% endif %}

G0 X{x_min} Y{y_min} F{travel_speed} # Move near object area
G0 Z{z_height} # Move Z to park height
G0 Z{z_height} # Move Z to park height
6 changes: 5 additions & 1 deletion Configuration/Voron_Purge.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ gcode:
{action_respond_info("KAMP purge is not using firmware retraction, it is recommended to configure it.")}
{% endif %}

SAVE_GCODE_STATE NAME=Prepurge_State # Create gcode state

G92 E0 # Reset extruder
G0 F{travel_speed} # Set travel speed
G90 # Absolute positioning
Expand All @@ -81,6 +83,8 @@ gcode:
G1 E-.5 F2100 # Retract
G92 E0 # Reset extruder distance
M82 # Absolute extrusion mode
G0 Z{purge_height*2} F{travel_speed}
G0 Z{purge_height*2} F{travel_speed} # Z hop

RESTORE_GCODE_STATE NAME=Prepurge_State # Restore gcode state

{% endif %}
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ The cleanest and easiest way to get started with KAMP is to use Moonraker's Upda
>
> It is also possible that with older setups of klipper or moonraker that your config path will be different. Be sure to use the correct config path for your machine when making the symbolic link, and when copying `KAMP_Settings.cfg` to your config directory.
2. Open your `moonraker.cfg` file and add this configuration:
2. Open your `moonraker.conf` file and add this configuration:
```yaml
[update_manager Klipper-Adaptive-Meshing-Purging]
[update_manager Klipper-Adaptive-Meshing-Purging]
type: git_repo
channel: dev
path: ~/Klipper-Adaptive-Meshing-Purging
Expand Down Expand Up @@ -207,7 +207,17 @@ It is required to add `max_extrude_cross_section: 5` to your `[extruder]` config
* `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 `Smart_Park` near the end of your `Print_Start` macro, *before* the final heating command is called.**

## Troubleshooting:
*

<details>
<summary>
<b>
I'm getting 'gcode_macro BED_MESH_CALIBRATE:gcode': TypeError: bad operand type for abs(): 'Undefined'
</b>
</summary>
<p>
</p>
This was likely caused by you commenting out a setting in KAMP_Settings.cfg rather than just setting it to false. These checks needs to be in place, so instead of commenting them out, just set them to disabled.
</details>

## Credits:

Expand Down

0 comments on commit 7399a37

Please sign in to comment.