Filament_motion_sensor not working with extruder_stepper

Basic Information:

Printer Model: Modded Ender 3 v2
MCU / Printerboard: Octopus v1.1
Host / SBC: Raspberry PI 4B
klippy.log

klippy.log (3.5 MB)

Describe your issue:

I’ve got 4 extruders connected to a single hotend. The first extruder is defined as an extruder object, and the others are defined as extruder_stepper objects. I’ve got some BTT smart filament sensors (v2) that I’d like to add to each extruder. The first one works fine, but when I try to add the second one I get this error:

Internal error during ready callback: 'PrinterExtruderStepper' object has no attribute 'find_past_position'

I saw a similar post from last May with a solution involving adding the missing find_past_position method to the PrinterExtruderStepper class. The author said they might submit a PR to add this fix to the code base, but it doesn’t look like this was done.

Is there a better way to configure filament motion sensors on extruder_stepper objects? Should the fix suggested in that post get committed and merged? Thanks in advance!

Unfortunately, the log file is missing the Klipper version and seems modified.
Regardless, the method exists in the mainline.
So, you probably have to update to a more recent release than the one you have.

d77928b17b klippy/kinematics/extruder.py (Kevin O'Connor  2021-02-22 21:38:33 -0500 257)     def find_past_position(self, print_time):
6627d036ac klippy/kinematics/extruder.py (Kevin O'Connor  2022-02-21 13:51:27 -0500 258)         if self.extruder_stepper is None:
6627d036ac klippy/kinematics/extruder.py (Kevin O'Connor  2022-02-21 13:51:27 -0500 259)             return 0.
ffbd2698fe klippy/kinematics/extruder.py (Kevin O'Connor  2022-01-11 14:21:57 -0500 260)         return self.extruder_stepper.find_past_position(print_time)

Hope that helps.


Ah, well, you probably right.
But it is strange, you do request the extruder, not the extruder_stepper

Hmmm.


Aaah, there is more then one filament_motion_sensor

Ah sorry, I was trying to focus the log on the error itself, here’s the unmodified log. As for the release being outdated, I’m on v0.12.0-159 which is admittedly a bit old, but the problem seems to be with the PrinterExtruderStepper class used by extruder_stepper (as opposed to the ExtruderStepper class you’ve referenced, which my first extruder uses without any issues). The source for the PrinterExtruderStepper class hasn’t been updated in 3 years so I’m wary of updating unless I know it’ll fix the problem.

klippy.log (3.5 MB)

1 Like

Haha yeah, the first filament_motion_sensor works like a charm, it’s the additional sensors that aren’t playing nicely.

Here’s the pertinent config, if it helps any:

# Extruder 0
# Driver = DRIVER4 / MOTOR4
# Heater = HE0
# Thermistor = T0
# Runout = DIAG4
[extruder]
max_extrude_only_distance: 450
max_extrude_cross_section: 2
step_pin: PF9
dir_pin: PF10
enable_pin: !PG2
microsteps: 16
rotation_distance: 22.725 # 22.748
nozzle_diameter: 0.800
filament_diameter: 1.750
heater_pin: PA2
sensor_pin:  PF4
sensor_type: EPCOS 100K B57560G104F
#control: pid
# tuned for stock hardware with 200 degree Celsius target
#pid_Kp: 28.22
#pid_Ki: 3.12
#pid_Kd: 63.77
min_temp: 0
max_temp: 240
# PLA 0.4mm nozzle = 0.6944
#pressure_advance: 0.6944

[tmc2209 extruder]
uart_pin: PF2
run_current: 0.800
stealthchop_threshold: 999999

[filament_switch_sensor runout_switch]
switch_pin: PG11

[filament_motion_sensor runout_encoder]
switch_pin: PG10
detection_length: 4
extruder: extruder

# Extruder 1
# Driver = DRIVER5 / MOTOR5
# Runout = DIAG5
[extruder_stepper extruder1]
extruder: # If blank, not synchronized
step_pin: PC13
dir_pin: PF0
enable_pin: !PF1
rotation_distance: 22.725 # 22.748
microsteps: 16

[tmc2209 extruder_stepper extruder1]
uart_pin: PE4
run_current: 0.800
stealthchop_threshold: 999999

[filament_switch_sensor runout_switch1]
switch_pin: PF6

[filament_motion_sensor runout_encoder1]
switch_pin: PF5
detection_length: 4
extruder: extruder_stepper extruder1

extruder is the first extruder motor, which is tied to runout_switch and runout_encoder and works without any problems. extruder1 is the second extruder motor, which is tied to runout_switch1 and runout_encoder1. The switch sensor is fine, but the motion sensor throws the error. If I use extruder: extruder1 then it complains that the config object doesn’t exist.

Yes, I can reproduce that locally, I look for what can be done.

This seems correct:

diff --git a/klippy/extras/extruder_stepper.py b/klippy/extras/extruder_stepper.py
index 4ac5289f8..79d4feef8 100644
--- a/klippy/extras/extruder_stepper.py
+++ b/klippy/extras/extruder_stepper.py
@@ -15,6 +15,10 @@ class PrinterExtruderStepper:
                                             self.handle_connect)
     def handle_connect(self):
         self.extruder_stepper.sync_to_extruder(self.extruder_name)
+    def find_past_position(self, print_time):
+        return self.extruder_stepper.find_past_position(print_time)
+    def sync_to_extruder(self, extruder_name):
+        return self.extruder_stepper.sync_to_extruder(extruder_name)
     def get_status(self, eventtime):
         return self.extruder_stepper.get_status(eventtime)

I will make an PR: extruder_stepper: define missing public methods methods by nefelim4ag · Pull Request #7032 · Klipper3d/klipper · GitHub

Thanks for the report.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.