diff --git a/config/config/ercf/client_macros.cfg b/config/config/ercf/client_macros.cfg index 6c1268c..a837166 100644 --- a/config/config/ercf/client_macros.cfg +++ b/config/config/ercf/client_macros.cfg @@ -45,13 +45,13 @@ gcode: [gcode_macro RESUME] rename_existing: BASE_RESUME gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int != 0 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int != 0 %} M118 You can't resume the print without unlocking the ERCF first. M118 Run ERCF_UNLOCK and solve any issue before hitting Resume again {% else %} RESTORE_GCODE_STATE NAME=PAUSE_state G90 - {% if printer["gcode_macro ERCF_VAR"].clog_detection|int == 1 %} + {% if printer["gcode_macro _ERCF_VAR"].clog_detection|int == 1 %} SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1 {% endif %} BASE_RESUME diff --git a/config/config/ercf/ercf_hardware.cfg b/config/config/ercf/ercf_hardware.cfg index 563321f..ccf0f4d 100644 --- a/config/config/ercf/ercf_hardware.cfg +++ b/config/config/ercf/ercf_hardware.cfg @@ -1,43 +1,58 @@ ## Enraged Rabbit : Carrot Feeder V1.1 hardware config file +# Values are an example for voron 2.4 with 2 SKR1.4 +# Carrot Feeder 5mm D-cut shaft +# Example for an SKR 1.4 Board (E1 on the XY mcu) [manual_stepper gear_stepper] step_pin: mcu2:PD8 dir_pin: mcu2:PB12 enable_pin: !mcu2:PD9 rotation_distance: 22.6789511 #Bondtech 5mm Drive Gears gear_ratio: 80:20 -microsteps: 16 -full_steps_per_rotation: 200 +microsteps: 16 # Please do not go higher than 16, this can cause 'MCU Timer too close' issues under Klipper +full_steps_per_rotation: 200 #200 for 1.8 degree, 400 for 0.9 degree velocity: 35 accel: 150 #Right now no pin is used for the endstop, but we need to define one for klipper. So just use a random, not used pin endstop_pin: mcu2:PB7 [tmc2209 manual_stepper gear_stepper] +# Adapt accordingly to your setup and desires +# The default values are tested with the BOM NEMA14 motor +# Please adapt those values to the motor you are using +# Example : for NEMA17 motors, you'll usually set the stealthchop_threshold to 0 +# and use higher current uart_pin: mcu2:PE15 interpolate: True run_current: 0.40 hold_current: 0.1 sense_resistor: 0.110 - -# Carrot Feeder selector -[manual_stepper selector_stepper] -step_pin: mcu2:PE11 -dir_pin: mcu2:PE10 -enable_pin: !mcu2:PE9 -microsteps: 16 -rotation_distance: 40 -full_steps_per_rotation: 200 #200 for 1.8 degree, 400 for 0.9 degree -velocity: 200 -accel: 600 -endstop_pin: mcu2:PA1 +stealthchop_threshold: 500 [tmc2209 manual_stepper selector_stepper] uart_pin: mcu2:PE7 run_current: 0.55 interpolate: True sense_resistor: 0.110 -stealthchop_threshold: 5000 +stealthchop_threshold: 500 +# Uncomment the lines below if you want to use sensorless homing for the selector +#diag_pin: ^P1.27 # Set to MCU pin connected to TMC DIAG pin +#driver_SGTHRS: 75 # 255 is most sensitive value, 0 is least sensitive + +# Carrot Feeder selector +# Example for an SKR 1.4 Board (Z1 on the XY mcu) +[manual_stepper selector_stepper] +step_pin: mcu2:PE11 +dir_pin: mcu2:PE10 +enable_pin: !mcu2:PE9 +microsteps: 16 # Please do not go higher than 16, this can cause 'MCU Timer too close' issues under Klipper +rotation_distance: 40 +full_steps_per_rotation: 200 #200 for 1.8 degree, 400 for 0.9 degree +velocity: 200 +accel: 600 +# Select the endstop you want depending if you are using sensorless homing for the selector or not +endstop_pin: mcu2:PA1 +#endstop_pin: tmc2209_selector_stepper:virtual_endstop # Values are for the MG90S servo [servo ercf_servo] @@ -54,9 +69,9 @@ pins: mcu2:PA0 [filament_motion_sensor encoder_sensor] switch_pin: ^mcu2:PA0 pause_on_runout: False -detection_length: 4.0 +detection_length: 10.0 extruder: extruder -# runout_gcode: ERCF_ENCODER_MOTION_ISSUE +# runout_gcode: _ERCF_ENCODER_MOTION_ISSUE [filament_switch_sensor toolhead_sensor] pause_on_runout: False diff --git a/config/config/ercf/ercf_software.cfg b/config/config/ercf/ercf_software.cfg index d725076..6ed0855 100644 --- a/config/config/ercf/ercf_software.cfg +++ b/config/config/ercf/ercf_software.cfg @@ -15,7 +15,8 @@ long_moves_accel: 400 # mm/s². Default value is 400mm/s² short_moves_speed: 25 # mm/s. Default value is 25mm/s. short_moves_accel: 400 # mm/s². Default value is 400mm/s² -[gcode_macro ERCF_VAR] +[gcode_macro _ERCF_VAR] +description: Empty macro to store ERCF variables # ======================================================= # ================== VALUES TO ADJUST =================== # ======================================================= @@ -27,7 +28,7 @@ short_moves_accel: 400 # mm/s². Default value is 400mm/s² # Galileo Clockwork with ERCF V1.1 sensor (hall effect) : 27.0 # LGX on AfterBurner with ERCF V1.1 sensor (hall effect) : 44.0 # AfterBurner Clockwork with ERCF V1.1 sensor (hall effect) : 36.0 -variable_end_of_bowden_to_sensor: 36.0 +variable_end_of_bowden_to_sensor: 27.0 # Length from the sensor to the nozzle melt pool. # Reduce this value if there are blobs of filament on each load, before the purge on the tower. # Increase this value if there are big gaps on the purge tower (i.e. if it takes time for the filament to get pushed out after a swap) @@ -35,7 +36,7 @@ variable_end_of_bowden_to_sensor: 36.0 # Galileo Clockwork with ERCF 1.1 sensor (hall effect) & Dragon Normal Flow : 60.5 # LGX on AfterBurner with ERCF 1.1 sensor (hall effect) & Dragon Normal Flow : 55.6 # AfterBurner Clockwork with ERCF 1.1 sensor (hall effect) & Dragon Normal Flow : 54.0 -variable_sensor_to_nozzle: 54.0 +variable_sensor_to_nozzle: 60.5 # # ==== Values to tune ==== # @@ -54,12 +55,24 @@ variable_servo_up_angle: 30 # MG90S servo : 140 # SAVOX SH0255MG : 30 variable_servo_down_angle: 140 +# Threshold for the final load check (i.e. the move from the toolhead sensor to the nozzle) +# Check the _ERCF_GET_LOAD_THRESHOLD command to get the proper value for your setup +variable_final_load_check_threshold: 10.0 # Options to use or not # Beware that the clog detection and endless spool mode are in BETA mode for now # Use at your own risk (beware of the involved macros and the pause(s) and resume ones) # Put 0 to disable, 1 to enable variable_clog_detection: 0 variable_endless_spool_mode: 0 +variable_sensorless_selector: 0 +# The hair puller move is an extruder move that extrudes during an unload, +# right before the long unload move done by the ercf. The purpose is to pull off any +# potential long hair from the filament tip. This small extrusion move is done after +# the ercf has already unloaded the length defined by the unload_move_before_hair_pulling. +# Put 0 to disable, 1 to enable +variable_hair_puller_move: 0 +variable_unload_move_before_hair_pulling: 20.0 + # ======================================================= # ============ END OF VALUES TO ADJUST ================== # ======================================================= @@ -69,8 +82,12 @@ variable_endless_spool_mode: 0 variable_unload_modifier: 9.0 # Modifier to adjust the ERCF park position (where the filament ends when doing an unload) 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 +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 +variable_gear_stepper_accel: 0 # The acceleration value applied to the gear stepper on moves, standard is to use 0 +variable_extra_servo_dwell_up: 0 # Additional dwell time in ms to apply to dwell prior to turning off the servo +variable_extra_servo_dwell_down: 0 # Additional dwell time in ms to apply to dwell prior to turning off the servo +variable_num_moves: 1 # Nunber of moves to use for load/unload. Increase to 2 or 3 to prevent 'Timer too close' error gcode: [save_variables] @@ -79,106 +96,105 @@ filename: /home/klipper/printer_data/config/config/ercf/ercf_vars.cfg ############################### # ERCF Calibration macros ############################### -[gcode_macro ERCF_CALIB_SELECTOR] +[gcode_macro _ERCF_CALIB_SELECTOR] description: Calibration of the selector position for a defined Tool gcode: - ERCF_SERVO_UP + _ERCF_SERVO_UP {% set move_length=(20.0 + (params.TOOL|int + 1)*21.0 + ((params.TOOL|int + 1)/3)*5.0) %} M118 Measuring the selector position for tool {params.TOOL} ERCF_GET_SELECTOR_POS REF={move_length|int} - ERCF_MOTORS_OFF + _ERCF_MOTORS_OFF -[gcode_macro ERCF_CALIBRATE] +[gcode_macro _ERCF_CALIBRATE] description: Complete calibration of all ERCF Tools gcode: SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 - M118 Start the complete auto calibration... + M118 Start the complete auto calibration... M118 First home the ERCF - ERCF_HOME + ERCF_HOME - {% for chan in range(printer["gcode_macro ERCF_VAR"].colorselector|length) %} - ERCF_CALIBRATE_SINGLE TOOL={chan|int} - {% endfor %} + {% for chan in range(printer["gcode_macro _ERCF_VAR"].colorselector|length) %} + _ERCF_CALIBRATE_SINGLE TOOL={chan|int} + {% endfor %} - M118 End of the complete auto calibration! + M118 End of the complete auto calibration! M118 Please reload the firmware for the calibration to be active! -[gcode_macro ERCF_CALIBRATE_SINGLE] +[gcode_macro _ERCF_CALIBRATE_SINGLE] description: Calibration of a single ERCF Tool gcode: SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 - {% if params.TOOL|int >= 0 and params.TOOL|int < printer["gcode_macro ERCF_VAR"].colorselector|length %} - {% if printer["gcode_macro ERCF_HOME"].home == -1 %} - M118 First home the ERCF - ERCF_HOME - {% endif %} + {% if params.TOOL|int >= 0 and params.TOOL|int < printer["gcode_macro _ERCF_VAR"].colorselector|length %} + {% if printer["gcode_macro ERCF_HOME"].home == -1 %} + M118 First home the ERCF + ERCF_HOME + {% endif %} - ERCF_SELECT_TOOL TOOL={params.TOOL} + _ERCF_SELECT_TOOL TOOL={params.TOOL} ERCF_SET_STEPS RATIO=1.0 {% if params.TOOL|int == 0 %} - {% if printer['extruder'].temperature < printer["gcode_macro ERCF_VAR"].min_temp_extruder %} - M109 S{printer["gcode_macro ERCF_VAR"].min_temp_extruder|int} + {% if printer['extruder'].temperature < printer["gcode_macro _ERCF_VAR"].min_temp_extruder %} + M109 S{printer["gcode_macro _ERCF_VAR"].min_temp_extruder|int} {% endif %} M118 Calibrating reference tool {params.TOOL} - ERCF_LOAD LENGTH={printer["gcode_macro ERCF_VAR"].min_bowden_length} + ERCF_LOAD LENGTH={printer["gcode_macro _ERCF_VAR"].min_bowden_length} MOVES={printer["gcode_macro _ERCF_VAR"].num_moves} ERCF_HOME_EXTRUDER TOTAL_LENGTH=400 STEP_LENGTH=0.5 - ERCF_CALIB_SAVE_VAR TOOL={params.TOOL} + _ERCF_CALIB_SAVE_VAR TOOL={params.TOOL} G91 G92 E0 MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} SPEED=25 ACCEL=0 SYNC=0 - G1 E-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} F1500.0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float} SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SYNC=0 + G1 E-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float} F1500.0 - ERCF_CALIB_UNLOAD - + _ERCF_CALIB_UNLOAD ERCF_BUZZ_GEAR_MOTOR - ERCF_IS_FILAMENT_STUCK_IN_ERCF + _ERCF_IS_FILAMENT_STUCK_IN_ERCF - ERCF_UNSELECT_TOOL + _ERCF_UNSELECT_TOOL {% else %} M118 Calibrating tool {params.TOOL} - ERCF_LOAD LENGTH={printer["gcode_macro ERCF_VAR"].min_bowden_length|float - 100.0} - ERCF_CALIB_SAVE_VAR tool={params.TOOL} + ERCF_LOAD LENGTH={printer["gcode_macro _ERCF_VAR"].min_bowden_length|float - 100.0} MOVES={printer["gcode_macro _ERCF_VAR"].num_moves} + _ERCF_CALIB_SAVE_VAR tool={params.TOOL} - ERCF_CALIB_UNLOAD LENGTH={printer["gcode_macro ERCF_VAR"].min_bowden_length|float - 100.0 + 27.0} + _ERCF_CALIB_UNLOAD LENGTH={printer["gcode_macro _ERCF_VAR"].min_bowden_length|float - 100.0 + 27.0} MOVES={printer["gcode_macro _ERCF_VAR"].num_moves} {% endif %} - {% else %} - M118 Tool out of range - {% endif %} + {% else %} + M118 Tool out of range + {% endif %} -[gcode_macro ERCF_CALIB_SAVE_VAR] +[gcode_macro _ERCF_CALIB_SAVE_VAR] description: Saving ERCF calibration values gcode: {% if params.TOOL|int == 0 %} M118 Tool {params.TOOL} calibration value is {printer['ercf'].encoder_pos|float} SAVE_VARIABLE VARIABLE=ercf_calib_ref VALUE={printer['ercf'].encoder_pos|float} # this is the reference value SAVE_VARIABLE VARIABLE=ercf_calib_{params.TOOL|int} VALUE=1.0 - SET_GCODE_VARIABLE MACRO=ERCF_CALIB_UNLOAD VARIABLE=ref VALUE={printer['ercf'].encoder_pos|float} - SET_GCODE_VARIABLE MACRO=ERCF_CALIB_UNLOAD VARIABLE=ratio VALUE=1.0 + SET_GCODE_VARIABLE MACRO=_ERCF_CALIB_UNLOAD VARIABLE=ref VALUE={printer['ercf'].encoder_pos|float} + SET_GCODE_VARIABLE MACRO=_ERCF_CALIB_UNLOAD VARIABLE=ratio VALUE=1.0 {% else %} - {% set ratio = (printer["gcode_macro ERCF_VAR"].min_bowden_length|float - 100.0) / printer['ercf'].encoder_pos|float %} + {% set ratio = (printer["gcode_macro _ERCF_VAR"].min_bowden_length|float - 100.0) / printer['ercf'].encoder_pos|float %} M118 Tool {params.TOOL} ratio is {ratio|float} SAVE_VARIABLE VARIABLE=ercf_calib_{params.TOOL|int} VALUE={ratio|float} - SET_GCODE_VARIABLE MACRO=ERCF_CALIB_UNLOAD VARIABLE=ratio VALUE={ratio|float} + SET_GCODE_VARIABLE MACRO=_ERCF_CALIB_UNLOAD VARIABLE=ratio VALUE={ratio|float} {% endif %} -[gcode_macro ERCF_CALIB_UNLOAD] +[gcode_macro _ERCF_CALIB_UNLOAD] description: Filament unload during ERCF calibration variable_ratio: 0.0 variable_ref: 0.0 gcode: {% set unload_length = params.LENGTH|default(0.0)|float %} {% if unload_length|float == 0.0 %} - ERCF_UNLOAD LENGTH={(ref|float)*(ratio|float) - printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float + 27.0} + ERCF_UNLOAD LENGTH={(ref|float)*(ratio|float) - printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float + 27.0} {% else %} {% if ratio|float < 1.0 %} # No correction move is done in case of "over targeting", hence the correction ratio is not applied during this unload sequence ERCF_UNLOAD LENGTH={(unload_length|float)} @@ -187,6 +203,11 @@ gcode: {% endif %} {% endif %} +[gcode_macro _ERCF_GET_LOAD_THRESHOLD] +description: Measure the encoder threshold for the last part of the load +gcode: + _ERCF_CHANGE_TOOL_STANDALONE TOOL=0 TUNE=1 + [respond] default_type: command @@ -194,40 +215,41 @@ default_type: command # ERCF servo ############################### # Push the top hat down (enable the bondtech gears) while "buzzing" the gear motor to ensure proper BMG gear meshing -[gcode_macro ERCF_SERVO_DOWN] +[gcode_macro _ERCF_SERVO_DOWN] description: Engage the ERCF gear gcode: MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=0.5 SPEED=25 ACCEL=0 SYNC=0 - SET_SERVO SERVO=ercf_servo ANGLE={printer["gcode_macro ERCF_VAR"].servo_down_angle} + MANUAL_STEPPER STEPPER=gear_stepper MOVE=0.5 SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SYNC=0 + SET_SERVO SERVO=ercf_servo ANGLE={printer["gcode_macro _ERCF_VAR"].servo_down_angle} G4 P200 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=0.0 SPEED=25 ACCEL=0 SYNC=0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=0.0 SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SYNC=0 G4 P100 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=-0.5 SPEED=25 ACCEL=0 SYNC=0 - G4 P100 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=0.0 SPEED=25 ACCEL=0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=-0.5 SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SYNC=0 + G4 P{100 + printer["gcode_macro _ERCF_VAR"].extra_servo_dwell_down|int} + MANUAL_STEPPER STEPPER=gear_stepper MOVE=0.0 SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SET_SERVO SERVO=ercf_servo WIDTH=0.0 # Pull the top hat up (disengage the bondtech gears) -[gcode_macro ERCF_SERVO_UP] +[gcode_macro _ERCF_SERVO_UP] description: Disengage the ERCF gear gcode: - SET_SERVO SERVO=ercf_servo ANGLE={printer["gcode_macro ERCF_VAR"].servo_up_angle} - G4 P250 + SET_SERVO SERVO=ercf_servo ANGLE={printer["gcode_macro _ERCF_VAR"].servo_up_angle} + G4 P{250 + printer["gcode_macro _ERCF_VAR"].extra_servo_dwell_up|int} SET_SERVO SERVO=ercf_servo WIDTH=0.0 ############################### # ERCF motors ############################### -[gcode_macro ERCF_MOTORS_OFF] +[gcode_macro _ERCF_MOTORS_OFF] description: Turn off both ERCF motors gcode: MANUAL_STEPPER STEPPER=gear_stepper ENABLE=0 MANUAL_STEPPER STEPPER=selector_stepper ENABLE=0 + SET_GCODE_VARIABLE MACRO=ERCF_HOME VARIABLE=home VALUE=-1 ############################### # PAUSE MACROS -# ERCF_PAUSE is called when an human intervention is needed +# _ERCF_PAUSE is called when an human intervention is needed # use ERCF_UNLOCK to start the manual intervention # and use RESUME when the intervention is over to resume the current print ############################### @@ -237,20 +259,20 @@ gcode: description: Unlock ERCF operations gcode: M118 Unlock the ERCF - SET_GCODE_VARIABLE MACRO=ERCF_PAUSE VARIABLE=is_paused VALUE=0 + SET_GCODE_VARIABLE MACRO=_ERCF_PAUSE VARIABLE=is_paused VALUE=0 UPDATE_DELAYED_GCODE ID=disable_heater DURATION=0 {% if printer['filament_switch_sensor toolhead_sensor'].filament_detected == False %} - ERCF_UNSELECT_TOOL + _ERCF_UNSELECT_TOOL {% else %} - ERCF_UNSELECT_TOOL FORCED=0 + _ERCF_UNSELECT_TOOL FORCED=0 {% endif %} - M104 S{printer["gcode_macro ERCF_PAUSE"].extruder_temp} + M104 S{printer["gcode_macro _ERCF_PAUSE"].extruder_temp} RESTORE_GCODE_STATE NAME=ERCF_state M118 Refer to the manual before resuming the print [delayed_gcode disable_heater] gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int != 0 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int != 0 %} M118 Disable extruder heater M104 S0 {% endif %} @@ -258,15 +280,15 @@ gcode: # 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 accordingly to timeout_pause -[gcode_macro ERCF_PAUSE] +[gcode_macro _ERCF_PAUSE] description: Pause the current print and lock the ERCF operations variable_is_paused: 0 variable_extruder_temp: 0 gcode: - SET_GCODE_VARIABLE MACRO=ERCF_PAUSE VARIABLE=extruder_temp VALUE={printer.extruder.target} - SET_GCODE_VARIABLE MACRO=ERCF_PAUSE VARIABLE=is_paused VALUE=1 - SET_IDLE_TIMEOUT TIMEOUT={printer["gcode_macro ERCF_VAR"].timeout_pause} - UPDATE_DELAYED_GCODE ID=disable_heater DURATION={printer["gcode_macro ERCF_VAR"].disable_heater} + SET_GCODE_VARIABLE MACRO=_ERCF_PAUSE VARIABLE=extruder_temp VALUE={printer.extruder.target} + SET_GCODE_VARIABLE MACRO=_ERCF_PAUSE VARIABLE=is_paused VALUE=1 + SET_IDLE_TIMEOUT TIMEOUT={printer["gcode_macro _ERCF_VAR"].timeout_pause} + UPDATE_DELAYED_GCODE ID=disable_heater DURATION={printer["gcode_macro _ERCF_VAR"].disable_heater} M118 An issue with the ERCF has been detected and the ERCF has been PAUSED M118 When you intervene to fix the issue, first call the "ERCF_UNLOCK" Gcode M118 Refer to the manual before resuming the print @@ -276,210 +298,274 @@ gcode: ############################################ # Changing tool macros -# ERCF_CHANGE_TOOL_STANDALONE TOOL=XX to change filament outside of a print -# ERCF_CHANGE_TOOL_SLICER TOOL=XX will be called automatically (from the ACTIVATE_EXTRUDER gcode from SuperSlicer), don't use that for "manual" filament swap +# _ERCF_CHANGE_TOOL_STANDALONE TOOL=XX to change filament outside of a print +# _ERCF_CHANGE_TOOL_SLICER 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 T0] gcode: - ERCF_CHANGE_TOOL TOOL=0 + _ERCF_CHANGE_TOOL TOOL=0 [gcode_macro T1] gcode: - ERCF_CHANGE_TOOL TOOL=1 + _ERCF_CHANGE_TOOL TOOL=1 [gcode_macro T2] gcode: - ERCF_CHANGE_TOOL TOOL=2 + _ERCF_CHANGE_TOOL TOOL=2 [gcode_macro T3] gcode: - ERCF_CHANGE_TOOL TOOL=3 + _ERCF_CHANGE_TOOL TOOL=3 [gcode_macro T4] gcode: - ERCF_CHANGE_TOOL TOOL=4 + _ERCF_CHANGE_TOOL TOOL=4 [gcode_macro T5] gcode: - ERCF_CHANGE_TOOL TOOL=5 + _ERCF_CHANGE_TOOL TOOL=5 [gcode_macro T6] gcode: - ERCF_CHANGE_TOOL TOOL=6 + _ERCF_CHANGE_TOOL TOOL=6 [gcode_macro T7] gcode: - ERCF_CHANGE_TOOL TOOL=7 + _ERCF_CHANGE_TOOL TOOL=7 [gcode_macro T8] gcode: - ERCF_CHANGE_TOOL TOOL=8 + _ERCF_CHANGE_TOOL TOOL=8 -[gcode_macro ERCF_CHANGE_TOOL] +[gcode_macro _ERCF_CHANGE_TOOL] description: Perform a tool swap gcode: + {% set initial_tool_string = 'unknown tool' %} + {% if printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int != -1 %} + {% set initial_tool_string = 'T' + printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|string %} + {% endif %} + M118 Tool swap request, from {initial_tool_string} to T{params.TOOL|int} + M117 {initial_tool_string} -> T{params.TOOL|int} {% if printer.idle_timeout.state == "Printing" %} - ERCF_CHANGE_TOOL_SLICER TOOL={params.TOOL|int} + _ERCF_CHANGE_TOOL_SLICER TOOL={params.TOOL|int} {% else %} - ERCF_CHANGE_TOOL_STANDALONE TOOL={params.TOOL|int} + _ERCF_CHANGE_TOOL_STANDALONE TOOL={params.TOOL|int} {% endif %} -[gcode_macro ERCF_CHANGE_TOOL_SLICER] +[gcode_macro _ERCF_CHANGE_TOOL_SLICER] description: Perform a tool swap during a print gcode: SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 - {% if printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int != params.TOOL|int %} + {% if printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int != params.TOOL|int %} # 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} - ERCF_UNLOAD_TOOL - ERCF_LOAD_TOOL TOOL={params.TOOL|int} - ERCF_CHANGE_TOOL_SLICER_END + _ERCF_UNLOAD_TOOL + _ERCF_LOAD_TOOL TOOL={params.TOOL|int} {% endif %} + _ERCF_CHANGE_TOOL_SLICER_END -[gcode_macro ERCF_CHANGE_TOOL_SLICER_END] +[gcode_macro _ERCF_CHANGE_TOOL_SLICER_END] gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} - {% if printer["gcode_macro ERCF_VAR"].clog_detection|int == 1 %} - SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1 - {% endif %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_VAR"].clog_detection|int == 1 %} + SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1 {% endif %} + {% endif %} -[gcode_macro ERCF_CHANGE_TOOL_STANDALONE] +[gcode_macro _ERCF_CHANGE_TOOL_STANDALONE] description: Perform a tool swap out of a print gcode: SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 + {% set tune = params.TUNE|default(0)|int %} {% if printer["gcode_macro ERCF_HOME"].home == -1 %} M118 ERCF not homed, homing it... ERCF_HOME - M117 Change Tool T{params.TOOL|int} - ERCF_LOAD_TOOL TOOL={params.TOOL|int} - {% elif printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int != params.TOOL|int %} - M117 Change Tool T{params.TOOL|int} + _ERCF_LOAD_TOOL TOOL={params.TOOL|int} TUNE={tune} + {% elif printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int != params.TOOL|int %} {% if printer['filament_switch_sensor toolhead_sensor'].filament_detected == True %} M118 Unloading current filament {% if printer['extruder'].temperature < 178 %} M118 Preheat Nozzle - M109 S{printer["gcode_macro ERCF_VAR"].extruder_eject_temp} + M109 S{printer["gcode_macro _ERCF_VAR"].extruder_eject_temp} {% endif %} ERCF_EJECT {% endif %} - ERCF_LOAD_TOOL TOOL={params.TOOL|int} + _ERCF_LOAD_TOOL TOOL={params.TOOL|int} TUNE={tune} {% endif %} - + ############################################ # Unloading/Loading Macros ############################################ # Load filament from ERCF to nozzle -[gcode_macro ERCF_LOAD_TOOL] +[gcode_macro _ERCF_LOAD_TOOL] description: Load the filament from the ERCF to the toolhead gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} {% if printer["gcode_macro ERCF_HOME"].home == -1 %} M118 ERCF not homed, homing it... ERCF_HOME {% endif %} + {% set tune = params.TUNE|default(0)|int %} M118 Loading tool {params.TOOL|int} ... - ERCF_SELECT_TOOL TOOL={params.TOOL|int} + _ERCF_SELECT_TOOL TOOL={params.TOOL|int} {% set ercf_params = printer.save_variables.variables %} ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (params.TOOL|string)]} M118 Loading filament from ERCF to extruder ... {% set ercf_params = printer.save_variables.variables %} - ERCF_LOAD LENGTH={ercf_params.ercf_calib_ref|float - printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} - ERCF_LOAD_FILAMENT_IN_EXTRUDER + ERCF_LOAD LENGTH={ercf_params.ercf_calib_ref|float - printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float} + _ERCF_LOAD_FILAMENT_IN_EXTRUDER TUNE={tune} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} # Unload filament from nozzle to ERCF, using built-in tip forming macro [gcode_macro ERCF_EJECT] description: Eject the filament out of a print and park it into the ERCF gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} - {% if printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int != -1 %} - M118 Unloading tool {printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int} ... + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int != -1 %} + M118 Unloading tool {printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int} ... {% if printer['filament_switch_sensor toolhead_sensor'].filament_detected == True %} - ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING + _ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING {% set ercf_params = printer.save_variables.variables %} - ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|string)]} - ERCF_UNLOAD LENGTH={ercf_params.ercf_calib_ref|float - printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float + printer["gcode_macro ERCF_VAR"].unload_modifier|float} - ERCF_UNSELECT_TOOL + ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|string)]} + ERCF_UNLOAD LENGTH={ercf_params.ercf_calib_ref|float + printer["gcode_macro _ERCF_VAR"].unload_modifier|float - 60.0} + _ERCF_UNSELECT_TOOL {% else %} - ERCF_EJECT_UNKNOW_STATE + _ERCF_EJECT_UNKNOW_STATE {% endif %} {% else %} - ERCF_EJECT_UNKNOW_STATE + _ERCF_EJECT_UNKNOW_STATE {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} # Unload filament from nozzle to ERCF, using SuperSlicer ramming -[gcode_macro ERCF_UNLOAD_TOOL] +[gcode_macro _ERCF_UNLOAD_TOOL] description: Eject the filament during a print and park it into the ERCF gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} - {% if printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int != -1 %} - M118 Unload tool {printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int} ... - ERCF_HOME_EXTRUDER - ERCF_SELECT_TOOL TOOL={printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int != -1 %} + M118 Unload tool {printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int} ... + G1 E-10.00 F1200.0 + G1 E-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float + 20.0} F2000 + _ERCF_SELECT_TOOL TOOL={printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int} {% set ercf_params = printer.save_variables.variables %} - ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|string)]} - G91 - G92 E0 - MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float + 20.0} SPEED=25 ACCEL=0 SYNC=0 - G1 E-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float + 20.0} F1500.0 + ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|string)]} + G4 P100 + M400 + _ERCF_EXTRACT_FROM_EXTRUDER {% set ercf_params = printer.save_variables.variables %} - ERCF_UNLOAD LENGTH={ercf_params.ercf_calib_ref|float - printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float + printer["gcode_macro ERCF_VAR"].unload_modifier|float - 20.0} - ERCF_UNSELECT_TOOL + ERCF_UNLOAD LENGTH={ercf_params.ercf_calib_ref|float + printer["gcode_macro _ERCF_VAR"].unload_modifier|float - 60.0} + _ERCF_UNSELECT_TOOL {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} +# Unload filament from nozzle to ERCF, using SuperSlicer ramming +[gcode_macro _ERCF_EXTRACT_FROM_EXTRUDER] +description: Extract the tip at the parking position from the extruder +gcode: + {% if printer['filament_switch_sensor toolhead_sensor'].filament_detected == True %} + M118 Filament still below the extruder... Trying extraction again... + _ERCF_SERVO_UP + G1 E-5.00 F1200.0 + G1 E-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float + 25.0} F2000 + _ERCF_SERVO_DOWN + G4 P100 + M400 + _ERCF_RETRY_EXTRACT_FROM_EXTRUDER + {% else %} + _ERCF_HAIR_PULLING_MOVE + {% endif %} + +# Unload filament from nozzle to ERCF, using SuperSlicer ramming +[gcode_macro _ERCF_RETRY_EXTRACT_FROM_EXTRUDER] +description: Check if extraction retry went properly or not +gcode: + {% if printer['filament_switch_sensor toolhead_sensor'].filament_detected == True %} + M118 Filament is stuck below the extruder... + M118 Calling ERCF_PAUSE + _ERCF_PAUSE + {% else %} + _ERCF_HAIR_PULLING_MOVE + {% endif %} + +[gcode_macro _ERCF_HAIR_PULLING_MOVE] +description: Optionnal hair pulling move before the long unload +gcode: + G91 + G92 E0 + {% if printer["gcode_macro _ERCF_VAR"].hair_puller_move|int == 1 %} + MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro _ERCF_VAR"].unload_move_before_hair_pulling|float} SPEED=25 ACCEL=0 + MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=-10 SPEED=25 ACCEL=0 SYNC=0 + G1 E10 F2000.0 + {% else %} + MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=-30 SPEED=25 ACCEL=0 + {% endif %} + + ############################################ # Select/Unselect a tool # move the selector (if needed) to the requested tool ############################################ # Select a tool. move the idler and then move the color selector (if needed) -[gcode_macro ERCF_SELECT_TOOL] +[gcode_macro _ERCF_SELECT_TOOL] description: Move the selector to the Tool and select it variable_tool_selected: -1 variable_color_selected: -1 gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} {% if printer["gcode_macro ERCF_HOME"].home != -1 %} M118 Select Tool {params.TOOL} ... - ERCF_SERVO_UP - MANUAL_STEPPER STEPPER=selector_stepper MOVE={printer["gcode_macro ERCF_VAR"].colorselector[params.TOOL|int]} - SET_GCODE_VARIABLE MACRO=ERCF_SELECT_TOOL VARIABLE=tool_selected VALUE={params.TOOL} - SET_GCODE_VARIABLE MACRO=ERCF_SELECT_TOOL VARIABLE=color_selected VALUE={params.TOOL} - ERCF_SERVO_DOWN + _ERCF_SERVO_UP + {% if printer["gcode_macro _ERCF_VAR"].sensorless_selector|int == 1 %} + ERCF_MOVE_SELECTOR TARGET={printer["gcode_macro _ERCF_VAR"].colorselector[params.TOOL|int]} + {% else %} + MANUAL_STEPPER STEPPER=selector_stepper MOVE={printer["gcode_macro _ERCF_VAR"].colorselector[params.TOOL|int]} + {% endif %} + SET_GCODE_VARIABLE MACRO=_ERCF_SELECT_TOOL VARIABLE=tool_selected VALUE={params.TOOL} + SET_GCODE_VARIABLE MACRO=_ERCF_SELECT_TOOL VARIABLE=color_selected VALUE={params.TOOL} + _ERCF_SERVO_DOWN M118 Tool {params.TOOL} Enabled {% else %} M118 Could not select tool, ERCF is not homed {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} # Unselect a tool -[gcode_macro ERCF_UNSELECT_TOOL] +[gcode_macro _ERCF_UNSELECT_TOOL] description: Unselect current Tool gcode: {% set unselect_color = params.FORCED|default(1)|int %} - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} {% if printer["gcode_macro ERCF_HOME"].home != -1 %} - ERCF_SERVO_UP - SET_GCODE_VARIABLE MACRO=ERCF_SELECT_TOOL VARIABLE=tool_selected VALUE=-1 + _ERCF_SERVO_UP + SET_GCODE_VARIABLE MACRO=_ERCF_SELECT_TOOL VARIABLE=tool_selected VALUE=-1 {% if unselect_color == 1 %} - SET_GCODE_VARIABLE MACRO=ERCF_SELECT_TOOL VARIABLE=color_selected VALUE=-1 + SET_GCODE_VARIABLE MACRO=_ERCF_SELECT_TOOL VARIABLE=color_selected VALUE=-1 {% endif %} ERCF_SET_STEPS RATIO=1.0 {% else %} M118 Could not unselect tool, ERCF is not homed {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} ############################################ @@ -487,33 +573,36 @@ gcode: ############################################ # Load the filament into the extruder -# Call ERCF_PAUSE if the filament is not detected by the toolhead sensor -[gcode_macro ERCF_LOAD_FILAMENT_IN_EXTRUDER] +# Call _ERCF_PAUSE if the filament is not detected by the toolhead sensor +[gcode_macro _ERCF_LOAD_FILAMENT_IN_EXTRUDER] description: Load filament from the toolhead entrance to the nozzle gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} - {% if printer.extruder.temperature > printer["gcode_macro ERCF_VAR"].min_temp_extruder %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} + {% set tune = params.TUNE|default(0)|int %} + {% if printer.extruder.temperature > printer["gcode_macro _ERCF_VAR"].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 ERCF_VAR"].end_of_bowden_to_sensor|float - 7} SPEED=25 ACCEL=0 SYNC=0 - G1 E{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float - 7} F1500.0 - G4 P100 + MANUAL_STEPPER STEPPER=gear_stepper MOVE={printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float - 7} SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SYNC=0 + G1 E{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float - 7} F1500.0 + G4 P100 + M400 ERCF_HOME_EXTRUDER TOTAL_LENGTH=30.0 STEP_LENGTH=0.5 - ERCF_UNSELECT_TOOL FORCED=0 - ERCF_FINALIZE_LOAD LENGTH={printer["gcode_macro ERCF_VAR"].sensor_to_nozzle|float} - G92 E0 - G90 - M118 Load Complete + _ERCF_UNSELECT_TOOL FORCED=0 + ERCF_FINALIZE_LOAD LENGTH={printer["gcode_macro _ERCF_VAR"].sensor_to_nozzle|float} THRESHOLD={printer["gcode_macro _ERCF_VAR"].final_load_check_threshold|float} TUNE={tune} + G92 E0 + G90 {% else %} M118 Extruder too cold - ERCF_PAUSE + _ERCF_PAUSE {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} # StandAlone cooling moves to extract proper filament tip -[gcode_macro ERCF_FORM_TIP_STANDALONE] +[gcode_macro _ERCF_FORM_TIP_STANDALONE] description: Generic tip forming macro gcode: {% set COOLING_TUBE_LENGTH = params.COOLING_TUBE_LENGTH|default(15) %} # Dragon ST: 15, Dragon HF: 10, Mosquito: 20 @@ -522,7 +611,7 @@ gcode: {% set FINAL_COOLING_SPEED = params.FINAL_COOLING_SPEED|default(50) %} {% set COOLING_MOVES = params.COOLING_MOVES|default(5) %} {% set TOOLCHANGE_TEMP = params.TOOLCHANGE_TEMP|default(0) %} - {% set USE_SKINNYDIP = params.USE_SKINNYDIP|default(1) %} + {% set USE_SKINNYDIP = params.USE_SKINNYDIP|default(0) %} {% set USE_FAST_SKINNYDIP = params.USE_FAST_SKINNYDIP|default(1) %} {% set SKINNYDIP_DISTANCE = params.SKINNYDIP_DISTANCE|default(26) %} {% set DIP_INSERTION_SPEED = params.DIP_INSERTION_SPEED|default(33) %} @@ -613,55 +702,43 @@ gcode: G92 E0 # Unload from extruder with tip forming sequence -[gcode_macro ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING] +[gcode_macro _ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING] description: Unload filament from the nozzle to the toolhead entrance using generic tip forming macro gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} - {% if printer.extruder.temperature > printer["gcode_macro ERCF_VAR"].min_temp_extruder %} - {% if printer["gcode_macro ERCF_SELECT_TOOL"].tool_selected|int == -1 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer.extruder.temperature > printer["gcode_macro _ERCF_VAR"].min_temp_extruder %} + {% if printer["gcode_macro _ERCF_SELECT_TOOL"].tool_selected|int == -1 %} M118 Forming filament tip and Unloading Filament... G91 - ERCF_FORM_TIP_STANDALONE - G1 E-4.00 F1200.0 - G1 E-15.00 F2000 - ERCF_HOME_EXTRUDER - ERCF_SERVO_DOWN - G91 - G92 E0 - MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} SPEED=25 ACCEL=0 SYNC=0 - G1 E-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} F1500.0 + _ERCF_FORM_TIP_STANDALONE + G1 E-10.00 F1200.0 + G1 E-{printer["gcode_macro _ERCF_VAR"].sensor_to_nozzle|float - 10.00} F2000 + G1 E-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float + 20.00} F2000 + _ERCF_SERVO_DOWN + G4 P100 + _ERCF_EXTRACT_FROM_EXTRUDER M118 Filament removed {% else %} M118 Tool selected, UNSELECT it - ERCF_PAUSE + _ERCF_PAUSE {% endif %} {% else %} M118 Extruder too cold - ERCF_PAUSE + _ERCF_PAUSE {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} ############################################ # Endstop check macros ############################################ - -# Call ERCF_PAUSE if the filament is not detected by the toolhead sensor -[gcode_macro ERCF_IS_FILAMENT_IN_EXTRUDER] -gcode: - {% if printer['filament_switch_sensor toolhead_sensor'].filament_detected == True %} - M118 Filament is in extruder - {% else %} - M118 Filament not in extruder - ERCF_PAUSE - {% endif %} - -# Call ERCF_PAUSE if the filament is stuck in the ERCF -[gcode_macro ERCF_IS_FILAMENT_STUCK_IN_ERCF] +# Call _ERCF_PAUSE if the filament is stuck in the ERCF +[gcode_macro _ERCF_IS_FILAMENT_STUCK_IN_ERCF] gcode: {% if printer.ercf.encoder_pos|float != 0 %} M118 Filament stuck in ERCF - ERCF_PAUSE + _ERCF_PAUSE {% else %} M118 Filament not in ERCF {% endif %} @@ -671,7 +748,7 @@ gcode: ############################################ # Eject from extruder gear to the ERCF -[gcode_macro ERCF_EJECT_UNKNOW_STATE] +[gcode_macro _ERCF_EJECT_UNKNOW_STATE] description: Unload filament from an unknown position gcode: M118 Eject Filament if loaded ... @@ -679,19 +756,18 @@ gcode: M118 Filament in extruder, trying to eject it .. {% if printer['extruder'].temperature < 178 %} M118 Preheat Nozzle - M109 S{printer["gcode_macro ERCF_VAR"].extruder_eject_temp} + M109 S{printer["gcode_macro _ERCF_VAR"].extruder_eject_temp} {% endif %} - ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING - ERCF_UNLOAD LENGTH={printer["gcode_macro ERCF_VAR"].min_bowden_length - 50} UNKNOWN=1 + _ERCF_UNLOAD_FILAMENT_IN_EXTRUDER_WITH_TIP_FORMING + ERCF_UNLOAD LENGTH={printer["gcode_macro _ERCF_VAR"].min_bowden_length - 50} UNKNOWN=1 MOVES={printer["gcode_macro _ERCF_VAR"].num_moves} {% else %} - ERCF_SERVO_DOWN + _ERCF_SERVO_DOWN + ERCF_BUZZ_GEAR_MOTOR + _ERCF_EJECT_FROM_BOWDEN {% endif %} - ERCF_BUZZ_GEAR_MOTOR - G4 P200 - ERCF_EJECT_FROM_BOWDEN # Eject from the bowden to the ERCF -[gcode_macro ERCF_EJECT_FROM_BOWDEN] +[gcode_macro _ERCF_EJECT_FROM_BOWDEN] description: Unload filament from the reverse bowden gcode: {% if printer.ercf.encoder_pos|float != 0 %} @@ -700,7 +776,7 @@ gcode: {% else %} M118 Filament already ejected ! {% endif %} - ERCF_SERVO_UP + _ERCF_SERVO_UP ############################################ # Homing macros @@ -708,58 +784,71 @@ gcode: ############################################ # Home the ERCF -# eject filament if loaded with ERCF_EJECT_UNKNOW_STATE -# next home the ERCF with ERCF_HOME_ONLY +# eject filament if loaded with _ERCF_EJECT_UNKNOW_STATE +# next home the ERCF with _ERCF_HOME_ONLY [gcode_macro ERCF_HOME] description: Home the ERCF variable_home: -1 gcode: SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 SET_GCODE_VARIABLE MACRO=ERCF_HOME VARIABLE=home VALUE=1 - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 1 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 1 %} ERCF_UNLOCK {% endif %} M118 Homing ERCF ... QUERY_ENDSTOPS - ERCF_EJECT_UNKNOW_STATE - ERCF_HOME_SELECTOR - ERCF_HOME_ONLY + _ERCF_EJECT_UNKNOW_STATE + _ERCF_HOME_SELECTOR + _ERCF_HOME_ONLY TOOL={params.TOOL|default(0)|int} -[gcode_macro ERCF_HOME_SELECTOR] +[gcode_macro _ERCF_HOME_SELECTOR] description: Home the ERCF selector gcode: M118 Homing selector - ERCF_SERVO_UP + _ERCF_UNSELECT_TOOL - {% set number_of_chan=printer["gcode_macro ERCF_VAR"].colorselector|length %} + {% set number_of_chan=printer["gcode_macro _ERCF_VAR"].colorselector|length %} {% set selector_length=(20.0 + number_of_chan*21.0 + (number_of_chan/3)*5.0) %} - MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=selector_stepper SPEED=100 MOVE=-{selector_length|float} STOP_ON_ENDSTOP=1 - MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=selector_stepper SPEED=100 MOVE=5.0 - MANUAL_STEPPER STEPPER=selector_stepper SPEED=10 MOVE=-10.0 STOP_ON_ENDSTOP=1 - MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 - SET_GCODE_VARIABLE MACRO=ERCF_SELECT_TOOL VARIABLE=tool_selected VALUE=-1 - SET_GCODE_VARIABLE MACRO=ERCF_SELECT_TOOL VARIABLE=color_selected VALUE=-1 + {% if printer["gcode_macro _ERCF_VAR"].sensorless_selector|int == 1 %} + MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 + MANUAL_STEPPER STEPPER=selector_stepper SPEED=60 MOVE=-{selector_length|float} STOP_ON_ENDSTOP=1 + MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 + {% else %} + MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 + MANUAL_STEPPER STEPPER=selector_stepper SPEED=100 MOVE=-{selector_length|float} STOP_ON_ENDSTOP=1 + MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 + MANUAL_STEPPER STEPPER=selector_stepper SPEED=100 MOVE=5.0 + MANUAL_STEPPER STEPPER=selector_stepper SPEED=10 MOVE=-10.0 STOP_ON_ENDSTOP=1 + MANUAL_STEPPER STEPPER=selector_stepper SET_POSITION=0 + {% endif %} + QUERY_ENDSTOPS + M400 + MANUAL_STEPPER STEPPER=selector_stepper SPEED=50 MOVE=3.0 + M400 -# 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] +# Home the ERCF (home the color selector if needed) +# if everything is ok, the ERCF is ready to be used +[gcode_macro _ERCF_HOME_ONLY] gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} - M118 Test load filament 1 - ERCF_SELECT_TOOL TOOL=0 - ERCF_SET_STEPS RATIO=1.0 - M118 Loading filament to ERCF... - ERCF_LOAD LENGTH=45 - G4 P50 - ERCF_UNLOAD LENGTH=68 - ERCF_UNSELECT_TOOL - SET_GCODE_VARIABLE MACRO=ERCF_HOME VARIABLE=home VALUE=1 - M118 Homing ERCF ended ... + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} + {% set selector_homed = 0 %} + {% if printer["gcode_macro _ERCF_VAR"].sensorless_selector|int == 1 %} + {% if printer.query_endstops.last_query["manual_stepper gear_stepper"] == 1 %} + {% set selector_homed = 1 %} + {% endif %} + {% else %} + {% if printer.query_endstops.last_query["manual_stepper selector_stepper"] == 1 %} + {% set selector_homed = 1 %} + {% endif %} + {% endif %} + {% if selector_homed != 1 %} + M118 Homing ERCF selector failed, check what is blocking the selector + M118 Pausing the ERCF, run "ERCF_UNLOCK" to unlock it ... + _ERCF_PAUSE + {% else %} + M118 Homing ERCF ended ... + {% endif %} {% else %} M118 Homing ERCF failed, ERCF is paused, run "ERCF_UNLOCK" to unlock it ... {% endif %} @@ -767,12 +856,12 @@ gcode: ############################################### # Test Macros ############################################### -[gcode_macro ERCF_DISPLAY_ENCODER_POS] +[gcode_macro _ERCF_DISPLAY_ENCODER_POS] description: Display current value of the ERCF encoder gcode: M118 Encoder value is {printer['ercf'].encoder_pos|float} -[gcode_macro ERCF_TEST_MOVE_GEAR] +[gcode_macro _ERCF_TEST_MOVE_GEAR] description: Move the ERCF gear gcode: {% set move_length = params.LENGTH|default(200.0)|float %} @@ -781,36 +870,36 @@ gcode: MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 MANUAL_STEPPER STEPPER=gear_stepper MOVE={move_length|float} SPEED={move_speed|float} ACCEL={move_accel|float} -[gcode_macro ERCF_TEST_SERVO] +[gcode_macro _ERCF_TEST_SERVO] description: Test the servo angle gcode: SET_SERVO SERVO=ercf_servo ANGLE={params.VALUE|float} - G4 P250 + G4 P{250 + printer["gcode_macro _ERCF_VAR"].extra_servo_dwell_up|int} SET_SERVO SERVO=ercf_servo WIDTH=0.0 -[gcode_macro ERCF_TEST_GRIP] +[gcode_macro _ERCF_TEST_GRIP] description: Test the ERCF grip for a Tool gcode: - ERCF_SERVO_DOWN - ERCF_MOTORS_OFF + _ERCF_SERVO_DOWN + _ERCF_MOTORS_OFF -[gcode_macro ERCF_TEST_LOAD_SEQUENCE] +[gcode_macro _ERCF_TEST_LOAD_SEQUENCE] description: Test sequence gcode: {% set loop_number = params.LOOP|default(10)|int %} {% set use_rand = params.RAND|default(0)|int %} {% for iteration in range(loop_number|int) %} - {% for load in range((printer["gcode_macro ERCF_VAR"].colorselector|length)|int) %} + {% for load in range((printer["gcode_macro _ERCF_VAR"].colorselector|length)|int) %} {% if use_rand|int == 1 %} - ERCF_SELECT_TOOL TOOL={range(0, printer["gcode_macro ERCF_VAR"].colorselector|length)|random} + _ERCF_SELECT_TOOL TOOL={range(0, printer["gcode_macro _ERCF_VAR"].colorselector|length)|random} {% else %} - ERCF_SELECT_TOOL TOOL={load|int} + _ERCF_SELECT_TOOL TOOL={load|int} {% endif %} ERCF_LOAD LENGTH=100 G4 P50 ERCF_UNLOAD LENGTH=100 - ERCF_UNSELECT_TOOL + _ERCF_UNSELECT_TOOL G4 P200 {% endfor %} {% endfor %} @@ -819,31 +908,33 @@ gcode: # Endless spool mode and clog detection ############################################### -[gcode_macro ERCF_ENCODER_MOTION_ISSUE] +[gcode_macro _ERCF_ENCODER_MOTION_ISSUE] description: Perform a test when the encoder sense an issue (clog or runout) gcode: - M118 Issue on tool {printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int} + M118 Issue on tool {printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int} M118 Checking if this is a clog or a runout... SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=0 - ERCF_SERVO_DOWN + _ERCF_SERVO_DOWN ERCF_BUZZ_GEAR_MOTOR - ERCF_SERVO_UP - ERCF_CLOG_OR_RUNOUT + _ERCF_SERVO_UP + _ERCF_CLOG_OR_RUNOUT -[gcode_macro ERCF_CLOG_OR_RUNOUT] +[gcode_macro _ERCF_CLOG_OR_RUNOUT] description: Actions taken if a clog or a runout is detected by the ERCF encoder gcode: {% if printer.ercf.encoder_pos|float != 0 %} M118 Clog detected, please check the ERCF and the printer {% else %} M118 Runout detected ! - {% if printer["gcode_macro ERCF_VAR"].endless_spool_mode|int == 1 %} - {% if printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int >= (printer["gcode_macro ERCF_VAR"].colorselector|length -1) %} + {% if printer["gcode_macro _ERCF_VAR"].endless_spool_mode|int == 1 %} + {% set pre_change_PA = printer.extruder.pressure_advance %} + M118 EndlessSpool mode is ON! + {% if printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int >= (printer["gcode_macro _ERCF_VAR"].colorselector|length -1) %} {% set nexttool = 0 %} {% else %} - {% set nexttool = (printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|int + 1) %} + {% set nexttool = (printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|int + 1) %} {% endif %} M118 Loading tool {nexttool|int} @@ -855,34 +946,35 @@ gcode: # G0 X45 Y310 Z1 F3000 # Custom unload sequence - M118 Forming filament tip and Unloading Filament... + M118 Unloading Filament... G91 - ERCF_FORM_TIP_STANDALONE - ERCF_HOME_EXTRUDER TOTAL_LENGTH={printer["gcode_macro ERCF_VAR"].sensor_to_nozzle} STEP_LENGTH=2.0 - ERCF_SERVO_DOWN + _ERCF_FORM_TIP_STANDALONE + ERCF_HOME_EXTRUDER TOTAL_LENGTH={printer["gcode_macro _ERCF_VAR"].sensor_to_nozzle} STEP_LENGTH=2.0 + _ERCF_SERVO_DOWN G91 G92 E0 MANUAL_STEPPER STEPPER=gear_stepper SET_POSITION=0 - MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} SPEED=25 ACCEL=0 SYNC=0 - G1 E-{printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float} F1500.0 + MANUAL_STEPPER STEPPER=gear_stepper MOVE=-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float} SPEED=25 ACCEL={printer["gcode_macro _ERCF_VAR"].gear_stepper_accel|int} SYNC=0 + G1 E-{printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float} F1500.0 {% set ercf_params = printer.save_variables.variables %} - ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (printer["gcode_macro ERCF_SELECT_TOOL"].color_selected|string)]} - ERCF_UNLOAD LENGTH={ercf_params.ercf_calib_ref|float - printer["gcode_macro ERCF_VAR"].end_of_bowden_to_sensor|float + printer["gcode_macro ERCF_VAR"].unload_modifier|float} - ERCF_UNSELECT_TOOL + ERCF_SET_STEPS RATIO={ercf_params['ercf_calib_%s' % (printer["gcode_macro _ERCF_SELECT_TOOL"].color_selected|string)]} + ERCF_UNLOAD LENGTH={ercf_params.ercf_calib_ref|float - printer["gcode_macro _ERCF_VAR"].end_of_bowden_to_sensor|float + printer["gcode_macro _ERCF_VAR"].unload_modifier|float} + _ERCF_UNSELECT_TOOL - ERCF_LOAD_TOOL TOOL={nexttool|int} - ERCF_CHECK_IF_RESUME + _ERCF_LOAD_TOOL TOOL={nexttool|int} + SET_PRESSURE_ADVANCE ADVANCE={pre_change_PA} + _ERCF_CHECK_IF_RESUME {% else %} M118 EndlessSpool mode not enabled, please do something {% endif %} {% endif %} -[gcode_macro ERCF_CHECK_IF_RESUME] +[gcode_macro _ERCF_CHECK_IF_RESUME] description: Safety checks before resuming the print after an encoder event gcode: - {% if printer["gcode_macro ERCF_PAUSE"].is_paused|int == 0 %} + {% if printer["gcode_macro _ERCF_PAUSE"].is_paused|int == 0 %} # Adapt the example below to your own setup # The goal is just to clean the nozzle after the change # In my case I have a purge bucket with a brush @@ -890,8 +982,10 @@ gcode: # BRUSH_CLEAN RESTORE_GCODE_STATE NAME=ERCF_Pre_Brush_init RESUME - {% if printer["gcode_macro ERCF_VAR"].clog_detection|int == 1 %} + {% if printer["gcode_macro _ERCF_VAR"].clog_detection|int == 1 %} SET_FILAMENT_SENSOR SENSOR=encoder_sensor ENABLE=1 {% endif %} + {% else %} + M118 ERCF is currently paused. Please use ERCF_UNLOCK {% endif %} - +