################################################################################################################# ################################# Orbiter Sensor CONFIGURATION ################################################## ################################################################################################################# #config file version v2.2.04 #release date: 23.09.2023 # PAUSE and RESUME macros are defined at the end of this config file. # If you prefer using your own p[lease delete them, otherwise define parking position below. ################################################################################################################# ################################# CHANGE HERE MACRO CONFIGURABLES################################################ ################################################################################################################# [gcode_macro _SENSOR_VARIABLES] # change here macro configurables, enable disable functions!************************* variable_filament_load_temp :230 # temperature to heat up hotend for filament loading, default is 235 variable_filament_unload_temp :200 # temperature to heat up hotend for filament un-loading, default is 185 variable_filament_load_min_temp :200 # minimum hotend set temperature allowed in filament load macro, default is 190 variable_nozzle_purge_length :160 # filament extrude amount during load sequenc, hotend purge from old filament, default is 200 variable_nozzle_purge_speed :450 # filament extrude speed in mm/min adjust this value lower if flow is too high and extruder skips during loading, default is 300 variable_unload_distance :120 # filament retract distance for unload procedure. this length shall be long enough to extract the filament above the drive gears variable_disable_autoload :False # disable filament autoload feature by setting this variable True variable_disable_runnout :False # disable runnout by setting this variable True variable_disable_autounload :False # disable auto unload filament by setting this variable to True variable_enable_beep :True # uses M300 sound feature, set it True to enable variable_park_position_x :10 # edit your X parking position here for pause macro trigerred by runnout variable_park_position_y :10 # edit your Y parking position here for pause macro trigerred by runnout variable_park_lift_z :10 # edit your Z lift amount for parking position here, default is 10 Variable_park_retraction :1 # edit your retraction amount for parking, default is 1 gcode: #///////////////////////////filament sensor button macros///////////////////////////////////////////////// [gcode_button filament_sense] pin: !toolboard: PB5 # remove the negation "!" for sensor v1 - use just PA9 as example press_gcode: # sensor released -runnout detected! runnout_init release_gcode: #gcode macro for filament auto-load, sensor pressed filament_load_init #******************************************************************************************************** #////////////////////////////////////////Filament Unload macros///////////////////////////////////////////////// [gcode_button filament_unload] pin: !toolboard: PB7 # remove the negation "!" for sensor v1 - use just PA9 as example release_gcode: # filament unload procedure filament_unload_init press_gcode: # do not add any macro call here ################################################################################################################################# ####################################### DO NOT CHANGE ANYTHING BELOW THIS LINE!!! ############################################### ################################################################################################################################# ####################################### UNLESS YOU KNOW WHAT YOU ARE DOING OR YOU ARE BORED AND NEED TO DO SOMETHING OR YOU ARE ALONE AND NEED SOMETHING TO MESS UP YOUR LIFE OR YOU CAN DO IT BETTER THAN ME OR YOU ARE A REAL SMARTASS OR JUST BECAUSE YOU CAN OR YOU RUN OUT OF BEAR OR HAS NOTHING BETTER TO DO OR ANY UNREASONABLE REASON ################################################################################################################################# [respond] default_type: echo [force_move] enable_force_move: True [gcode_macro runnout_init] gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% if (printer.print_stats.state == "printing") %} {% if(sensor.disable_runnout|lower == 'false') %} filament_change_state1 {% else %} M118 Filament runnout is disabled in the sensor config file! {% endif %} {% endif %} UPDATE_DELAYED_GCODE ID=clear_loadbusy DURATION=2 UPDATE_DELAYED_GCODE ID=clear_unloadbusy DURATION=2 SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=filamentpresent VALUE=0 [gcode_macro filament_change_state1] variable_changebusy: 0 variable_temp_target: 0 gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% if changebusy == 0 %} PAUSE # call printer pause macro SET_GCODE_VARIABLE MACRO=filament_change_state1 VARIABLE=changebusy VALUE=1 M118 Filament runnout! filament_change_state2 # comment this line if you do not want to automatically unload filament in case there is a runnout detected. {% else %} {% endif %} [gcode_macro filament_change_state2] gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1 {% if (sensor.enable_beep|lower == 'true') %} M300 # beep sound {% endif %} M118 Unloading filament... M83 G92 E0 # {% if printer[printer.toolhead.extruder].temperature < 185 %} # hardcoded threshold {% if (printer.extruder.can_extrude|lower != 'true')%} # checing for minimum extrusion temperature # check if temperature is over the minimum extrusion temp. min_extrude_temp must be defined in the extruder config (to about 185) M118 Hotend heating! SET_HEATER_TEMPERATURE HEATER=extruder TARGET={sensor.filament_unload_temp} # restore user temp if it was set before loading TEMPERATURE_WAIT SENSOR=extruder MINIMUM={sensor.filament_unload_temp} #wait for reaching filament unload temp {% endif %} {% if(printer.extruder.target == 0) %} # checing for set temperature if is zero than set to 200 / hotend hot but cooling due to set target temp 0 SET_HEATER_TEMPERATURE HEATER=extruder TARGET={sensor.filament_unload_temp} # restore user temp if it was set before loading TEMPERATURE_WAIT SENSOR=extruder MINIMUM={sensor.filament_unload_temp} #wait for reaching filament unload temp {% endif %} G0 E-5 F3600 #extract filament to cold end G4 P2000 # wait for two seconds G0 E5 F3600 # push the filament back G0 E-5 F3600 #extract filament to cold end G0 E-{sensor.unload_distance} F300 # continue extraction slow allow filament to be cooled enough before reaches the gears M400 M118 Load new filament! Wait until is loaded, then resume printing. SET_HEATER_TEMPERATURE HEATER=extruder TARGET=0 # swicth off heater UPDATE_DELAYED_GCODE ID=clear_loadbusy DURATION=2.5 # timing must be set to clear delay plus 0.5s. is due to wait to remove filament before starting load even in case there is a blob at the tip of the extracted filament which woudl trigger the sensor twice #############################################END filament auto load macro section END*********************************************************** [gcode_macro filament_load_init] gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% if (printer.print_stats.state != "printing") %} {% if(sensor.disable_autoload|lower == 'false') %} filament_load {% else %} M118 Filament auto-load is disabled in the sensor config file! {% endif %} {% else %} M118 Printing! Cant load filament right now! {% endif %} SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=filamentpresent VALUE=1 UPDATE_DELAYED_GCODE ID=clear_changebusy DURATION=2 [gcode_macro filament_load] variable_loadbusy: 0 variable_USER_TEMP: 0 variable_LOAD_TEMP: 0 gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% if loadbusy == 0 %} # requires [virtual_sdcard] SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1 SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=1 {% set USER_TEMP = printer.extruder.target %} # save user set temperature before loading {% set LOAD_TEMP = 0 %} #M118 USER TEMP {USER_TEMP} # echo back for debug only {% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target < sensor.filament_load_min_temp) %} # checking for minimum extrusion temperature # check if temperature is over the minimum extrusion temp. min_extrude_temp must be defined in the extruder config (to about 185) SET_HEATER_TEMPERATURE HEATER=extruder TARGET={sensor.filament_load_temp} # set user defined load temperature {% set LOAD_TEMP = sensor.filament_load_temp %} # save user set temperature before loading M118 Hotend heating! {% endif %} {% if (sensor.enable_beep|lower == 'true') %} M300 # beep sound {% endif %} M118 Filament loading! M82 #set extruder to absolute mode G92 E0 G4 P1500 # wait for 1.5 seconds FORCE_MOVE STEPPER=extruder DISTANCE=15 VELOCITY=10 ACCEL=1000 # load filament inside the gears force move needs to be enabled TEMPERATURE_WAIT SENSOR=extruder MINIMUM={LOAD_TEMP} # wait for reaching set temperature TEMPERATURE_WAIT SENSOR=extruder MINIMUM={USER_TEMP} # wait for reaching set temperature G1 E{sensor.nozzle_purge_length} F{sensor.nozzle_purge_speed} # extrude preconfigured purge length M400 # wait to complete nozzle purge SET_HEATER_TEMPERATURE HEATER=extruder TARGET={USER_TEMP} # restore user temp if it was set before loading M118 Filament load complete! UPDATE_DELAYED_GCODE ID=clear_unloadbusy DURATION=2 {% else %} M118 Filament already loaded! {% endif %} #############################################END filament suto load macro section END*********************************************************** #############################################filament auto unload macro section***************************************************************** [gcode_macro filament_unload_init] gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% if (printer.print_stats.state != "printing") %} {% if(sensor.disable_autounload|lower == 'false') %} filament_unload {% else %} M118 Filament auto-unload is disabled in the sensor config file! {% endif %} {% else %} M118 Printing! Cant unload filament right now! {% endif %} [gcode_macro filament_unload] variable_unloadbusy: 0 variable_filamentpresent: 0 gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% if unloadbusy == 0 %} # requires [virtual_sdcard] SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=1 SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1 {% if (sensor.enable_beep|lower == 'true') %} M300 # beep sound {% endif %} M118 Filament unloading! M83 G92 E0 # {% if (printer.extruder.can_extrude|lower != 'true') or (printer.extruder.target == 0)%} # checing for minimum extrusion temperature {% if (printer.extruder.can_extrude|lower != 'true')%} # checing for minimum extrusion temperature # check if temperature is over the minimum extrusion temp. min_extrude_temp must be defined in the extruder config (to about 185) M118 Hotend heating! SET_HEATER_TEMPERATURE HEATER=extruder TARGET={sensor.filament_unload_temp} # restore user temp if it was set before loading TEMPERATURE_WAIT SENSOR=extruder MINIMUM={sensor.filament_unload_temp} # wait for reaching configured unload temperature {% endif %} {% if(printer.extruder.target == 0) %} # checing for set temperature if is zero than set to 185 / hotend hot but cooling due to set target temp 0 TEMPERATURE_WAIT SENSOR=extruder MINIMUM={sensor.filament_unload_temp} # wait for reaching configured unload temperature {% endif %} G0 E10 F500 # extruder 20mm of filament before extracting G0 E-5 F3600 #extract filament to cold end G4 P2000 # wait for two seconds G0 E6 F3600 # push the filament back G0 E-10 F3600 #extract filament to cold end G0 E-{sensor.unload_distance} F300 # continue extraction slow allow filament to be cooled enough before reaches the gears M104 S0 T0 M400 # wait to complete unload M118 Filament unload complete! #SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=0 {% else %} M118 Nothing to unload! {% endif %} #############################################END filament auto unload macro section END*********************************************************** [delayed_gcode clear_unloadbusy] gcode: SET_GCODE_VARIABLE MACRO=filament_unload VARIABLE=unloadbusy VALUE=0 #M118 Clear Unload busy! [delayed_gcode clear_changebusy] gcode: SET_GCODE_VARIABLE MACRO=filament_change_state1 VARIABLE=changebusy VALUE=0 #M118 Clear Load busy! [delayed_gcode set_loadbusy] gcode: SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=1 #M118 Set Load busy! [delayed_gcode clear_loadbusy] gcode: SET_GCODE_VARIABLE MACRO=filament_load VARIABLE=loadbusy VALUE=0 #M118 Clear Load busy! ################################################################################################################################# ##################### DELETE PAUSE AND RESUME MACROS IF YOU WANT TO USE YOUR OWN ONES!########################################### ################################################################################################################################# [gcode_macro PAUSE] rename_existing: BASE_PAUSE gcode: {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} {% set x = params.X|default(sensor.park_position_x) %} {% set y = params.Y|default(sensor.park_position_y) %} {% set z = params.Z|default(sensor.park_lift_z)|float %} {% set e = params.E|default(sensor.park_retraction) %} ##### calculate save lift position ##### {% set max_z = printer.toolhead.axis_maximum.z|float %} {% set act_z = printer.toolhead.position.z|float %} {% set lift_z = z|abs %} {% if act_z < (max_z - lift_z) %} {% set z_safe = lift_z %} {% else %} {% set z_safe = max_z - act_z %} {% endif %} SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=bed_restore_temp VALUE={printer.heater_bed.target} SET_GCODE_VARIABLE MACRO=RESUME VARIABLE=extruder_restore_temp VALUE={printer.extruder.target} ##### end of definitions ##### SAVE_GCODE_STATE NAME=PAUSE_state BASE_PAUSE G91 G1 E-{e} F2100 G1 Z{z_safe} G90 G1 X{x} Y{y} F6000 # SET_LED LED=OrbiLED RED=1.0 GREEN=1.0 BLUE=0.0 [gcode_macro RESUME] rename_existing: BASE_RESUME variable_bed_restore_temp:0 variable_extruder_restore_temp:0 gcode: ##### set defaults ##### {% set sensor = printer['gcode_macro _SENSOR_VARIABLES'] %} M118 Restoring heaters temperature, it might take a whyle! M140 S{bed_restore_temp} TEMPERATURE_WAIT SENSOR=heater_bed MINIMUM={bed_restore_temp} M104 S{extruder_restore_temp} TEMPERATURE_WAIT SENSOR=extruder MINIMUM={extruder_restore_temp} {% set e = params.E|default(sensor.park_retraction) %} G91 G1 E{e} F2100 G90 RESTORE_GCODE_STATE NAME=PAUSE_state MOVE=1 BASE_RESUME # SET_LED LED=OrbiLED RED=1.0 GREEN=1.0 BLUE=1.0 # config file version v2.2.04 change note # Commented ou the set Orbiled commands. # config file version v2.2.03 change note # 1 - defined user variables at the begining of the file for easier macro parameters adjustment # 2 - defined disable configuration of features # 3 - included PAUSE and RESUME macros with restoring bed and hotend temperature featres. # config file version v2.2.02 change note # 1 - filament loading will not set hotend temperature to zero in case the hotend was already set hot before the loading / filament change procedure # 2 - Filament load / unload waits for hotend to reach temp not to reach stabilized temperature - faster filament loading and unloading. # 3 - Removed messages to screen, only console echo is present # 4 - Panel beep replaced by M300 / comment it out if not available on your printer # 5 - unload procedure changed for better filament tip forming. # 6 - known issue - if printer paused due to runout detection and new filament is not loaded whiting Klipper heaters timeout period (default is 10min) the heaters will be switched OFF. # If user loads new filament autoload with work with its default loading temperature of 230 deg C but the heaters temperature will not be restored afterwards user needs to set back heaters temperature. # on my printer this timeout also causes loosing of extruder position and printing can be resumed only after homing first and setting back temperatures manually.