Skip to content

Commit

Permalink
4.5.23
Browse files Browse the repository at this point in the history
  • Loading branch information
DrumClock committed May 4, 2023
1 parent a840855 commit 538e550
Show file tree
Hide file tree
Showing 8 changed files with 86 additions and 126 deletions.
158 changes: 55 additions & 103 deletions 4EX2/SYNC_MULTI_HOTEND.cfg
Original file line number Diff line number Diff line change
@@ -1,60 +1,56 @@
#-------------------- SYNC MULTI HOTEND---------------------------------------------

### filament insertion check for SYNC-MULTI hotend during printing
# {% if 'gcode_macro SYNC_MULTI_HOTEND' in printer %} #and printer['virtual_sdcard'].is_active == true %}
# SYNC_MULTI_HOTEND EXTRUDERS={tool_0 + "," + tool_1}
# {% endif %}


# ------------------------ user_variable ---------------------------------


# sync_switching_tool : 'T0': {0:'extruder', 1: 'extruder2'}, 'T1':{ 0:'extruder1', 1: 'extruder3' }
# multi_hotend = {1: 'extruder3', 0: 'extruder1', 'unload': 40, 'load': 60, 'speed': 25, 'parking': [-32, 278], 'feedrate': 30000}


##########################################################################
[gcode_macro SYNC_MULTI_HOTEND]
description: SYNC_MULTI_HOTEND EXTRUDERS={extruder,extruder2}
gcode:

{% set user_vars = printer["gcode_macro VARIABLE"] %}
{% set init = user_vars.multi_hotend %}
{% set user_vars = printer["gcode_macro VARIABLE"] %}
{% set systems = 'TOOL' if 'gcode_macro SWITCHING_EXTRUDER' in printer or 'gcode_macro SWITCHING_HOTEND' in printer
else 'EXTRUDER' %}

### filament insertion check for SYNC-MULTI hotend during printing
# {% if params.EXTRUDERS is defined and params.EXTRUDERS.split(",")|length == 2 %}
{% set target_extruder_0 = params.EXTRUDERS.split(",")[0] %}
{% set target_extruder_1 = params.EXTRUDERS.split(",")[1] %}
{% if params.EXTRUDERS is defined and params.EXTRUDERS.split(",")|length == 2 %}
{% set target_extruder_0 = params.EXTRUDERS.split(",")[0] | default(user_vars.toolhead[0][0]) %} # default = carriage 0 / tool 0
{% set target_extruder_1 = params.EXTRUDERS.split(",")[1] | default(user_vars.toolhead[1][0]) %} # default = carriage 1 / tool 0

{action_respond_info("target_extruder_0 = %s" % target_extruder_0 )}
{action_respond_info("target_extruder_1 = %s" % target_extruder_1 )}
{% if target_extruder_0 != user_vars.multi_hotend.0 %}

# {action_respond_info("target_extruder_0 = %s" % target_extruder_0 )}
# {action_respond_info("target_extruder_1 = %s" % target_extruder_1 )}

### unsync both carriages
SET_DUAL_CARRIAGE_MODE MODE=FULL_CONTROL
## ! cariiages must be unsync !

### parking carriages
SYNC_MULTI_HOTEND_PARKING

# >>>>>>>>>>>>>>>>>>>>

### sync unload filament
MULTI_CHANGE_FILAMENT ACTION=unload
G4 P2000

### sync load filament
ACTIVATE_{systems} EXTRUDER={target_extruder_1}
ACTIVATE_{systems} EXTRUDER={target_extruder_0}
SYNC_EXTRUDER_MOTION EXTRUDER={user_vars.toolhead[1][0]} MOTION_QUEUE={target_extruder_0}
MULTI_CHANGE_FILAMENT ACTION=load
G4 P2000


### sync change filament
SYNC_MULTI_CHANGE_FILAMENT EXTRUDER={target_extruder_0}

# >>>>>>>>>>>>>>>>>>>>
### update and save variable after sync change filament
SYNC_MULTI_HOTEND_UPDATE_VARIABLE EXTRUDERS={target_extruder_0 + "," + target_extruder_1}

### restore parking carriages
SYNC_MULTI_HOTEND_RESTORE_PARKING

### re-activate mode
{% if user_vars.idex_mode.active == 2 %}
SET_DUAL_CARRIAGE_MODE MODE=DUPLICATION
{% elif user_vars.idex_mode.active == 3 %}
SET_DUAL_CARRIAGE_MODE MODE=MIRRORED
{% endif %}


