-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfilament_loading.cfg
190 lines (165 loc) · 6.1 KB
/
filament_loading.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
##### filament loading Variables #####
[gcode_macro FILAMENT_VARS]
variable_extruder_temp: 235
variable_ending_length: -25
variable_purge_length: 100
variable_prepurge_length: 120
variable_purge_retries: 5
variable_current_purge_retries: 0
variable_purge_flow_rate: 20
variable_filament_load_length: 5
gcode:
##### filament sensors #####
[filament_switch_sensor post]
switch_pin: ^EBB:PB9
pause_on_runout: False
[filament_switch_sensor pre]
switch_pin: ^EBB:PB8
pause_on_runout: False
insert_gcode:
{% set OriginalState = printer.print_stats.state %}
{% if not (OriginalState == "paused" or OriginalState == "printing") %}
RESPOND MSG="Filament inserted"
_PRELOAD_FILAMENT_START
{% endif %}
runout_gcode:
{% set CURRENT_ACCEL = printer.toolhead.max_accel %}
{% set CURRENT_TEMP = printer['extruder'].target %}
{% set OriginalState = printer.print_stats.state %}
{% if OriginalState == "printing" and printer['filament_switch_sensor post'].filament_detected and not printer['filament_switch_sensor pre'].filament_detected %}
PAUSE
RESPOND TYPE=error msg="FILAMENT RUNOUT !!"
_FS_DISABLE
_UNLOAD_FILAMENT_START
_FS_ENABLE
{% endif %}
[gcode_macro SET_TEMP]
gcode:
{% set HEATER = params.HEATER|default("")|string %}
{% set TEMP = params.TEMP|default(0)|int %}
{% set WAIT = params.WAIT|default(0)|int %}
{% if HEATER == "extruder" %}
{% if WAIT == 1 %}
M109 S{TEMP}
{% else %}
M104 S{TEMP}
{% endif %}
{% else %}
{% if WAIT == 1 %}
M190 S{TEMP}
{% else %}
M140 S{TEMP}
{% endif %}
{% endif %}
[gcode_macro _LOW_TEMP_CHECK]
description: Check the nozzle is at temperature and heat it if needed
gcode:
{% set T = params.T|default(printer["gcode_macro FILAMENT_VARS"].extruder_temp)|float %}
{% if printer.extruder.target != 0 %}
{% if printer.extruder.temperature < printer.extruder.target %}
SET_TEMP HEATER="extruder" TEMP={printer.extruder.target|float} WAIT=1
{% endif %}
{% else %}
{% if printer.extruder.target < T %}
SET_TEMP HEATER="extruder" TEMP={T} WAIT=1
{% endif %}
{% endif %}
##### Loading Filament Macros #####
[gcode_macro _PRELOAD_FILAMENT_START]
variable_loaded: False
gcode:
SAVE_GCODE_STATE NAME=LOAD_FILAMENT_state
M83 #Relative extrusions
{% for step in range(10) %}
_PRELOAD_FILAMENT_MOVE_TO_POST_SENSOR
{% endfor %}
_LOW_TEMP_CHECK
_PRELOAD_FILAMENT_PURGE
[gcode_macro _PRELOAD_FILAMENT_MOVE_TO_POST_SENSOR]
gcode:
{% set FLL = printer["gcode_macro FILAMENT_VARS"].filament_load_length %}
{% if not printer['filament_switch_sensor post'].filament_detected %}
G1 E{FLL} F1200
{% endif %}
[gcode_macro _PRELOAD_FILAMENT_PURGE]
gcode:
{% set PURGE = printer["gcode_macro FILAMENT_VARS"].purge_length%}
{% set MAX_RETRIES = printer["gcode_macro FILAMENT_VARS"].purge_retries%}
{% set FLOW = printer["gcode_macro FILAMENT_VARS"].purge_flow_rate%}
{% set CURRENT = printer["gcode_macro FILAMENT_VARS"].current_purge_retries %}
{% set FSPEED = (60*FLOW)/2.405 %}
M83 #Relative extrusions
{% if CURRENT < MAX_RETRIES %}
M400 # Wait for buffer to clear
G1 E{PURGE} F{FSPEED}
_PRELOAD_FILAMENT_PROMPT_START
{% else %}
_PRELOAD_FILAMENT_PROMPT_ERROR
{% endif %}
[gcode_macro _PRELOAD_FILAMENT_PROMPT_START]
gcode:
{% set RETRIES = printer["gcode_macro FILAMENT_VARS"].current_purge_retries %}
SET_GCODE_VARIABLE MACRO=FILAMENT_VARS VARIABLE=current_purge_retries VALUE={ RETRIES + 1 }
RESPOND TYPE=command MSG="action:prompt_begin Question"
RESPOND TYPE=command MSG="action:prompt_text Is the filament loaded and extruding correctly?"
RESPOND TYPE=command MSG="action:prompt_button Yes|_PRELOAD_FILAMENT_END"
RESPOND TYPE=command MSG="action:prompt_button No|_PRELOAD_FILAMENT_PURGE"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _PRELOAD_FILAMENT_PROMPT_ERROR]
gcode:
RESPOND TYPE=command MSG="action:prompt_begin Error:"
RESPOND TYPE=command MSG="action:prompt_text Maximum number of retries, Check toolhead"
RESPOND TYPE=command MSG="action:prompt_button Ok|_PRELOAD_FILAMENT_PROMPT_END"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro _PRELOAD_FILAMENT_PROMPT_END]
gcode:
RESPOND TYPE=command MSG="action:prompt_end"
SET_GCODE_VARIABLE MACRO=FILAMENT_VARS VARIABLE=current_purge_retries VALUE=0
RESTORE_GCODE_STATE NAME=LOAD_FILAMENT_state
[gcode_macro _PRELOAD_FILAMENT_END]
gcode:
{% set RETRACT = printer["gcode_macro FILAMENT_VARS"].ending_length|default(0)%}
G1 E{RETRACT} F1800
_PRELOAD_FILAMENT_PROMPT_END
##### Unloading Filament Macros #####
[gcode_macro _UNLOAD_FILAMENT_START]
variable_loaded: False
gcode:
_LOW_TEMP_CHECK
_UNLOAD_FILAMENT_PROMPT_START
[gcode_macro _UNLOAD_FILAMENT_PROMPT_START]
gcode:
{% set RETRIES = printer["gcode_macro FILAMENT_VARS"].current_purge_retries %}
RESPOND TYPE=command MSG="action:prompt_begin Notice:"
RESPOND TYPE=command MSG="action:prompt_text Filament runout triggered, press ok to unload filament."
RESPOND TYPE=command MSG="action:prompt_button Ok|UNLOAD_FILAMENT"
RESPOND TYPE=command MSG="action:prompt_show"
[gcode_macro UNLOAD_FILAMENT]
gcode:
{% set TEMP = params.TEMP|default(230)|float %}
{% set DISTANCE = params.DISTANCE|default(105)|float %}
M400 #CLEAR_BUFFER
SAVE_GCODE_STATE NAME=UNLOAD_FILAMENT_state
_LOW_TEMP_CHECK T={TEMP}
M82 #ABSOLUTE_EXTRUSION
; Filament tip shaping sequence
G92 E0 #RESET_EXTRUDER
G1 E2 F3600
G1 E0 F3600
G1 E3 F3600
G1 E0 F3600
G1 E4 F3600
G1 E0 F3600
M83 #RELATIVE_EXTRUSION
G1 E-20 F3600
G4 P3000
G1 E{DISTANCE|float * -1} F3000
RESTORE_GCODE_STATE NAME=UNLOAD_FILAMENT_state
[gcode_macro _FS_ENABLE]
description: Enable Post Filament Sensor
gcode:
SET_FILAMENT_SENSOR SENSOR=post ENABLE=1
[gcode_macro _FS_DISABLE]
description: Disable Post Filament Sensor
gcode:
SET_FILAMENT_SENSOR SENSOR=post ENABLE=0