-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmacros.cfg
More file actions
433 lines (365 loc) · 16.7 KB
/
Copy pathmacros.cfg
File metadata and controls
433 lines (365 loc) · 16.7 KB
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
########################################
############# Start Print ##############
########################################
[gcode_macro START_PRINT]
gcode:
WLED_ON ; Turn On Light
{% set BED_TEMP=params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP=params.EXTRUDER_TEMP|default(150)|float %}
{% set CHAMBER_TEMP=params.CHAMBER_TEMP|default(30)|int %}
CALIBRATE_Z ; (Calibrate ZOffset) Includes g28
led_heating
M104 S150 ; (Hotend idle temp)
M140 S60 ; (Bed idle temp)
HEAT_SOAK
G90 ; (Absolute Coordinates)
M190 S{BED_TEMP} ; (Bed print temp)
led_mesh
BED_MESH_CALIBRATE ; Run KAMP
led_heating
M109 S{EXTRUDER_TEMP} ; (Hotend print temp)
#CALCULATE_PA ; Set Pressure Advance ; Defined in Cura
CLEAN_NOZZLE ; Wipe Nozzle
led_printing
ZEROG_PURGE ; purge nozzle
########################################
############## End Print ###############
########################################
[gcode_macro END_PRINT]
gcode:
G91
led_finish
# Retract and wipe out Z
G1 E-1 Z0.1 F1500
G1 X5 Y5 F3000
CLEAN_NOZZLE
# Present print
G1 Z10 F1500
G90
G1 X330 Y330
led_standby
# Shut things down
M107 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M106 S0 ;Turn-off bed blowers
M84 X Y E ;Disable motors
[gcode_macro PRINT_END]
description: END_PRINT Alias
gcode:
RESPOND TYPE=command MSG='END_PRINT Called'
END_PRINT #RUN END PRINT Macro
[gcode_macro PRINT_START]
description: END_PRINT Alias
gcode:
RESPOND TYPE=command MSG='START_PRINT Called'
START_PRINT #RUN START PRINT Macro
[gcode_macro PRIME_LINE]
gcode:
# Move Z up a little to prevent scratching the surface
#G1 Z1.0 F3000
# Move to prime line position
G1 X0.1 Y40 F5000.0
# Move Z down to begin prime line
G1 z0.2 F5000.0
# Reset Extruder
M83
G92 E0
# Draw prime lines
G1 X0.1 Y250.0 Z0.3 F1500.0 E15
G1 X0.4 Y250.0 Z0.3 F5000.0
G1 X0.4 Y40 Z0.3 F1500.0 E25
# Reset Extruder
G92 E0
######################################
[gcode_macro LOAD_FILAMENT]
description: Load 120mm of Filament
gcode:
M83 # Put the extruder into relative mode
G92 E0.0 # Reset the extruder so that it thinks it is at position zero
G1 E120 F350 # Move the extruder forward 120mm at a speed of 350mm/minute
G92 E0.0 # Reset the extruder again
M82 # Put the extruder back into absolute mode.
[gcode_macro UNLOAD_FILAMENT]
description: Unload 120mm of Filament
gcode:
M83 # Put the extruder into relative mode
G92 E0.0 # Reset the extruder so that it thinks it is at position zero
G1 E-120 F350 # Move the extruder forward 120mm at a speed of 350mm/minute
G92 E0.0 # Reset the extruder again
M82 # Put the extruder back into absolute mode.
[gcode_macro CLEAN_NOZZLE]
description: Simple Y-axis back and forth nozzle wipe for coreXY performed wipe_count/2 times. Two PARAMETERS are both optional. The LAYER parameter provides the current layer info from your slicer's Layer Change G-code and CLEAN_LAYERS provides the iteration control for how frequently the nozzle procedure is actually performed. Defaults to 1, i.e., every layer. E.g. , CLEAN_NOZZLE LAYER={[layer_num] CLEAN_LAYERS=3 will clean the nozzle every third layer. Omitting the parameters forces the clean to be performed. While wipe_count could be changed to a parameter, once you determine how many wipes are sufficient it's simpler to set its value within the macro and fuhgetaboutit.
gcode:
{% set layer = params.LAYER|default(0)|int %}; active layer number
{% set clean_layers = params.CLEAN_LAYERS|default(1)|int %}; perform clean procedure every X layer
{% if layer%clean_layers == 0 %} #the percent sign performs a modulo math operation, i.e., it calcs the remainder of a division operation
SAVE_GCODE_STATE NAME=clean_nozzle_state
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=input_shaping VALUE=True
{% set wipe_count = 8|int %} # each count is a wipe in one-direction
{% set x_dir = 0|int %}
{% if printer.toolhead.position.x > (printer.toolhead.axis_maximum.x - 10) %}: # check for potential nozzle movement interference with bed's edge retaining clips
{% set y_dir = -1 %}
{% elif printer.toolhead.position.y < (printer.toolhead.axis_minimum.y + 10) %}
{% set x_dir = 1 %}
{% endif %}
G91
G0 Z5 F1500 # avoid potential nozzle drag across existing print
G90
G0 X-10 F1500 # move nozzle away from edge clips
{% for wipe in range(wipe_count) %} # simple X-axis back-and-forth wipe
G0 Y{40 - (10 * (loop.index is even))} F7500
{% endfor %}
RESTORE_GCODE_STATE NAME=clean_nozzle_state MOVE=1 MOVE_SPEED=150
SET_GCODE_VARIABLE MACRO=_KNOMI_STATUS VARIABLE=input_shaping VALUE=False
{% endif %}
###############################################################################################################
###Puase Resume Cancel ########################################################################################
###https://ellis3dp.com/Print-Tuning-Guide/articles/useful_macros/pause_resume_filament.html#pause--resume ####
###############################################################################################################
[gcode_macro PAUSE]
rename_existing: BASE_PAUSE
gcode:
# Parameters
{% set z = params.Z|default(10)|int %} ; z hop amount
{% if printer['pause_resume'].is_paused|int == 0 %}
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE={z} ; set z hop variable for reference in resume macro
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=etemp VALUE={printer['extruder'].target} ; set hotend temp variable for reference in resume macro
SET_filament_SENSOR SENSOR=switch_sensor ENABLE=0 ; disable filament sensor
SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 ; disable filament monitor
SAVE_GCODE_STATE NAME=PAUSE ; save current print position for resume
BASE_PAUSE ; pause print
{% if (printer.gcode_move.position.z + z) < printer.toolhead.axis_maximum.z %} ; check that zhop doesn't exceed z max
G91 ; relative positioning
G1 Z{z} F900 ; raise Z up by z hop amount
{% else %}
{ action_respond_info("Pause zhop exceeds maximum Z height.") } ; if z max is exceeded, show message and set zhop value for resume to 0
SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=zhop VALUE=0
{% endif %}
G90 ; absolute positioning
G1 X{printer.toolhead.axis_maximum.x/2} Y{printer.toolhead.axis_minimum.y+25} F6000 ; park toolhead at front center
SAVE_GCODE_STATE NAME=PAUSEPARK ; save parked position in case toolhead is moved during the pause (otherwise the return zhop can error)
M104 S0 ; turn off hotend
SET_IDLE_TIMEOUT TIMEOUT=43200 ; set timeout to 12 hours
{% endif %}
[gcode_macro RESUME]
rename_existing: BASE_RESUME
variable_zhop: 0
variable_etemp: 0
gcode:
# Parameters
{% set e = params.E|default(2.5)|int %} ; hotend prime amount (in mm)
{% if printer['pause_resume'].is_paused|int == 1 %}
SET_FILAMENT_SENSOR SENSOR=switch_sensor ENABLE=1
SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1 ; enable filament sensor
#INITIAL_RGB ; reset LCD color
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
{% if etemp > 0 %}
M109 S{etemp|int} ; wait for hotend to heat back up
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSEPARK MOVE=1 MOVE_SPEED=100 ; go back to parked position in case toolhead was moved during pause (otherwise the return zhop can error)
G91 ; relative positioning
M83 ; relative extruder positioning
{% if printer[printer.toolhead.extruder].temperature >= printer.configfile.settings.extruder.min_extrude_temp %}
G1 Z{zhop * -1} E{e} F900 ; prime nozzle by E, lower Z back down
{% else %}
G1 Z{zhop * -1} F900 ; lower Z back down without priming (just in case we are testing the macro with cold hotend)
{% endif %}
RESTORE_GCODE_STATE NAME=PAUSE MOVE=1 MOVE_SPEED=60 ; restore position
BASE_RESUME ; resume print
led_printing
{% endif %}
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
led_fail
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
CLEAR_PAUSE
#SDCARD_RESET_FILE
END_PRINT
BASE_CANCEL_PRINT
[gcode_macro START_DRYER]
description: Start the heated bed filament dryer.
gcode:
{% set ChamberTemperature = params.CHAMBER | default(25.0) | float %}
{% set BedTemperature = params.TEMPERATURE | default(50.0) | float %}
{% set DryTime = params.TIME | default(14400) | int %}
; turn the heaters on, however you do that.
M140 S{BedTemperature} ; Sets the print bed temperature without waiting.
# M141 S{ChamberTemperature} ; [OPTIONAL] Sets the enclosure temperature.
; then finally,
SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE={DryTime}
SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=bed_temperature VALUE={BedTemperature}
# SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=chamber_temperature VALUE={ChamberTemperature}
UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=1
[gcode_macro STOP_DRYER]
gcode:
; Turn off heaters etc. here
M140 S0 ; Disable bed heater
# M141 S0 ; [OPTIONAL] Disable enclosure heater/fan
SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE=0
UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=0 ; Stop the timer.
M117 Drying Stopped
[gcode_macro DRYER_STATUS]
variable_time_remaining: 0
variable_bed_temperature: 0
variable_chamber_temperature: 0
gcode:
{% if time_remaining > 0 %}
M140 S{bed_temperature} ; Reset bed temperature (prevents timeout)
SET_GCODE_VARIABLE MACRO=DRYER_STATUS VARIABLE=time_remaining VALUE={time_remaining - 1}
M117 Drying {time_remaining}
{% else %}
STOP_DRYER
{% endif %}
[delayed_gcode DRYER_TIMER]
gcode:
UPDATE_DELAYED_GCODE ID=DRYER_TIMER DURATION=1
DRYER_STATUS
[gcode_macro DRY_PLA]
gcode:
START_DRYER TEMPERATURE=50 CHAMBER=25 TIME=14400
[gcode_macro DRY_PETG]
gcode:
START_DRYER TEMPERATURE=55 CHAMBER=30 TIME=18000
[gcode_macro DRY_ABS]
gcode:
START_DRYER TEMPERATURE=65 CHAMBER=40 TIME=14400
## UNSAFE_MOVE_TOOL
## Move the toolhead without homing
########## Parameters ##########
## X: The X distance to move by (default: 0) mm
## Y: The Y distance to move by (default: 0) mm
## Z: The Z distance to move by (default: 0) mm
## F: The feedrate to use (default: 10) mm/s
[gcode_macro UNSAFE_MOVE_TOOL]
description: Move the toolhead without homing
gcode:
{% set z = params.Z|default(0)|float %}
{% set x = params.X|default(0)|float %}
{% set y = params.Y|default(0)|float %}
{% set f = params.E|default(10)|float %}
G90
SET_KINEMATIC_POSITION Z={(printer.toolhead.axis_maximum.z/2)} X={(printer.toolhead.axis_maximum.x/2)} Y={(printer.toolhead.axis_maximum.y/2)}
G0 X{(printer.toolhead.axis_maximum.x/2)+x} Y{(printer.toolhead.axis_maximum.y/2)+y} Z{(printer.toolhead.axis_maximum.z/2)+z} F{ (f*60) }
M84
[gcode_macro BED_BLOWER]
gcode:
# Use a default fan speed to off - expecting an INT as input
{% set S = (params.S)|default(0)|float %}
{% if S > 0 %}
{% set S = (S/100) %}
{% endif %}
SET_FAN_SPEED FAN=Bed_Blower SPEED={S}
[gcode_macro M106]
rename_existing: M106.1
gcode:
M106.1 { rawparams }
{% set bed_blower_speed = params.S|float * 100/255 %}
SET_FAN_SPEED FAN=Bed_Blower SPEED={ bed_blower_speed/100 }
# BOWDEN_LENGTH in centimeters
# LAYER_HEIGHT and NOZZLE_SIZE in millimeters
# PRINT_SPEED in millimeters per secound
[gcode_macro CALCULATE_PA]
gcode:
{% set material = params.material_type|default("PLA") %}
{% set bowden_length = (params.BOWDEN_LENGTH|default(2.6)|float) / 10 %}
{% set layer_height = params.LAYER_HEIGHT|default(0.2)|float %}
{% set nozzle_size = params.NOZZLE_SIZE|default(0.4)|float %}
{% set print_speed = params.PRINT_SPEED|default(80)|float %}
{% set material_constant = {'PLA': 100, 'PLA+': 100, 'PET': 120, 'PETG': 120, 'ABS': 110, 'ABS+':110, 'ASA': 110, 'Nylon': 130, 'TPU': 150, 'PVB': 100, 'PBT': 100}[material] %}
{% set vfr = nozzle_size * layer_height * print_speed %}
{% set pressure_advance = (vfr * bowden_length) / material_constant %}
SET_PRESSURE_ADVANCE ADVANCE={pressure_advance}
SET_PRESSURE_ADVANCE SMOOTH_TIME=0.025
[gcode_macro LOAD_SPOOL]
gcode:
{% if params.ID %}
{% set id = params.ID|int %}
{action_call_remote_method(
"spoolman_set_active_spool",
spool_id=id
)}
{% else %}
{action_respond_info("Parameter 'ID' is required")}
{% endif %}
[gcode_macro UNLOAD_SPOOL]
gcode:
{action_call_remote_method(
"spoolman_set_active_spool",
spool_id=None
)}
[gcode_macro SPEED_TEST_MOVES]
gcode:
{% set offset = 25 %}
{% if params.OFFSET is defined %}
{% set offset = params.OFFSET|int %}
{% if offset < 5 %}
{% set offset = 5 %}
{% endif %}
{% endif %}
{% set speed = 1200 %}
{% set acc = 500 %}
{% if params.SPEED is defined %}
{% set speed = params.SPEED|int * 60 %}
{% endif %}
{% if params.ACC is defined %}
{% set acc = params.ACC|int %}
{% endif %}
{% set iters = 1 %}
{% if params.MOVES is defined %}
{% set iters = params.MOVES|int %}
{% endif %}
{% set x = 1 %}
{% if params.X is defined %}
{% set x = params.X|int %}
{% if x < 0 %}
{% set x = 0 %}
{% endif %}
{% if x > 1 %}
{% set x = 1 %}
{% endif %}
{% endif %}
{% set y = 1 %}
{% if params.Y is defined %}
{% set y = params.X|int %}
{% if y < 0 %}
{% set y = 0 %}
{% endif %}
{% if y > 1 %}
{% set y = 1 %}
{% endif %}
{% endif %}
{% set z = 0 %}
{% if params.Z is defined %}
{% set z = params.Z|int %}
{% if z < 0 %}
{% set z = 0 %}
{% endif %}
{% if z > 1 %}
{% set z = 1 %}
{% endif %}
{% endif %}
RESPOND PREFIX="info" MSG="Testing {iterS} moves with {speed/60|float} speed and {acc} acceleration on axis x={x} y={y} y={y} with offset {offset}"
M204 S{acc}
G0 F{speed}
{% set tool = printer.toolhead %}
{% set axisMax = {'x':printer.configfile.settings.stepper_x.position_max|int-offset, 'y':printer.configfile.settings.stepper_y.position_max|int-offset, 'z':printer.configfile.settings.stepper_z.position_max|int-offset } %}
{% set axisMin = {'x':printer.configfile.settings.stepper_x.position_min|int+offset, 'y':printer.configfile.settings.stepper_y.position_min|int+offset, 'z':printer.configfile.settings.stepper_z.position_min|int+offset } %}
{% for f in range(0,iters) %}
{% set moveto = "" %}
{% if x == 1 %}
{% set px = range(axisMin.x, axisMax.x)|random %}
{% set moveto = moveto ~ " X" ~ px %}
{% endif %}
{% if y == 1 %}
{% set py = range(axisMin.y, axisMax.y)|random %}
{% set moveto = moveto ~ " Y" ~ py %}
{% endif %}
{% if z == 1 %}
{% set pz = range(axisMin.z, axisMax.z)|random %}
{% set moveto = moveto ~ " Z" ~ pz %}
{% endif %}
RESPOND PREFIX="info" MSG="Test: {moveto}"
G0 {moveto}
{% endfor %}