# {% else %}
# {action_respond_info("Not defined params EXTRUDERS !")}
# {% endif %}
SYNC_MULTI_HOTEND_RESTORE_PARKING

{% endif %}

{% else %}
{action_respond_info("Not defined params EXTRUDERS !")}
{% endif %}

############################################################################
[gcode_macro SYNC_MULTI_HOTEND_PARKING]
Expand All @@ -68,8 +64,8 @@ gcode:
else 'x' %}

### actual position crriage 0 / 1
{% set axis_pos_0 = printer['dual_carriage'].init_mode_positions[0][ (0 if axis == 'x' else 1) |int] %}
{% set axis_pos_1 = printer['dual_carriage'].init_mode_positions[1][ (0 if axis == 'x' else 1) |int] %}
{% set pos_carr_0 = printer['dual_carriage'].init_mode_positions[0][ (0 if axis == 'x' else 1) |int] %}
{% set pos_carr_1 = printer['dual_carriage'].init_mode_positions[1][ (0 if axis == 'x' else 1) |int] %}

### parking the carriage 0 to position
SET_DUAL_CARRIAGE CARRIAGE=0
Expand All @@ -80,7 +76,7 @@ gcode:
G1 {axis + ( user_vars.multi_hotend.parking.1|string)} F{user_vars.multi_hotend.feedrate}

### create variable 'gcode_position'
{% set _dummy = init.update( {'gcode_position':{ 'axis':axis , 'value_0':axis_pos_0|float, 'value_1':axis_pos_1|float }} ) %}
{% set _dummy = init.update( {'gcode_position':{ 'axis':axis , 'pos_carr_0':pos_carr_0|float, 'pos_carr_1':pos_carr_1|float }} ) %}
SET_GCODE_VARIABLE MACRO=VARIABLE VARIABLE=multi_hotend VALUE="{init}"


Expand All @@ -90,18 +86,18 @@ gcode:

{% set user_vars = printer["gcode_macro VARIABLE"] %}
{% set init = user_vars.multi_hotend %}

{% set axis = init.gcode_position.axis %}
{% set axis_pos_0 = init.gcode_position.value_0 %}
{% set axis_pos_1 = init.gcode_position.value_1 %}
{% set pos_carr_0 = init.gcode_position.pos_carr_0 %}
{% set pos_carr_1 = init.gcode_position.pos_carr_1 %}

### restore position befor park carrige 0
SET_DUAL_CARRIAGE CARRIAGE=0
G1 {axis + ( axis_pos_0|string)} F{user_vars.multi_hotend.feedrate}
G1 {axis + ( pos_carr_0|string)} F{user_vars.multi_hotend.feedrate}

### restore position befor park carrige 1
SET_DUAL_CARRIAGE CARRIAGE=1
G1 {axis + ( axis_pos_1|string)} F{user_vars.multi_hotend.feedrate}
G1 {axis + ( pos_carr_1|string)} F{user_vars.multi_hotend.feedrate}


### delete variable 'gcode_position'
Expand All @@ -110,65 +106,21 @@ gcode:


############################################################################
[gcode_macro SYNC_MULTI_CHANGE_FILAMENT]
gcode:

{% set user_vars = printer["gcode_macro VARIABLE"] %}
{% set name = "multi_hotend" %} # name variable
{% set init = user_vars.multi_hotend %} # default preset
[gcode_macro SYNC_MULTI_HOTEND_UPDATE_VARIABLE]
gcode:

{% set target_extruder = params.EXTRUDER|default("extruder") %}
{% set act_extruder = printer.toolhead.extruder %}
{% set user_vars = printer["gcode_macro VARIABLE"] %}
{% set name = "multi_hotend" %} # name variable
{% set init = user_vars.multi_hotend %} # default preset

