Solved it, more or less.
[filament_motion_sensor] indeed expects a stepper, not an [extruder].
After adding
def find_past_position(self, print_time):
return self.extruder_stepper.find_past_position(print_time)
to the PrinterExtruder class, I was able to set the following in my printer.cfg:
[filament_motion_sensor e0_sensor]
detection_length: 9
extruder: extruder
switch_pin: P1.26
pause_on_runout: False
runout_gcode:
RUNOUT_MACRO SOURCE=extruder
[filament_motion_sensor e1_sensor]
detection_length: 9
extruder: extruder_stepper extruder1
switch_pin: P1.25
pause_on_runout: False
runout_gcode:
RUNOUT_MACRO SOURCE=extruder1
Now each filament_motion_sensor refers to its assigned stepper and ignores the movements of the other.
However, now both sensors triggered during toolchanges. I worked around this by setting pause_on_runout to False, using a custom runout macro and a delayed_gcode to ignore this during and immediately after toolchanges:
[gcode_macro RUNOUT_MACRO]
variable_toolchange: 0
gcode:
{% set svv = printer.save_variables.variables %}
{% if svv.currentextruder != params.SOURCE %}
M118 IGNORING filament sensor { params.SOURCE } triggered while { svv.currentextruder } is active.
{% elif toolchange == 1 %}
M118 IGNORING filament sensor { params.SOURCE } triggered during toolchange.
{% else %}
M118 HALTING: Filament sensor { params.SOURCE } triggered.
PAUSE_MACRO
{% endif %}
[gcode_macro CHANGE_TOOLHEAD]
gcode:
DISABLE_FILAMENT_SENSORS
SWITCH_TOOL TARGET={ params.TARGET }
UPDATE_DELAYED_GCODE ID=ENABLE_FILAMENT_SENSOR DURATION=10
[gcode_macro DISABLE_FILAMENT_SENSORS]
gcode:
SET_GCODE_VARIABLE MACRO=RUNOUT_MACRO VARIABLE=toolchange VALUE=1
[delayed_gcode ENABLE_FILAMENT_SENSOR]
gcode:
SET_GCODE_VARIABLE MACRO=RUNOUT_MACRO VARIABLE=toolchange VALUE=0
[gcode_macro SWITCH_TOOL]
gcode:
M400
SYNC_EXTRUDER_MOTION EXTRUDER="extruder" MOTION_QUEUE=""
SYNC_EXTRUDER_MOTION EXTRUDER="extruder1" MOTION_QUEUE=""
SYNC_EXTRUDER_MOTION EXTRUDER={ params.TARGET } MOTION_QUEUE="extruder"
SAVE_VARIABLE VARIABLE=currentextruder VALUE='"{ params.TARGET }"'
G92 E0
It’s not pretty, but it works.
Plus: This solution is independent from the ENABLE state of each sensor, meaning that I can toggle them from Mainsail at any time, without having my manual setting reset by the next toolchange.
If there aren’t any objections, I might submit a PR for my fix to the PrinterExtruder class.