-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathz_filament_switch_unload.cfg
220 lines (181 loc) · 6.77 KB
/
z_filament_switch_unload.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
# 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_load]
pin: PA11 # PIN switch to load filament
release_gcode:
{% if (printer.print_stats.state != "printing")%}
filament_load
{% else %}
M117 Printing, can't load now!
M118 Printing, can't load now!
{% endif %}
press_gcode: # do not add macro here
[gcode_button fil_unload]
pin: PA10 # PIN switch to unload filament
release_gcode:
{% if (printer.print_stats.state != "printing")%}
filament_unload
{% else %}
M117 Printing, can't unload now!
M118 Printing, can't unload now!
{% endif %}
press_gcode: # do not add macro here
########################################
# Filament runnout sensor with a switch
########################################
[gcode_button fil_runnout]
pin: PA9 ######## PIN FILAMENT SENSOR SWITCH ########
press_gcode: # FILAMENT NOT DETECTED
{% if (printer.print_stats.state == "printing") %}
filament_change_state1
{% endif %}
UPDATE_DELAYED_GCODE ID=clear_loadbusy DURATION=2
UPDATE_DELAYED_GCODE ID=clear_unloadbusy DURATION=2
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=filamentpresent VALUE=0
release_gcode: # Macro when reload filament, switch pressed after runnout
{% if (printer.print_stats.state != "printing") %}
filament_load
{% else %}
M117 Printing! Can't load filament right now!
M118 Printing! Can't load filament right now!
UPDATE_DELAYED_GCODE ID=clear_display DURATION=10
{% endif %}
SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=filamentpresent VALUE=1
UPDATE_DELAYED_GCODE ID=clear_changebusy DURATION=2
# 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 S240 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' %}
M104 S235 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 S240 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 %}
[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 S240 T0 ###### set temperature to 240 #####
{% endif %}
G0 E-5 F3600 # move 5mm of filament to a cold zone
G4 P2000 # wait 2s
G0 E4.5 F3600 # extrude a bit
G0 E-5 F3600 # 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!