-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathfilament.cfg
341 lines (298 loc) · 10.8 KB
/
filament.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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
######################################################################
# Filament Change
######################################################################
# M600: Filament Change. This macro will pause the printer, move the
# tool to the change position, and retract the filament 50mm. Adjust
# the retraction settings for your own extruder. After filament has
# been changed, the print can be resumed from its previous position
# with the "RESUME" gcode.
[pause_resume]
[extruder]
max_extrude_only_distance: 120
[gcode_macro M600]
variable_version: 0.4
description: Unloads filament, waiting for a manual load and a resume
gcode:
#TODO set this from printer_variables
{% set X = params.X|default(printer.toolhead.axis_minimum.x + 10)|float %}
{% set Y = params.Y|default(printer.toolhead.axis_minimum.y + 10)|float %}
_DISABLE_FS # Do this out of state save
PAUSE X={X} Y={Y} #this saves gcode state
_SOUND_ALARM
G4
UNLOAD
# Unload stratergy:
# Check temp
# Purge extrude
# retract tip, pause, dip to remove string, retract
# main distance retract, pause , slow roll
#define FILAMENT_UNLOAD_PURGE_RETRACT 13 // (mm) Unload initial retract length.
#define FILAMENT_UNLOAD_PURGE_DELAY 5000 // (ms) Delay for the filament to cool after retract.
#define FILAMENT_UNLOAD_PURGE_LENGTH 8 // (mm) An unretract is done, then this length is purged.
#define FILAMENT_UNLOAD_PURGE_FEEDRATE 25
#F300 12mm3/s 5mm/s
[gcode_macro _UNLOAD_SEQUENCE]
gcode:
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro M600"].version %}
{% if svv.filament_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version
You should check the values in INIT_SETUP and run it to update
")}
{% endif %}
{% set purge_retract = svv.filament_unload_purge_retract|float %}
{% set purge_delay = svv.filament_unload_purge_delay|int %}
{% set purge_length = svv.filament_unload_purge_length|float %}
{% set retract_feedrate = svv.filament_retract_feedrate|int * 60 %}
{% set fast_purge_feedrate = svv.filament_purge_feedrate|int * 60 %}
# this should be load length - safety
{% set unload_length = svv.filament_load_length|int - svv.filament_unload_safety|int %}
{% set eject_length = svv.filament_unload_safety|float + printer.configfile.settings.extruder.rotation_distance|float %}
M83 ; relative
G1 E-{purge_retract} F{retract_feedrate}
M117 Wait
G4 P{purge_delay}
M117 Unloading
G1 E{purge_retract} F{retract_feedrate}
G1 E{purge_length} F{fast_purge_feedrate}
G1 E-{purge_retract} F{retract_feedrate}
G1 E-{unload_length-purge_retract} F{retract_feedrate}
#M300
G4 P5000
M117 Eject
G1 E-{eject_length} F{fast_purge_feedrate}
G4
M300
M117 Done
M82 ; absolute
[gcode_macro UNLOAD]
gcode:
_DISABLE_FS # Do this out of state save
SAVE_GCODE_STATE NAME=UNLOAD_state
{% set tool_t = printer.extruder.temperature %}
{% set target_t = printer.extruder.target %}
{% set min_extrude_t = printer.configfile.settings.extruder.min_extrude_temp %}
{% if target_t > min_extrude_t %}
#M300
M117 {target_t|int} is enough
{%if not printer.extruder.can_extrude %}
M117 Wait for {target_t|int}C
M300
M109 S{target_t}
M300
M117 Hot!
{% endif %}
_UNLOAD_SEQUENCE
{% else %}
M117 {target_t|int} is too cold
M300
G4 P200
M300
{% endif %}
# _RESET_FS NO, only do on LOAD
UPDATE_DELAYED_GCODE ID=clear_display DURATION=30
RESTORE_GCODE_STATE NAME=UNLOAD_state
M117 Filament Sensor Disabled
{ action_respond_info("Filament Motion Sensor will be reenabled on LOAD")}
# Load stratergy:
# check extrude temp
# PAUSE
# Slow roll 10mm
# Fast approach meltzone
# purge
[gcode_macro _LOAD_SEQUENCE]
gcode:
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro M600"].version %}
{% if svv.filament_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version
You should check the values in INIT_SETUP and run it to update
")}
{% endif %}
{% set purge_retract = svv.filament_pause_retraction %}
{% set retract_feedrate = svv.filament_retract_feedrate * 60 %}
{% set purge_length = svv.filament_load_purge_length %}
{% set load_feedrate = svv.filament_load_feedrate * 60 %}
{% set fast_purge_feedrate = svv.filament_purge_feedrate * 60 %}
{% set slow_load_length= svv.filament_load_slow_lenght %}
{% set slow_load_feedrate= svv.filament_slow_load_feedrate * 60 %}
{% set load_length = svv.filament_load_length %}
M83 ; relative
M117 SLOW E{slow_load_length} F{slow_load_feedrate}
G1 E{slow_load_length} F{slow_load_feedrate}
G4
M300
M117 Fast E{load_length} F{load_feedrate}
G1 E{load_length - slow_load_length} F{load_feedrate}
G4
#M300
M117 PURGE E{purge_length} F{fast_purge_feedrate / 2}
G1 E{purge_length} F{fast_purge_feedrate / 2}
G4 P5000
M117 E{purge_retract} F{fast_purge_feedrate / 2}
G1 E-{purge_retract} F{retract_feedrate}
G4
M300
M117 Done
G4 P5000
M82 ; absolute
[gcode_macro LOAD]
gcode:
SAVE_GCODE_STATE NAME=LOAD_state
{% set tool_t = printer.extruder.temperature %}
{% set target_t = printer.extruder.target %}
{% set min_extrude_t = printer.configfile.settings.extruder.min_extrude_temp %}
_DISABLE_FS
{% if target_t > min_extrude_t %}
M300
M117 {target_t|int} is enough
{%if not printer.extruder.can_extrude %}
M117 Wait for {target_t|int}C
M300
M109 S{target_t}
M300
M117 Hot!
{% endif %}
_LOAD_SEQUENCE
{% else %}
M117 {target_t|int} is too cold
M300
G4 P200
M300
{% endif %}
#_RESET_FS
UPDATE_DELAYED_GCODE ID=clear_display DURATION=30
RESTORE_GCODE_STATE NAME=LOAD_state
_RESET_FS
[gcode_macro PURGE]
gcode:
SAVE_GCODE_STATE NAME=PURGE_state
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro M600"].version %}
{% if svv.filament_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version
You should check the values in INIT_SETUP and run it to update
")}
{% endif %}
{% set tool_t = printer.extruder.temperature %}
{% set target_t = printer.extruder.target %}
{% set min_extrude_t = printer.configfile.settings.extruder.min_extrude_temp %}
{% set purge_retract = svv.filament_pause_retraction %}
{% set retract_feedrate = svv.filament_retract_feedrate * 60 %}
{% set purge_length = svv.filament_load_purge_length %}
{% set fast_purge_feedrate = svv.filament_purge_feedrate * 60 %}
_DISABLE_FS
{% if target_t > min_extrude_t %}
#M300
M117 {target_t|int} is enough
{%if not printer.extruder.can_extrude %}
M117 Wait for {target_t|int}C
M109 S{target_t}
M117 Hot!
{% endif %}
M83
M117 PURGE E{purge_length} F{fast_purge_feedrate / 2}
G1 E{purge_length} F{fast_purge_feedrate / 2}
G4 P5000
G1 E-{purge_retract} F{retract_feedrate}
M82
{% else %}
M117 {target_t|int} is too cold
M300
G4 P200
M300
{% endif %}
_RESET_FS
UPDATE_DELAYED_GCODE ID=clear_display DURATION=30
RESTORE_GCODE_STATE NAME=PURGE_state
# These expect a filament motion sensor named "filament_sensor"
# only works if filament_disable_ms is set to 1
[gcode_macro _DISABLE_FS]
description: placehlder, disables filament sensor that might trigger an M600 in the middle of a load/unload/M600...
variable_triggered: 0
gcode:
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro M600"].version %}
#{% set ignore = "none" %}
{% if svv.filament_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version
You should check the values in INIT_SETUP and run it to update
")}
{% endif %}
{% if (svv.filament_disable_ms|int == 1|int) %}
# and ( printer["filament_motion_sensor my_sensor"].enabled or printer["filament_switch_sensor my_sensor"].enabled)
#this should be waaay smarter.
SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0
SET_FILAMENT_SENSOR SENSOR=switch_sensor ENABLE=0
{ action_respond_info("Filament Motion Sensor Disabled")}
SET_GCODE_VARIABLE MACRO=_DISABLE_FS VARIABLE=triggered VALUE=1
{% endif %}
[gcode_macro _RESET_FS]
description: placehlder, enables filament sensor if and only if it was turned off by _DISABLE_FS
gcode:
{% set svv = printer.save_variables.variables %}
{% set version = printer["gcode_macro M600"].version %}
{% if svv.filament_version|float < version|float %}
{ action_raise_error("Setup data is older than macro version
You should check the values in INIT_SETUP and run it to update
")}
{% endif %}
{% set triggered = printer["gcode_macro _DISABLE_FS"].triggered %}
{% if (triggered|int == 1|int) %}
# this shoiuld check _DISABLE_FS for smart
SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1
SET_FILAMENT_SENSOR SENSOR=switch_sensor ENABLE=1
SET_GCODE_VARIABLE MACRO=_DISABLE_FS VARIABLE=triggered VALUE=0
{ action_respond_info("Filament Motion Sensor re-enabled")}
{% endif %}
[menu __main __filament __autoload]
type: command
name: Auto Load
gcode:
SAVE_GCODE_STATE NAME=__filament__load
LOAD
RESTORE_GCODE_STATE NAME=__filament__load
[menu __main __filament __autounload]
type: command
name: Auto Unload
gcode:
SAVE_GCODE_STATE NAME=__filament__unload
UNLOAD
RESTORE_GCODE_STATE NAME=__filament__unload
[menu __main __filament __purge]
type: command
name: Auto Purge
gcode:
SAVE_GCODE_STATE NAME=__filament__purge
PURGE
RESTORE_GCODE_STATE NAME=__filament__purge
[menu __main __filament __resume]
type: command
enable: {printer.print_stats.state == "paused"}
name: Resume printing
gcode:
{% if printer.print_stats.state == "paused" %}
{% if "pause_resume" in printer %}
RESUME
{% else %}
M24
{% endif %}
_SOUND_YES
{% else %}
_SOUND_NO
{% endif %}
[menu __main __filament __pause]
type: command
enable: {printer.print_stats.state != "paused"}
name: Pause printing
gcode:
{% if printer.print_stats.state != "paused" %}
{% if "pause_resume" in printer %}
PAUSE
{% else %}
M24
{% endif %}
_SOUND_YES
{% else %}
_SOUND_NO
{% endif %}