Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nozzle cleaning parameters update #569

Merged
merged 4 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/brush_center_offset.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
The purpose of this document is to explain the purpose of the brush center offset variable in variables.cfg.

The brush center offset takes the brush center and moves it in the direction of the brush normal by the specified amount.
This is useful for avoiding brush strokes that would cause the toolhead to crash into something or otherwise cause undesired affects.
One example (and the impetus for this feature) is the case in which one has a brush and a gantry-mounted depressor for a filament cutter on the same side of the gantry. If nozzle cleaning is perform with filament loaded and the brush strokes occur in the same space as the depressor, then the filament cutter is actuated (repeatedly) which results in unnecessary wear and unwanted filament cutting.
One could simply move the center of the brush away from the depressor, but this would cause the nozzle to leave the brush and be wasted motion.

How it works:
The brush center should be set as normal in the variables.cfg file. The brush center offset should be set to a value (in mm) that will prevent the toolhead from crashing into anything.
The brush size is provided to accomodate different brush sizes and is used to calculate the brush stroke distance.

For example, if the variable_brush_xyz is set to (40, 250, 2) and the variable_brush_center_offset is set to 10, then the new brush center will be (50, 250, 2).
This will create the following brush action:

|-----------------------------|---------------|--------------|
left center center + offset right
^ nozzle starts here
---------------> first brush stroke direction {(brush size/2) - brush center offset}
<-------------------------------------------- n brush stroke direction {(brush size/2)}
--------------------------------------------> n+1 brush stroke direction {(brush size/2)}

If variable_brush_center_offset is set to -10, then the new brush center will be (30, 250, 2) and the nozzle will start to the left of the center and do the mirror of the above brush action.

Therefore, this allows the nozzle brushing action to occur entirely with the brush with no wasted motion or unwanted interactions with other components.
24 changes: 17 additions & 7 deletions macros/helpers/nozzle_cleaning.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ gcode:
{% set status_leds_enabled = printer["gcode_macro _USER_VARIABLES"].status_leds_enabled %}
{% set brush_clean_accel = printer["gcode_macro _USER_VARIABLES"].brush_clean_accel %}
{% set brush_over_y_axis = printer["gcode_macro _USER_VARIABLES"].brush_over_y_axis %}
{% set brush_offset = printer["gcode_macro _USER_VARIABLES"].brush_center_offset|default(0)|float %}
{% set brush_size = printer["gcode_macro _USER_VARIABLES"].brush_width_x|default(40)|float %}
{% set brushes = printer["gcode_macro _USER_VARIABLES"].brushes|default(6)|int %}
{% set verbose = printer["gcode_macro _USER_VARIABLES"].verbose %}

{% if purge_and_brush_enabled %}
Expand All @@ -14,6 +17,7 @@ gcode:
{% set Sc = printer["gcode_macro _USER_VARIABLES"].brush_clean_speed * 60 %}

{% set Bx, By, Bz = printer["gcode_macro _USER_VARIABLES"].brush_xyz|map('float') %}
{% set Bx = Bx + brush_offset %}

{% if status_leds_enabled %}
STATUS_LEDS COLOR="CLEANING"
Expand All @@ -25,7 +29,7 @@ gcode:

# Set the cleaning acceleration prior to any movement
{% set saved_accel = printer.toolhead.max_accel %}
M204 S{brush_clean_accel}
SET_VELOCITY_LIMIT ACCEL={brush_clean_accel}

# Move to purge zone (left side)
G90
Expand All @@ -36,17 +40,23 @@ gcode:
# Wipe procedure
G91
{% if brush_over_y_axis %}
{% for wipe in range(6) %}
{% for wipe in range(brushes) %}
G1 Y-5 F{Sc}
G1 Y+5 F{Sc}
{% endfor %}
{% endif %}

G1 X+20 F{Sc}
# Move to the right side of the brush
{% if brush_offset < 0 %} # brush center biased towards 0
G1 X+{ brush_size/2 } F{Sc}
{% else %} # brush center biased towards x_max
G1 X+{ (brush_size/2) - brush_offset} F{Sc}
{% endif %}

{% for wipe in range(6) %}
G1 X-40 F{Sc}
G1 X+40 F{Sc}
# Brush procedure
{% for wipe in range(brushes) %}
G1 X-{ (brush_size) - brush_offset } F{Sc}
G1 X+{ (brush_size) - brush_offset } F{Sc}
{% endfor %}

G90
Expand Down Expand Up @@ -162,4 +172,4 @@ gcode:
{% endif %}

RESTORE_GCODE_STATE NAME=CONDITIONAL_MOVE_TO_PURGE_BUCKET_STATE
{% endif %}
{% endif %}
3 changes: 3 additions & 0 deletions user_templates/variables.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ variable_purge_and_brush_enabled: False
variable_force_homing_before_brush: False # Add an homing of the Z axis before a clean to be sure to not miss the brush
variable_brush_over_y_axis: True # Cleanup is done moving the extruder along the Y axis, then X axis. If false, only X axis is done
variable_brush_xyz: -1, -1, -1 # Position of the brush center for nozzle cleaning
variable_brush_width_x: 40 # Width of the brush in X direction (in mm)
variable_brush_center_offset: 0 # Offset of the brush center to start brushing (in mm), + is towards max X
variable_brushes: 6 # Number of brushes of the nozzle to perform
variable_purge_bucket_xyz: -1, -1, -1 # Purge bucket position
variable_purge_distance: 30 # Amount to purge (in mm)
variable_purge_ooze_time: 10 # Time (in seconds) to wait after the purge to let the nozzle ooze before going to the brush
Expand Down