Klipper3d / klipper

Klipper is a 3d-printer firmware
GNU General Public License v3.0
8.99k stars 5.17k forks source link

Keep stepcompress move history relative to current time #6439

Closed EiNSTeiN- closed 6 months ago

EiNSTeiN- commented 6 months ago

Currently the stepcompress history is removed as soon as it's older than 30 seconds before the furthest move in the stepcompress queue. If the furthest move is long and will end more than 30 seconds in the future, then the stepcompress history will return a "future" stepper position rather than a past position.

I found this issue while trying to graph the output of extruder.find_past_position(print_time) with a 45mm move at 1.33mm/s, which puts it around 33.8 seconds, and it would give me a graph like this one:

image

Note the purple line (the expected extruder position) is constant for the first ~4 seconds of the move rather than providing the expected stepper position. With this fix applied, the graph is as expected:

image

This was reported, for example, in: https://klipper.discourse.group/t/filament-sensor-triggers-on-long-g0-e-command/3771. It's hard to track real world problems which can be caused by flushing the history too early but I've personally observed false positives with my BTT SFS v1 which might be related t this. I have a 350mm printer so long moves on top/bottom layers are to be expected when printing large parts at slow speeds, as we do with the first layer and the top infill.

KevinOConnor commented 6 months ago

Okay, thanks. However, the flushing in DripModeEndSignal was not corrected. Also, it is confusing to use two different mechanisms to implement a full flush in force_move.py and manual_stepper.py (it would be preferable to consistently use either use "+ 99999.9" or "reactor.NEVER").

-Kevin

EiNSTeiN- commented 6 months ago

I made the last changes, this should be good to go if you're OK with my other comment

KevinOConnor commented 6 months ago

Thanks. I committed this PR along with commit 9847b449 on top.

-Kevin

KevinOConnor commented 6 months ago

I just realized that the new history flushing code would not do the right thing when in a debugging "batch mode" ( https://www.klipper3d.org/Debugging.html#translating-gcode-files-to-micro-controller-commands ). I pushed commit 25bc649c to address this.

-Kevin