Filament Motion Sensor Malfunction with Multiple Extruder Configuration

Basic Information:

Printer Model: TT1SM (DIY) reprapy.pl - Zaloguj się
MCU / Printerboard: BTT Manta M8P
Host / SBC: CM4
klippy.log

klippy.log (111.9 KB)

Bug Report: Filament Motion Sensor Malfunction with Multiple Extruder Configuration

System Configuration

  • Firmware: Klipper
  • Hardware: BTT Smart Filament Sensor Module v1.0 (SFSM)
  • Setup: 4 extruders configuration
    • 1 main extruder [extruder] (with motor [extruder_stepper e0], heater, etc.)
    • 3 auxiliary extruders configured as [extruder_stepper ex] (where x = 1-3)
    • Each auxiliary extruder has mechanical filament sensors (on/off)
    • Bowden tubes from 3 auxiliary extruders merge in a special connector, then pass through SFSM, then connect to main extruder at printhead

Problem Description

Expected Behavior

The filament motion sensor should accurately detect filament presence and movement based on actual filament state in the sensor.

Actual Behavior

After Klipper restart:

  • Three mechanical sensors show correct states (empty/detected based on filament presence)
  • Motion sensor (SFSM) shows “empty” regardless of actual filament presence

When executing tool change commands (T0, T1, or T2):

  • SFSM sensor state changes to “detected” and remains in this state until Klipper restart
  • State remains “detected” regardless of:
    • Whether extruders are actually working
    • Whether filament is present in the sensor or not

Configuration Details

Filament Motion Sensor Configuration:

[filament_motion_sensor main_sensor]
detection_length: 7.0
extruder: extruder
switch_pin: PF5
event_delay: 3
pause_delay: 2
pause_on_runout: True

Tool Change Macro Example (T0):

[gcode_macro T0]
gcode:
  SET_STEPPER_ENABLE STEPPER="extruder_stepper e1" ENABLE=1
  SYNC_EXTRUDER_MOTION EXTRUDER=e1 MOTION_QUEUE=extruder
  SYNC_EXTRUDER_MOTION EXTRUDER=e2 MOTION_QUEUE=
  SET_STEPPER_ENABLE STEPPER="extruder_stepper e2" ENABLE=0
  SYNC_EXTRUDER_MOTION EXTRUDER=e3 MOTION_QUEUE=
  SET_STEPPER_ENABLE STEPPER="extruder_stepper e3" ENABLE=0
  SET_GCODE_VARIABLE MACRO=_CURRENT_TOOL VARIABLE=tool VALUE='"e1"'

Troubleshooting Performed

When changing sensor type from filament_motion_sensor to filament_switch_sensor, the sensor works correctly - showing cyclical detected/empty state changes when manually moving filament inside the sensor. This confirms the hardware is functioning properly.

Suspected Root Cause

The issue appears to be related to MOTION_QUEUE operations. Adding or removing steppers from the motion queue seems to cause a software malfunction in the motion sensor. This is particularly puzzling because:

  • The sensor is configured based on [extruder] movements
  • The main extruder motor state doesn’t change (no E movement)
  • The main extruder remains constantly connected to the motion queue

Impact

This bug prevents reliable filament runout detection in multi-extruder setups using motion sensors, which is a critical safety feature for unattended printing.

Request

Please investigate the interaction between SYNC_EXTRUDER_MOTION operations and filament motion sensor state management. The sensor state should only be affected by actual filament movement through the sensor, not by motion queue reconfiguration operations.

If I’m not mistaken the BTT module has 2 outputs. Are you moving wires when you change sensor type?

No. This sensor (v1, not v2) only has an encoder. The manual specifies three pins on the connector: V, GND, and Signal. Only v2 introduced a separate binary signal for filament presence.

I have this one: smart-filament-detection-module/V1.0/manual/smart filament sensor module manual201125.pdf at master · bigtreetech/smart-filament-detection-module · GitHub

Welcome rozarh,

doesn’t help. I can’t log in!

This seems not a bug but a “by design”:

  • The motion run-out sensor is only evaluated during printing, aka extrusion moves
  • A run-out is detected if a certain distance should have passed the sensor but no matching pulses have been received
  • After raising a run-out condition, it is only reset when again the moving filament is creating pulses → There is no reset command or anything like this