diff --git a/HTE530-5-4-22.cfg b/HTE530-5-4-22.cfg index 61abee80fed7..b67207c7b4a0 100644 --- a/HTE530-5-4-22.cfg +++ b/HTE530-5-4-22.cfg @@ -22,8 +22,8 @@ path: /home/ste/uploads [include stereotech_config/second_extruder.cfg] [include stereotech_config/nozzle_offset.cfg] [include stereotech_config/extruder_macros.cfg] -[include stereotech_config/filament_control_2.cfg] -[include stereotech_config/filament_control_second_2.cfg] +[include stereotech_config/filament_control.cfg] +[include stereotech_config/filament_control_second.cfg] [include stereotech_config/power_control.cfg] [include stereotech_config/module_3d_300.cfg] diff --git a/stereotech_config/HFE530-5-3-23.cfg b/stereotech_config/HFE530-5-3-23.cfg index e43db32e3880..5f2eb4d7a074 100644 --- a/stereotech_config/HFE530-5-3-23.cfg +++ b/stereotech_config/HFE530-5-3-23.cfg @@ -22,7 +22,7 @@ path: /home/ste/uploads [include config/fiber_extruder_2.cfg] [include config/fiber_nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] +[include config/filament_control.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/HFE530-5-4-22.cfg b/stereotech_config/HFE530-5-4-22.cfg index f7142c9314b9..a972bbda5764 100644 --- a/stereotech_config/HFE530-5-4-22.cfg +++ b/stereotech_config/HFE530-5-4-22.cfg @@ -22,7 +22,7 @@ path: /home/ste/uploads [include config/fiber_extruder_2.cfg] [include config/fiber_nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] +[include config/filament_control.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/HFE530-5-8-23.cfg b/stereotech_config/HFE530-5-8-23.cfg index 53b25249455e..d18376ed2441 100644 --- a/stereotech_config/HFE530-5-8-23.cfg +++ b/stereotech_config/HFE530-5-8-23.cfg @@ -22,7 +22,7 @@ path: /home/ste/uploads [include config/fiber_extruder_3.cfg] [include config/fiber_nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] +[include config/filament_control.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/HFE530-5-C-22.cfg b/stereotech_config/HFE530-5-C-22.cfg index cb8d69fd182e..98a58dd75c6e 100644 --- a/stereotech_config/HFE530-5-C-22.cfg +++ b/stereotech_config/HFE530-5-C-22.cfg @@ -22,7 +22,7 @@ path: /home/ste/uploads [include config/fiber_extruder_2.cfg] [include config/fiber_nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] +[include config/filament_control.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/HTE530-5-3-23.cfg b/stereotech_config/HTE530-5-3-23.cfg index 5039dbbbea45..963edf7f53fe 100644 --- a/stereotech_config/HTE530-5-3-23.cfg +++ b/stereotech_config/HTE530-5-3-23.cfg @@ -22,8 +22,8 @@ path: /home/ste/uploads [include config/second_extruder.cfg] [include config/nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] -[include config/filament_control_second_2.cfg] +[include config/filament_control.cfg] +[include config/filament_control_second.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/HTE530-5-4-22.cfg b/stereotech_config/HTE530-5-4-22.cfg index 742e9b54cab8..f31f64b11622 100644 --- a/stereotech_config/HTE530-5-4-22.cfg +++ b/stereotech_config/HTE530-5-4-22.cfg @@ -22,8 +22,8 @@ path: /home/ste/uploads [include config/second_extruder.cfg] [include config/nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] -[include config/filament_control_second_2.cfg] +[include config/filament_control.cfg] +[include config/filament_control_second.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/HTE530-5-8-23.cfg b/stereotech_config/HTE530-5-8-23.cfg index 78b6d664a8b2..0bf5d9db0a6d 100644 --- a/stereotech_config/HTE530-5-8-23.cfg +++ b/stereotech_config/HTE530-5-8-23.cfg @@ -22,8 +22,8 @@ path: /home/ste/uploads [include config/second_extruder.cfg] [include config/nozzle_offset.cfg] [include config/extruder_macros.cfg] -[include config/filament_control_2.cfg] -[include config/filament_control_second_2.cfg] +[include config/filament_control.cfg] +[include config/filament_control_second.cfg] [include config/power_control.cfg] [include config/module_3d_300.cfg] diff --git a/stereotech_config/filament_control.cfg b/stereotech_config/filament_control.cfg index e34638a518e1..6bc81265888a 100644 --- a/stereotech_config/filament_control.cfg +++ b/stereotech_config/filament_control.cfg @@ -1,39 +1,18 @@ [filament_motion_sensor extruder_sensor] extruder: extruder detection_length: 10.5 -event_delay: 60.0 +event_delay: 15.0 switch_pin: PG14 pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} M117 trigered_filament_sensor0 - {action_respond_warning('The filament has run out or there is a problem with its supply at the Extruder0.')} - PAUSE TURN_OFF_EXTRUDERS=0 E=0 - M400 - SET_STATE_TRY_EXTRUDE_FILAMENT SENSOR='extruder_sensor' ENABLE=1 - UPDATE_STATE_FILAMENT_RUNOUT_POSITION SENSOR='extruder_sensor' - G4 P1000 - TRY_DO_EXTRUDE SENSOR='extruder_sensor' - SET_STATE_TRY_EXTRUDE_FILAMENT SENSOR='extruder_sensor' ENABLE=0 - CHECK_FILAMENT_MOTION_SENSOR SENSOR='extruder_sensor' + {action_respond_warning('411: The filament has run out or there is a problem with its supply at the Extruder0.')} + RECOVER_EXTRUSION SENSOR='extruder_sensor' {% else %} FILAMENT_ERROR EXTRUDER=extruder {% endif %} -[gcode_macro TRY_DO_EXTRUDE] -variable_retries_count: 1 -gcode: - {% set sensor = params.SENSOR %} - {% if printer[printer.toolhead.extruder].can_extrude %} - M400 - M117 try_do_extrude_{printer["gcode_macro TRY_DO_EXTRUDE"].retries_count} - EXTRUDE_WITH_CURRENT_TEMP - M400 - EXTRUDE_WITH_COOLING_AND_HEATING SENSOR={sensor} - {% else %} - {action_respond_warning('Extruder not heat enough!')} - {% endif %} - [gcode_macro FILAMENT_ERROR] gcode: {% if params.EXTRUDER == 'extruder' %} @@ -48,128 +27,162 @@ gcode: SET_FILAMENT_SENSOR_OLD SENSOR={params.SENSOR} ENABLE={params.ENABLE} SAVE_VARIABLE VARIABLE={params.SENSOR} VALUE={params.ENABLE} -[gcode_macro CHECK_FILAMENT_MOTION_SENSOR] +[gcode_macro RECOVER_EXTRUSION] +variable_enable_offset: 1 +variable_enable_prime: 1 +variable_enable_second_extruder: 0 +variable_count_trigered_sensor: 0 gcode: {% set sensor = params.SENSOR %} - {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} - {% if filament_detected %} - {action_respond_warning('Extruding attempt completed successfully, resuming printing.')} - M117 resume_after_trigered_sensor - RESUME + {% if params.RESET %} + RECOVER_EXTRUSION_BY_OFFSET RESET=1 + RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor} RESET=1 + {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder %} + RECOVER_EXTRUSION_BY_SECOND_EXTRUDER RESET=1 + {% endif %} + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 + SET_PRINT_STATS_INFO COUNT_TRIGERED_SENSOR={printer["gcode_macro RECOVER_EXTRUSION"].count_trigered_sensor} + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_trigered_sensor VALUE=0 {% else %} - M117 failed_try_do_extrude - {action_respond_warning('All extruding attempt completed failed.')} - {% if sensor == 'extruder_sensor' %} - SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=0 - {% elif sensor == 'extruder1_sensor' %} - SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_trigered_sensor VALUE={printer["gcode_macro RECOVER_EXTRUSION"].count_trigered_sensor + 1} + {% if printer.print_stats.info.current_layer == 0 and printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} + {action_respond_warning('412: Recover extrusion by offset %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made)} + RECOVER_EXTRUSION_BY_OFFSET SENSOR={sensor} + {% else %} + {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset %} + RECOVER_EXTRUSION_BY_OFFSET RESET=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=0 + {% endif %} + {% if not printer.pause_resume.is_paused %} + PAUSE TURN_OFF_EXTRUDERS=0 E=0 + {% endif %} + {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_prime and (printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].check_count or printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].use_cooldown) %} + RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor} + {% else %} + {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_prime %} + RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor} RESET=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=0 + {% endif %} + {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder and sensor == 'extruder_sensor' and printer["filament_motion_sensor extruder1_sensor"] and not printer["gcode_macro RECOVER_EXTRUSION_BY_SECOND_EXTRUDER"].enabled %} + RECOVER_EXTRUSION_BY_SECOND_EXTRUDER + {% else %} + {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder and sensor == 'extruder_sensor' %} + {action_respond_warning('413: Switch to second extruder and resume printing.')} + RECOVER_EXTRUSION_BY_SECOND_EXTRUDER RESET=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 + {% endif %} + #Set timeout and wait for user + {action_respond_warning('414: All attempt to extrude failed.')} + M117 all_attempt_extrude_failed + UPDATE_DELAYED_GCODE ID=TURN_OFF_EXTRUDERS_DELAYED DURATION=300 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=1 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 + {% endif %} + {% endif %} {% endif %} - UPDATE_DELAYED_GCODE ID=CHECK_PRINT_CONTINUE_DELAYED DURATION=300 {% endif %} -[delayed_gcode CHECK_PRINT_CONTINUE_DELAYED] +[delayed_gcode RECOVER_EXTRUSION_DELAY] gcode: - ; checking the printer state is pause, maybe user resumed printing - {% if printer.pause_resume.is_paused %} - {% if printer["gcode_macro CONTINUE_PRINT_WITH_EXTRUDER"].enabled|int > 0 %} - {action_respond_warning('Function "continue printing with another extruder" is enabled')} - CONTINUE_PRINT_WITH_EXTRUDER + RECOVER_EXTRUSION SENSOR='extruder_sensor' + +[gcode_macro RECOVER_EXTRUSION_BY_OFFSET] +variable_check_count: 3 +variable_checks_made: 0 +variable_check_value: 0.1 +gcode: + {% set sensor = params.SENSOR %} + {% if params.RESET %} + {% set reset_value = printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value * printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made %} + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_OFFSET VARIABLE=checks_made VALUE=0 + {% if printer.gcode_move.current_wcs == 0 %} + SET_GCODE_OFFSET Z_ADJUST=-{reset_value} MOVE=1 + {% else %} + G10 L2 P0 R1 Z-{reset_value} + {% endif %} + {% else %} + M117 recover_extrusion_by_offset_attempt_{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made + 1} + {% if printer.gcode_move.current_wcs == 0 %} + SET_GCODE_OFFSET Z_ADJUST={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} MOVE=1 {% else %} - {action_respond_warning('Function "continue printing with another extruder" is disabled. Turn off all extruder')} - TURN_OFF_EXTRUDERS + G10 L2 P0 R1 Z{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} {% endif %} + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_OFFSET VARIABLE=checks_made VALUE={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made + 1} + UPDATE_STATE_FILAMENT_RUNOUT_POSITION SENSOR={sensor} {% endif %} -[gcode_macro CONTINUE_PRINT_WITH_EXTRUDER] -variable_enabled: 0 -variable_triggered_extruder: -1 +[gcode_macro RECOVER_EXTRUSION_BY_PRIME] +variable_check_count: 3 +variable_checks_made: 0 +variable_use_cooldown: 1 gcode: - ; checked what the printer name is hybrid(get objekt extruder1_sensor). - {% if printer.pause_resume.is_paused and printer["filament_motion_sensor extruder1_sensor"] %} - {% set triggered_extruder = printer["gcode_macro CONTINUE_PRINT_WITH_EXTRUDER"].triggered_extruder|int %} - {% if triggered_extruder == 0 %} - {action_reaction_respond_warningspond_info('Printing continued with extruder 2.')} - M117 resume_print_another_extruder - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=1 - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE=0 - SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=1 - RESUME - {% elif triggered_extruder == 1 %} - {action_respond_warning('Continue printing with extruder0 fails because this function is not available.')} - {action_respond_warning('Turn off all extruder')} - TURN_OFF_EXTRUDERS - SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=-1 + {% set sensor = params.SENSOR %} + {% set extruder = 'extruder' if sensor == 'extruder_sensor' else 'extruder1' %} + {% if params.RESET %} + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=checks_made VALUE=0 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=use_cooldown VALUE=1 + {% else %} + {% if printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].use_cooldown and printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made >= printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].check_count %} + {% set extruder_temp = printer["gcode_macro PAUSE"].extruder_temp if extruder == 'extruder' else printer["gcode_macro PAUSE"].extruder1_temp %} + {action_respond_warning('415: Recover extrusion after cooling and heating.')} + M106 S255 + M109 S50 + M107 + M109 S{extruder_temp} + M400 + G4 P3000 + LOAD_MATERIAL + LOAD_MATERIAL + M400 + G4 P3000 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=use_cooldown VALUE=0 + CHECK_FILAMENT_MOTION_SENSOR SENSOR={sensor} {% else %} - {action_respond_warning('Turn off all extruder')} - TURN_OFF_EXTRUDERS + {action_respond_warning('416: Recover extrusion do extrude attempt %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made)} + M117 try_do_extrude_{printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made + 1} + M400 + G4 P3000 + LOAD_MATERIAL + LOAD_MATERIAL + M400 + G4 P3000 + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=checks_made VALUE={printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made + 1} + CHECK_FILAMENT_MOTION_SENSOR SENSOR={sensor} {% endif %} {% endif %} -[gcode_macro RESET_CONTINUE_PRINT_WITH_EXTRUDER] -variable_needed_reset: 0 +[gcode_macro CHECK_FILAMENT_MOTION_SENSOR] gcode: - {% if printer["gcode_macro RESET_CONTINUE_PRINT_WITH_EXTRUDER"].needed_reset > 0 %} - {action_respond_warning('Reset offset.')} - SET_GCODE_OFFSET X_ADJUST=25.0 MOVE=1 - ENABLE_CONSTRAIN ENABLE=0 - SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=1 - SET_GCODE_VARIABLE MACRO=RESET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_reset VALUE=0 - {% endif %} - {% if params.RESET_VARIABLES|default(0) > 0 %} - {action_respond_warning('Reset variable.')} - SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=enabled VALUE=0 - SET_GCODE_VARIABLE MACRO=CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=triggered_extruder VALUE=-1 - SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=0 - SET_GCODE_VARIABLE MACRO=RESET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_reset VALUE=0 + {% set sensor = params.SENSOR %} + {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} + {% if filament_detected %} + {action_respond_warning('417: Extruding attempt completed successfully, resuming printing.')} + M117 resume_after_trigered_sensor + RESUME + {% else %} + UPDATE_DELAYED_GCODE ID=RECOVER_EXTRUSION_DELAY DURATION=1 {% endif %} -[gcode_macro SET_CONTINUE_PRINT_WITH_EXTRUDER] -variable_needed_set: 0 +[gcode_macro RECOVER_EXTRUSION_BY_SECOND_EXTRUDER] +variable_enabled: 0 gcode: - {% if printer["gcode_macro SET_CONTINUE_PRINT_WITH_EXTRUDER"].needed_set|int > 0 %} - {action_respond_warning('An offset is set to continue printing on another extruder.')} + {% if params.RESET and printer["gcode_macro RECOVER_EXTRUSION_BY_SECOND_EXTRUDER"].enabled %} + SET_GCODE_OFFSET X_ADJUST=25.0 MOVE=1 + ENABLE_CONSTRAIN ENABLE=0 + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=0 + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE=0 + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_SECOND_EXTRUDER VARIABLE=enabled VALUE=0 + {% else %} + M117 resume_print_another_extruder + SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_SECOND_EXTRUDER VARIABLE=enabled VALUE=1 SET_GCODE_OFFSET X_ADJUST=-25.0 MOVE=1 - ;if an offset is added, movement beyond coord_min is possible, you need to enable the coordinate limit for movement in the tolhead module ENABLE_CONSTRAIN ENABLE=1 - SET_GCODE_VARIABLE MACRO=RESET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_reset VALUE=1 - SET_GCODE_VARIABLE MACRO=SET_CONTINUE_PRINT_WITH_EXTRUDER VARIABLE=needed_set VALUE=0 - {% endif %} - -[gcode_macro EXTRUDE_WITH_CURRENT_TEMP] -description: Trying to extrude the filament. -gcode: - {% for attempt in range(printer["gcode_macro TRY_DO_EXTRUDE"].retries_count|int) %} - {action_respond_warning('Attempt to extrude the filament.')} - G91 - G0 E25 F600 - G90 - {% endfor %} - -[gcode_macro EXTRUDE_WITH_COOLING_AND_HEATING] -description: Trying to extrude the filament after the extruder has cooled down. -gcode: - {% set sensor = params.SENSOR %} - {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} - {% if not filament_detected %} - {action_respond_warning('Attempt to extrude the filament is failed.')} - {% if sensor == 'extruder_sensor' %} - {action_respond_warning('Cooling and heat extruder0.')} - {% set temp_extruder = printer["gcode_macro PAUSE"].extruder_temp|int %} - M117 cooling_extruder - M109 T0 S50 - M117 heat_extruder - M109 T0 S{temp_extruder} - {% elif sensor == 'extruder1_sensor' %} - {action_respond_warning('Cooling and heat extruder1.')} - {% set temp_extruder = printer["gcode_macro PAUSE"].extruder1_temp|int %} - M117 cooling_extruder - M109 T1 S50 - M117 heat_extruder - M109 T1 S{temp_extruder} - {% endif %} - UPDATE_STATE_FILAMENT_RUNOUT_POSITION SENSOR={sensor} - EXTRUDE_WITH_CURRENT_TEMP - M400 + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=1 + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} + SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE=0 + RESUME {% endif %} - G4 P2000 diff --git a/stereotech_config/filament_control_2.cfg b/stereotech_config/filament_control_2.cfg deleted file mode 100644 index 6bc81265888a..000000000000 --- a/stereotech_config/filament_control_2.cfg +++ /dev/null @@ -1,188 +0,0 @@ -[filament_motion_sensor extruder_sensor] -extruder: extruder -detection_length: 10.5 -event_delay: 15.0 -switch_pin: PG14 -pause_on_runout: False -runout_gcode: - {% if printer.virtual_sdcard.is_active %} - M117 trigered_filament_sensor0 - {action_respond_warning('411: The filament has run out or there is a problem with its supply at the Extruder0.')} - RECOVER_EXTRUSION SENSOR='extruder_sensor' - {% else %} - FILAMENT_ERROR EXTRUDER=extruder - {% endif %} - -[gcode_macro FILAMENT_ERROR] -gcode: - {% if params.EXTRUDER == 'extruder' %} - {action_raise_error('401: Filament error on Extruder0')} - {% else %} - {action_raise_error('402: Filament error on Extruder1')} - {% endif %} - -[gcode_macro SET_FILAMENT_SENSOR] -rename_existing: SET_FILAMENT_SENSOR_OLD -gcode: - SET_FILAMENT_SENSOR_OLD SENSOR={params.SENSOR} ENABLE={params.ENABLE} - SAVE_VARIABLE VARIABLE={params.SENSOR} VALUE={params.ENABLE} - -[gcode_macro RECOVER_EXTRUSION] -variable_enable_offset: 1 -variable_enable_prime: 1 -variable_enable_second_extruder: 0 -variable_count_trigered_sensor: 0 -gcode: - {% set sensor = params.SENSOR %} - {% if params.RESET %} - RECOVER_EXTRUSION_BY_OFFSET RESET=1 - RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor} RESET=1 - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder %} - RECOVER_EXTRUSION_BY_SECOND_EXTRUDER RESET=1 - {% endif %} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 - SET_PRINT_STATS_INFO COUNT_TRIGERED_SENSOR={printer["gcode_macro RECOVER_EXTRUSION"].count_trigered_sensor} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_trigered_sensor VALUE=0 - {% else %} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=count_trigered_sensor VALUE={printer["gcode_macro RECOVER_EXTRUSION"].count_trigered_sensor + 1} - {% if printer.print_stats.info.current_layer == 0 and printer["gcode_macro RECOVER_EXTRUSION"].enable_offset and printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_count %} - {action_respond_warning('412: Recover extrusion by offset %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made)} - RECOVER_EXTRUSION_BY_OFFSET SENSOR={sensor} - {% else %} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_offset %} - RECOVER_EXTRUSION_BY_OFFSET RESET=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=0 - {% endif %} - {% if not printer.pause_resume.is_paused %} - PAUSE TURN_OFF_EXTRUDERS=0 E=0 - {% endif %} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_prime and (printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made < printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].check_count or printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].use_cooldown) %} - RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor} - {% else %} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_prime %} - RECOVER_EXTRUSION_BY_PRIME SENSOR={sensor} RESET=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=0 - {% endif %} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder and sensor == 'extruder_sensor' and printer["filament_motion_sensor extruder1_sensor"] and not printer["gcode_macro RECOVER_EXTRUSION_BY_SECOND_EXTRUDER"].enabled %} - RECOVER_EXTRUSION_BY_SECOND_EXTRUDER - {% else %} - {% if printer["gcode_macro RECOVER_EXTRUSION"].enable_second_extruder and sensor == 'extruder_sensor' %} - {action_respond_warning('413: Switch to second extruder and resume printing.')} - RECOVER_EXTRUSION_BY_SECOND_EXTRUDER RESET=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 - {% endif %} - #Set timeout and wait for user - {action_respond_warning('414: All attempt to extrude failed.')} - M117 all_attempt_extrude_failed - UPDATE_DELAYED_GCODE ID=TURN_OFF_EXTRUDERS_DELAYED DURATION=300 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_offset VALUE=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_prime VALUE=1 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION VARIABLE=enable_second_extruder VALUE=0 - {% endif %} - {% endif %} - {% endif %} - {% endif %} - -[delayed_gcode RECOVER_EXTRUSION_DELAY] -gcode: - RECOVER_EXTRUSION SENSOR='extruder_sensor' - -[gcode_macro RECOVER_EXTRUSION_BY_OFFSET] -variable_check_count: 3 -variable_checks_made: 0 -variable_check_value: 0.1 -gcode: - {% set sensor = params.SENSOR %} - {% if params.RESET %} - {% set reset_value = printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value * printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made %} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_OFFSET VARIABLE=checks_made VALUE=0 - {% if printer.gcode_move.current_wcs == 0 %} - SET_GCODE_OFFSET Z_ADJUST=-{reset_value} MOVE=1 - {% else %} - G10 L2 P0 R1 Z-{reset_value} - {% endif %} - {% else %} - M117 recover_extrusion_by_offset_attempt_{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made + 1} - {% if printer.gcode_move.current_wcs == 0 %} - SET_GCODE_OFFSET Z_ADJUST={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} MOVE=1 - {% else %} - G10 L2 P0 R1 Z{printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].check_value} - {% endif %} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_OFFSET VARIABLE=checks_made VALUE={printer["gcode_macro RECOVER_EXTRUSION_BY_OFFSET"].checks_made + 1} - UPDATE_STATE_FILAMENT_RUNOUT_POSITION SENSOR={sensor} - {% endif %} - -[gcode_macro RECOVER_EXTRUSION_BY_PRIME] -variable_check_count: 3 -variable_checks_made: 0 -variable_use_cooldown: 1 -gcode: - {% set sensor = params.SENSOR %} - {% set extruder = 'extruder' if sensor == 'extruder_sensor' else 'extruder1' %} - {% if params.RESET %} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=checks_made VALUE=0 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=use_cooldown VALUE=1 - {% else %} - {% if printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].use_cooldown and printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made >= printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].check_count %} - {% set extruder_temp = printer["gcode_macro PAUSE"].extruder_temp if extruder == 'extruder' else printer["gcode_macro PAUSE"].extruder1_temp %} - {action_respond_warning('415: Recover extrusion after cooling and heating.')} - M106 S255 - M109 S50 - M107 - M109 S{extruder_temp} - M400 - G4 P3000 - LOAD_MATERIAL - LOAD_MATERIAL - M400 - G4 P3000 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=use_cooldown VALUE=0 - CHECK_FILAMENT_MOTION_SENSOR SENSOR={sensor} - {% else %} - {action_respond_warning('416: Recover extrusion do extrude attempt %s' % printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made)} - M117 try_do_extrude_{printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made + 1} - M400 - G4 P3000 - LOAD_MATERIAL - LOAD_MATERIAL - M400 - G4 P3000 - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_PRIME VARIABLE=checks_made VALUE={printer["gcode_macro RECOVER_EXTRUSION_BY_PRIME"].checks_made + 1} - CHECK_FILAMENT_MOTION_SENSOR SENSOR={sensor} - {% endif %} - {% endif %} - -[gcode_macro CHECK_FILAMENT_MOTION_SENSOR] -gcode: - {% set sensor = params.SENSOR %} - {% set filament_detected = printer['filament_motion_sensor ' ~ sensor].filament_detected %} - {% if filament_detected %} - {action_respond_warning('417: Extruding attempt completed successfully, resuming printing.')} - M117 resume_after_trigered_sensor - RESUME - {% else %} - UPDATE_DELAYED_GCODE ID=RECOVER_EXTRUSION_DELAY DURATION=1 - {% endif %} - -[gcode_macro RECOVER_EXTRUSION_BY_SECOND_EXTRUDER] -variable_enabled: 0 -gcode: - {% if params.RESET and printer["gcode_macro RECOVER_EXTRUSION_BY_SECOND_EXTRUDER"].enabled %} - SET_GCODE_OFFSET X_ADJUST=25.0 MOVE=1 - ENABLE_CONSTRAIN ENABLE=0 - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=0 - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE=0 - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_SECOND_EXTRUDER VARIABLE=enabled VALUE=0 - {% else %} - M117 resume_print_another_extruder - SET_GCODE_VARIABLE MACRO=RECOVER_EXTRUSION_BY_SECOND_EXTRUDER VARIABLE=enabled VALUE=1 - SET_GCODE_OFFSET X_ADJUST=-25.0 MOVE=1 - ENABLE_CONSTRAIN ENABLE=1 - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=current_extruder VALUE=1 - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder1_temp VALUE={printer["gcode_macro PAUSE"].extruder_temp} - SET_GCODE_VARIABLE MACRO=PAUSE VARIABLE=extruder_temp VALUE=0 - RESUME - {% endif %} diff --git a/stereotech_config/filament_control_second.cfg b/stereotech_config/filament_control_second.cfg index e30339e681ab..8b4115062902 100644 --- a/stereotech_config/filament_control_second.cfg +++ b/stereotech_config/filament_control_second.cfg @@ -1,21 +1,14 @@ [filament_motion_sensor extruder1_sensor] extruder: extruder1 detection_length: 10.5 -event_delay: 60.0 +event_delay: 15.0 switch_pin: PG15 pause_on_runout: False runout_gcode: {% if printer.virtual_sdcard.is_active %} M117 trigered_filament_sensor1 {action_respond_warning('411: The filament has run out or there is a problem with its supply at the Extruder2.')} - PAUSE TURN_OFF_EXTRUDERS=0 E=0 - M400 - SET_STATE_TRY_EXTRUDE_FILAMENT SENSOR='extruder1_sensor' ENABLE=1 - UPDATE_STATE_FILAMENT_RUNOUT_POSITION SENSOR='extruder1_sensor' - G4 P1000 - TRY_DO_EXTRUDE SENSOR='extruder1_sensor' - SET_STATE_TRY_EXTRUDE_FILAMENT SENSOR='extruder1_sensor' ENABLE=0 - CHECK_FILAMENT_MOTION_SENSOR SENSOR='extruder1_sensor' + RECOVER_EXTRUSION SENSOR='extruder1_sensor' {% else %} FILAMENT_ERROR EXTRUDER=extruder1 {% endif %} diff --git a/stereotech_config/filament_control_second_2.cfg b/stereotech_config/filament_control_second_2.cfg deleted file mode 100644 index 8b4115062902..000000000000 --- a/stereotech_config/filament_control_second_2.cfg +++ /dev/null @@ -1,14 +0,0 @@ -[filament_motion_sensor extruder1_sensor] -extruder: extruder1 -detection_length: 10.5 -event_delay: 15.0 -switch_pin: PG15 -pause_on_runout: False -runout_gcode: - {% if printer.virtual_sdcard.is_active %} - M117 trigered_filament_sensor1 - {action_respond_warning('411: The filament has run out or there is a problem with its supply at the Extruder2.')} - RECOVER_EXTRUSION SENSOR='extruder1_sensor' - {% else %} - FILAMENT_ERROR EXTRUDER=extruder1 - {% endif %}