{% set max_extrude = printer.configfile.settings[(printer.toolhead.extruder)].max_extrude_only_distance|int %}
{% set step = user_vars.multi_hotend.unload // max_extrude|int %}
{% set rest = user_vars.multi_hotend.unload % max_extrude|float %}
{% set target_extruder_0 = params.EXTRUDERS.split(",")[0] | default(user_vars.toolhead[0][0]) %} # default = carriage 0 / tool 0
{% set target_extruder_1 = params.EXTRUDERS.split(",")[1] | default(user_vars.toolhead[1][0]) %} # default = carriage 1 / tool 0


{action_respond_info("target_extruder = %s" % target_extruder )}

SAVE_GCODE_STATE NAME=MULTI_HOTEND

### only when printing and heated extruder
{% if printer[(act_extruder)].can_extrude | lower == 'true' %}
# and printer['virtual_sdcard'].is_active == true %}

### unload activation for "max_extrude_only_distance"

# ACTIVATE_TOOL EXTRUDER={act_extruder}
M83
G92 E0
{% for n in range(step) %}
G1 E{ max_extrude*-1 } F{(user_vars.multi_hotend.speed * 60)|int}
{% endfor %}
{% if rest > 0.0 %}
G1 E{rest*-1 } F{(user_vars.multi_hotend.speed * 60)|int}
{% endif %}

G4 P3000
{% endif %}

### load activation for "max_extrude_only_distance"
{% if printer[(target_extruder)].can_extrude | lower == 'true' %}
# and printer['virtual_sdcard'].is_active == true %}

# ACTIVATE_TOOL EXTRUDER={target_extruder}
M83
G92 E0
{% for n in range(step) %}
G1 E{max_extrude} F{(user_vars.multi_hotend.speed * 60)|int}
{% endfor %}
{% if rest > 0.0 %}
G1 E{rest} F{(user_vars.multi_hotend.speed * 60)|int}
{% endif %}

G4 P3000
### update and save variable after sync change filament
{% set _dummy = init.update( {0 : target_extruder_0} ) %}
{% set _dummy = init.update( {1 : target_extruder_1} ) %}

### update and save variable after load filament
{% set _dummy = init.update( { 0|int : target_extruder} ) %}
SET_GCODE_VARIABLE MACRO=VARIABLE VARIABLE={name} VALUE="{init}"
SAVE_VARIABLE VARIABLE={name} VALUE="{init}"

{% endif %}

RESTORE_GCODE_STATE NAME=MULTI_HOTEND

SET_GCODE_VARIABLE MACRO=VARIABLE VARIABLE={name} VALUE="{init}"
SAVE_VARIABLE VARIABLE={name} VALUE="{init}"

24 changes: 15 additions & 9 deletions 4EX2/SYNC_SWITCHING_TOOL.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,24 @@ gcode:
{% set user_vars = printer["gcode_macro VARIABLE"] %}
{% set target_tool = params.T|default(0)|int %} ; 0

{% if target_tool in [0,1] %}
#{action_respond_info("T=%s" % ext_nr)}
{% if target_tool in [0,1] %}
{% set act_extruder = printer.toolhead.extruder %}

### define sync tool carriage 0/1
{% set axis = printer.configfile.settings.dual_carriage.axis %} ;x
{% set t_code = "T%s" % target_tool %}
{% set tool_0 = user_vars.sync_switching_tool[t_code][0] %} # params.T 0 ='extruder' / 1 ='extruder1'
{% set tool_1 = user_vars.sync_switching_tool[t_code][1] %} # params.T 0 ='extruder2' / 1 ='extruder3'
### define sync tool carriage 0/1
{% set axis = printer.configfile.settings.dual_carriage.axis %} ;x
{% set t_code = "T%s" % target_tool %}
{% set tool_0 = user_vars.sync_switching_tool[t_code][0] %} # params.T 0 ='extruder' / 1 ='extruder1'
{% set tool_1 = user_vars.sync_switching_tool[t_code][1] %} # params.T 0 ='extruder2' / 1 ='extruder3'

{% if tool_0 != act_extruder %}

### unsync both carriages
SET_DUAL_CARRIAGE_MODE MODE=FULL_CONTROL

#-------------------- SYNC MULTI HOTEND---------------------------------------------

### filament insertion check for SYNC-MULTI hotend during printing
{% if 'gcode_macro SYNC_MULTI_HOTEND' in printer %} #and printer['virtual_sdcard'].is_active == true %}
{% if 'gcode_macro MULTI_HOTEND' in printer and 'gcode_macro SYNC_MULTI_HOTEND' in printer %} #and printer['virtual_sdcard'].is_active == true %}
SYNC_MULTI_HOTEND EXTRUDERS={tool_0 + "," + tool_1}
{% endif %}

Expand Down Expand Up @@ -123,8 +125,12 @@ gcode:
### update variable 'sync_switching_tool'
{% set _dummy = user_vars.sync_switching_tool.update( {'active': t_code} ) %}
SET_GCODE_VARIABLE MACRO=VARIABLE VARIABLE=sync_switching_tool VALUE="{user_vars.sync_switching_tool}"

{% else %}
{action_respond_info("The Tool is alredy activated.")}
{% endif %}

{% else %}
{% else %}
### ignore command
{action_respond_info("Ignore command T%s" % target_tool )}
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions MCU/HW_4EX2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ enable_pin: !PB7
microsteps: 16
rotation_distance: 2
endstop_pin: PD8 ### probe:z_virtual_endstop .... for BLTouch
#position_endstop: 0.0 ### in main .... printer.cfg
position_endstop: -0.197 ### in main .... printer.cfg
position_max: 200
position_min: -2 ### The Z carriage may need to travel below the Z=0

Expand Down Expand Up @@ -327,7 +327,7 @@ control_pin: PA15
#probe_with_touch_mode: True
x_offset: 0
y_offset: 0
#z_offset: 2 ### in main .... printer.cfg
z_offset: 2.0 ### in main .... printer.cfg
speed: 5.0
samples: 2
sample_retract_dist: 3.0
Expand Down
10 changes: 5 additions & 5 deletions MULTI/MULTI_HOTEND.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ gcode:


{% if name in recovery %} # -------------------------------------------------
### restore variable from SD card
{action_respond_info("Restore loaded extruder after restart from SD card.")}
### restore variable from SD card
{action_respond_info("Restore loaded extruder after restart from SD card.") if printer.save_variables.variables.dump_list}

{% if user_vars.toolhead|length > 1 %}
{% set init_toolhead_1 = recovery[name].1 %}
Expand Down Expand Up @@ -81,7 +81,7 @@ gcode:

### save / update variable
SET_GCODE_VARIABLE MACRO=VARIABLE VARIABLE={name} VALUE="{init}"
{action_respond_info("Creating a list of variables for multi hotend")}
{action_respond_info("Creating a list of variables for multi hotend") if printer.save_variables.variables.dump_list}


#####################################################################
Expand Down Expand Up @@ -182,8 +182,8 @@ gcode:
{% set rest = user_vars.multi_hotend[action] % max_extrude|float %}

### only when printing and heated extruder
{% if printer[act_extruder].can_extrude | lower == 'true'
and printer['virtual_sdcard'].is_active == true %}
{% if printer[act_extruder].can_extrude | lower == 'true' %}
# and printer['virtual_sdcard'].is_active == true %}

SAVE_GCODE_STATE NAME=MULTI_HOTEND
### load/unload activation for "max_extrude_only_distance"
Expand Down
4 changes: 3 additions & 1 deletion PRINTER/printer_4EX2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#[include /home/pi/my_config/W_T/*]
[include /home/pi/my_config/IDEX/*]
[include /home/pi/my_config/MULTI/*]
#[include /home/pi/my_config/MULTI/*]


### users TESTED mareo configurations ###
Expand All @@ -40,6 +40,8 @@
[include /home/pi/my_config/4EX2/*]
[include /home/pi/my_config/SWITCHING/*]

[include /home/pi/my_config/MULTI/*]


###############################################################
# Define restore default screen after restart
Expand Down
4 changes: 2 additions & 2 deletions save_variables_2in_1out.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ active = {'mode': 0, 'z': {'hop': 4.0, 'restore': 0.0, 'print_offset': 0.0}}
auto_power_off = {'enable': True}
beeper = {'enable': True, 'silent': False, 'output_pin': 'beeper'}
dual_carriage = {'auto_exchange': True, 'movespeed': 500, 'feedrate': 30000}
dump_list = True
dump_list = False
endless_spool = {'enable': False, 'retract': 1, 'extrude': 2}
extrude_factor = {'extruder': 1.0, 'extruder1': 1.0, 'extruder2': 1.0, 'extruder3': 1.0}
fan = {'menu': True, 'index': ['fan', 'fan1'], 'active': 0}
filament_sensor = {'defined': True, 'switch': ['extruder', 'extruder1', 'extruder2', 'extruder3'], 'count': 4}
heater = {1: 'heater_1'}
hotend_offset = {0: {'y': 0.0, 'x': 0.0, 'z': 0.0}, 1: {'y': 0.0, 'x': -10.0, 'z': 0.0}, 2: {'y': 0.0, 'x': 0.0, 'z': 0.0}, 3: {'y': 0.0, 'x': -10.0, 'z': 0.0}, 'change_T0': False}
multi_hotend = {1: 'extruder3', 0: 'extruder1', 'unload': 40, 'load': 60, 'speed': 25, 'parking': [-32, 278], 'feedrate': 30000, 'gcode_position': {'axis': 'x', 'value': 51.952}}
multi_hotend = {1: 'extruder3', 0: 'extruder1', 'unload': 40, 'load': 60, 'speed': 25, 'parking': [-32, 278], 'feedrate': 30000, 'gcode_position': {'axis': 'x', 'value': 50.98}}
neopixel = {'enable': True, 'index': {0: 'axis_X'}, 'RGB': {0: '0,0,0'}, 'menu': {'active': 0}}
offset_temp = {'extruder': 0, 'extruder1': 0, 'extruder2': 0, 'extruder3': 0}
print_mode = {'active': 1, 'enable': False}
Expand Down
4 changes: 2 additions & 2 deletions save_variables_4ex2.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ active = {'z': {'restore': 0.0, 'print_offset': 0.0, 'hop': 4.0}, 'mode': 0}
auto_power_off = {'enable': True}
beeper = {'enable': True, 'silent': False, 'output_pin': 'beeper'}
dual_carriage = {'movespeed': 500, 'feedrate': 30000, 'auto_exchange': True, 'sync_exchange': False, 'parking': [-52, 298]}
dump_list = True
dump_list = False
endless_spool = {'retract': 1, 'extrude': 2, 'enable': False}
extrude_factor = {'extruder': 1.0, 'extruder1': 1.0, 'extruder2': 1.0, 'extruder3': 1.0}
fan = {'active': 0, 'menu': True, 'index': ['fan', 'fan1']}
Expand All @@ -13,7 +13,7 @@ filament_sensor = {'defined': True, 'count': 4, 'switch': ['extruder', 'extruder
heater = {1: 'heater_1'}
hotend_offset = {0: {'y': 0.0, 'x': 0.0, 'z': 0.0}, 1: {'y': 0.0, 'x': -10.0, 'z': 0.0}, 2: {'y': 0.0, 'x': 0.0, 'z': 0.0}, 3: {'y': 0.0, 'x': -10.0, 'z': 0.0}, 'change_T0': False}
idex_mode = {'active': 1, 'movespeed': 500, 'feedrate': 30000, 'carriage_offset': 0, 'position': {'dupl_max': 120, 'dupl_min': 52, 'mirrored': 240}}
multi_hotend = {1: 'extruder3', 0: 'extruder1', 'unload': 40, 'load': 60, 'speed': 25, 'parking': [-32, 278], 'feedrate': 30000, 'gcode_position': {'x': 130.0}}
multi_hotend = {1: 'extruder2', 0: 'extruder', 'unload': 40, 'load': 60, 'speed': 25, 'parking': [-32, 278], 'feedrate': 30000, 'gcode_position': {'axis': 'x', 'pos_carr_0': 50.0, 'pos_carr_1': 170.0}}
neopixel = {'index': {0: 'axis_X'}, 'RGB': {0: '0,0,0'}, 'enable': True, 'menu': {'active': 0}}
offset_temp = {'extruder3': 0, 'extruder1': 0, 'extruder2': 0, 'extruder': 0}
print_mode = {'active': 1, 'enable': False}
Expand Down
4 changes: 2 additions & 2 deletions virtual_printer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@

#[include /home/pi/my_config/PRINTER/printer_IDEX_axis_X.cfg]
#[include /home/pi/my_config/PRINTER/printer_IDEX_axis_Y.cfg]
#[include /home/pi/my_config/PRINTER/printer_4EX2.cfg]
[include /home/pi/my_config/PRINTER/printer_4EX2.cfg]

#[include /home/pi/my_config/PRINTER/printer_DUAL_GANTRY.cfg]

[include /home/pi/my_config/PRINTER/printer_2in_1out.cfg]
#[include /home/pi/my_config/PRINTER/printer_2in_1out.cfg]

#[include /home/pi/my_config/PRINTER/printer_hx711_load_cell.cfg]

Expand Down

0 comments on commit 538e550

Please sign in to comment.