-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmacros.cfg
286 lines (245 loc) · 13 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
########################################
############# Start Print ##############
########################################
[gcode_macro START_PRINT]
gcode:
SET_LED LED="my_neopixel" RED=1 GREEN=1 BLUE=1 SYNC=0 TRANSMIT=1 ; Turn On Light
{% set BED_TEMP=params.BED_TEMP|default(60)|float %}
{% set EXTRUDER_TEMP=params.EXTRUDER_TEMP|default(245)|float %}
M104 S180 ; (Hotend idle temp)
M140 S40 ; (Bed idle temp)
G90 ; (Absolute Coordinates)
G28 ; (Home All Axis)
M190 S{BED_TEMP} ; (Bed print temp)
BED_MESH_CALIBRATE ; Run KAMP
M109 S{EXTRUDER_TEMP} ; (Hotend print temp)
CALCULATE_PA BOWDEN_LENGTH=12 ; Set Pressure Advance
#CLEAN_NOZZLE ; Wipe Nozzle
LINE_PURGE ; purge nozzle
########################################
############## End Print ###############
########################################
[gcode_macro END_PRINT]
gcode:
G91
# Retract and wipe out Z
G1 E-.75 Z0.2 F2700
G1 X5 Y5 F3000
# Present print
G1 Z50 F1500
G90
G1 X185 Y370
# Shut things down
M107 S0 ;Turn-off fan
M104 S0 ;Turn-off hotend
M140 S0 ;Turn-off bed
M84 X Y E ;Disable motors
SET_LED LED="my_neopixel" RED=0 GREEN=0 BLUE=0 SYNC=0 TRANSMIT=1 ;turn off light
[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 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 # avoid potential nozzle drag across existing print
G90
G0 X-5 # move nozzle away from edge clips
{% for wipe in range(wipe_count) %} # simple X-axis back-and-forth wipe
G0 Y{20 - (10 * (loop.index is even))} F7500
{% endfor %}
RESTORE_GCODE_STATE NAME=clean_nozzle_state MOVE=1 MOVE_SPEED=150
{% 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_runout SENSOR=filament_runout ENABLE=0 ; disable filament sensor
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
{% endif %}
[gcode_macro CANCEL_PRINT]
rename_existing: BASE_CANCEL_PRINT
gcode:
SET_IDLE_TIMEOUT TIMEOUT={printer.configfile.settings.idle_timeout.timeout} ; set timeout back to configured value
CLEAR_PAUSE
#SDCARD_RESET_FILE
PRINT_END
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.F|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
# 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(10)|float) / 10 %}
{% set layer_height = params.LAYER_HEIGHT|default(0.2)|float %}
{% set nozzle_size = params.NOZZLE_SIZE|default(0.6)|float %}
{% set print_speed = params.PRINT_SPEED|default(180)|float %}
{% set material_constant = {'PLA': 100, 'PET': 120, 'PETG': 120, 'ABS': 110, 'ASA': 110, 'Nylon': 130, 'TPU': 150, 'PVB': 100}[material] %}
{% set vfr = nozzle_size * layer_height * print_speed %}
{% set pressure_advance = (vfr * bowden_length) / material_constant %}
SET_PRESSURE_ADVANCE ADVANCE={pressure_advance}