Marlin icon indicating copy to clipboard operation
Marlin copied to clipboard

FTMotion: Limit reset-on-threshold e position to avoid precision loss on long prints

Open dbuezas opened this issue 1 month ago • 4 comments

Description

Float32 numbers have 23 bits of precision, so the minimum increment ("resolution") around a value x is: resolution = 2^(floor(log2(|x|)) - 23) By resetting at ±1'000mm (1 meter), we get a minimum resolution of ~ 0.00006mm, enough for smoothing to work well.

We could reset every mm if we wanted, but that is just a waste of cpu. (this is actually how i tested the code)

Note that "reset" in this context involves adding - current position to all shaping/smoothing/linear advance/stepping buffers too so state is kept consistent and there are no discontinuities.

Requirements

Benefits

Without this, FTMotion accumulates e-position to very large numbers, the floats stop being able to represent single steps and the extruder starts becoming noisy. I made a 300g print test and by the end of it the extruder had became noisy and imprecise.

Configurations

Related Issues

dbuezas avatar Nov 24 '25 16:11 dbuezas

No rush if this is not fixing a common bug. Once you rebase this it will be closer to being reviewable and usable for further development and discussion, which should be interesting!

thinkyhead avatar Dec 02 '25 23:12 thinkyhead

Need to test this properly

dbuezas avatar Dec 03 '25 06:12 dbuezas

@thisiskeithb, don't merge label can be removed now

dbuezas avatar Dec 05 '25 06:12 dbuezas

@thinkyhead

No rush if this is not fixing a common bug

It happens on any and all long prints, so it is rather important.

dbuezas avatar Dec 08 '25 06:12 dbuezas