Skip to content

FTMotion: Fix K unit and Improve linear advance - #28058

Merged
thinkyhead merged 6 commits into
MarlinFirmware:bugfix-2.1.xfrom
dbuezas:dbuezas/FTMotion-fix_linear_advance
Sep 21, 2025
Merged

FTMotion: Fix K unit and Improve linear advance#28058
thinkyhead merged 6 commits into
MarlinFirmware:bugfix-2.1.xfrom
dbuezas:dbuezas/FTMotion-fix_linear_advance

Conversation

@dbuezas

@dbuezas dbuezas commented Sep 13, 2025

Copy link
Copy Markdown
Contributor

Description

FTMotion had K defined in a different unit (100 times that of the normal motion system, klipper, etc)

This PR aligns that, and also fixes problems during (de)retraction: these blocks shouldn't use linear advance.

Furthermore, I simplified the math by using the integral of the linear advance equation used in the classic motion planner, which has the advantage of not losing track of the integration constant between blocks due to instantaneous changes in velocity (i.e, linear advance is now jerk aware)

Equivalence of rate base and position based linear advance

  1. Typical formulation in terms of rates and acceleration
$$ e_{\text{rate}}(t) \;=\; e_{\text{planned\_rate}}(t) \;+\; k\,e_{\text{acc}}(t) $$
  1. Integrate both sides over time
$$ \int e_{\text{rate}}(t)\,dt \;=\; \int e_{\text{planned\_rate}}(t)\,dt \;+\; k\!\int e_{\text{acc}}(t)\,dt $$
  1. Using the definitions
$$ \int e_{\text{rate}}\,dt = e_{\text{pos}}, \qquad \int e_{\text{planned\_rate}}\,dt = e_{\text{planned\_pos}}, \qquad \int e_{\text{acc}}\,dt = e_{\text{vel}}, $$
  1. we get
$$ e_{\text{pos}}(t) \;=\; e_{\text{planned\_pos}}(t) \;+\; k\,e_{\text{vel}}(t) \;+\; C. $$
  1. Where the integration constant $C$ is zero because the print starts with no nozzle pressure. So finally:
$$ \boxed{\,e_{\text{pos}}(t) = e_{\text{planned\_pos}}(t) + k\,e_{\text{vel}}(t)\,} $$

Requirements

FTMotion

Benefits

Same unit, simpler code, no drift, better pressure management

Configurations

Related Issues

@dbuezas dbuezas changed the title Fix linear advance FTMotion: Fix K unit and Improve linear advance Sep 13, 2025
@narno2202

Copy link
Copy Markdown
Contributor

@dbuezas , don't forget to update the motion menu accordingly. I've tested your FT_MOTION code in the last Marlin bugfix, great work, nice improvement in sound.

@dbuezas

dbuezas commented Sep 14, 2025

Copy link
Copy Markdown
Contributor Author

Thanks!
Do you mean the maximum value or what would be missing in the menu?

@narno2202

Copy link
Copy Markdown
Contributor

I mean the maximum value and the display to be aligned with the new value. float32 instead of float62 should be enough in the menu item.

@dbuezas

dbuezas commented Sep 15, 2025

Copy link
Copy Markdown
Contributor Author

Got it, good catch. Maybe i even do more decimals

@Crazy-Charles

Copy link
Copy Markdown

Any chance of fixing the output from M493?
X base dynamic shaper frequency: 37.00Hz scaling: 0.00Hz/mm
Y base dynamic shaper frequency: 37.00 Hz scaling: 0.00Hz/mm

@dbuezas

dbuezas commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

Just realized i can reuse the use_advance_lead from the block

@dbuezas

dbuezas commented Sep 16, 2025

Copy link
Copy Markdown
Contributor Author

@Crazy-Charles Yes, will be fixed in a different PR.
@narno2202 Menues fixed, and also reused the use_advance_lead calculated in the planner.

It's ready for review & merge

@dbuezas
dbuezas force-pushed the dbuezas/FTMotion-fix_linear_advance branch from 3bd3f1c to 1ffa8e9 Compare September 16, 2025 20:07
@dbuezas
dbuezas force-pushed the dbuezas/FTMotion-fix_linear_advance branch from 607bb0e to f78c928 Compare September 17, 2025 20:10
@thinkyhead
thinkyhead force-pushed the dbuezas/FTMotion-fix_linear_advance branch from 503173f to 0014831 Compare September 21, 2025 04:41
@thinkyhead
thinkyhead force-pushed the dbuezas/FTMotion-fix_linear_advance branch from 0014831 to d5c1128 Compare September 21, 2025 04:43
@thinkyhead
thinkyhead merged commit 5917aa7 into MarlinFirmware:bugfix-2.1.x Sep 21, 2025
67 checks passed
bsdnomad pushed a commit to bsdnomad/Marlin that referenced this pull request Sep 25, 2025
@dbuezas dbuezas mentioned this pull request Oct 26, 2025
@dbuezas
dbuezas deleted the dbuezas/FTMotion-fix_linear_advance branch December 16, 2025 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants