-
Notifications
You must be signed in to change notification settings - Fork 8
/
nozzle-clean-purge.cfg
161 lines (140 loc) · 7.75 KB
/
nozzle-clean-purge.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
[gcode_macro move_to_purge_bucket]
description: Move the nozzle over the purge bucket. Lifts Z only if it is below the clearance height.
# These parameters define the size of your purge bucket. Update as necessary. If you decided to not enable purge, you can ignore
# this section. A visual reference is provided below. Note that orientation of parameters remain the same whether bucket is at rear
# or front.
#
# bucket_gap
# ← ---- →
# __________________________________________
# | | | |
# | | | |
# bucket_start (x) | |______| |
# | | | |
# | | | |
# |_________________|. . . |_________________|
# ← ------------- → ← ------------- →
# bucket_left_width bucket_right_width
# _______________________________________________________________________________________
# PRINTER FRONT
#variable_bucket_left_width: 42 ; V2.4 250x250
## For V2.4 300mm build, uncomment below
#variable_bucket_left_width: 67 ; V2.4 300x300
## For V2.4 350mm build, uncomment below
variable_bucket_left_width: 92 ; V2.4 350x350
variable_bucket_right_width: 40 ; all models
variable_bucket_gap: 22
variable_bucket_start: 0
gcode:
{% set MoveSpeed = params.SPEED | default(3000) | int %}
{% set ZClearance = params.Z_CLEARANCE | default(10) | int %}
{% set YClearance = params.Y_CLEARANCE | default(40) | int %}
SAVE_GCODE_STATE NAME=purge_bucket
G90 ; absolute positioning
{% set bucket_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
{% set bucket_random = (range(8) | random) %}
{% if bucket_random <= 6 %}
{% set bucket_pos = 0 %}
{% else %}
{% set bucket_pos = 1 %}
{% endif %}
{% set bucket_x = bucket_start + (bucket_left_width / (2 - bucket_pos)) + (bucket_pos * bucket_gap) + (bucket_pos * (bucket_right_width / 2)) %}
{% set toolhead_z = printer.toolhead.position.z|float %}
{% set toolhead_y = printer.toolhead.position.y|float %}
{% set clearance = ZClearance|float %}
{% set clearance_y = 350 - YClearance|float %}
{% if toolhead_z < clearance %}
G0 Z{ZClearance} F{MoveSpeed}
{% endif %}
{% if toolhead_y > clearance_y %}
G0 Y{clearance_y}
{%endif %}
G1 X{bucket_x} Y{clearance_y} F{MoveSpeed}
G1 X{bucket_x} Y{bucket_y} F{MoveSpeed}
RESTORE_GCODE_STATE NAME=purge_bucket
[gcode_macro clean_nozzle]
variable_enable_purge: True
variable_purge_spd: 150 ; Speed, in mm/min, of the purge.
variable_purge_temp_min: 215 ; Minimum nozzle temperature to permit a purge. Otherwise, purge will not occur.
variable_purge_ret: 10 ; Retract length, in mm, after purging to prevent slight oozing. Adjust as necessary.
variable_ooze_dwell: 2 ; Dwell/wait time, in seconds, after purging and retracting.
# Adjust this so that your nozzle scrubs within the brush. Currently defaulted to be a lot higher for safety. Be careful not to go too low!
variable_brush_top: 2.3
# These parameters define your scrubbing, travel speeds, safe z clearance and how many times you want to wipe. Update as necessary. Wipe
# direction is randomized based off whether the left or right bucket is randomly selected in the purge & scrubbing routine.
variable_clearance_z: 10 ; Z height that safely clears the top of the scrubbing brush.
variable_wipe_qty: 3 ; Number of complete (A complete wipe: left, right, left OR right, left, right) wipes.
variable_prep_spd_xy: 3000 ; Travel (not cleaning) move speed (mm/min)
variable_prep_spd_z: 1500 ; Travel speed (mm/min) when lowering the nozzle into the brush
variable_wipe_spd_xy: 5000 ; Nozzle wipe speed in mm/min.
# These parameters define the size of the brush. Update as necessary. A visual reference is provided below. Note that orientation of
# parameters remain the same whether bucket is at rear or front.
#
# ← brush_width →
# _________________ ↑
# | | ↑ If you chose location_bucket_rear = True, Y position is acquired
# brush_start (x) | | brush_depth from your stepper_y position_max. Adjust your brush physically in
# |_________________| ↓ Y so that the nozzle scrubs within the brush.
# (y) ↓
# brush_front
# __________________________________________________________
# PRINTER FRONT
#
#
## For V1.8, you may need to measure where your brush is on the x axis and input manually into any of the variable_brush_start uncommented.
## For V2.4 250mm build, uncomment this below:
#variable_brush_start: 25
## For V2.4 300mm build, uncomment this below:
#variable_brush_start: 50
## For V2.4 350mm build, uncomment this below:
variable_brush_start: 65
# This value is defaulted from brush location in CAD (rear left). Change if your brush width is different.
variable_brush_width: 57.4
## These are only used if location_bucket_rear is False. You specify a custom location in y axis for your brush - see diagram above. ##
variable_brush_front: 0
variable_brush_depth: 0
gcode:
{% set YClearance = params.Y_CLEARANCE | default(35) | int %}
{% set PurgeLength = params.PURGE_LENGTH | default(50) | float %}
{% set PurgeSpeed = params.PURGE_SPEED | default(200) | float %}
# First, check if the axes are homed.
{% if "xyz" in printer.toolhead.homed_axes %}
## Save the gcode state in this macro instance.
SAVE_GCODE_STATE NAME=clean_nozzle
## Set to absolute positioning.
G90
## Grab max position of Y-axis from config to use in setting a fixed y position for location_bucket_rear = True.
{% set Ry = printer.configfile.config["stepper_y"]["position_max"]|float %}
## Check if user enabled purge option or not.
{% if enable_purge %}
move_to_purge_bucket SPEED={prep_spd_xy} Z_CLEARANCE={clearance_z} Y_CLEARANCE={YClearance}
G0 Z{clearance_z}
{% if printer.extruder.temperature >= purge_temp_min %}
M83 ; relative mode
G1 E{PurgeLength} F{PurgeSpeed}
G1 E-{purge_ret} F{PurgeSpeed * 5}
G4 P{ooze_dwell * 1000}
G92 E0 ; reset extruder
{% endif %}
{% endif %}
G1 X{brush_start} Y{Ry} Z{clearance_z} F{prep_spd_xy}
G1 Z{brush_top} F{prep_spd_z}
{% for wipes in range(1, (wipe_qty + 1)) %}
G1 X{brush_start + brush_width} F{wipe_spd_xy}
G1 X{brush_start} F{wipe_spd_xy}
{% endfor %}
G0 Z{clearance_z}
{% set clearance_y = 350.0 - YClearance|float %}
G0 Y{clearance_y}
#move_to_purge_bucket SPEED={prep_spd_xy} Z_CLEARANCE={clearance_z}
RESTORE_GCODE_STATE NAME=clean_nozzle
{% else %}
## raise error will stop any macros that clean_nozzle is referenced in from proceeding for safety.
{ action_raise_error("Please home your axes.") }
M117 Must home axes
{% endif %}
#[menu __main __filament __clean]
#type: command
#name: Clean Nozzle
#gcode:
# clean_nozzle