-
Notifications
You must be signed in to change notification settings - Fork 0
/
trad_rack_optional.cfg
254 lines (227 loc) · 8.47 KB
/
trad_rack_optional.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
[trad_rack]
# optional custom gcode
pre_unload_gcode:
{% if printer.virtual_sdcard.is_active %}
{% set z_max = printer.toolhead.axis_maximum.z %}
{% set z_lift = printer["gcode_macro TR_Variables"].z_lift|float %}
{% set x_park = printer["gcode_macro TR_Variables"].x_park|float %}
{% set y_park = printer["gcode_macro TR_Variables"].y_park|float %}
{% set do_x_park = printer["gcode_macro TR_Variables"].x_park %}
{% set do_y_park = printer["gcode_macro TR_Variables"].y_park %}
{% set st = printer["gcode_macro TR_Variables"].travel_speed * 60 %}
{% set shape_tip = printer["gcode_macro TR_Variables"].shape_tip %}
{% set use_wiper = printer["gcode_macro TR_Variables"].use_wiper %}
{% set x = printer.toolhead.position.x %}
{% set y = printer.toolhead.position.y %}
{% set z = printer.toolhead.position.z %}
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=x VALUE={x}
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=y VALUE={y}
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=z VALUE={z}
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=saved_pos VALUE={True}
SAVE_GCODE_STATE NAME=PRE_UNLOAD_state
# lift z
{% if z + z_lift < z_max %}
G91 # relative positioning
G1 Z{z_lift} # lift z
{% else %}
G90 # absolute positioning
G1 Z{z_max} # lift z to max position
{% endif %}
# move to purge location
{% if use_wiper %}
Go_To_Purge_Location
# park x and y
{% else %}
G90 # absolute positioning
{% if do_x_park %}
{% set x = x_park %}
{% endif %}
{% if do_y_park %}
{% set y = y_park %}
{% endif %}
G1 X{x} Y{y} F{st} # move to x and y position
{% endif %}
RESTORE_GCODE_STATE NAME=PRE_UNLOAD_state
# shape filament tip
{% if shape_tip %}
Shape_Tip
{% endif %}
{% else %}
Shape_Tip
{% endif %}
post_load_gcode:
{% set use_wiper = printer["gcode_macro TR_Variables"].use_wiper %}
{% if printer.virtual_sdcard.is_active %}
{% set st = printer["gcode_macro TR_Variables"].travel_speed * 60 %}
{% set take_frame = printer["gcode_macro TR_Variables"].take_frame %}
{% set x = printer["gcode_macro TR_Variables"].x %}
{% set y = printer["gcode_macro TR_Variables"].y %}
{% set z = printer["gcode_macro TR_Variables"].z %}
{% set saved_pos = printer["gcode_macro TR_Variables"].saved_pos %}
# take timelapse frame
{% if take_frame %}
TIMELAPSE_TAKE_FRAME
{% endif %}
SAVE_GCODE_STATE NAME=POST_LOAD_state
# wipe nozzle
{% if use_wiper %}
Home_and_Wipe_Nozzle
{% endif %}
# move to pre-toolchange position
{% if saved_pos %}
G90 # absolute positioning
G1 X{x} Y{y} F{st}
G1 Z{z}
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=saved_pos VALUE={False}
{% endif %}
Restore_Pressure_Advance # restore PA from before ramming
RESTORE_GCODE_STATE NAME=POST_LOAD_state
{% elif use_wiper %}
Home_and_Wipe_Nozzle
{% endif %}
[gcode_macro TR_Variables]
description: Variables for use with Trad Rack pre unload and post load gcode
variable_z_lift: 0.1 # distance to lift z axis before toolchange
variable_x_park: 0.0 # x position to park before unloading
variable_y_park: 175.0 # y position to park before unloading
variable_do_x_park: False # whether to park x before unloading
variable_do_y_park: False # whether to park y before unloading
variable_travel_speed: 300 # how fast travel speeds will be performed
variable_shape_tip: False # whether to add tip-shaping gcode on unload during printing
# (set to False if you are using ramming from the slicer)
variable_take_frame: False # whether to take a timelapse frame after each toolchange
# requires: https://github.com/mainsail-crew/moonraker-timelapse
# (use "layermacro" mode)
variable_use_wiper: False # intended for the Annex K3 printer and requires
# Go_To_Purge_Location and Wipe_Nozzle gcode
# macros. Makes the toolchange occur over the
# purge bucket and wipes the nozzle before
# resuming the print. Variables relating to
# parking will be ignored if this is set to True
# don't change any of the variables below this line
variable_x: 0
variable_y: 0
variable_z: 0
variable_saved_pos: False
gcode:
[gcode_macro Home_and_Wipe_Nozzle]
description: Home x and y if needed, then wipe the nozzle
gcode:
# home x and y if needed
{% if not 'xy' in printer.toolhead.homed_axes %}
G28 X Y
{% endif %}
# wipe nozzle
Wipe_Nozzle
[gcode_macro Save_Pressure_Advance]
# call this in your print start gcode after setting PA for the print
# (only necessary if the slicer inserts ramming gcode that sets PA to 0)
description: Save the current pressure advance value
# don't change any of the variables below this line
variable_pa: -1
gcode:
# save PA if it is not 0
{% set pa = printer.extruder.pressure_advance %}
{% if pa > 0 %}
SET_GCODE_VARIABLE MACRO=Save_Pressure_Advance VARIABLE=pa VALUE={pa}
{% endif %}
[gcode_macro Restore_Pressure_Advance]
description: Restore saved pressure advance value
gcode:
# restore PA if a previous value was saved
{% if not (printer["gcode_macro Save_Pressure_Advance"].pa == -1) %}
SET_PRESSURE_ADVANCE ADVANCE={printer["gcode_macro Save_Pressure_Advance"].pa}
{% endif %}
[gcode_macro Shape_Tip]
description: Perform tip-shaping, retraction, and cooling moves
gcode:
SAVE_GCODE_STATE NAME=Shape_Tip_state
Save_Pressure_Advance
M83 # extruder relative mode
# gcode generated by SuperSlicer, with XY moves removed
;--------------------
; CP TOOLCHANGE START
; toolchange #1
; material : PLA -> PLA
;--------------------
M220 S100
; CP TOOLCHANGE UNLOAD
;WIDTH:0.65
# G1 X66.273 Y170.819
SET_PRESSURE_ADVANCE ADVANCE=0
G1 F68
G1 E0.2816
G1 F73
G1 E0.3051
G1 F83
G1 E0.3453
G1 F96
G1 E0.399
G1 F114
G1 E0.4761
G1 F138
G1 E0.5767
G1 F163
G1 E0.5691
# G1 Y170.039 F7200
G1 F162
G1 E0.1081
G1 F196
G1 E0.7644
G1 F186
G1 E0.8248
G1 F203
G1 E0.8483
;WIDTH:0.5
G1 E-15 F6000
G1 E-15.4 F5400
G1 E-4.4 F2700
G1 E-2.2 F1620
# G1 Y169.259
G1 E14 F1200
G1 E-14
G1 E14
G1 E-14
G1 E14
G1 E-14
G1 E14
G1 E-14
; SKINNYDIP START
G1 E24 F1980
G4 P0
G1 E-24 F4200
G4 P0
; SKINNYDIP END
G1 F2000
# G1 Y169.399 F2400
G4 S0
; custom gcode: end_filament_gcode
; Filament-specific end gcode
;END gcode for filament
; custom gcode end: end_filament_gcode
Restore_Pressure_Advance
RESTORE_GCODE_STATE NAME=Shape_Tip_state
[gcode_macro TR_Print_Start]
description: Loads the first filament into the toolhead.
# params:
# EXTRUDER extruder temperature (if loading a new filament)
# LANE filament lane number to load into the toolhead
# WAIT_TEMP whether to wait to reach original extruder target
# before continuing
gcode:
{% set EXTRUDER = params.EXTRUDER|default(260) %}
{% set LANE = params.LANE|default(-1)|int %}
{% set WAIT_TEMP = params.WAIT_TEMP|default('False') %}
{% if not (0 <= LANE < printer.configfile.config["trad_rack"]["lane_count"]|int) %}
{ action_raise_error("Invalid lane") }
{% endif %}
{% if printer.trad_rack.active_lane != LANE %}
{% set prev_target = printer.extruder.target %}
M109 S{EXTRUDER} # wait for extruder temp
TR_LOAD_TOOLHEAD LANE={LANE} # load toolhead from lane
{% if WAIT_TEMP|lower == 'true' %}
M109 S{prev_target} # set and wait for previous extruder temp
{% else %}
M104 S{prev_target} # set previous extruder temp
{% endif %}
{% endif %}