forked from scheffield/nozzle-cleaner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean_nozzle.cfg
184 lines (144 loc) · 10.5 KB
/
clean_nozzle.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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
# Inspired by https://github.com/VoronDesign/VoronUsers/blob/master/orphaned_mods/printer_mods/edwardyeeks/Decontaminator_Purge_Bucket_%26_Nozzle_Scrubber/Macros/nozzle_scrub.cfg
#######################################################################################################################################
# The goal of this macro is to provide a nozzle cleaning and purging routine that is easily copied/referenced into your printer.cfg.
# Users can simply change parameters and enable/disable options in the first half. Descriptions are plentiful, making this macro
# look huge but informative and are laid out in sequence to be read first describing the line below; PLEASE READ CAREFULLY.
# This sample config assumes the following: The user has implemented the default decontaminator purge bucket & nozzle cleaner mod
# for the VORON 1/2. It can be tweaked to customised purge bucket geometries.
# Features in this macro: option of putting the bucket at the rear or front of the bed. Purge routine that can be enabled/disabled.
# By default, bucket is located at rear left of bed and purge routine is enabled. The purge and scrubbing routine is randomized
# in either left or right bucket to ensure as even as possible distribution of filament gunk.
# Default parameters are set for safe speeds and movements. Where necessary, tweak the parameters for the nozzle scrub procedure
# to fit your printer.
#######################################################################################################################################
[gcode_macro clean_nozzle]
# Name of the macro is clean_nozzle.
# These parameters define your filament purging. The retract variable is used to retract right after purging to prevent unnecessary
# oozing. Some filament are particularly oozy and may continue to ooze out of the nozzle for a second or two after retracting. The
# ooze dwell variable makes allowance for this. Update as necessary. If you decided to not enable purge, you can ignore this section.
variable_purge_len: 10 ; Amount of filament, in mm, to purge.
variable_purge_spd: 200 ; Speed, in mm/min, of the purge.
variable_purge_temp_min: 150 ; Minimum nozzle temperature to permit a purge. Otherwise, purge will not occur.
variable_purge_ret: 2 ; Retract length, in mm, after purging to prevent slight oozing. Adjust as necessary.
variable_ooze_offset_z: 40 ; After purging, how far up to move Z, in mm.
variable_ooze_spd_z: 120 ; After purging, how fast to move up Z, in mm/min.
# Adjust this so that your nozzle hits the tube. The nozzle should hit the upper 1/4th to 1/2nd part of the tube.
variable_tube_top: 4.5 ; Z position in mm
# These parameters define your cleaning, 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: 5 ; When traveling, but not cleaning, the clearance along the z-axis between nozzle and tube.
variable_wipe_qty: 2 ; Number of complete (A complete wipe: left, right, left OR right, left, right) wipes.
variable_prep_spd_xy: 6000 ; Travel (not cleaning) speed along x and y-axis in mm/min.
variable_prep_spd_z: 1500 ; Travel (not cleaning) speed along z axis in mm/min.
variable_wipe_spd_xy: 5000 ; Nozzle wipe speed in mm/min.
# Tube position
variable_tube_x: 110 # X position of tube, Y is assumed to be 0
# This value is defaulted from tube location in CAD (rear left).
variable_wipe_travel: 20 # distance to travel when claening in mm
# 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.
#
# bucket_gap
# ← ---- →
# __________________________________________
# | | | |
# | | | |
# bucket_start (x) | |______| |
# | | | |
# | | | |
# |_________________|. . . |_________________|
# ← ------------- → ← ------------- →
# bucket_left_width bucket_right_width
# _______________________________________________________________________________________
# PRINTER FRONT
#
## For V2.4 250mm build, uncomment below
#variable_bucket_left_width: 42
## For V2.4 300mm build, uncomment below
#variable_bucket_left_width: 67
## For V2.4 350mm build, uncomment below
variable_bucket_left_width: 92
# These values are defaulted from bucket geometry in CAD (rear left location). Change only if you're using a custom bucket.
variable_bucket_right_width: 40
variable_bucket_gap: 22
# For V1.8, you may need to measure where your bucket start is and input into bucket_start. Otherwise, a value of 0 is for a default
# installation of purge bucket at rear left.
variable_bucket_start: 0
###############################################################################################################################################
###############################################################################################################################################
### From here on, unless you know what you're doing, it's recommended not to change anything
###############################################################################################################################################
###############################################################################################################################################
# Placeholder. The variable will later be set to contain, at random, a number representing the left or right bucket.
variable_bucket_pos: 1
gcode:
# Temperature in °C at which the filament is extruded/purged. Should be the print temperature. If no temperature or below 150 °C is
# specified, no purging will happen.
{% set purge_temp = params.PURGE|default("0")|int %}
# Temperature in °C below which the nozzle is whiped over the tube. If not termperature is defined, the cleaning will happen without
# waiting to reach any particular temperature.
{% set clean_temp = params.CLEAN|default("0")|int %}
# 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
SET_DISPLAY_TEXT MSG="Cleaning nozzle" ; Displays info
# Grab max position of Y-axis from config to use in setting a fixed y position.
{% set Ry = printer.configfile.config["stepper_y"]["position_max"]|float %}
# Randomly select left or right bin for purge. 0 = left, 1 = right
SET_GCODE_VARIABLE MACRO=clean_nozzle VARIABLE=bucket_pos VALUE={(range(2) | random)}
# Raise Z for travel.
G1 Z{tube_top + clearance_z} F{prep_spd_z}
# Position for purge. Randomly selects middle of left or right bucket. It references from the middle of the left bucket.
G1 Y{Ry} F{prep_spd_xy}
G1 X{bucket_start + (bucket_left_width / (2 - bucket_pos)) + (bucket_pos * bucket_gap) + (bucket_pos * (bucket_right_width / 2))}
# Purge filament if temp above 150 °C is specified
{% if purge_temp > purge_temp_min %}
# Lower as far as we can go
G1 Z{tube_top} F{prep_spd_z}
# Heats up the nozzle up to target via data from slicer
SET_DISPLAY_TEXT MSG="Hotend: {purge_temp}c" ; Displays info
STATUS_HEATING ; Sets SB-leds to heating-mode
M107 ; Turns off partcooling fan
M109 S{purge_temp} ; Heats the nozzle to printing temp
### Small retract after purging to minimize any persistent oozing at 5x purge_spd. G4 dwell is in milliseconds,
### hence * 1000 in formula.
M83 ; relative mode
G1 E{purge_len} F{purge_spd}
G1 E-{purge_ret} F{purge_spd * 5}
M106 S127 ; use part cooling to harden the material
G92 E0 ; reset extruder
{% endif %}
# Wait till hotend is below given temperature if provided
{% if clean_temp > 0 %}
# Cooling nozzle to a given temperature. This helps with cleanly breaking off extruded filament
SET_DISPLAY_TEXT MSG="Hotend: {clean_temp}c" ; Displays info
M104 S{clean_temp} ; Heats the nozzle to 150c without waiting
G1 Z{tube_top + ooze_offset_z} F{ooze_spd_z} ; Slowly moving up to ensure ooze is straight and can be broken off
M109 S{clean_temp} ; Actually waiting for temperature to reach
M107 ; stop part cooling fan
{% endif %}
# Position for wipe. Either left or right of tube based off bucket_pos to avoid unnecessary travel.
G1 Z{tube_top + clearance_z} F{prep_spd_z}
G1 X{tube_x + (wipe_travel / 2 * (bucket_pos * 2 - 1))} F{prep_spd_xy}
G1 Y{Ry}
# Move nozzle down to hit the tube.
G1 Z{tube_top} F{prep_spd_z}
# Perform wipe. Wipe direction based off bucket_pos for cool random scrubby routine.
{% for wipes in range(1, (wipe_qty + 1)) %}
G1 X{tube_x - (wipe_travel / 2 * (bucket_pos * 2 - 1))} F{wipe_spd_xy}
G1 X{tube_x + (wipe_travel / 2 * (bucket_pos * 2 - 1))} F{wipe_spd_xy}
{% endfor %}
# Clear from area.
SET_DISPLAY_TEXT MSG="Nozzle cleaned"
G1 Z{tube_top + clearance_z} F{prep_spd_z}
G1 X{bucket_start + (bucket_left_width / 4)} F{prep_spd_xy} #bugfix for right side mounted buckets
# Restore the gcode state to how it was before the macro.
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!") }
SET_DISPLAY_TEXT MSG="Please home first!"
{% endif %}