-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIDEX_mode.cfg
424 lines (395 loc) · 16 KB
/
IDEX_mode.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
# This file contains a configuration snippet for a dual extruder
# printer using dual carriages (an "IDEX" printer).
# See docs/Config_Reference.md for a description of parameters.
# Definition for the primary carriage (holding the primary extruder)
# and the definition for the primary extruder in main config file
########################################
# DUAL-CARRIAGES
########################################
[respond]
#CALIBRATE_IDEX_OFFSETS offsets: [-0.100, -0.088, -0.596]
[gcode_macro DC_VARS]
# Offset coordinates for dual_carriage
variable_offset_x: -0.10 #-0.25 #-0.05 # -0.15 #-0.30 #-0.29 ##-0.34 #0.31 ##0.40 ##0.70 #-0.06 #-0.3 #was -0.15
variable_offset_y: -0.43 #-0.38 #-0.28 #-0.23 #-0.17 #-0.27 ##-0.17 ##-0.22 #-0.05 #-0.15 ##0.20 #1.5 #-0.15 #was -0.15 #-0.3 #was0
variable_offset_z: 0.20 #0.03 #-0.1 # 0.23
# Autopark parameters
## default autopark: 0:inactive - 1:active
variable_autopark: 1
variable_z_hop: 0
variable_movespeed: 300
variable_feedrate: 18000
# HeatBed size
variable_bed_x_min: 0
variable_bed_x_max: 200
# Print cooling fans names
variable_fan0: 'fanX1'
variable_fan1: 'fanX2'
# Extruders temp
variable_offset_temp: 0
gcode:
## DUAL-CARRIAGES : FULL_CONTROL - AUTO-PARK
; [homing_override]
; axes: xyz
; gcode:
; # either none or all
; {% set dcvars = printer["gcode_macro DC_VARS"] %}
; {% set has_z = ('Z' in params or 'z' in params) %}
; {% set has_x = ('X' in params or 'x' in params) %}
; {% set has_y = ('Y' in params or 'y' in params) %}
; {% set has_all = (has_z and has_x and has_y) %}
; {% set has_none = (not has_z and not has_x and not has_y) %}
; {% set no_xy = (not has_x and not has_y) %}
; {% set only_z = (no_xy and has_z) %}
; {% set home_all = (has_none or has_all) %}
; {% set X_T0_MIN = printer.configfile.config.stepper_x.position_min|float %}
; {% set X_T1_MAX = printer.configfile.config.dual_carriage.position_max|float %}
;
; # Always drop to avoid hitting in XY.
; UNSAFE_LOWER_BED
;
; {% if home_all or has_y %}
; # home Y
;
; # having both T0 in X_MIN and T1 in X_MAX helps with Y HOME
; # we will home again if X is requested
; G28 X0
; ACTIVATE_EXTRUDER EXTRUDER=extruder1
; SET_DUAL_CARRIAGE CARRIAGE=1
; _PARK_TOOL
; ACTIVATE_EXTRUDER EXTRUDER=extruder
; SET_DUAL_CARRIAGE CARRIAGE=0
; _PARK_TOOL
;
; G90
; # move T0 over to the MIN (left)
; G1 X{X_T0_MIN} F{dcvars.feedrate}
;
; # now actually home Y
; IDEX_HOME_Y
; {% endif %}
;
; {% if home_all or has_x %}
; # home X (possibly for a second time)
; IDEX_HOME_X
; {% endif %}
;
; {% if home_all or has_z %}
; # home Z
; CENTER
; G28 Z
; G91
; G1 Z3 F1200
; G90
; {% endif %}
[gcode_macro UPDATE_IDEX_OFFSETS]
gcode:
{% if (params.OFFSET_X) is defined %}
{% set offset_x = params.OFFSET_X %}
{% else %}
{% set offset_x = printer.idex_offsets_calibration.last_offset_x %}
{% endif %}
{% if offset_x != None %}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_x VALUE={offset_x}
{% endif %}
{% if (params.OFFSET_Y) is defined %}
{% set offset_y = params.OFFSET_Y %}
{% else %}
{% set offset_y = printer.idex_offsets_calibration.last_offset_y %}
{% endif %}
{% if offset_y != None %}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_y VALUE={offset_y}
{% endif %}
{% if (params.OFFSET_Z) is defined %}
{% set offset_z = params.OFFSET_Z %}
{% else %}
{% set offset_z = printer.idex_offsets_calibration.last_offset_z %}
{% endif %}
{% if offset_z != None %}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_z VALUE={offset_z}
{% endif %}
{ action_respond_info("UPDATE_IDEX_OFFSETS: [" + offset_x|string
+ ", " + offset_y|string
+ ", " + offset_z|string
+ "]") }
[gcode_macro SHOW_IDEX_OFFSETS]
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{ action_respond_info("IDEX_OFFSETS: [" + dcvars.offset_x|string
+ ", " + dcvars.offset_y|string
+ ", " + dcvars.offset_z|string
+ "]") }
[gcode_macro T0]
description: Activate T0 in "FULL_CONTROL" or "AUTO-PARK"
gcode:
SB_T0
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% set tweaked_z_offset = printer.gcode_move.homing_origin.z %}
{% if printer.dual_carriage is defined %}
{% if printer.dual_carriage.active_carriage == "CARRIAGE_1" %}
M400
{% if dcvars.autopark == 1 %}
# z-hop
{% if dcvars.z_hop|float > 0.0 %}
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set cur_z = printer.toolhead.position.z|float %}
{% set z_safe = dcvars.z_hop|float if cur_z < (max_z - dcvars.z_hop|float) else (max_z - cur_z) %}
G91
G1 Z{z_safe}
G90
{% endif %}
# park tool
SAVE_GCODE_STATE NAME=toolhead_state
_PARK_TOOL
#STATUS_READY
{% endif %}
# toggle carriage
SB_T0
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_DUAL_CARRIAGE CARRIAGE=0
ACTIVATE_IDEX_PROBE CARRIAGE=0
SET_INPUT_SHAPER SHAPER_FREQ_X=46.6 SHAPER_FREQ_Y=57.0 SHAPER_TYPE_X=EI SHAPER_TYPE_Y=MZV
#SET_INPUT_SHAPER SHAPER_FREQ_X=45.6 SHAPER_FREQ_Y=82.8 SHAPER_TYPE_X=EI SHAPER_TYPE_Y=ZV
#_NOZZLE_SCRUB
{% if dcvars.autopark == 1 %}
RESTORE_GCODE_STATE NAME=toolhead_state MOVE=1 MOVE_SPEED={dcvars.movespeed}
{% endif %}
# offsets
{% if tweaked_z_offset == 0 %}
#Z-Offset was cleared when T1 was active, this can cause errors and compound offset if done repeatedly
SET_GCODE_OFFSET X=0 Y=0 Z=0 MOVE=1
{% else %}
SET_GCODE_OFFSET X=0 Y=0 Z={tweaked_z_offset - dcvars.offset_z} MOVE=1
{% endif %}
# print fan speed
_SET_PRINT_FANS_SPEED
# restore z
{% if (z_safe) is defined and printer.idle_timeout.state != "Printing" %}
G91
G1 Z-{z_safe}
G90
{% endif %}
{% endif %}
#STATUS_PRINTING
{% endif %}
[gcode_macro T1]
description: Activate T1 in "FULL_CONTROL" or "AUTO-PARK"
gcode:
SB_T1
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% set tweaked_z_offset = printer.gcode_move.homing_origin.z %}
{% if printer.dual_carriage is defined %}
{% if printer.dual_carriage.active_carriage == "CARRIAGE_0" %}
M400
{% if dcvars.autopark == 1 %}
# z-hop
{% if dcvars.z_hop|float > 0.0 %}
{% set max_z = printer.toolhead.axis_maximum.z|float %}
{% set cur_z = printer.toolhead.position.z|float %}
{% set z_safe = dcvars.z_hop|float if cur_z < (max_z - dcvars.z_hop|float) else (max_z - cur_z) %}
G91
G1 Z{z_safe}
G90
{% endif %}
# park tool
SAVE_GCODE_STATE NAME=toolhead_state
_PARK_TOOL
#STATUS_READY
{% endif %}
# toggle carriage
SB_T1
ACTIVATE_EXTRUDER EXTRUDER=extruder1
SET_DUAL_CARRIAGE CARRIAGE=1
ACTIVATE_IDEX_PROBE CARRIAGE=1
SET_INPUT_SHAPER SHAPER_FREQ_X=46.6 SHAPER_FREQ_Y=57.0 SHAPER_TYPE_X=EI SHAPER_TYPE_Y=MZV
#SET_INPUT_SHAPER SHAPER_FREQ_X=43.6 SHAPER_FREQ_Y=70.4 SHAPER_TYPE_X=EI SHAPER_TYPE_Y=EI
#_NOZZLE_SCRUB
{% if dcvars.autopark == 1 %}
RESTORE_GCODE_STATE NAME=toolhead_state MOVE=1 MOVE_SPEED={dcvars.movespeed}
{% endif %}
# offsets
{% if not ('SKIP_OFFSET' in params) %}
SET_GCODE_OFFSET X={dcvars.offset_x} Y={dcvars.offset_y} Z={dcvars.offset_z + tweaked_z_offset} MOVE=1
{% endif %}
# print fan speed
_SET_PRINT_FANS_SPEED
# restore z
{% if (z_safe) is defined and printer.idle_timeout.state != "Printing" %}
G91
G1 Z-{z_safe}
G90
{% endif %}
{% endif %}
#STATUS_PRINTING
{% endif %}
[gcode_macro _PARK_TOOL]
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% if printer.dual_carriage is defined %}
SAVE_GCODE_STATE NAME=park_tool
SET_GCODE_OFFSET X=0 Y=0 Z=0
G90
{% if printer.toolhead.extruder == 'extruder' %}
{% set XPOS = printer.configfile.config.stepper_x.position_endstop|float + 0.2 %}
G1 X{XPOS} F{dcvars.feedrate}
#G1 X{printer.configfile.config.stepper_x.position_endstop} F{dcvars.feedrate}
{% elif (printer.toolhead.extruder) == 'extruder1' %}
{% set XPOS = printer.configfile.config.dual_carriage.position_max|float - 0.2 %}
G1 X{XPOS} F{dcvars.feedrate}
#G1 X{printer.configfile.config.dual_carriage.position_endstop} F{dcvars.feedrate}
{% else %}
RESPOND TYPE=error MSG={ "Unknown extruder: %s".format(printer.toolhead.extruder) }
{% endif %}
RESTORE_GCODE_STATE NAME=park_tool
{% endif %}
#by dorkscript from #tridex-dev on discord
[gcode_macro _NOZZLE_SCRUB]
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% if printer.dual_carriage is defined and printer.toolhead.extruder in ['extruder', 'extruder1'] %}
G90
{% if printer.toolhead.extruder == 'extruder' %}
{% set XPOS = printer.configfile.config.stepper_x.position_min|float + 1.0 %}
{% set XPOS1 = printer.configfile.config.stepper_x.position_min|float + 15.0 %}
{% else %}
{% set XPOS = printer.configfile.config.dual_carriage.position_max|float - 1.0 %}
{% set XPOS1 = printer.configfile.config.dual_carriage.position_max|float - 15.0 %}
{% endif %}
G1 X{XPOS} F{dcvars.feedrate}
G1 X{XPOS1} F{dcvars.feedrate}
G1 X{XPOS} F{dcvars.feedrate}
{% endif %}
## DUAL-CARRIAGES : MODES ACTIVATION
[gcode_macro M605]
description: Set the dual-carriages mode
gcode:
{% set mode = params.S|default(1)|int %}
{% set offset_temp = params.R|default(0)|float %}
{% if printer.dual_carriage is defined %}
{% if (mode) == 0 %}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=autopark VALUE=0
MODE_FULL_CONTROL
{% elif (mode) == 1 %}
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=autopark VALUE=1
MODE_FULL_CONTROL
{% elif (mode) == 2 and (params.X) is defined %}
MODE_DUPLICATION X={params.X} R={offset_temp}
{% elif (mode) == 2 %}
MODE_DUPLICATION R={offset_temp}
{% elif (mode) == 3 %}
MODE_MIRRORED R={offset_temp}
{% endif %}
G1 F3000
{% endif %}
[gcode_macro MODE_FULL_CONTROL]
description: Set the dual-carriages mode to "FULL_CONTROL"
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% if printer.dual_carriage is defined %}
SET_DUAL_CARRIAGE_MODE MODE=FULL_CONTROL
G28 X
#SYNC_STEPPER_TO_EXTRUDER EXTRUDER=extruder1
ACTIVATE_EXTRUDER EXTRUDER=extruder
SET_GCODE_OFFSET X=0 Y=0 Z=0
# set print fan speed
_SET_PRINT_FANS_SPEED
{% endif %}
[gcode_macro MODE_DUPLICATION]
description: Set the dual-carriages mode to "DUPLICATION"
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% set bed_x_mid = 0.5 * (dcvars.bed_x_max|float - dcvars.bed_x_min|float) %}
{% set offset_temp = params.R|default(0)|float %}
{% if printer.dual_carriage is defined %}
# unsync both carriages
SET_DUAL_CARRIAGE_MODE MODE=FULL_CONTROL
G28 X
#SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder1 EXTRUDER=extruder1
#SYNC_EXTRUDER_STEPPERS EXTRUDER=extruder1
ACTIVATE_EXTRUDER EXTRUDER=extruder
# place both carriages
SET_DUAL_CARRIAGE CARRIAGE=0
G1 X{dcvars.bed_x_min|float} F{dcvars.feedrate}
SET_DUAL_CARRIAGE CARRIAGE=1
G1 X{params.X|default(bed_x_mid)|float} F{dcvars.feedrate}
# heaters management
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_temp VALUE={offset_temp}
_SYNC_EXTRUDERS_TEMP
# steppers management
#SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder EXTRUDER=extruder1
SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder
#SYNC_EXTRUDER_STEPPERS EXTRUDER=extruder1 TO=extruder
SET_DUAL_CARRIAGE_MODE MODE=DUPLICATION
# print fans management
_SET_PRINT_FANS_SPEED
{% endif %}
[gcode_macro MODE_MIRRORED]
description: Set the dual-carriages mode to "MIRRORED"
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% set offset_temp = params.R|default(0)|float %}
{% if printer.dual_carriage is defined %}
# unsync both carriages
SET_DUAL_CARRIAGE_MODE MODE=FULL_CONTROL
G28 X
#SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder1 EXTRUDER=extruder1
#SYNC_EXTRUDER_STEPPERS EXTRUDER=extruder1
ACTIVATE_EXTRUDER EXTRUDER=extruder
# place both carriages
SET_DUAL_CARRIAGE CARRIAGE=0
G1 X{dcvars.bed_x_min|float} F{dcvars.feedrate}
SET_DUAL_CARRIAGE CARRIAGE=1
G1 X{dcvars.bed_x_max|float} F{dcvars.feedrate}
# heaters management
SET_GCODE_VARIABLE MACRO=DC_VARS VARIABLE=offset_temp VALUE={offset_temp}
_SYNC_EXTRUDERS_TEMP
# steppers management
#SYNC_STEPPER_TO_EXTRUDER STEPPER=extruder EXTRUDER=extruder1
SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder
#SYNC_EXTRUDER_STEPPERS EXTRUDER=extruder1 TO=extruder
SET_DUAL_CARRIAGE_MODE MODE=MIRRORED
# print fans management
_SET_PRINT_FANS_SPEED
{% endif %}
## DUAL-CARRIAGES : PRINT FANS MANAGEMENT
[gcode_macro M106]
description: Override "M106" to allow multiple extruders.
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% set raw_speed = params.S|default(0)|float %}
{% set fan_speed = (raw_speed / 255.0)|round(2) %}
{% if (params.P) is defined %}
{% set P_fan = dcvars.fan0 if (params.P)|int == 0 else dcvars.fan1 %}
SET_FAN_SPEED FAN={P_fan} SPEED={fan_speed}
{% elif printer.dual_carriage is defined %}
_SET_PRINT_FANS_SPEED SPEED={fan_speed}
{% endif %}
[gcode_macro M107]
description: Override "M107" to allow multiple extruders.
gcode:
M106 S0
[gcode_macro _SET_PRINT_FANS_SPEED]
gcode:
{% set dcvars = printer["gcode_macro DC_VARS"] %}
{% if params.SPEED is defined %}
{% set fan_speed = params.SPEED|float %}
{% else %}
# read print fan speed from active extruder
{% set fan0_speed = printer["fan_generic " + dcvars.fan0].speed|float %}
{% set fan1_speed = printer["fan_generic " + dcvars.fan1].speed|float %}
{% set fan_speed = [fan0_speed, fan1_speed]|max %}
{% endif %}
{% if printer.dual_carriage.active_carriage == "BOTH" %}
SET_FAN_SPEED FAN={dcvars.fan0} SPEED={fan_speed}
SET_FAN_SPEED FAN={dcvars.fan1} SPEED={fan_speed}
{% elif printer.dual_carriage.active_carriage == "CARRIAGE_0" %}
SET_FAN_SPEED FAN={dcvars.fan0} SPEED={fan_speed}
SET_FAN_SPEED FAN={dcvars.fan1} SPEED={fan_speed}
{% elif printer.dual_carriage.active_carriage == "CARRIAGE_1" %}
SET_FAN_SPEED FAN={dcvars.fan0} SPEED={fan_speed}
SET_FAN_SPEED FAN={dcvars.fan1} SPEED={fan_speed}
{% endif %}
[gcode_macro _SYNC_EXTRUDERS_TEMP]
gcode:
{% set temp = printer["extruder"].target|float %}
M109 S{temp}