# Fast filament motion sensor does not keep up - false triggers

**URL:** <https://klipper.discourse.group/t/fast-filament-motion-sensor-does-not-keep-up-false-triggers/11865>\
**Category:** General Discussion\
**Created:** [November 26, 2023, 1:55pm UTC](https://klipper.discourse.group/t/fast-filament-motion-sensor-does-not-keep-up-false-triggers/11865 "2023-11-26T13:55:13Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![EiNSTeiN](https://yyz2.discourse-cdn.com/free1/user_avatar/klipper.discourse.group/einstein/32/8788_2.png) [@EiNSTeiN](https://klipper.discourse.group/u/EiNSTeiN)\
**Post date:** [December 20, 2023, 11:27pm UTC](https://klipper.discourse.group/t/fast-filament-motion-sensor-does-not-keep-up-false-triggers/11865/2 "2023-12-20T23:27:25Z")

</div>

I’m building a high resolution filament sensor myself ([GitHub - EiNSTeiN-/roadrunner-filament-sensor: High resolution filament sensor for 3D printers based on the AS5600 magnetic rotary encoder](https://github.com/EiNSTeiN-/roadrunner-filament-sensor)) and while I’m not using Klipper’s `filament_motion_sensor` code I used it as a base, and I believe I accidentally stumbled on the answer to your problem.

The motion sensor code calls `self._get_extruder_pos(eventtime)` which itself ends up calling `self.extruder.find_past_position(print_time)` every so often to get the estimated extruder position at a given point in time. When an extrusion is requested we should see the extruder accelerate up to speed and maintain a constant speed until the move is done and `find_past_position` catches up to the requested position. Calling `find_past_position` repeatedly and graphing the results should produce an approximately straight line going up with a constant slope.

The issue I’m noticing is when I request a long extrusion move, let’s say for example with `G1 E45` for the first few seconds `find_past_position` returns a large value, e.g. it will return 5 for the first 3 seconds right after the G1 command and afterwards start returning linearly increasing values until the 45mm is fully extruded. In other words at the beginning of a move there is a large jump in the expected extruder position which doesn’t catch up to reality for a few seconds.

Going back to your issue, I believe there might be a pulse from your sensor right before a long move occurs, at which point this code is executed:

```auto
self.filament_runout_pos = (
                self._get_extruder_pos(eventtime) +
                self.detection_length)

```

Which means the filament is detected as “present” as long as `self._get_extruder_pos(eventtime) < self.filament_runout_pos`. Now because of the behavior I explained above with `find_past_position`, the estimated extruder position can increase by a value larger than `detection_length` at the beginning of an extrusion move and trigger the runout code.

---

_[View the full topic](https://klipper.discourse.group/t/fast-filament-motion-sensor-does-not-keep-up-false-triggers/11865)._
