-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_macros.cfg
421 lines (362 loc) · 14 KB
/
client_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
#
# This is an example (but working) macro to park toolhead out of the way of print
# You can also use your existing
#
[gcode_macro _PARK]
description: Park toolhead safely away from print
gcode:
{% set Z_HOP = params.Z_HOP|default(5)|float %}
{% set x_park = printer.toolhead.axis_minimum.x|float + 5.0 %}
{% set y_park = printer.toolhead.axis_maximum.y|float - 5.0 %}
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set act_z = printer.toolhead.position.z|float %}
{% if act_z < (max_z - Z_HOP) %}
{% set z_safe = Z_HOP %}
{% else %}
{% set z_safe = max_z - act_z %}
{% endif %}
G91
G1 Z{z_safe} F900
G90
G0 X{x_park} Y{y_park} F6000
[gcode_macro test_up]
gcode:
SET_SERVO SERVO=testServo ANGLE=160
# wait for deploy
#SET_SERVO SERVO=probeServo WIDTH=0 # OFF
[gcode_macro test_down]
gcode:
SET_SERVO SERVO=testServo ANGLE=20
# wait for retract
SET_SERVO SERVO=testServo WIDTH=0 # OFF
#
# This is an example (but working) CANCEL_PRINT macro
# You can also use your existing, but it should follow this pattern
#
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
description: Cancel print
gcode:
TURN_OFF_HEATERS
SDCARD_RESET_FILE
_PARK Z_HOP=20
CLEAR_PAUSE
BASE_CANCEL_PRINT
#
# This is an example (but working) PAUSE macro
# You can also use your existing, but it should follow this pattern
#
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
description: Pause the print and park
gcode:
{% if printer.pause_resume.is_paused %}
RESPOND MSG="Print is already paused"
{% else %}
G92 E0
G1 E-1.0 F1500.0 ; Retract a little to reduce ooze
G90
SAVE_GCODE_STATE NAME=PAUSE_state
BASE_PAUSE
_PARK Z_HOP=5
{% endif %}
#
# This is an example (but working) RESUME macro
# You can also use your existing, but it should follow this pattern
#
[gcode_macro RESUME]
rename_existing: BASE_RESUME
description: Resume the print
gcode:
{% if not printer.pause_resume.is_paused %}
RESPOND MSG="Print is not paused. Resume ignored"
{% else %}
#
# Good place to add other things like purging or nozzle cleaning
#
RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 MOVE_SPEED=100
G90
BASE_RESUME
{% endif %}
######################################################################
# 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]
# Make BambuStudio happy
[gcode_macro G3]
gcode:
[gcode_macro G17]
gcode:
[gcode_macro M981]
gcode:
[gcode_macro M1003]
gcode:
[gcode_macro M600]
gcode:
{% set X = params.X|default(50)|float %}
{% set Y = params.Y|default(0)|float %}
{% set Z = params.Z|default(10)|float %}
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
#####################################################################
# Macros
#####################################################################
[gcode_macro CALIBRATE_Z]
rename_existing: BASE_CALIBRATE_Z
gcode:
{% set bed_position = params.BED_POSITION|default('None') %}
G28 # can also be a conditional homing macro
M117 Z-Calibration..
ATTACH_PROBE # a macro for fetching the probe first
{% if bed_position != 'None' %}
BASE_CALIBRATE_Z BED_POSITION={bed_position}
{% else %}
BASE_CALIBRATE_Z
{% endif %}
DOCK_PROBE # and parking it afterwards (or DOCK_PROBE in klicky macros)
M117
[gcode_macro PRIMING]
gcode:
M106 S255 ;partcooling fan max .1
G1 X162 Y352 F30000 ;move to purge position X/Y .3
G1 Z5 F5000 ;move to purge position Z .4
G91 ;incremental positioning .5
G1 E14 F500 ;prime hotend .6
G1 E25 F250 ;purge .7
M82 ;extruder absolute .12
G92 E0.0 ;extruder reset .13
G90 ;absolute positioning .14
M107 ;partcooling fan off .15
CLEAN_NOZZLE
[gcode_macro CLEAN]
gcode:
M204 S6000 ;set acceleration to 6000 .16
G1 X180 Y30 F30000 ;move to position X/Y .17
G1 Z0.8 F5000 ;move to position Z .18
G1 Y0 F30000 ;kik the prime tower off .19
[gcode_macro PARK]
gcode:
G1 X162 Y352 F30000 ;move to purge position X/Y .3
G1 Z5 F5000 ;move to purge position Z .4
[gcode_macro G32]
gcode:
SAVE_GCODE_STATE NAME=STATE_G32
G90
G28
QUAD_GANTRY_LEVEL
G28
## Uncomment for for your size printer:
#--------------------------------------------------------------------
## Uncomment for 250mm build
#G0 X125 Y125 Z30 F3600
## Uncomment for 300 build
#G0 X150 Y150 Z30 F3600
## Uncomment for 350mm build
G0 X175 Y175 Z30 F3600
#--------------------------------------------------------------------
RESTORE_GCODE_STATE NAME=STATE_G32
# Use PRINT_START for the slicer starting script - please customise for your slicer of choice
[gcode_macro PRINT_START]
gcode:
g90
#Get Printer built volume dimensions
{% set X_MAX = printer.toolhead.axis_maximum.x|default(100)|float %}
{% set Y_MAX = printer.toolhead.axis_maximum.y|default(100)|float %}
{% set Z_MAX = printer.toolhead.axis_maximum.z|default(100)|float %}
#Get Nozzle diameter and filament width for conditioning
{% set NOZZLE = printer.extruder.nozzle_diameter|default(0.4)|float %}
{% set FILADIA = printer.extruder.filament_diameter|default(1.75)|float %}
#Set Start coordinates of priming lines
{% set X_START = 5.0|default(10.0)|float %}
{% set Y_START = 1.0|default(20.0)|float %}
#Calculate Primer line extrusion volume and filament length
{% set PRIMER_WIDTH = 0.75 * NOZZLE %}
{% set PRIMER_HEIGHT = 0.70 * NOZZLE %}
{% set PRIMER_SECT = PRIMER_WIDTH * PRIMER_HEIGHT %}
{% set PRIMER_VOL = PRIMER_SECT * (X_MAX - 3 * X_START) %}
{% set FILA_SECT = 3.1415 * ( FILADIA / 2.0)**2 %}
{% set FILA_LENGTH = 1.55 * PRIMER_VOL / FILA_SECT %}
#Get Bed and Extruder temperature from Slicer GCode
{% set BED_TEMP = params.BED|default(60)|float %}
{% set EXTRUDER_TEMP = params.EXTRUDER|default(190)|float %}
{% set CHAMBER_TEMP = params.CHAMBER|default(0)|float %}
#Home
STATUS_HOMING
M109 S140
G28 ; home all axes
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
G90 ; absolute positioning
G1 Z20 F3000 ; move nozzle away from bed
#Heat bed
STATUS_HEATING
M117 Heating Bed
M190 S{BED_TEMP}
STATUS_MESHING
M117 Probing Bed
G0 X50 Y25
BED_MESH_CALIBRATE
M109 S140 ;Heat Nozzle
CLEAN_NOZZLE
CALIBRATE_Z
CLEAN_NOZZLE
STATUS_HOMING
G28
#Precondition extruder
M117 Heating Extruder
STATUS_HEATING
PARK
M109 S{EXTRUDER_TEMP} T0
M117 Priming
G1 Z10
PRIMING
CLEAN_NOZZLE
STATUS_BUSY
M117 Printing
# Use PRINT_END for the slicer ending script - please customise for your slicer of choice
[gcode_macro PRINT_END]
# Use PRINT_END for the slicer ending script - please customize for your slicer of choice
gcode:
M400 ; wait for buffer to clear
G92 E0 ; zero the extruder
G1 E-4.0 F3600 ; retract filament
G91 ; relative positioning
# Get Boundaries
{% set max_x = printer.configfile.config["stepper_x"]["position_max"]|float %}
{% set max_y = printer.configfile.config["stepper_y"]["position_max"]|float %}
{% set max_z = printer.configfile.config["stepper_z"]["position_max"]|float %}
# Check end position to determine safe direction to move
{% if printer.toolhead.position.x < (max_x - 20) %}
{% set x_safe = 20.0 %}
{% else %}
{% set x_safe = -20.0 %}
{% endif %}
{% if printer.toolhead.position.y < (max_y - 20) %}
{% set y_safe = 20.0 %}
{% else %}
{% set y_safe = -20.0 %}
{% endif %}
{% if printer.toolhead.position.z < (max_z - 2) %}
{% set z_safe = 2.0 %}
{% else %}
{% set z_safe = max_z - printer.toolhead.position.z %}
{% endif %}
G0 Z{z_safe} F3600 ; move nozzle up
G0 X{x_safe} Y{y_safe} F20000 ; move nozzle to remove stringing
TURN_OFF_HEATERS
M107 ; turn off fan
G90 ; absolute positioning
G0 X300 Y300 F3600 ; park nozzle at rear
M117 Print Finished
# Home, get position, throw around toolhead, home again.
# If MCU stepper positions (first line in GET_POSITION) are greater than a full step different (your number of microsteps), then skipping occured.
# We only measure to a full step to accomodate for endstop variance.
# Example: TEST_SPEED SPEED=300 ACCEL=5000 ITERATIONS=10
[gcode_macro TEST_SPEED]
gcode:
# Speed
{% set speed = params.SPEED|default(printer.configfile.settings.printer.max_velocity)|int %}
# Iterations
{% set iterations = params.ITERATIONS|default(5)|int %}
# Acceleration
{% set accel = params.ACCEL|default(printer.configfile.settings.printer.max_accel)|int %}
# Bounding inset for large pattern (helps prevent slamming the toolhead into the sides after small skips, and helps to account for machines with imperfectly set dimensions)
{% set bound = params.BOUND|default(20)|int %}
# Size for small pattern box
{% set smallpatternsize = SMALLPATTERNSIZE|default(20)|int %}
# Large pattern
# Max positions, inset by BOUND
{% set x_min = printer.toolhead.axis_minimum.x + bound %}
{% set x_max = printer.toolhead.axis_maximum.x - bound %}
{% set y_min = printer.toolhead.axis_minimum.y + bound %}
{% set y_max = printer.toolhead.axis_maximum.y - bound %}
# Small pattern at center
# Find X/Y center point
{% set x_center = (printer.toolhead.axis_minimum.x|float + printer.toolhead.axis_maximum.x|float ) / 2 %}
{% set y_center = (printer.toolhead.axis_minimum.y|float + printer.toolhead.axis_maximum.y|float ) / 2 %}
# Set small pattern box around center point
{% set x_center_min = x_center - (smallpatternsize/2) %}
{% set x_center_max = x_center + (smallpatternsize/2) %}
{% set y_center_min = y_center - (smallpatternsize/2) %}
{% set y_center_max = y_center + (smallpatternsize/2) %}
# Save current gcode state (absolute/relative, etc)
SAVE_GCODE_STATE NAME=TEST_SPEED
# Output parameters to g-code terminal
{ action_respond_info("TEST_SPEED: starting %d iterations at speed %d, accel %d" % (iterations, speed, accel)) }
# Home and get position for comparison later:
G28
# QGL if not already QGLd (only if QGL section exists in config)
{% if printer.configfile.settings.quad_gantry_level %}
{% if printer.quad_gantry_level.applied == False %}
QUAD_GANTRY_LEVEL
G28 Z
{% endif %}
{% endif %}
# Move 50mm away from max position and home again (to help with hall effect endstop accuracy - https://github.com/AndrewEllis93/Print-Tuning-Guide/issues/24)
#G90
#G1 X{printer.toolhead.axis_maximum.x-50} Y{printer.toolhead.axis_maximum.y-50} F{30*60}
#G28 X Y
#G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Go to starting position
G0 X{x_min} Y{y_min} Z{bound + 5} F{speed*60}
# Set new limits
SET_VELOCITY_LIMIT VELOCITY={speed} ACCEL={accel} ACCEL_TO_DECEL={accel / 2}
{% for i in range(iterations) %}
# Large pattern
# Diagonals
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Box
G0 X{x_min} Y{y_min} F{speed*60}
G0 X{x_min} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_max} F{speed*60}
G0 X{x_max} Y{y_min} F{speed*60}
# Small pattern
# Small diagonals
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
# Small box
G0 X{x_center_min} Y{y_center_min} F{speed*60}
G0 X{x_center_min} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_max} F{speed*60}
G0 X{x_center_max} Y{y_center_min} F{speed*60}
{% endfor %}
# Restore max speed/accel/accel_to_decel to their configured values
SET_VELOCITY_LIMIT VELOCITY={printer.configfile.settings.printer.max_velocity} ACCEL={printer.configfile.settings.printer.max_accel} ACCEL_TO_DECEL={printer.configfile.settings.printer.max_accel_to_decel}
# Re-home and get position again for comparison:
G28 X Y
# Go to XY home positions (in case your homing override leaves it elsewhere)
G90
G0 X{printer.toolhead.axis_maximum.x-1} Y{printer.toolhead.axis_maximum.y-1} F{30*60}
G4 P1000
GET_POSITION
# Restore previous gcode state (absolute/relative, etc)
RESTORE_GCODE_STATE NAME=TEST_SPEED