-
Notifications
You must be signed in to change notification settings - Fork 0
/
TR_Flow.cfg
452 lines (393 loc) · 17.4 KB
/
TR_Flow.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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
[trad_rack]
selector_max_velocity: 200
selector_max_accel: 5000
toolhead_fil_sensor_pin: TB:mt_det
lane_count: 9
lane_spacing: 16.718750
servo_down_angle: 0.0
servo_up_angle: 131.0
toolhead_unload_speed: 20
extruder_load_speed: 20
toolhead_sense_speed: 20
selector_unload_length: 17.5
bowden_length: 700.0
toolhead_unload_length: 0
extruder_load_length: 77.66
hotend_load_length: 25 #13.05
buffer_pull_speed: 200.0 # increase this to 300+ once you are ready (but some motors may not be able to handle this).
sync_to_extruder: False
save_active_lane: True
# optional custom gcode
pre_unload_gcode:
SFS_DISABLE
SAVE_GCODE_STATE NAME=PRE_UNLOAD_state
{% if printer.virtual_sdcard.is_active %}
{% set z_max = printer.toolhead.axis_maximum.z - printer.gcode_move.homing_origin.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"].do_x_park %}
{% set do_y_park = printer["gcode_macro TR_Variables"].do_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.gcode_move.gcode_position.x %}
{% set y = printer.gcode_move.gcode_position.y %}
{% set z = printer.gcode_move.gcode_position.z %}
{% set z_park = [z + z_lift, z_max]|min %}
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}
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=z_park VALUE={z_park}
# lift z
G90 # absolute positioning
G1 Z{z_park} # move to z position
# 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 %}
# shape filament tip
{% if shape_tip %}
Shape_Tip
{% endif %}
{% else %}
# move to purge location
{% if use_wiper %}
Go_To_Purge_Location
{% endif %}
# shape filament tip
Shape_Tip
{% endif %}
RESTORE_GCODE_STATE NAME=PRE_UNLOAD_state
post_load_gcode:
SAVE_GCODE_STATE NAME=POST_LOAD_state
{% 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 %}
{% set z_park = printer["gcode_macro TR_Variables"].z_park %}
# take timelapse frame
{% if take_frame %}
TIMELAPSE_TAKE_FRAME
{% endif %}
# wipe nozzle
{% if use_wiper %}
Home_and_Wipe_Nozzle
{% endif %}
# move to pre-toolchange position
{% if saved_pos %}
G90 # absolute positioning
G1 Z{z_park} # restore z parking position
G1 X{x} Y{y} F{st} # restore original x and y position
G1 Z{z} # restore original z position
SET_GCODE_VARIABLE MACRO=TR_Variables VARIABLE=saved_pos VALUE={False}
{% endif %}
Restore_Pressure_Advance # restore PA from before ramming
{% elif use_wiper %}
Home_and_Wipe_Nozzle
{% endif %}
RESTORE_GCODE_STATE NAME=POST_LOAD_state
SFS_ENABLE
[stepper_tr_selector]
step_pin: TR:selector_step
dir_pin: TR:selector_dir
enable_pin: !TR:selector_enable
rotation_distance: 40
microsteps: 16
full_steps_per_rotation: 200
endstop_pin: TR:endstop
position_min: -0.887
position_endstop: -0.887
position_max: 133.751
homing_speed: 30
[tmc2209 stepper_tr_selector]
uart_pin: TR:selector_uart
run_current: 0.96
sense_resistor: 0.110
[stepper_tr_fil_driver]
step_pin: TR:driver_step
dir_pin: TR:driver_dir
enable_pin: !TR:driver_enable
rotation_distance: 22.67895
gear_ratio: 50:17
microsteps: 16
full_steps_per_rotation: 200
endstop_pin: ^TR:encoder # selector filament sensor
position_min: -5000
position_endstop: 0
position_max: 5000
homing_positive_dir: False
[tmc2209 stepper_tr_fil_driver]
uart_pin: TR:driver_uart
interpolate: False
run_current: 0.96
sense_resistor: 0.110
[servo tr_servo]
pin: TR:servo
maximum_servo_angle: 131
minimum_pulse_width: 0.000700
maximum_pulse_width: 0.002200
[extruder]
max_extrude_only_distance: 200
max_extrude_cross_section: 100
# Macros
[gcode_macro ACTIVATE_EXTRUDER]
rename_existing: ACTIVATE_EXTRUDER.1
gcode:
{% set EXTRUDER = params.EXTRUDER|default('extruder')|lower|replace('extruder', '') %}
{% if EXTRUDER == '' %}
{% set EXTRUDER = '0' %}
{% endif %}
TR_LOAD_TOOLHEAD LANE={EXTRUDER}
[gcode_macro TR_Variables]
description: Variables for use with Trad Rack pre unload and post load gcode
variable_z_lift: 10 # distance to lift z axis before toolchange
variable_x_park: 140 # x position to park before unloading
variable_y_park: 254 # y position to park before unloading
variable_do_x_park: True # whether to park x before unloading
variable_do_y_park: True # whether to park y before unloading
variable_travel_speed: 500 # how fast travel speeds will be performed
variable_shape_tip: True # 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: True # 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
variable_z_park: 0
gcode:
[gcode_macro Shape_Tip]
description: Perform tip-shaping, retraction, and cooling moves
gcode:
SAVE_GCODE_STATE NAME=Shape_Tip_state
Save_Pressure_Advance
Slicer_Unload # replace this with a different macro/gcode
# to change unloading
Restore_Pressure_Advance
RESTORE_GCODE_STATE NAME=Shape_Tip_state
[gcode_macro Set_Slicer_Unload_Preset]
description: Apply a preset of values to use for the Slicer_Unload macro
# params:
# PRESET Name of the preset to apply. Must match one of the variables below.
# see gcode_macro Slicer_Unload for variables that can be changed in a preset
# SuperSlicer presets
variable_asa_ss = {
"filament_ramming_parameters": "120 110 5.32258 5.45161 5.67742 6 6.48387 7.12903 7.90323 8.70968 9.3871 9.83871 10.0968 10.2258| 0.05 5.30967 0.45 5.50967 0.95 6.1871 1.45 7.39677 1.95 9.05484 2.45 10 2.95 10.3098 3.45 13.0839 3.95 7.6 4.45 7.6 4.95 7.6",
"superslicer": True}
variable_pla_ss = {
"filament_ramming_parameters": "130 120 2.70968 2.93548 3.32258 3.83871 4.58065 5.54839 6.51613 7.35484 7.93548 8.16129| 0.05 2.66451 0.45 3.05805 0.95 4.05807 1.45 5.97742 1.95 7.69999 2.45 8.1936 2.95 11.342 3.45 11.4065 3.95 7.6 4.45 7.6 4.95 7.6",
"superslicer": True}
# PrusaSlicer presets
variable_asa_ps = {
"filament_ramming_parameters": "120 110 5.32258 5.45161 5.67742 6 6.48387 7.12903 7.90323 8.70968 9.3871 9.83871 10.0968 10.2258| 0.05 5.30967 0.45 5.50967 0.95 6.1871 1.45 7.39677 1.95 9.05484 2.45 10 2.95 10.3098 3.45 13.0839 3.95 7.6 4.45 7.6 4.95 7.6",
"superslicer": False}
variable_pla_ps = {
"filament_ramming_parameters": "130 120 2.70968 2.93548 3.32258 3.83871 4.58065 5.54839 6.51613 7.35484 7.93548 8.16129| 0.05 2.66451 0.45 3.05805 0.95 4.05807 1.45 5.97742 1.95 7.69999 2.45 8.1936 2.95 11.342 3.45 11.4065 3.95 7.6 4.45 7.6 4.95 7.6",
"superslicer": False}
# presets should follow the format below:
# variable_<preset_name_in_lowercase> = {
# "<variable1_name>": <variable1_value>,
# "<variable2_name>": <variable2_value>,
# "<variable3_name>": <variable3_value>}
gcode:
{% set preset_name = params.PRESET|lower %}
{% if preset_name in printer['gcode_macro Set_Slicer_Unload_Preset'] %}
{% set preset = printer['gcode_macro Set_Slicer_Unload_Preset'].preset_name %}
{% for key in preset %}
SET_GCODE_VARIABLE MACRO=Slicer_Unload VARIABLE={key} VALUE={preset[key]}
{% endfor %}
{% else %}
{ action_raise_error("Preset \"%s\" does not exist" % preset_name) }
{% endif %}
[gcode_macro Slicer_Unload]
# logic based on WipeTower::toolchange_Unload() from PrusaSlicer and SuperSlicer
description: Mimic ramming and unload behavior of PrusaSlicer or SuperSlicer
# params:
# NEW_TEMPERATURE extruder temperature to set (optional; only needs to be
# passed if the new filament requires a different
# temperature than the current temperature target)
# printer settings
variable_cooling_tube_length = 26
variable_cooling_tube_retraction = 49
# filament settings
variable_filament_cooling_final_speed = 30
variable_filament_cooling_initial_speed = 20
variable_filament_cooling_moves = 4
variable_filament_diameter = 1.75
variable_filament_unloading_speed = 90
variable_filament_unloading_speed_start = 100
variable_filament_toolchange_delay = 0
variable_filament_ramming_parameters = "120 110 5.32258 5.45161 5.67742 6 6.48387 7.12903 7.90323 8.70968 9.3871 9.83871 10.0968 10.2258| 0.05 5.30967 0.45 5.50967 0.95 6.1871 1.45 7.39677 1.95 9.05484 2.45 10 2.95 10.3098 3.45 13.0839 3.95 7.6 4.45 7.6 4.95 7.6"
# filament settings only in SuperSlicer
variable_filament_enable_toolchange_temp = False
variable_filament_toolchange_temp = 200
variable_filament_use_fast_skinnydip = False
variable_filament_enable_toolchange_part_fan = False
variable_filament_toolchange_part_fan_speed = 50
variable_filament_use_skinnydip = True
variable_filament_skinnydip_distance = 24
variable_filament_melt_zone_pause = 0
variable_filament_cooling_zone_pause = 0
variable_filament_dip_insertion_speed = 33
variable_filament_dip_extraction_speed = 70
# other settings
variable_superslicer = True # whether to enable extra functionality only found in SuperSlicer
variable_do_ramming = True # whether to include ramming
variable_do_unload = True # whether to include retraction, cooling moves, and skinnydip
gcode:
{% set NEW_TEMPERATURE = params.NEW_TEMPERATURE|default(0)|float %}
{% set prev_temp_target = printer.extruder.target %}
SAVE_GCODE_STATE NAME=Slicer_Unload_state
Save_Pressure_Advance
M83
M220 S100
SET_PRESSURE_ADVANCE ADVANCE=0
# ramming
{% if do_ramming %}
# parse ramming parameters
{% set ramming_speed = (filament_ramming_parameters.split('|')[0]).split(' ') %}
# set ramming constants
{% set filament_area = 3.1415 * (filament_diameter / 2) ** 2 %}
# iterate through ramming speed values
{% for i in range(2, ramming_speed|length) %}
# calculate extrusion feedrate in mm/s
{% set f = ramming_speed[i]|float / filament_area %}
# calculate extrusion length in mm for a 0.25s move
{% set e = f * 0.25 %}
# do ramming move
G1 E{e} F{f * 60}
{% endfor %}
{% endif %}
# unload
{% if do_unload %}
# set toolchange temperature before retraction
{% if superslicer and filament_enable_toolchange_temp and not filament_use_fast_skinnydip %}
_Wait_for_Toolchange_Temp
{% endif %}
# retraction
{% set total_retraction_distance = cooling_tube_retraction + cooling_tube_length / 2 - 15 %}
G1 E-15 F{filament_unloading_speed_start * 60}
G1 E-{0.70 * total_retraction_distance} F{1.0 * filament_unloading_speed * 60}
G1 E-{0.20 * total_retraction_distance} F{0.5 * filament_unloading_speed * 60}
G1 E-{0.10 * total_retraction_distance} F{0.3 * filament_unloading_speed * 60}
# set temperature
{% if not superslicer or not filament_enable_toolchange_temp %}
{% if NEW_TEMPERATURE != 0 and (NEW_TEMPERATURE != prev_temp_target) %}
M104 S{NEW_TEMPERATURE}
{% endif %}
# else return to the previously set temperature
{% elif superslicer and filament_enable_toolchange_temp and not filament_use_fast_skinnydip %}
{% if NEW_TEMPERATURE != 0 %}
M104 S{NEW_TEMPERATURE}
{% else %}
M104 S{prev_temp_target}
{% endif %}
{% endif %}
# cooling moves
{% set speed_inc = (filament_cooling_final_speed - filament_cooling_initial_speed) / (2 * filament_cooling_moves - 1) %}
{% for i in range(filament_cooling_moves) %}
{% set speed = filament_cooling_initial_speed + speed_inc * 2 * i %}
G1 E{cooling_tube_length} F{speed * 60}
{% set speed = speed + speed_inc %}
G1 E-{cooling_tube_length} F{speed * 60}
{% endfor %}
# skinnydip
{% if superslicer %}
# wait for toolchange temperature
{% if filament_enable_toolchange_temp and filament_use_fast_skinnydip %}
_Wait_for_Toolchange_Temp
{% endif %}
# do skinnydip
{% if filament_use_skinnydip %}
G1 E{filament_skinnydip_distance} F{filament_dip_insertion_speed * 60}
G4 P{filament_melt_zone_pause}
G1 E-{filament_skinnydip_distance} F{filament_dip_extraction_speed * 60}
G4 P{filament_cooling_zone_pause}
{% endif %}
# restore temperature from before skinnydip
{% if filament_enable_toolchange_temp and filament_use_fast_skinnydip %}
{% if NEW_TEMPERATURE != 0 %}
M109 S{NEW_TEMPERATURE}
{% else %}
M109 S{prev_temp_target}
{% endif %}
{% elif filament_enable_toolchange_temp and filament_use_fast_skinnydip %}
{% if NEW_TEMPERATURE != 0 and (NEW_TEMPERATURE != prev_temp_target) %}
M109 S{NEW_TEMPERATURE}
{% endif %}
{% endif %}
{% endif %}
# wait
G4 P{filament_toolchange_delay}
# (normally the slicer may insert an extruder move here to move the
# filament to parking_pos_retraction; this is skipped)
{% endif %}
Restore_Pressure_Advance
RESTORE_GCODE_STATE NAME=Slicer_Unload_state
[gcode_macro _Wait_for_Toolchange_Temp]
# logic based on wait_for_toolchange_temp() from SuperSlicer
description: Helper function for Slicer_Unload
gcode:
{% set tc_temp = printer["gcode_macro Slicer_Unload"].filament_toolchange_temp %}
{% set fan_on = printer["gcode_macro Slicer_Unload"].filament_enable_toolchange_part_fan %}
{% set fan_speed = printer["gcode_macro Slicer_Unload"].filament_toolchange_part_fan_speed %}
{% set prev_fan_speed = printer.fan.speed %}
{% if fan_on %}
M106 S{(fan_speed / 100.0 * 255)|int}
{% endif %}
M109 S{filament_toolchange_temp}
{% if fan_on %}
M106 S{(prev_fan_speed * 255)|int}
{% endif %}
[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 %}