-
Notifications
You must be signed in to change notification settings - Fork 11
/
Macros.cfg
422 lines (357 loc) · 11.5 KB
/
Macros.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
# __ __
# | \/ |
# | \ / | __ _ ___ _ __ ___ ___
# | |\/| |/ _` |/ __| '__/ _ \/ __|
# | | | | (_| | (__| | | (_) \__ \
# |_| |_|\__,_|\___|_| \___/|___/
###########################################################
## Marcos
###########################################################
# https://albertogrespan.com/blog/3d-printing/klipper-on-an-ender-3/
# https://github.com/Klipper3d/klipper/blob/master/docs/G-Codes.md
# https://www.klipper3d.org/Command_Templates.html
# https://www.bondtech.se/2018/05/03/load-unload-script/
# https://github.com/albertogg/klipper-config/blob/97b36987ebfe697a084584e684897f2f1b13dea1/ender-3/printer.cfg#L194
# https://github.com/Klipper3d/klipper/blob/master/docs/G-Codes.md
# https://github.com/Desuuuu/klipper-macros
# https://albertogrespan.com/blog/3d-printing/klipper-on-an-ender-3/
# https://www.reddit.com/r/klippers/comments/kj2h5r/stepbystep_guide_for_ender_3_v2_klipper_w_bltouch/
# --------------------------- Start Print ----------------------------
[gcode_macro START_PRINT]
#variable_bed_temp: 50
#variable_extruder_temp: 205
gcode:
# Home
{% if printer.homed_axes != 'XYZ' %}
G28
{% endif %}
# Prime line
M117 PRIME LINE
PRIME_LINE
# Print message on LCD
M117 Start printing...
# --------------------------------------------------------------------
# --------------------------- Start Print PLA ----------------------------
[gcode_macro START_PRINT_PLA]
# variable_bed_temp: 50
# variable_extruder_temp: 210
gcode:
{% set T_BED = params.T_BED|default(50)|float %}
{% set T_EXTRUDER = params.T_EXTRUDER|default(210) %}
# Print message on LCD
M117 Start Homing
# Use absolute coordinates
G92
# Start heating and continue
M117 Waiting for temperature
M140 S{T_BED}
M109 S{T_EXTRUDER}
M190 S{T_BED} # wait till bed temp is reached, then continue
# Use absolute coordinates
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
#z_offset: 3.270
#SET_GCODE_OFFSET Z=3.270
START_PRINT
# --------------------------------------------------------------------
# --------------------------- Start Print PETG ----------------------------
[gcode_macro START_PRINT_PETG]
# variable_parameter_T_BED: 60
# variable_parameter_T_EXTRUDER: 225
gcode:
{% set T_BED = params.T_BED|default(60)|float %}
{% set T_EXTRUDER = params.T_EXTRUDER|default(225)|float %}
# Use absolute coordinates
G92
# Start bed heating and continue
M117 Waiting for temperature
M140 S{T_BED}
M109 S{T_EXTRUDER}
M190 S{T_BED} # wait till bed temp is reached, then continue
# Use absolute coordinates
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
# z_offset: 3.270
# SET_GCODE_OFFSET Z=3.270
START_PRINT
# --------------------------------------------------------------------
# ---------------------------- End Print -----------------------------
[gcode_macro END_PRINT]
variable_machine_depth: 235
gcode:
# Relative positionning
G91
# Unload little filament
G1 E-5 Z+10 F3000
G1 E-10 F1500
# Print message on LCD
M117 Done printing :)
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M106 S0
M107 ; turn off fan
# Absolute positionning
G90
# absolute xy
G1 X10 Y200 F2000
M84
#BED_MESH_CLEAR
# --------------------------------------------------------------------
# ---------------------------- Prime Line -----------------------------
# prime the nozzle
[gcode_macro PRIME_LINE]
gcode:
# Reset Extruder
G92 E0
G1 Z10 F240
# Move the nozzle very close to the bed
G1 X2 Y10 F3000
G1 Z0.28 F240
# Wait for bed to reach temperature
#M190 S{bed_temp}
# Set and wait for nozzle to reach temperature
#M109 S{extruder_temp}
G1 E10 F100 # load little filament
# Reset Extruder
G92 E0
# Move Z Axis up
G1 Z2.0 F5000
# Move to start position
G1 X2.1 Y20 Z0.28 F300
# Draw the first line
G1 X2.1 Y150 Z0.28 F1500 E15
# Move to side a little
G1 X2.4 Y150 Z0.28 F1500.0
# Draw the second line
G1 X2.4 Y20 Z0.28 F1500.0 E30
# Reset Extruder
G92 E0
# Move Z Axis up
G1 Z2.0 F300
M117 Start Printing...
# ---------------------------- Countdown -----------------------------
#[gcode_macro COUNTDOWN]
#default_parameter_MSG: "Time: "
#default_parameter_TIME: 10
#gcode:
# countdown
# {% for s in range(TIME|int, 0, -1) %}
# # dwell 1 second
# G4 P1000
# # echo
# M117 {params.MSG} {s}s
# M118 {params.MSG} {s}s
# {% endfor %}
# --------------------------------------------------------------------
# ---------------------------- Load Filament -------------------------
[gcode_macro LOAD_FILAMENT]
# M701
gcode:
SAVE_GCODE_STATE NAME=loading_filament
M117 Loading Filament
M83
G92 E0.0
LOW_TEMP_CHECK
G1 E320 F300 # length of bowden tube till cold-end (~420mm)
G1 E20 F100 # some extra to prime the nozzle --> slower
G92 E0.0
RESTORE_GCODE_STATE NAME=loading_filament
# --------------------------------------------------------------------
# ---------------------------- Unload Filament -----------------------
[gcode_macro UNLOAD_FILAMENT]
# M702
gcode:
SAVE_GCODE_STATE NAME=unloading_filament
M125 # park
M117 Unloading Filament
LOW_TEMP_CHECK
G91 # set relative
G1 E10 F100
G92 E0.0
G1 E-20 F1000
G1 E-300 F400 # the E is the length of the bowden tube (420mm) + 100 mm.
G92 E0.0
RESTORE_GCODE_STATE NAME=unloading_filament
# --------------------------------------------------------------------
# ---------------------------- Pause ---------------------------------
[gcode_macro PAUSE]
description: Pause the actual running print
rename_existing: PAUSE_BASE
# change this if you need more or less extrusion
variable_extrude: 1.0
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
##### set park positon for x and y #####
# default is your max posion from your printer.cfg
{% set x_park = printer.toolhead.axis_maximum.x|float - 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
##### calculate save lift position #####
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - 2.0) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
##### end of definitions #####
PAUSE_BASE
G91
{% if printer.extruder.can_extrude|lower == 'true' %}
G1 E-{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
{% if "xyz" in printer.toolhead.homed_axes %}
G1 Z{z_safe} F900
G90
G1 X{x_park} Y{y_park} F6000
{% else %}
{action_respond_info("Printer not homed")}
{% endif %}
# --------------------------------------------------------------------
# ---------------------------- Resume --------------------------------
[gcode_macro RESUME]
rename_existing: RESUME_BASE
description: Resume the actual running print
gcode:
##### read E from pause macro #####
{% set E = printer["gcode_macro PAUSE"].extrude|float %}
#### get VELOCITY parameter if specified ####
{% if 'VELOCITY' in params|upper %}
{% set get_params = ('VELOCITY=' + params.VELOCITY) %}
{%else %}
{% set get_params = "" %}
{% endif %}
##### end of definitions #####
{% if printer.extruder.can_extrude|lower == 'true' %}
G91
G1 E{E} F2100
{% else %}
{action_respond_info("Extruder not hot enough")}
{% endif %}
RESUME_BASE {get_params}
# --------------------------------------------------------------------
# ---------------------------- Cancel Print --------------------------
[gcode_macro CANCEL_PRINT]
description: Cancel the actual running print
rename_existing: CANCEL_PRINT_BASE
gcode:
#TURN_OFF_HEATERS
G91 # Set all axes to relative
# G90 # Absolute positionning
CANCEL_PRINT_BASE
G1 Z10 # Raise Z more
G1 X10 Y200 F2000 # Absolute xy
# G1 X0 Y{machine_depth}
M84 X Y E ; disable motors
# --------------------------------------------------------------------
# ------------------------- 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.
#[gcode_macro FILAMENT_CHANGE1]
# M600
#default_parameter_X: 50
#default_parameter_Y: 0
#default_parameter_Z: 10
#gcode:
# SAVE_GCODE_STATE NAME=M600_state
# PAUSE
# G91
# G1 E-.8 F2700
# G1 Z{Z}
# G90
# G1 X{X} Y{Y} F3000
# G91
# G1 E-50 F1000
# RESTORE_GCODE_STATE NAME=M600_state
# filament change
[gcode_macro FILAMENT_CHANGE]
# M600
gcode:
M117 Filament Change
M118 Filament Change
SAVE_GCODE_STATE NAME=filament_change
PAUSE
LOW_TEMP_CHECK
G91 # relative
G1 E-1 F300 # retract 1
M125 # park
M702 # unload
M117 New filament
M118 New filament
COUNTDOWN TIME=25 MSG="Switch"
M701
COUNTDOWN TIME=10 MSG="Clean"
RESUME
M117 Resuming
M118 Resuming
RESTORE_GCODE_STATE NAME=filament_change
M117 Printing..
M118 Printing..
# --------------------------------------------------------------------
# ------------------------- Motors Off -------------------------------
[gcode_macro MOTORS_OFF]
gcode:
M84 X Y E ; disable motors
# --------------------------------------------------------------------
# ------------------------- Bed Mesh Calibrate -----------------------
#[gcode_macro CALIBRATE]
#gcode:
# G28
# M118 Start clibrating...
# BED_MESH_CALIBRATE
# G0 X0 Y0 Z10 F6000
# BED_MESH_PROFILE save=default
# SAVE_CONFIG
[gcode_macro CALIBRATE]
gcode:
G28
{% set t = params.T|default(0)|float %}
{% if printer.idle_timeout.state == "Printing" %}
{action_respond_info("This command cannot be used while printing")}
{% elif printer.toolhead.homed_axes != "xyz" %}
{action_respond_info("Please home XYZ first")}
{% else %}
SAVE_GCODE_STATE NAME=G29_state
# G90
# G1 Z10 F240
{% if t > 30.0 %}
M190 S{t}
{% endif %}
BED_MESH_CALIBRATE
{% if 'S' in params %}
M140 S{params.S}
{% endif %}
G28
BED_MESH_CALIBRATE
#G90
#G1 Z10 F240
G1 X150 Y155 F6000
BED_MESH_PROFILE save=default
RESTORE_GCODE_STATE NAME=G29_state MOVE=0
{% endif %}
#--------------------------------------------------------------------
# ------------------------- Low Temp Check --------------------------
# LOW_TEMP_CHECK checks if there is a setpoint for the extruder. Untested!
# - If this setpoint is reached, continue.
# - If not, heat to setpoint.
# - If no setpoint, heat to parameter T (default@200)
[gcode_macro LOW_TEMP_CHECK]
gcode:
{% set T_EXTRUDER = params.T_EXTRUDER|default(205) %}
{% if printer.extruder.target != 0 %} # if there is a setpoint for extruder
{% if printer.extruder.temperature < printer.extruder.target %} # if not reached, heat
M118 Heating from {printer.extruder.temperature} to {printer.extruder.target}.
M109 S{printer.extruder.target|float}
{% endif %}
{% else %} # if no setpoint for extruder
{% if printer.extruder.target < T_EXTRUDER %} # heat to T.
M118 No setpoint, heating to {T_EXTRUDER}.
M109 S{T_EXTRUDER}
{% endif %}
{% endif %}