-
Notifications
You must be signed in to change notification settings - Fork 6
/
ercf_macros.cfg
685 lines (622 loc) · 24.8 KB
/
ercf_macros.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
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
###############################
# Parameters you need to adapt
###############################
[gcode_macro VAR_ERCF]
variable_timeout_pause: 72000
variable_disable_heater: 600
variable_bowden_load_length: [763, 776, 766.3, 776.5, 790.2, 762, 760, 770, 770]
variable_bowden_global_shift: -4.5
variable_bowden_speed: 90
variable_bowden_accel: 60
variable_ercf_load_length: 35
variable_ercf_unload_length: 20
variable_colorselector = [2,23,43.5,70,91,111,137,158,179]
variable_min_temp_extruder: 180
variable_extruder_eject_temp: 240
variable_servo_up_angle: 30
variable_servo_down_angle: 110
gcode:
###############################
# End of parameters you need to adapt
###############################
[respond]
default_type: command
###############################
# ERCF servo
###############################
# Push the servo down (enable the bondtech gears)
[gcode_macro SERVO_DOWN]
gcode:
SET_SERVO SERVO=revolver ANGLE={printer["gcode_macro VAR_ERCF"].servo_down_angle}
G4 P500
SERVO_OFF
# Push the servo up (disable the bondtech gears)
[gcode_macro SERVO_UP]
gcode:
SET_SERVO SERVO=revolver ANGLE={printer["gcode_macro VAR_ERCF"].servo_up_angle}
G4 P500
SERVO_OFF
# Turn the servo off
[gcode_macro SERVO_OFF]
gcode:
SET_SERVO SERVO=revolver WIDTH=0
# Test the servo angle
[gcode_macro SERVO_TEST]
gcode:
SET_SERVO SERVO=revolver ANGLE={params.VALUE|int}
G4 P1000
SERVO_OFF
###############################
# ERCF endstop status : IR extruder, ERCF filament, ERCF home
# 0 : open, 1 : triggered
###############################
# Display the last queried status
[gcode_macro ENDSTOPS_STATUS]
gcode:
M118 Endstop status :
M118 Extruder : {printer["filament_switch_sensor ir_sensor"].filament_detected}
M118 ERCF filament : {printer.query_endstops.last_query["manual_stepper stepper_ercf_gear"]}
M118 ERCF home : {printer.query_endstops.last_query["manual_stepper stepper_ercf_selector"]}
# Query and display the status
[gcode_macro infos]
gcode:
QUERY_ENDSTOPS
ENDSTOPS_STATUS
###############################
# PAUSE MACROS
# PAUSE_ERCF is called when an human intervention is needed
# use ERCF_UNLOCK to unlock the ERCF and start the manual intervention
# and use RESUME when the invention is ended to resume the current print
###############################
# Stop the delayed stop of the heater
[gcode_macro ERCF_UNLOCK]
gcode:
M118 Resuming print
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_paused VALUE=0
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_changing_filament VALUE=0
UPDATE_DELAYED_GCODE ID=disable_heater DURATION=0
M109 S{printer["gcode_macro PAUSE_ERCF"].extruder_temp}
RESTORE_GCODE_STATE NAME=ERCF_state
[delayed_gcode disable_heater]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int != 0 %}
M118 Disabling extruder heater
M104 S0
{% endif %}
# Pause the ERCF
# Save the current state and start the delayed stop of the heated
# modify the timeout of the printer acorrdingly to timeout_pause
[gcode_macro PAUSE_ERCF]
variable_is_paused: 0
variable_extruder_temp: 0
variable_is_changing_filament: 0
gcode:
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=extruder_temp VALUE={printer.extruder.temperature}
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_paused VALUE=1
SET_IDLE_TIMEOUT TIMEOUT={printer["gcode_macro VAR_ERCF"].timeout_pause}
UPDATE_DELAYED_GCODE ID=disable_heater DURATION={printer["gcode_macro VAR_ERCF"].disable_heater}
M118 START PAUSE
SAVE_GCODE_STATE NAME=ERCF_state
{% for i in range(3) %}
M300
{% endfor %}
{% if printer["gcode_macro PAUSE_ERCF"].is_changing_filament|int != 0 %}
G91
G1 Z-3
RESTORE_GCODE_STATE NAME=ERCF_state
{% endif %}
PAUSE
############################################
# Changing tool macros
# CHANGE_TOOL_0, CHANGE_TOOL_1, ...CHANGE_TOOL_8 : Change extruder macro
# if the new extruder is different from the current extruder :
# eject the filament if needed
# load the new one
###########################################
[gcode_macro ACTIVATE_EXTRUDER]
rename_existing: CHANGE_TOOL
gcode:
{% if EXTRUDER == "extruder" %}
{% set index = '0' %}
{% elif EXTRUDER == "extruder1" %}
{% set index = '1' %}
{% elif EXTRUDER == "extruder2" %}
{% set index = '2' %}
{% elif EXTRUDER == "extruder3" %}
{% set index = '3' %}
{% elif EXTRUDER == "extruder4" %}
{% set index = '4' %}
{% elif EXTRUDER == "extruder5" %}
{% set index = '5' %}
{% elif EXTRUDER == "extruder6" %}
{% set index = '6' %}
{% elif EXTRUDER == "extruder7" %}
{% set index = '7' %}
{% elif EXTRUDER == "extruder8" %}
{% set index = '8' %}
{% endif %}
{% if printer["gcode_macro SELECT_TOOL"].color_selected|int != index %}
M117 Change Tool T{index}
G91
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_changing_filament VALUE=1
SAVE_GCODE_STATE NAME=ACTIVATE_EXTRUDER_state
G1 Z3
G90
UT
LT VALUE={index}
G91
G1 Z-3
RESTORE_GCODE_STATE NAME=ACTIVATE_EXTRUDER_state
G90
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_changing_filament VALUE=0
{% endif %}
############################################
# Unloading/Loading Macros
############################################
# Load filament from ERCF to nozzle
[gcode_macro LT]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
M118 LT {params.VALUE|int} ...
SELECT_TOOL VALUE={params.VALUE|int}
LOAD_FILAMENT_TO_EXTRUDER VALUE={params.VALUE|int}
LOAD_FILAMENT_IN_EXTRUDER
{% endif %}
# Unload filament from nozzle to ERCF
[gcode_macro UT]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].color_selected|int != -1 %}
M118 UT {printer["gcode_macro SELECT_TOOL"].color_selected|int} ...
UNLOAD_FILAMENT_IN_EXTRUDER_WITH_RAMMING
SELECT_TOOL VALUE={printer["gcode_macro SELECT_TOOL"].color_selected|int}
UNLOAD_FILAMENT_FROM_EXTRUDER VALUE={printer["gcode_macro SELECT_TOOL"].color_selected|int}
{% endif %}
{% endif %}
############################################
# Select/Unselect a tool
# move the selector (if needed) to the requested tool (0-4)
############################################
# Select a tool. move the idler and then move the color selector (if needed)
[gcode_macro SELECT_TOOL]
variable_tool_selected: -1
variable_color_selected: -1
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro HOME_ERCF"].home != -1 %}
M118 Select Tool {params.VALUE} ...
SERVO_UP
MANUAL_STEPPER STEPPER=stepper_ercf_selector MOVE={printer["gcode_macro VAR_ERCF"].colorselector[params.VALUE|int]} SPEED=100 ACCEL=200
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=tool_selected VALUE={params.VALUE}
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=color_selected VALUE={params.VALUE}
SERVO_DOWN
M118 Tool {params.VALUE} Enabled
{% else %}
M118 Could not select tool, ERCF is not homed
{% endif %}
{% else %}
M118 Could not select tool, ERCF is paused
{% endif %}
# Unselect a tool
[gcode_macro UNSELECT_TOOL]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro HOME_ERCF"].home != -1 %}
SERVO_UP
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=tool_selected VALUE=-1
{% else %}
M118 Could not unselect tool, ERCF is not homed
{% endif %}
{% endif %}
############################################
# Loading/Unloading part FROM/TO EXTRUDER TO/FROM NOZZLE
# During loading, if the IR sensor does not detect the filament, it tries 3 times to reinsert it
############################################
# Load the filament into the extruder
# the ERCF push the filament of 20mm and the extruder gear try to insert it into the nozzle
# if the filament is not detected by the IR, call RETRY_LOAD_FILAMENT_IN_EXTRUDER 3 times
# Call PAUSE_ERCF if the filament is not detected by the IR sensor
[gcode_macro LOAD_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer.extruder.temperature > printer["gcode_macro VAR_ERCF"].min_temp_extruder %}
M118 Loading Filament...
G91
G92 E0
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=35 SPEED=20 ACCEL=0 SYNC=0
SAVE_GCODE_STATE NAME=LOAD_FILAMENT_IN_EXTRUDER_state
G1 E35.00 F1200.0
G4 P500
UNSELECT_TOOL
G1 E6.3 F300
G1 E16 F1800
INFOS
{% for i in range(10) %}
RETRY_LOAD_FILAMENT_IN_EXTRUDER
{% endfor %}
IS_FILAMENT_IN_EXTRUDER
G1 E15 F1800
G1 E16 F1393
G1 E15 F614
RESTORE_GCODE_STATE NAME=LOAD_FILAMENT_IN_EXTRUDER_state
G92 E0
G90
M118 Load Complete
{% else %}
M118 Extruder too cold
PAUSE_ERCF
{% endif %}
{% endif %}
# Try to reinsert the filament into the extruder
# Called when the IR sensor does not detect the filament
[gcode_macro RETRY_LOAD_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["filament_switch_sensor ir_sensor"].filament_detected == False %}
M118 Retry loading ....
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer.extruder.temperature > printer["gcode_macro VAR_ERCF"].min_temp_extruder %}
M118 Loading Filament...
G91
G92 E0
SERVO_DOWN
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=5 SPEED=20 ACCEL=0 SYNC=0
SAVE_GCODE_STATE NAME=RETRY_LOAD_FILAMENT_IN_EXTRUDER_state
G1 E5.00 F1200.0
RESTORE_GCODE_STATE NAME=RETRY_LOAD_FILAMENT_IN_EXTRUDER_state
G4 P500
UNSELECT_TOOL
G92 E0
G90
QUERY_ENDSTOPS
{% endif %}
{% endif %}
{% endif %}
# Unload the filament from the nozzle (without RAMMING !!!)
# Retract the filament from the nozzle to the out of the extruder gear
# Call PAUSE_ERCF if the IR sensor detects the filament after the ejection
[gcode_macro UNLOAD_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer.extruder.temperature > printer["gcode_macro VAR_ERCF"].min_temp_extruder %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int == -1 %}
M118 Unloading Filament...
G91
SAVE_GCODE_STATE NAME=UNLOAD_FILAMENT_IN_EXTRUDER_state
G1 E-45 F3000
RESTORE_GCODE_STATE NAME=UNLOAD_FILAMENT_IN_EXTRUDER_state
G90
G92 E0
INFOS
{% for i in range(3) %}
RETRY_UNLOAD_FILAMENT_IN_EXTRUDER
{% endfor %}
IS_FILAMENT_STUCK_IN_EXTRUDER
M118 Filament removed
{% else %}
M118 Tool selected, UNSELECT it
PAUSE_ERCF
{% endif %}
{% else %}
M118 Extruder too cold
PAUSE_ERCF
{% endif %}
{% endif %}
# Retry unload, try correct misalignement of bondtech gear
[gcode_macro RETRY_UNLOAD_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["filament_switch_sensor ir_sensor"].filament_detected == True %}
M118 Retry unloading ....
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer.extruder.temperature > printer["gcode_macro VAR_ERCF"].min_temp_extruder %}
M118 Unloading Filament...
G91
SAVE_GCODE_STATE NAME=RETRY_UNLOAD_FILAMENT_IN_EXTRUDER_state
G1 E-45 F3000
RESTORE_GCODE_STATE NAME=RETRY_UNLOAD_FILAMENT_IN_EXTRUDER_state
G90
G92 E0
{% endif %}
{% endif %}
{% endif %}
# Ramming process for ABS+
[gcode_macro RAMMING_SLICER]
gcode:
G91
G92 E0
G1 E-9.05 F1200
G1 E0.68 F165
G1 E0.70 F168
G1 E0.73 F177
G1 E0.78 F189
G1 E0.82 F197
G1 E0.84 F204
G1 E0.90 F216
G1 E0.97 F234
G1 E1.02 F246
G1 E1.04 F250
G1 E-15.00 F6000.0
G1 E-24.50 F5400.0
G1 E-7.00 F2700.0
G1 E-3.50 F1620.0
G1 E20.00 F900.0
G1 E-13 F500.0
G1 E13 F400.0
G1 E-11 F500.0
G1 E11 F400.0
G1 E-2.00 F50.0
G1 E-4.00 F1200.0
G1 E-10.00 F2000
G92 E0
# Unload from extruder with ramming
[gcode_macro UNLOAD_FILAMENT_IN_EXTRUDER_WITH_RAMMING]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer.extruder.temperature > printer["gcode_macro VAR_ERCF"].min_temp_extruder %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int == -1 %}
M118 Ramming and Unloading Filament...
G91
RAMMING_SLICER
UNLOAD_FILAMENT_IN_EXTRUDER
M118 Filament rammed and removed
{% else %}
M118 Tool selected, UNSELECT it
PAUSE_ERCF
{% endif %}
{% else %}
M118 Extruder too cold
PAUSE_ERCF
{% endif %}
{% endif %}
############################################
# Loading/Unloading MACROS from ERCF to the enter of the extruder gear
############################################
# Load filament until the ERCF detects it and pushes it 10mm more to be sure it's well detected
# PAUSE_ERCF is called if the ERCF does not detect the filament
[gcode_macro LOAD_FILAMENT_TO_ERCF]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int != -1 %}
M118 Loading filament to ERCF...
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE={printer["gcode_macro VAR_ERCF"].ercf_load_length} SPEED=40 ACCEL=20 STOP_ON_ENDSTOP=2
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=60 SPEED=50 ACCEL=50
IS_FILAMENT_IN_ERCF
M118 Loading done to ERCF
{% else %}
M118 Cannot load to ERCF, tool not selected !!
{% endif %}
{% endif %}
# Load from the ERCF to the extruder gear
[gcode_macro LOAD_FILAMENT_FROM_ERCF_TO_EXTRUDER]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int != -1 %}
M118 Loading filament from ERCF to extruder ...
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE={printer["gcode_macro VAR_ERCF"].bowden_load_length[params.VALUE|int] + printer["gcode_macro VAR_ERCF"].bowden_global_shift} SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
M118 Loading done from ERCF to extruder
{% else %}
M118 Cannot load to extruder, tool not selected !!
{% endif %}
{% endif %}
# Load from ERCF to extruder gear by calling LOAD_FILAMENT_TO_ERCF and next LOAD_FILAMENT_FROM_ERCF_TO_EXTRUDER
# PAUSE_ERCF is called if the ERCF does not detect the filament
[gcode_macro LOAD_FILAMENT_TO_EXTRUDER]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int != -1 %}
M118 Loading filament from ERCF to extruder ...
LOAD_FILAMENT_TO_ERCF
LOAD_FILAMENT_FROM_ERCF_TO_EXTRUDER VALUE={params.VALUE|int}
{% else %}
M118 Cannot load to extruder, tool not selected !!
{% endif %}
{% endif %}
# Unload filament until the ERCF stops detecting it and then pushes it more to ensure filament is not in the selector anymore (but still in the gears)
# PAUSE_ERCF is called if the ERCF does detect the filament after this procedure
[gcode_macro UNLOAD_FILAMENT_FROM_ERCF]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int != -1 %}
M118 Unloading filament from ERCF...
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=-90 SPEED=40 ACCEL=25 STOP_ON_ENDSTOP=-2
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=-{printer["gcode_macro VAR_ERCF"].ercf_unload_length} SPEED=40 ACCEL=35
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
IS_FILAMENT_STUCK_IN_ERCF
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=color_selected VALUE=-1
M118 Unloading done from ERCF
{% else %}
M118 Cannot unload from ERCF, tool not selected !!
{% endif %}
{% else %}
M118 Cannot unload from ERCF, ERCF is paused !!
{% endif %}
# Unload from extruder gear to the ERCF
[gcode_macro UNLOAD_FILAMENT_FROM_EXTRUDER_TO_ERCF]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int != -1 %}
M118 Unloading filament from extruder to ERCF...
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=-{printer["gcode_macro VAR_ERCF"].bowden_load_length[params.VALUE|int] + 10} SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
M118 Unloading done from ERCF to extruder
{% else %}
M118 Cannot unload from extruder to ERCF, tool not selected !!
{% endif %}
{% endif %}
# Unload from the extruder gear to the ERCF by calling UNLOAD_FILAMENT_FROM_EXTRUDER_TO_ERCF and next UNLOAD_FILAMENT_FROM_ERCF
[gcode_macro UNLOAD_FILAMENT_FROM_EXTRUDER]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro SELECT_TOOL"].tool_selected|int != -1 %}
M118 Unloading filament from extruder to ERCF...
G91
G92 E0
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE=-30 SPEED=20 ACCEL=0 SYNC=0
SAVE_GCODE_STATE NAME=UNLOAD_FILAMENT_FROM_EXTRUDER_state
G1 E-30.00 F1200.0
RESTORE_GCODE_STATE NAME=UNLOAD_FILAMENT_FROM_EXTRUDER_state
G4 P500
UNLOAD_FILAMENT_FROM_EXTRUDER_TO_ERCF VALUE={params.VALUE|int}
UNLOAD_FILAMENT_FROM_ERCF
M118 Unloading done from extruder to ERCF
{% else %}
M118 Cannot unload from extruder to ERCF, tool not selected !!
{% endif %}
{% endif %}
############################################
# Endstop check macros
# Verify the state of the ERCF or the IR sensor
############################################
# Call PAUSE_ERCF if the filament is not detected by the IR sensor
[gcode_macro IS_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["filament_switch_sensor ir_sensor"].filament_detected == True %}
M118 Filament in extruder
{% else %}
M118 Filament not in extruder
PAUSE_ERCF
{% endif %}
# Call PAUSE_ERCF if the filament is not detected by the ERCF
[gcode_macro IS_FILAMENT_IN_ERCF]
gcode:
QUERY_ENDSTOPS
IS_IN_ERCF
[gcode_macro IS_IN_ERCF]
gcode:
{% if printer.query_endstops.last_query["manual_stepper stepper_ercf_gear"] == 1 %}
M118 Filament in ERCF
{% else %}
M118 Filament not in ERCF
PAUSE_ERCF
{% endif %}
# Call PAUSE_ERCF if the filament is detected by the IR sensor
[gcode_macro IS_FILAMENT_STUCK_IN_EXTRUDER]
gcode:
{% if printer["filament_switch_sensor ir_sensor"].filament_detected == True %}
M118 Filament stuck in extruder
PAUSE_ERCF
{% else %}
M118 Filament not in extruder
{% endif %}
# Call PAUSE_ERCF if the filament is detected by the ERCF
[gcode_macro IS_FILAMENT_STUCK_IN_ERCF]
gcode:
QUERY_ENDSTOPS
IS_STUCK_IN_ERCF
[gcode_macro IS_STUCK_IN_ERCF]
gcode:
{% if printer.query_endstops.last_query["manual_stepper stepper_ercf_gear"] == 1 %}
M118 Filament stuck in ERCF
PAUSE_ERCF
{% else %}
M118 Filament not in ERCF
{% endif %}
############################################
# Macros called during homing to try to eject the filament if loaded
############################################
# Preheat the heater if needed and unload the filament with ramming
# eject from nozzle to extruder gear out
[gcode_macro EJECT_FROM_EXTRUDER]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["filament_switch_sensor ir_sensor"].filament_detected == True %}
M118 Filament in extruder, trying to eject it ..
M118 Preheat Nozzle
M109 S{printer["gcode_macro VAR_ERCF"].extruder_eject_temp}
UNLOAD_FILAMENT_IN_EXTRUDER_WITH_RAMMING
M104 S0
{% else %}
M118 Filament not in extruder
{% endif %}
{% endif %}
# Eject from extruder gear to ERCF
[gcode_macro EJECT_BEFORE_HOME]
gcode:
M118 Eject Filament if loaded ...
{% if printer["filament_switch_sensor ir_sensor"].filament_detected == True %}
EJECT_FROM_EXTRUDER
IS_FILAMENT_STUCK_IN_EXTRUDER
{% endif %}
{% if printer.query_endstops.last_query["manual_stepper stepper_ercf_gear"] == 1 %}
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=tool_selected VALUE=0
SERVO_DOWN
UNLOAD_FILAMENT_FROM_EXTRUDER value=0
IS_FILAMENT_STUCK_IN_ERCF
M118 Filament ejected !
{% else %}
M118 Filament already ejected !
{% endif %}
############################################
# Homing macros
# HOME_ERCF must be called before using the ERCF
############################################
# Home the ERCF
# eject filament if loaded with EJECT_BEFORE_HOME
# next home the ERCF with HOME_ERCF_ONLY
[gcode_macro HOME_ERCF]
variable_home: -1
gcode:
M118 Homing ERCF ...
{% if "z" not in printer.toolhead.homed_axes %} ; Home if needed
G28
{% endif %}
SET_FILAMENT_SENSOR SENSOR=ir_sensor ENABLE=0
SET_GCODE_VARIABLE MACRO=HOME_ERCF VARIABLE=home VALUE=0 # as not homed yet, shouldn't this be 0?
QUERY_ENDSTOPS
EJECT_BEFORE_HOME
HOME_ERCF_ONLY
# Home the ERCF:
# 1) home the color selector (if needed)
# 2) try to load filament 0 to ERCF and then unload it. Used to verify the ERCF gear
# if all is ok, the ERCF is ready to be used
[gcode_macro HOME_ERCF_ONLY]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
M118 Homing selector
SERVO_UP
MANUAL_STEPPER STEPPER=stepper_ercf_selector SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_selector MOVE=-190 STOP_ON_ENDSTOP=1
MANUAL_STEPPER STEPPER=stepper_ercf_selector SET_POSITION=0
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=tool_selected VALUE=-1
SET_GCODE_VARIABLE MACRO=SELECT_TOOL VARIABLE=color_selected VALUE=-1
M118 Test load filament 1
SELECT_TOOL VALUE=0
LOAD_FILAMENT_TO_ERCF
G4 P500
UNLOAD_FILAMENT_FROM_ERCF
UNSELECT_TOOL
SET_GCODE_VARIABLE MACRO=HOME_ERCF VARIABLE=home VALUE=1
M118 Homing ERCF ended ...
{% else %}
M118 Homing ERCF failed, ERCF is paused, unlock it ...
{% endif %}
###############################################
# Test and Calibration Macros
###############################################
[gcode_macro MOVE_GEAR_REL]
gcode:
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE={params.VALUE|int}
[gcode_macro MOVE_GEAR_ABS]
gcode:
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE={params.VALUE|int} SPEED=90 ACCEL=40
[gcode_macro CALIB_START]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
UNLOAD_FILAMENT_FROM_ERCF
SELECT_TOOL VALUE={params.CHANNEL|int}
LOAD_FILAMENT_TO_ERCF
MANUAL_STEPPER STEPPER=stepper_ercf_gear SET_POSITION=0
MANUAL_STEPPER STEPPER=stepper_ercf_gear MOVE={printer["gcode_macro VAR_ERCF"].bowden_load_length[params.CHANNEL|int]} SPEED=90 ACCEL=40
{% else %}
M118 Cannot run calibration, ERCF is paused !!
{% endif %}