-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm600.cfg
564 lines (398 loc) · 17.7 KB
/
m600.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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
#------------------------------------------------------
# MOM - My Overpowered M600 macro / written by Jay Lexx
# Also tenderly called the Mother Of Macros by u/Woodcat64
# Listen to MOM and everything will be alright!
#------------------------------------------------------
# NO RESPONSE TAKEN FOR ANY DAMAGE CAUSED BY MOM ;)
#------------------------------------------------------
#
#
# 09.11.2021 v0.1.6
#
# Sourcecode maintenance due to Klipper updates.
#
# v0.1.5
#
# - added ability to prevent nozzle cooldown
#
# Save this file f.e. as /home/pi/klipper_config/m600.cfg to leave printer.cfg nice and clean
# then use [include /home/pi/klipper_config/M600.cfg] in your printer.cfg
# Don't forget to configure default values in [gcode_makro m600cfg] down below
#
#
# Usage in CURA Slicer:
# Extensions > Post Processing > Modify G-Code
# Add a script -> Filament Change
# Set Layer to value at which filament should be changed
# I personally set the rest to 0, works like a charm
# ( Tbh, i even didn't check if they have any effect )
#
# The M600 command can also be used to just change filament from console or via Button, so,
# no more need for Unload,Park, Load etc. Macros anymore. The macro should return to the temp
# the printer had when it was started, regardless ff printer temperature at 0, 40 or 200
# It will check if temperature is high enough to extrude filament ( you have configured your
# min_extrude_temp in printer.cfg [extruder] didn't you ?!?), if not it will use the default
# temperature configured down below anyway.
#
#
# If the printer was not homed - therefore not knowing where it is - it will perform
# a G28 homing sequence . This will ( better say should ;) ) not happen mid print, don't worry.
#
# -----------------------------------------------------
# DESIGNED TO WORK ESPECIALLY WITH OCTOPRINT
# -----------------------------------------------------
# In Octoprint set Plugins -> Printer Dialogs -> Enable Support = Always
# Thx to u/josolanes for mentioning the fix for this possible issue
#
# Please apologize my english, i'm not a native speaker :)
#
# Those macros are in the magic box:
#
# [M876 S]
# Handle prompt response ( to communicate with octoprint )
#
# [JOBCENTER]
# Handles navigation inside the whole process ( better not to issue as terminal command )
#
# [M125]
# Park head
#
# [M701]
# Load filament
#
# [M702]
# Unload filament
#
# [LOW_TEMP_CHECK T]
# Heatup process & temperature processor
# uses printer.cfg [extruder] section max_temp & min_extrude_temp
#
# [M600]
# Marlin compatible guided Filament Change
#-------------------------------------------------------------------------
# Delete sections [respond] and [pause_resume] if already in your printer.cfg
# Both are needed to make MOM run the household and use social media ;)
#-------------------------------------------------------------------------
[pause_resume]
recover_velocity: 50
# When capture/restore is enabled, the speed at which to return to
# the captured position (in mm/s). Default is 50.0 mm/s.
[respond]
#default_type: echo
# Sets the default prefix of the "M118" and "RESPOND" output to one
# of the following:
# echo: "echo: " (This is the default)
# command: "// "
# error: "!! "
#default_prefix: echo:
# Directly sets the default prefix. If present, this value will
# override the "default_type".
#-------------------------------------------------------------------------
#####################
[gcode_macro m600cfg]
#####################
# CONFIGURE YOUR PREFERRED DEFAULT VALUES INSIDE THIS GCODE_MACRO
# Couldn't find anywhere if or how it's possible to define a config section
# Would have been much nicer to deal with, maybe one day i'll find out :)
# Leave me a hint if you know how.
variable_default_temp: 220
# Default temperature to heat up if M600 issued in terminal
# Ignored if a target temperature is already set at launch ( M104 / M109 )
# or started within a printjob
variable_cooldown: 1
# Wether the hotende should cool down or not when pause started
# 1 - Hotend cools down when paused ( Recommended for security reasons and saves some energy if
# you're away a longer period of time and therefore can't change the filament)
# 0 - Hotend stays hot ( Not recommended, you never know... )
variable_x: 165
variable_y: 0
# Coordinates to park hotend at (as absolute values)
variable_z: 20
# mm to raise z from current height (this is a relative value!)
variable_zmin: 100
# if current z height is below zmin (as an absolute value), head will lift zmin ( as relative value) instead z
# making it easier to clean the nozzle at that height
variable_load_fast: 30
# mm to load filament at fast speed (length of bowden-hotend-purge)
variable_load_slow: 30
# mm to load filament after fast speed slowly into the hotend incl. purge
variable_bowden: 50
# total mm to unload filament (all at high speed)
variable_speed_1: 6000
# Speed at which filament is loaded/unloaded
variable_speed_2: 9000
# Speed at which hotend is moved to park position
variable_purge: 10
# Possibility to extract xx mm filament after loading if loading was too short f.e.
variable_output: 118
#Additional output send via M117 or M118
# !-ATTENTION--------------------------------------------------------!
# ! !
# ! Uncomment the desired language / Comment ( Delete ) the other !
# ! If you edit the language please don't use special characters !
# ! like Ü,Ö,Ä, Ǣ or É in your language,macro will not work and show !
# ! a UnicodeDecodeError: 'ascii' ... !
# !------------------------------------------------------------------!
# Textdata HTML UI deutsch (german)
variable_step_a1: "<CENTER><P><B>SCHRITT 1/3 </B></P><H2>ZEIT ZU WECHSELN</H2>"
variable_step_b1:"Achtung, der Druckkopf ist ggfs. heiss!<dl><dt>"
variable_step_c1:"Die Temperatur wurde zur Sicherheit auf 0 gesetzt<dl><dt>"
variable_step_d1:"Klicke <b>WEITER</B> um (wieder) aufzuheizen<BR> Klipper wird anschliessend das Filament entladen<BR><BR>"
variable_step_2: "<CENTER><P><B>SCHRITT 2/3</B></P><B>Lade jetzt das neue Filament und klicke auf WEITER<BR><BR>( +/- 10mm in den PTFE Schlauch)"
variable_step_3: "<CENTER><P><B>SCHRITT 3/3</B></P><B>Reinige den Druckkopf, klicke dann WEITER um mit dem Druck fortzufahren oder ZURUECK um zum vorherigen Schritt 2 zu gelangen."
variable_next: "WEITER"
variable_previous: "ZURUECK"
variable_cancel: "ABBRUCH"
variable_purgetext: "EXTRAHIERE"
# Textdata HTML UI english
#variable_step_a1: "<CENTER><P><B>STEP 1/3 </B></P><H2>TIME TO CHANGE</H2>"
#variable_step_b1:"Beware, the nozzle could be hot! <dl><dt>"
#variable_step_c1:"Temperature set to 0 for security reasons<dl><dt>"
#variable_step_d1:"Click <b>NEXT</B> to heat up (again)<BR> Klipper will then unload the filament<BR><BR>"
#variable_step_2: "<CENTER><P><B>STEP 2/3</B></P><B>Load the new filament and click NEXT<BR><BR>( +/- 10mm into PTFE tube)"
#variable_step_3: "<CENTER><P><B>STEP 3/3</B></P><B>Wipe nozzle clean, then click NEXT to resume print or click BACK to unload again and return to step 2"
#variable_next: "NEXT"
#variable_previous: "BACK"
#variable_cancel: "CANCEL"
#variable_purgetext: "EXTRACT"
gcode:
#-# * * * THERE SHOULD BE NO NEED TO EDIT ANYTHING BELOW THIS POINT * * * #-#
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=default_temp VALUE={default_temp}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=cooldown VALUE={cooldown}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=x VALUE={x}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=y VALUE={y}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=z VALUE={z}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=zmin VALUE={zmin}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=retract_fast VALUE={retract_fast}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=retract_slow VALUE={retract_slow}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=speed_1 VALUE={speed_1}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=speed_2 VALUE={speed_2}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=purge VALUE={purge}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=output VALUE={output}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=step_a1 VALUE={step_a1}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=step_b1 VALUE={step_b1}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=step_v1 VALUE={step_c1}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=step_d1 VALUE={step_d1}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=step_2 VALUE={step_2}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=step_3 VALUE={step_3}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=next VALUE={next}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=previous VALUE={previous}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=cancel VALUE={cancel}
SET_GCODE_VARIABLE MACRO=m600cfg VARIABLE=purgetext VALUE={purgetext}
[gcode_macro BACK]
gcode:
M876 S1
[gcode_macro NEXT]
gcode:
m876 S2
[gcode_macro CANCEL]
gcode:
m876 S1
[gcode_macro EXTRACT]
gcode:
m876 S3
#####################
#####################
[gcode_macro M876]
#####################
variable_myjob: 0
gcode:
{% set S = params.S|default(-1)|int %}
{% set myjob = printer["gcode_macro JOBCENTER"].job %}
{% if myjob != 0 %}
{% if S == 1 %}
{% set myjob = myjob-2 %} #Jump to previous Step
{% elif S == 2%}
{% elif S == 3%}
{% if myjob == 6003 %}
{% set myjob = 6004 %}
{% else %}
{% set myjob = 6003 %}
{% endif %}
{% endif %}
{% if myjob == 5999 %}
JOBCENTER NEWJOB=5999
{% elif myjob == 6001%}
JOBCENTER NEWJOB=6001
{% elif myjob == 6002%}
JOBCENTER NEWJOB=6002
{% elif myjob == 6003%}
JOBCENTER NEWJOB=6003
{% elif myjob == 6004%}
JOBCENTER NEWJOB=6004
{% endif %}
{% endif %}
#######################
[gcode_macro JOBCENTER]
#######################
variable_temperature: 0
variable_job: 0
variable_myjob: 0
variable_cool: 1
variable_mystep: 1
gcode:
{% set NEWJOB = params.NEWJOB|default(0)|int %}
{% set myjob = printer["gcode_macro JOBCENTER"].job %}
{% if NEWJOB == 6004 %}
M{printer["gcode_macro m600cfg"].output|int} Extracting ...
M83
G92 E0.0
G1 E{printer["gcode_macro m600cfg"].purge|int} F200
G92 E0.0
{% set NEWJOB=6005 %}
{% endif %}
{% if NEWJOB == 6003 %}
M{printer["gcode_macro m600cfg"].output|int} Restoring printer state
{% if printer["gcode_macro JOBCENTER"].temperature==0 %}
M109 S0
{% else %}
M109 S{printer["gcode_macro JOBCENTER"].temperature}
{% endif%}
RESUME
RESPOND TYPE=command MSG="action:notification Resuming print..."
{% set myjob=0 %}
{% endif %}
{% if ( NEWJOB == 6002 or NEWJOB == 6005) %}
{% if NEWJOB==6002 %}
M{printer["gcode_macro m600cfg"].output|int} Loading filament
M701
{% endif %}
RESPOND TYPE=command MSG="action:prompt_begin {printer["gcode_macro m600cfg"].step_3}"
RESPOND TYPE=command MSG="action:prompt_choice {printer["gcode_macro m600cfg"].next}"
RESPOND TYPE=command MSG="action:prompt_choice {printer["gcode_macro m600cfg"].previous}"
RESPOND TYPE=command MSG="action:prompt_choice {printer["gcode_macro m600cfg"].purgetext} {printer["gcode_macro m600cfg"].purge|int} mm"
RESPOND TYPE=command MSG="action:prompt_show"
{% set myjob=6003 %}
{% endif %}
{% if NEWJOB == 6001 %}
LOW_TEMP_CHECK T={printer["gcode_macro JOBCENTER"].temperature}
M{printer["gcode_macro m600cfg"].output|int} Unloading filament
M702
RESPOND TYPE=command MSG="action:prompt_begin {printer["gcode_macro m600cfg"].step_2}"
RESPOND TYPE=command MSG="action:prompt_choice {printer["gcode_macro m600cfg"].next}"
RESPOND TYPE=command MSG="action:prompt_show"
{% set myjob=6002 %}
{% endif %}
{% if NEWJOB == 5999 %}
M{printer["gcode_macro m600cfg"].output|int} Restoring printer state
{% if printer["gcode_macro JOBCENTER"].temperature != 0 %}
LOW_TEMP_CHECK T={printer["gcode_macro JOBCENTER"].temperature} OVERRIDE=1
{% endif %}
RESUME
RESPOND TYPE=command MSG="action:notification M600 cancelled"
{% set myjob=0 %}
{% endif %}
{% if NEWJOB == 600 %}
PAUSE
M125
{% set cool=printer["gcode_macro m600cfg"].cooldown|int %}
{% set mystep=[printer["gcode_macro m600cfg"].step_a1,printer["gcode_macro m600cfg"].step_b1,printer["gcode_macro m600cfg"].step_d1]|join() %}
{% if cool != 0 %}
M104 S0
{% set mystep=[printer["gcode_macro m600cfg"].step_a1,printer["gcode_macro m600cfg"].step_c1,printer["gcode_macro m600cfg"].step_d1]|join() %}
{% endif %}
SET_IDLE_TIMEOUT TIMEOUT=7200
RESPOND TYPE=command MSG="action:prompt_begin {mystep}"
RESPOND TYPE=command MSG="action:prompt_choice {printer["gcode_macro m600cfg"].next}"
RESPOND TYPE=command MSG="action:prompt_choice {printer["gcode_macro m600cfg"].cancel}"
RESPOND TYPE=command MSG="action:prompt_show"
{% set myjob=6001 %}
{% endif %}
SET_GCODE_VARIABLE MACRO=JOBCENTER VARIABLE=job VALUE={myjob}
##################
[gcode_macro M125]
##################
gcode:
M{printer["gcode_macro m600cfg"].output|int} Moving hotend to {printer["gcode_macro m600cfg"].x|int}, {printer["gcode_macro m600cfg"].y|int}, {printer["gcode_macro m600cfg"].z|int} ({printer["gcode_macro m600cfg"].zmin|int})
SET_GCODE_VARIABLE MACRO=JOBCENTER VARIABLE=temperature VALUE={printer.extruder.target}
{% if printer.toolhead.homed_axes != "xyz" %}
# if not yet homed
M{printer["gcode_macro m600cfg"].output|int} Probably not printing. Homing needed ...
G28
{% endif %}
G91
# Note to self: Uncomment if ooze experienced (untested yet, just a logical thought)
# Retract small amount before moving if printer has a temperature set
# {% if printer.extruder.target != 0 %}
#
# LOW_TEMP_CHECK
# G1 E-3 F1500
#
# {% endif %}
{% if printer.toolhead.position.z|float + printer["gcode_macro m600cfg"].z|float < printer.configfile.config["stepper_z"]["position_max"]|float %}
{% if printer.toolhead.position.z < printer["gcode_macro m600cfg"].zmin|int %}
G1 Z{printer["gcode_macro m600cfg"].zmin|int|int-printer.toolhead.position.z|int}
{% else %}
SAVE_GCODE_STATE NAME=save_state
G1 Z{printer["gcode_macro m600cfg"].z|int}
RESTORE_GCODE_STATE NAME=save_state
{% endif %}
{% endif%}
G90
G1 X{printer["gcode_macro m600cfg"].x|int} Y{printer["gcode_macro m600cfg"].y|int} F{printer["gcode_macro m600cfg"].speed_2|int}
##################
[gcode_macro M701]
##################
gcode:
M83
G92 E0.0
LOW_TEMP_CHECK
G1 E{printer["gcode_macro m600cfg"].load_fast|int} F{printer["gcode_macro m600cfg"].speed_1|int}
G92 E0.0
G1 E{printer["gcode_macro m600cfg"].load_slow|int} F200
G92 E0.0
##################
[gcode_macro M702]
##################
gcode:
LOW_TEMP_CHECK
G91
G1 E10 F1200
G1 E-{printer["gcode_macro m600cfg"].bowden|int} F{printer["gcode_macro m600cfg"].speed_1|int}
G90
##################
[gcode_macro M600]
##################
gcode:
JOBCENTER NEWJOB=600
############################
[gcode_macro LOW_TEMP_CHECK]
############################
gcode:
{% if not params.OVERRIDE is defined %}
{% if params.T is defined %}
{% set TMP=params.T|int%}
{% if printer.configfile.config.extruder.max_temp is defined %}
{% if params.T|int>printer.configfile.config.extruder.max_temp|int %}
{% set TMP=printer["gcode_macro m600cfg"].default_temp|int %}
{% endif %}
{% endif %}
{% if TMP|int==0 %}
{% set TMP=printer["gcode_macro m600cfg"].default_temp|int %}
{% endif %}
{% else %}
{% set TMP=printer["gcode_macro m600cfg"].default_temp|int %}
{% if printer["gcode_macro JOBCENTER"].temperature|int > 0 %}
{% set TMP=printer["gcode_macro JOBCENTER"].temperature %}
{% endif %}
{% endif %}
{% if printer.configfile.config.extruder.min_extrude_temp is defined %}
{% if TMP|int<printer.configfile.config.extruder.min_extrude_temp|int %}
{% set TMP=printer["gcode_macro m600cfg"].default_temp %}
{% endif%}
{% endif %}
{% else %}
{% if params.T is defined %}
{% set TMP=params.T|int %}
{% else %}
{% set TMP=printer["gcode_macro m600cfg"].default_temp %}
{% endif %}
{% endif %}
{% if printer.extruder.temperature|int > TMP|int %}
M{printer["gcode_macro m600cfg"].output|int} Temperature set to {TMP}.
M104 S{TMP}
{% else %}
M{printer["gcode_macro m600cfg"].output|int} Heating to {TMP}
M109 S{TMP}
{% endif %}
##### THAT'S IT !