-
Notifications
You must be signed in to change notification settings - Fork 4
/
ercf_macros_v1.cfg
937 lines (858 loc) · 36.4 KB
/
ercf_macros_v1.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
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
###############################
# Parameters you need to adapt
###############################
[gcode_macro VAR_ERCF]
# Toolhead specific values
variable_sensor_to_nozzle: 60.0 # Length from the sensor to the nozzle melting pool
variable_end_of_bowden_to_sensor: 36.0 # Distance between the end of the reverse bowden and the toolhead sensor. Value is toolhead specific
variable_bowden_load_length: [762.0, 760.5, 761.0, 757.0, 759.5, 758.0] # Channel loading distance determined by the auto-calibration macro of the ERCF. Please scale this array to the number of channels you have
variable_min_bowden_length: 710 # Base value for the loading length used by the auto-calibration macro. Please use a value SMALLER than the real reverse bowden length (like 5cms less)
variable_colorselector = [2, 23, 43.5, 70, 91, 111.5] # Channel position for the selector. This has to be tubed by hand. Please scale this array to the number of channels you have
variable_servo_up_angle: 150 # Servo angle for the Up position (i.e. channel disengaged)
variable_servo_down_angle: 100 # Servo angle for the Down position (i.e. channel engaged)
# Options to use or not (please don't use endless spool mode for now)
variable_spare_tool_endless_mode: -1 # Put -1 to disable, or N to use a defined tool as the spare one (i.e. the one loaded with EndlessSpool mode ON)
# Things that you shouldn't have to change
variable_bowden_speed: 80 # Speed, in mm/s, for the reverse bowden load//unload phase
variable_bowden_accel: 70 # Accel, in mm/s², for the reverse bowden load//unload phase
variable_ercf_load_length: 35 # Load length, in mm, from the ERCF parking position to the ERCF selector det. Use the real distance + some safety margin
variable_ercf_unload_length: 25 # Distance, in mm, from the ERCF selector det to the parking position
variable_min_temp_extruder: 180 # Temp used during the auto-calibration macro, to ensure we can move the extruder (but not really extruding)
variable_extruder_eject_temp: 240 # Temp used during filament ejection (in the ERCF_HOME macro, if a filament is detected in the toolhead)
variable_timeout_pause: 72000 # Time out used by the ERCF_PAUSE
variable_disable_heater: 600 # Delay after which the hotend heater is disabled in the ERCF_PAUSE state
gcode:
###############################
# End of parameters you need to adapt
###############################
[respond]
default_type: command
###############################
# ERCF auto-calibration
###############################
[save_variables]
filename: /home/pi/klipper_config/ercf_vars.cfg
# Dump the auto-calibration variables in the console
[gcode_macro ERCF_DISPLAY_CALIBRATION]
gcode:
{% set path = printer.save_variables.variables %}
{% for chan in range(printer["gcode_macro VAR_ERCF"].bowden_load_length|length) %}
{% set varname = (ercf_calib_ + chan|string) %}
M118 Calibration values : {path[varname]}
{% endfor %}
# Auto-calibrate each channel loading length
# Once the macro is done, report the display values in the console into the "bowden_load_length" array at the beginning of this file
[gcode_macro ERCF_CALIBRATE_ALL]
gcode:
M118 Start the complete auto calibration...
M109 S{printer["gcode_macro VAR_ERCF"].min_temp_extruder|int}
{% for chan in range(printer["gcode_macro VAR_ERCF"].bowden_load_length|length) %}
ERCF_CALIBRATE_SINGLE CHANNEL={chan|int}
{% endfor %}
M118 End of the complete auto calibration!
ERCF_DISPLAY_CALIBRATION
[gcode_macro ERCF_CALIBRATE_SINGLE]
variable_calibration_value: 0
gcode:
{% if params.CHANNEL|int >= 0 and params.CHANNEL|int < printer["gcode_macro VAR_ERCF"].bowden_load_length|length %}
{% if printer["gcode_macro ERCF_HOME"].home == -1 %}
M118 First home the ERCF
ERCF_HOME
{% endif %}
M118 Calibrating channel {params.CHANNEL}
SELECT_TOOL VALUE={params.CHANNEL}
LOAD_FILAMENT_TO_ERCF
# Preload the filament slightly before the reverse bowden's end
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={printer["gcode_macro VAR_ERCF"].min_bowden_length} SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
SET_GCODE_VARIABLE MACRO=ERCF_CALIBRATE_SINGLE VARIABLE=calibration_value VALUE={printer["gcode_macro VAR_ERCF"].min_bowden_length|int}
# Slowly push the filament with both ERCF and Extruder, until the filament sensor below the extruder gears is ON
{% for try in range(40) %}
ERCF_PUSH_FOR_CALIBRATE
G4 P50
{% endfor %}
# Check that we reached the toolhead sensor
IS_FILAMENT_IN_EXTRUDER
# Retract until we're at the sensor edge
{% for try in range(80) %}
ERCF_PULL_FOR_CALIBRATE
G4 P50
{% endfor %}
ERCF_CALIB_SAVE_VAR CHANNEL={params.CHANNEL}
# Unload filament
ERCF_UNLOAD_FOR_CALIBRATE
{% else %}
M118 Channel out of range
{% endif %}
[gcode_macro ERCF_CALIB_SAVE_VAR]
gcode:
# Display the channel auto calib value
M118 Channel {params.CHANNEL} calibration value is {printer["gcode_macro ERCF_CALIBRATE_SINGLE"].calibration_value|float}
SAVE_VARIABLE VARIABLE=ercf_calib_{params.CHANNEL|int} VALUE={printer["gcode_macro ERCF_CALIBRATE_SINGLE"].calibration_value|float}
[gcode_macro ERCF_UNLOAD_FOR_CALIBRATE]
gcode:
G92 E0
{% set newpos = (printer["gcode_macro ERCF_CALIBRATE_SINGLE"].calibration_value|int - 80) %}
MANUAL_STEPPER STEPPER=gear_stepper MOVE={newpos|float} SPEED=15 ACCEL=0 SYNC=0
G1 E-80.00 F900.0
G4 P250
MANUAL_STEPPER STEPPER=gear_stepper MOVE=0 SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
UNLOAD_FILAMENT_FROM_ERCF
UNSELECT_TOOL
[gcode_macro ERCF_PUSH_FOR_CALIBRATE]
gcode:
{% if printer["filament_switch_sensor toolhead_sensor"].filament_detected == False %}
{% set newcalib = (printer["gcode_macro ERCF_CALIBRATE_SINGLE"].calibration_value|int + 5) %}
G92 E0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={newcalib|int} SPEED=15 ACCEL=0 SYNC=0
G1 E5.00 F900.0
# Increment the calibration value for this channel
SET_GCODE_VARIABLE MACRO=ERCF_CALIBRATE_SINGLE VARIABLE=calibration_value VALUE={newcalib|int}
{% endif %}
[gcode_macro ERCF_PULL_FOR_CALIBRATE]
gcode:
{% if printer["filament_switch_sensor toolhead_sensor"].filament_detected == True %}
{% set newcalib = (printer["gcode_macro ERCF_CALIBRATE_SINGLE"].calibration_value|float - 0.5) %}
G92 E0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={newcalib|float} SPEED=15 ACCEL=0 SYNC=0
G1 E-0.50 F900.0
# Decrement the calibration value for this channel
SET_GCODE_VARIABLE MACRO=ERCF_CALIBRATE_SINGLE VARIABLE=calibration_value VALUE={newcalib|float}
{% endif %}
###############################
# 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 P250
SERVO_OFF
G4 P50
SET_SERVO SERVO=revolver ANGLE={printer["gcode_macro VAR_ERCF"].servo_down_angle}
G4 P100
SERVO_OFF
G4 P100
SET_SERVO SERVO=revolver ANGLE={printer["gcode_macro VAR_ERCF"].servo_down_angle}
G4 P100
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 P250
SERVO_OFF
G4 P50
SET_SERVO SERVO=revolver ANGLE={printer["gcode_macro VAR_ERCF"].servo_up_angle}
G4 P100
SERVO_OFF
G4 P100
SET_SERVO SERVO=revolver ANGLE={printer["gcode_macro VAR_ERCF"].servo_up_angle}
G4 P100
SERVO_OFF
# Turn the servo off
[gcode_macro SERVO_OFF]
gcode:
SET_SERVO SERVO=revolver WIDTH=0
###############################
# 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 toolhead_sensor"].filament_detected}
M118 ERCF filament : {printer.query_endstops.last_query["manual_stepper gear_stepper"]}
M118 ERCF home : {printer.query_endstops.last_query["manual_stepper selector_stepper"]}
# Query and display the status
[gcode_macro ERCF_INFO]
gcode:
QUERY_ENDSTOPS
ENDSTOPS_STATUS
###############################
# PAUSE MACROS
# PAUSE_ERCF is called when an human intervention is needed
# use ERCF_UNLOCK to park the idler and start the manual intervention
# and use RESUME when the invention is ended to resume the current print
###############################
# park the idler, stop the delayed stop of the heater
[gcode_macro ERCF_UNLOCK]
gcode:
M118 Resume 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
SERVO_UP
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 Disable extruder heater
M104 S0
{% endif %}
# Pause the ERCF, park the extruder at the parking position
# 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:
SONG_PAUSE
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
{% if printer["gcode_macro PAUSE_ERCF"].is_changing_filament|int != 0 %}
G91
G1 Z3
G90
{% endif %}
PAUSE
############################################
# Changing tool macros
# CHANGE_TOOL_STANDALONE TOOL=XX to change filament outside of a print
# CHANGE_TOOL_SUSIE TOOL=XX will be called automatically (from the ACTIVATE_EXTRUDER gcode from SuperSlicer), don't use that for "manual" filament swap
# 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" %}
CHANGE_TOOL_SUSIE TOOL=0
{% elif EXTRUDER == "extruder1" %}
CHANGE_TOOL_SUSIE TOOL=1
{% elif EXTRUDER == "extruder2" %}
CHANGE_TOOL_SUSIE TOOL=2
{% elif EXTRUDER == "extruder3" %}
CHANGE_TOOL_SUSIE TOOL=3
{% elif EXTRUDER == "extruder4" %}
CHANGE_TOOL_SUSIE TOOL=4
{% elif EXTRUDER == "extruder5" %}
CHANGE_TOOL_SUSIE TOOL=5
{% elif EXTRUDER == "extruder6" %}
CHANGE_TOOL_SUSIE TOOL=6
{% elif EXTRUDER == "extruder7" %}
CHANGE_TOOL_SUSIE TOOL=7
{% elif EXTRUDER == "extruder8" %}
CHANGE_TOOL_SUSIE TOOL=8
{% endif %}
[gcode_macro CHANGE_TOOL_SUSIE]
gcode:
{% if printer["gcode_macro SELECT_TOOL"].color_selected|int != params.TOOL|int %}
# Preview of the EndlessSpool mode, don't use for now please
#{% if printer["gcode_macro PRINT_START"].endlessspoolvar|int == 1 %}
# SET_FILAMENT_SENSOR SENSOR=ERCF_sensor ENABLE=0
#{% endif %}
# Add a variable 'SwapCounter' in your PRINT_START macro to display this info
# {% set newcounter = (printer["gcode_macro PRINT_START"].SwapCounter|int + 1) %}
# SET_GCODE_VARIABLE MACRO=PRINT_START VARIABLE=SwapCounter VALUE={newcounter}
# M118 Swap {newcounter|int}
M117 Change Tool T{params.TOOL|int}
G91
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_changing_filament VALUE=1
G1 Z3
G90
UT
LT VALUE={params.TOOL|int}
G91
G1 Z-3
G90
SET_GCODE_VARIABLE MACRO=PAUSE_ERCF VARIABLE=is_changing_filament VALUE=0
# Preview of the EndlessSpool mode, don't use for now please
#CHANGE_TOOL_SUSIE_END
{% endif %}
# Preview of the EndlessSpool mode, don't use for now please
#[gcode_macro CHANGE_TOOL_SUSIE_END]
#gcode:
# {% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
# {% if printer["gcode_macro PRINT_START"].endlessspoolvar|int == 1 %}
# SET_FILAMENT_SENSOR SENSOR=ERCF_sensor ENABLE=1
# {% endif %}
# {% endif %}
[gcode_macro CHANGE_TOOL_STANDALONE]
gcode:
{% if printer["gcode_macro SELECT_TOOL"].color_selected|int != params.TOOL|int %}
M117 Change Tool T{params.TOOL|int}
UT_RAMMING
LT VALUE={params.TOOL|int}
{% 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, using built-in Ramming macro
[gcode_macro UT_RAMMING]
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_TIP_FORMING
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 %}
# Unload filament from nozzle to ERCF, using SuperSlicer ramming
[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} ...
G91
G1 E-20 F3000
G90
G92 E0
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 ERCF_HOME"].home != -1 %}
M118 Select Tool {params.VALUE} ...
SERVO_UP
MANUAL_STEPPER STEPPER=selector_stepper 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 %}
{% endif %}
# Unselect a tool
[gcode_macro UNSELECT_TOOL]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
{% if printer["gcode_macro ERCF_HOME"].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 Toolhead 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 Toolhead, call RETRY_LOAD_FILAMENT_IN_EXTRUDER 3 times
# Call PAUSE_ERCF if the filament is not detected by the Toolhead 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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={printer["gcode_macro VAR_ERCF"].end_of_bowden_to_sensor|float} SPEED=15 ACCEL=0 SYNC=0
G1 E{printer["gcode_macro VAR_ERCF"].end_of_bowden_to_sensor|float} F900.0
G4 P500
UNSELECT_TOOL
G1 E15 F1800
ERCF_INFO
{% for try in range(10) %}
RETRY_LOAD_FILAMENT_IN_EXTRUDER
{% endfor %}
IS_FILAMENT_IN_EXTRUDER
G1 E{printer["gcode_macro VAR_ERCF"].sensor_to_nozzle - 20} F1800
G1 E5 F600
G92 E0
G90
M118 Load Complete
{% else %}
M118 Extruder too cold
PAUSE_ERCF
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
# Try to reinsert the filament into the extruder
# Called when the Toolhead sensor does not detect the filament
[gcode_macro RETRY_LOAD_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["filament_switch_sensor toolhead_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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE=7 SPEED=15 ACCEL=0 SYNC=0
G1 E7.00 F900.0
G4 P500
UNSELECT_TOOL
G92 E0
G90
QUERY_ENDSTOPS
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
{% endif %}
# Unload the filament from the nozzle AFTER the SuperSlicer tip forming
# Call PAUSE_ERCF if the IR sensor detects the filament after the ejection
[gcode_macro UNLOAD_FILAMENT_IN_EXTRUDER_WITH_SUSIE]
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
G1 E-30 F3000
G90
G92 E0
ERCF_INFO
{% for try 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 %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
# Unload the filament from the nozzle (without RAMMING or tip forming)
# 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
G1 E-50 F3000
G90
G92 E0
ERCF_INFO
{% for try 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 %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
# Retry unload, try correct misalignement of bondtech gear
[gcode_macro RETRY_UNLOAD_FILAMENT_IN_EXTRUDER]
gcode:
{% if printer["filament_switch_sensor toolhead_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
G1 E-45 F3000
G90
G92 E0
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
{% endif %}
# StandAlone cooling moves to extract proper filament tip
[gcode_macro FORM_TIP]
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 tip forming sequence
[gcode_macro UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING]
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 Forming tip and Unloading Filament...
G91
FORM_TIP
UNLOAD_FILAMENT_IN_EXTRUDER
M118 Filament tip formed and removed
{% else %}
M118 Tool selected, UNSELECT it
PAUSE_ERCF
{% endif %}
{% else %}
M118 Extruder too cold
PAUSE_ERCF
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
############################################
# Loading/Unloading MACROS from ERCF to the enter of the extruder gear
############################################
# Load filament until the ERCF detects it and pushes it 60mm 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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={printer["gcode_macro VAR_ERCF"].ercf_load_length} SPEED=40 ACCEL=20 STOP_ON_ENDSTOP=2
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE=60 SPEED=25 ACCEL=50
QUERY_ENDSTOPS
{% for try in range(3) %}
RETRY_LOAD_FILAMENT_IN_ERCF
{% endfor %}
IS_FILAMENT_IN_ERCF
M118 Loading done to ERCF
{% else %}
M118 Cannot load to ERCF, tool not selected !!
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
# Try to reinsert the filament into the extruder
# Called when the Toolhead sensor does not detect the filament
[gcode_macro RETRY_LOAD_FILAMENT_IN_ERCF]
gcode:
{% if printer.query_endstops.last_query["manual_stepper gear_stepper"] != 1 %}
M118 Retry loading ....
SERVO_UP
G4 P1000
SERVO_DOWN
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={printer["gcode_macro VAR_ERCF"].ercf_load_length} SPEED=40 ACCEL=20 STOP_ON_ENDSTOP=2
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE=60 SPEED=25 ACCEL=50
QUERY_ENDSTOPS
{% 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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={printer["gcode_macro VAR_ERCF"].bowden_load_length[params.VALUE|int] - printer["gcode_macro VAR_ERCF"].end_of_bowden_to_sensor} SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
{% else %}
M118 Cannot load to extruder, tool not selected !!
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% 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 %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% 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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE=-100 SPEED=25 ACCEL=50 STOP_ON_ENDSTOP=-2
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro VAR_ERCF"].ercf_unload_length} SPEED=25 ACCEL=50
MANUAL_STEPPER STEPPER=gear_stepper 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 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% 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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper 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} STOP_ON_ENDSTOP=-2
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
M118 Unloading done from ERCF to extruder
{% else %}
M118 Cannot unload from extruder to ERCF, tool not selected !!
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% 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=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE=-40 SPEED=15 ACCEL=0 SYNC=0
G1 E-40.00 F900.0
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 %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% 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 toolhead_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 gear_stepper"] == 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 toolhead_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 gear_stepper"] == 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 toolhead_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_TIP_FORMING
M104 S0
{% else %}
M118 Filament not in extruder
{% endif %}
{% else %}
M118 ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
# Eject from extruder gear to ERCF
[gcode_macro EJECT_BEFORE_HOME]
gcode:
M118 Eject Filament if loaded ...
{% if printer["filament_switch_sensor toolhead_sensor"].filament_detected == True %}
EJECT_FROM_EXTRUDER
IS_FILAMENT_STUCK_IN_EXTRUDER
{% endif %}
{% if printer.query_endstops.last_query["manual_stepper gear_stepper"] == 1 %}
M109 S{printer["gcode_macro VAR_ERCF"].extruder_eject_temp}
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
# ERCF_HOME must be called before using the ERCF
############################################
# Home the ERCF
# eject filament if loaded with EJECT_BEFORE_HOME
# next home the ERCF with ERCF_HOME_ONLY
[gcode_macro ERCF_HOME]
variable_home: -1
gcode:
SET_FILAMENT_SENSOR SENSOR=toolhead_sensor ENABLE=0
# Preview of the EndlessSpool mode, don't use for now please
#SET_FILAMENT_SENSOR SENSOR=ERCF_sensor ENABLE=0
SET_GCODE_VARIABLE MACRO=ERCF_HOME VARIABLE=home VALUE=1
M118 Homing ERCF ...
QUERY_ENDSTOPS
EJECT_BEFORE_HOME
ERCF_HOME_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 ERCF_HOME_ONLY]
gcode:
{% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
M118 Homing selector
SERVO_UP
MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=selector_stepper MOVE=-190 STOP_ON_ENDSTOP=1
MANUAL_STEPPER STEPPER=selector_stepper 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=ERCF_HOME VARIABLE=home VALUE=1
M118 Homing ERCF ended ...
{% else %}
M118 Homing ERCF failed, ERCF is paused, run "ERCF_UNLOCK" to unlock it
{% endif %}
###############################################
# Test Macros
###############################################
[gcode_macro MOVE_GEAR_REL]
gcode:
MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0
MANUAL_STEPPER STEPPER=gear_stepper MOVE={params.VALUE|int} SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
[gcode_macro MOVE_GEAR_ABS]
gcode:
MANUAL_STEPPER STEPPER=gear_stepper MOVE={params.VALUE|int} SPEED={printer["gcode_macro VAR_ERCF"].bowden_speed} ACCEL={printer["gcode_macro VAR_ERCF"].bowden_accel}
# Push the servo down (enable the bondtech gears)
[gcode_macro SERVO_TEST]
gcode:
SET_SERVO SERVO=revolver ANGLE={params.VALUE|int}
G4 P1000
SERVO_OFF
# Preview of the EndlessSpool mode, don't use for now please
#[gcode_macro ERCF_RUNOUT]
#gcode:
# M118 Runout on tool{printer["gcode_macro SELECT_TOOL"].color_selected|int}
# SET_FILAMENT_SENSOR SENSOR=ERCF_sensor ENABLE=0
# #Case for regular endless spool mode (swap to tool + 1)
# {% if printer["gcode_macro VAR_ERCF"].spare_tool_endless_mode|int == -1 %}
# {% if printer["gcode_macro SELECT_TOOL"].color_selected|int >= (printer["gcode_macro VAR_ERCF"].bowden_load_length|length -1) %}
# {% set nexttool = 0 %}
# {% else %}
# {% set nexttool = (printer["gcode_macro SELECT_TOOL"].color_selected|int + 1) %}
# {% endif %}
# {% else %}
# #Case for spare tool mode (always swap to a specific tool, unless this is this tool that has runout, in this case, does nothing and warn the user
# {% if printer["gcode_macro SELECT_TOOL"].color_selected|int != printer["gcode_macro VAR_ERCF"].spare_tool_endless_mode|int %}
# {% set nexttool = printer["gcode_macro VAR_ERCF"].spare_tool_endless_mode|int %}
# {% else %}
# {% set nexttool = -1 %}
# {% endif%}
# {% endif %}
#
# {% if nexttool != -1 %}
# M118 Loading tool{nexttool|int}
# G0 X45 Y300 F18000
# SAVE_GCODE_STATE NAME=ERCF_Pre_Brush_init
# G0 X45 Y310 Z1 F3000
# CHANGE_TOOL_STANDALONE TOOL={nexttool|int}
# ERCF_CHECK_IF_RESUME
# {% endif %}
# Preview of the EndlessSpool mode, don't use for now please
#[gcode_macro ERCF_CHECK_IF_RESUME]
#gcode:
# {% if printer["gcode_macro PAUSE_ERCF"].is_paused|int == 0 %}
# BRUSH_PURGE
# BRUSH_CLEAN
# RESTORE_GCODE_STATE NAME=ERCF_Pre_Brush_init
# RESUME
# SET_FILAMENT_SENSOR SENSOR=ERCF_sensor ENABLE=1
# {% endif %}