forked from Travis90x/Klipper-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathz_filament_switch_loop_unload.cfg.cfg
256 lines (212 loc) · 8 KB
/
z_filament_switch_loop_unload.cfg.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
# Use a switch as filament runnout sensor
# Use a swithc for manual unload filament
# Need [virtual_sdcard] and PAUSE macro in mainsail.cfg
[respond]
default_type: echo
[delayed_gcode clear_display]
gcode:
M117 # clear display message
# needed for manual filament load/unload
[force_move]
enable_force_move: True
##################################################
# Macro Manual Load/Unload Filament with a switch
##################################################
[gcode_button fil_unload] # VERDE
pin: !PE6 # PIN switch to unload filament - PULSANTE VERDE
# release_gcode:
press_gcode: # do not add macro here
M117 PULSANTE VERDE PREMUTO
M118 PULSANTE VERDE PREMUTO
UPDATE_DELAYED_GCODE ID=LOOP_FIL_UNLOAD DURATION=2
[delayed_gcode LOOP_FIL_UNLOAD]
initial_duration: 0 # Set 0 to interrupt the timeout ?
gcode:
M117 Loop partito
M118 Loop partito
# {% if pin_status.PA15 %} ### ROMPE LE PALLE
{% if (printer.print_stats.state != "printing")%}
M118 Not Printing!
M117 Not Printing!
M83 # Estrusore relativo
G92 E0 # Reset Extruder
# CHECK or SET minimum extrusion temperature
{% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target == 0)%}
M118 Hotend heating!
M109 S240 T0 ###### set temperature to 240 #####
{% endif %}
#G0 E-5 F500 # move 5mm of filament to a cold zone
# G4 P2000 # wait 2s
# G0 E4.5 F500 # extrude a bit
#G0 E-5 F500 # retract again
G0 E-10 F300 # RETRACT 10mm
# M104 S0 T0 # Cooldown
M400 # WAIT MOVEMENTS
M118 Filament unloading!
M117 Filament unloading!
{% else %} # IF PRINTING
M118 Printing!
M117 Printing!
UPDATE_DELAYED_GCODE ID=LOOP_FIL_UNLOAD DURATION=0 #
{% endif %}
# {% else %}
M117 Filament unloaded!
M118 Filament unloaded!
UPDATE_DELAYED_GCODE ID=LOOP_FIL_UNLOAD DURATION=2 # ripeti tra 2 secondi
# {% endif %}
[gcode_button fil_load]
pin: PA2 # PIN switch to load filament - BOTTONE ROSSO
# release_gcode:
press_gcode: # do not add macro here
{% if (printer.print_stats.state != "printing")%}
# CHECK or SET minimum extrusion temperature
{% if printer.extruder.can_extrude|lower != 'true' %}
M118 Hotend heating!
M104 S100 T0 # set temp and wait.
{% endif %}
#M300 # Your BEEPER macro
M117 Filament loading!
M118 Filament loading!
M82 # extruder absolute movement
G92 E0 # extruder start from 0
# G4 P2000 # wait in ms
#FORCE_MOVE STEPPER=extruder DISTANCE=15 VELOCITY=5 ACCEL=1000
G1 E10 F300 # extrude 150mm
# M400
M117 Filament loaded!
M118 Filament loaded!
{% else %}
M117 Printing, can't load now!
M118 Printing, can't load now!
{% endif %}
########################################
# Filament runnout sensor with a switch
########################################
# PAUSE and ALERT
[gcode_macro filament_change_state1]
variable_changebusy: 0
gcode:
{% if changebusy == 0 %}
PAUSE
SET_GCODE_VARIABLE MACRO=filament_change_state1 VARIABLE=changebusy VALUE=1
M118 Filament runnout!
M117 Filament runnout!
filament_change_state2 # comment this to avoid automatically unload filament when runnout detected.
{% else %}
{% endif %}
[delayed_gcode clear_changebusy]
gcode:
SET_GCODE_VARIABLE MACRO=filament_change_state1 VARIABLE=changebusy VALUE=0
# M118 Clear Load busy!
# BEEP, ALERT, HEAT and UNLOAD FILAMENT
[gcode_macro filament_change_state2]
gcode:
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1
#M300 # Your BEEPER macro
M118 Unloading filament...
M117 Unloading filament...
M83
G92 E0
# {% if printer[printer.toolhead.extruder].temperature < 240 %}
# CHECK or SET minimum extrusion temperature
{% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target == 0) %}
M118 Hotend heating!
M109 S100 T0 ###### set temperature to 240 #####
{% endif %}
G0 E-5 F3600 #extract filament to cold end
G4 P2000 # wait for two seconds
G0 E4.5 F3600 # push the filament back
G0 E-5 F3600 #extract filament to cold end
G0 E-60 F300 # continue extraction slow allow filament to be cooled enough before reaches the gears
M400
M117 Load new filament, then resume.
M118 Load new filament, then resume.
#SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=0
UPDATE_DELAYED_GCODE ID=clear_loadbusy DURATION=2.5 # wait to remove filament before reload
########################################
# Filament load
########################################
[gcode_macro filament_load]
variable_loadbusy: 0
gcode:
{% if loadbusy == 0 %}
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=1
# CHECK or SET minimum extrusion temperature
{% if printer.extruder.can_extrude|lower != 'true' %}
M118 Hotend heating!
M104 S100 T0 # set temp and wait.
{% endif %}
#M300 # Your BEEPER macro
M117 Filament loading!
M118 Filament loading!
M82 # extruder absolute movement
G92 E0 # extruder start from 0
G4 P2000 # wait in ms
FORCE_MOVE STEPPER=extruder DISTANCE=15 VELOCITY=5 ACCEL=1000
# CHECK or SET minimum extrusion temperature
{% if printer.extruder.can_extrude|lower != 'true' %}
M118 Hotend heating!
M109 S100 T0 ###### set temperature to 240 #####
{% endif %}
G1 E150 F300 # extrude 150mm
M400
{% if (printer.print_stats.state != "printing") and (printer.print_stats.state != "paused")%}
M104 S0 T0 # Cooldown if not printing or paused
{% endif %}
M117 Filament loaded!
M118 Filament loaded!
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
UPDATE_DELAYED_GCODE ID=clear_unloadbusy DURATION=2
{% else %}
M118 Filament already loaded!
{% endif %}
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=filamentpresent VALUE=1
UPDATE_DELAYED_GCODE ID=clear_changebusy DURATION=2
[delayed_gcode set_loadbusy]
gcode:
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1
#M118 Set Load busy!
[delayed_gcode clear_loadbusy]
gcode:
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=0
#M118 Clear Load busy!
########################################
# Filament unload
########################################
[gcode_macro filament_unload]
variable_unloadbusy: 0
variable_filamentpresent: 0
gcode:
#{% if unloadbusy == 0 and filamentpresent == 1 %}
{% if unloadbusy == 0 %}
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=1
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1
#M300 # Your BEEPER macro
M118 Filament unloading!
M117 Filament unloading!
M83
G92 E0
# CHECK or SET minimum extrusion temperature
{% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target == 0)%}
M118 Hotend heating!
M109 S100 T0 ###### set temperature to 240 #####
{% endif %}
G0 E-5 F500 # move 5mm of filament to a cold zone
G4 P2000 # wait 2s
G0 E4.5 F500 # extrude a bit
G0 E-5 F500 # retract again
G0 E-60 F300 # retract slowly to cool
M104 S0 T0 # Cooldown
M400
M118 Filament unloaded!
M117 Filament unloaded!
SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=0
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
{% else %}
M118 Already unloaded!
{% endif %}
[delayed_gcode clear_unloadbusy]
gcode:
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=0
#M118 Clear Unload busy!