Mixing color support?

I solved my problem for mixing, their error had been that I multiplied the rotation distance by the percentage instead dividing it. I now have the following configs, that seam to work:

# Driver1 (Extruder 1 / T0)
[extruder]
step_pin: PL3 #PL6
dir_pin: PL5 #PL4
enable_pin: !PB6 #!PG0
microsteps: 16
rotation_distance: 6.98159 #7.7# 11.88736 #8.01504 #8.25549
nozzle_diameter: 0.4
filament_diameter: 1.750
heater_pin: PE5 #PE4
sensor_type: Generic 3950
sensor_pin: arduino:PC0 #PF1 #PF0
min_temp: 0 #0
max_temp: 250
min_extrude_temp: 180
max_extrude_only_distance: 150
pressure_advance = 0.6
max_extrude_cross_section: 2

# Driver42 (Extruder 2 / T1)
[extruder_stepper extruder1]
extruder: 
step_pin: PL0
dir_pin: PL2
enable_pin: !PL1
microsteps: 16
rotation_distance: 6.98159 #7.7# 11.88736 #8.01504 #8.25549 #33.500
pressure_advance = 0.6

[gcode_macro T0]
# Extruder 0 with a small amount from E1 to prevent clogging
gcode:
    M163 S0 P99
    M163 S1 P1
    M164
	
[gcode_macro T1]
# Extruder 1 with a small amount from E0 to prevent clogging
gcode:
    M163 S0 P1
    M163 S1 P99
    M164

[gcode_macro T2]
# only Extruder 0
gcode:
    M163 S1 P0
    M163 S0 P100
    M164 

[gcode_macro T3]
#only Extruder 1
gcode:
    M163 S1 P100
    M163 S0 P0
    M164 

[gcode_macro T4]
#only Extruder 1
gcode:
    M163 S1 P50
    M163 S0 P50
    M164 

[gcode_macro M163]  

# M163 [P<factor>] [S<index>] Set a single mix factor (in proportion to the sum total of all mix factors). The mix must be committed to a virtual tool by M164 before it takes effect.
gcode:
  {% if 'P' in params %}
     {% if 'S' in params %}
       {% set s = params.S|default(5)| int %}  
       {% if s == 1 %}
         M118 Set Mixing factor for extruder 1 to {params.P|default(50)|float}
         SET_GCODE_VARIABLE MACRO=M164 VARIABLE=e0_percentage VALUE={params.P|default(50)|float}
       {% else %}
         SET_GCODE_VARIABLE MACRO=M164 VARIABLE=e1_percentage VALUE={params.P|default(50)|float} 
         M118 Set Mixing factor for extruder 0 to {params.P|default(50)|float}
       {% endif %}  
     {% else %}
       SET_GCODE_VARIABLE MACRO=M164 VARIABLE=e0_percentage VALUE={params.P|default(50)|float}
       SET_GCODE_VARIABLE MACRO=M164 VARIABLE=e1_percentage VALUE={100-params.P|default(50)|float}
       M118 Set Mixing factor to {params.P|default(50)|float} and {100-params.P|default(50)|float}
       M118 {e0_percentage} {e1_percentage} 
     {% endif %} 
  {% else %}   
     M118 No Mixing factor set, missing values for P and S
  {% endif %}
   
  
[gcode_macro M164]    
  variable_e0_percentage : 50 # default values
  variable_e1_percentage : 50
  
gcode:
  {% set e0 = e0_percentage / (e0_percentage + e1_percentage) | float %} # later treat the sum for all tools to 100% extrusion
  {% set e1 = e1_percentage / (e0_percentage + e1_percentage) | float %}
  M118 Got e0 { printer.configfile.settings.extruder.rotation_distance }
  M118 Got e1 { printer.configfile.settings['extruder_stepper extruder1'].rotation_distance  }
  #M118 Mixing factor {e0} and {e1} 
  M118 e0 rot-dist { printer.configfile.settings.extruder.rotation_distance * e0|float }
  M118 e1 rot-dist { printer.configfile.settings['extruder_stepper extruder1'].rotation_distance * e1|float } 
   {% if e0 == 0 %}
     # only e1
     SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE= # e0 off
     SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder # Add e1
     SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=extruder DISTANCE={ printer.configfile.settings.extruder.rotation_distance |float }
     SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=extruder1 DISTANCE={ printer.configfile.settings['extruder_stepper extruder1'].rotation_distance |float } 
   {% elif e1 == 0 %}
     # only e0
     SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=extruder # add e0 
     SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE= # e1 off
     SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=extruder DISTANCE={ printer.configfile.settings.extruder.rotation_distance |float }
     SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=extruder1 DISTANCE={ printer.configfile.settings['extruder_stepper extruder1'].rotation_distance |float } 
   {% else %}
     # activate stepper percentages
     SYNC_EXTRUDER_MOTION EXTRUDER=extruder MOTION_QUEUE=extruder # Add e0
     SYNC_EXTRUDER_MOTION EXTRUDER=extruder1 MOTION_QUEUE=extruder # Add e1
     SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=extruder DISTANCE={ printer.configfile.settings.extruder.rotation_distance / e0|float }
     SET_EXTRUDER_ROTATION_DISTANCE EXTRUDER=extruder1 DISTANCE={ printer.configfile.settings['extruder_stepper extruder1'].rotation_distance / e1|float } 
   {% endif %}
  M118 Mixing factor {e0} and {e1} activated

I now have multiple tools with predefined mixes, where T0 and T1 are the tow colors with one percantage of the other one mixed in to prevent clogging.
And In have macros M163 and M164 to set other mixes.

I had to raise the max_extrude_cross_section to two to not get errors and aborting of the print during the hard color change between T0 and T1 during printing the wipe tower.
I hear heavy moves from the extruder steppers during that change. Any ideas to fix that would be welcome

1 Like