-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathTEST_Macros.cfg
307 lines (267 loc) · 8.25 KB
/
TEST_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
# __ __
# | \/ |
# | \ / | __ _ ___ _ __ ___ ___
# | |\/| |/ _` |/ __| '__/ _ \/ __|
# | | | | (_| | (__| | | (_) \__ \
# |_| |_|\__,_|\___|_| \___/|___/
###########################################################
## 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
# --------------------------- Start Print ----------------------------
[gcode_macro START_PRINT]
variable_bed_temp: 50
variable_extruder_temp: 205
gcode:
# Print message on LCD
M117 Start printing...
# Start bed heating
M140 S{bed_temp}
# Use absolute coordinates
G90
# Reset the G-Code Z offset (adjust Z offset if needed)
#SET_GCODE_OFFSET Z=0.0
# Home the printer
G28
# Move the nozzle near the bed
G1 Z50 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
# --------------------------------------------------------------------
# ---------------------------- End Print -----------------------------
[gcode_macro END_PRINT]
variable_machine_depth: 235
gcode:
G1 E-20 F100 # Unload little filament
# Print message on LCD
M117 Done printing :)
# Turn off bed, extruder, and fan
M140 S0
M104 S0
M106 S0
M107 ; turn off fan
# Relative positionning
G91
G1 E-10 Z+10 F3000 # unload little filament.
# Retract and raise Z
G1 Z0.2 E-2 F2400
# Wipe out
G1 X5 Y5 F3000
# Raise Z more
G1 Z10
# Absolute positionning
G90
# Present print
# G1 X10 Y220 F2000 # absolute xy
G1 X0 Y{machine_depth}
#disable hotend and heated bed
M104 S0
M140 S0
# disable steppers
M84 X Y E ; disable motors
# Disable steppers
#M84
#BED_MESH_CLEAR
# --------------------------------------------------------------------
# ---------------------------- 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 E300 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-300 F300 # 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
#CANCEL_PRINT_BASE
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.
[pause_resume]
[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 G29]
gcode:
G28
BED_MESH_CALIBRATE
G0 X0 Y0 Z10 F6000
BED_MESH_PROFILE save=default
SAVE_CONFIG
#--------------------------------------------------------------------