Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smooth Linear Advance with extruder synchronisation #27710

Open
wants to merge 19 commits into
base: bugfix-2.1.x
Choose a base branch
from

Conversation

dbuezas
Copy link
Contributor

@dbuezas dbuezas commented Feb 24, 2025

Description

Introduces a new smooth linear advance method that decouples extrusion from motion constraints, improving print speed and quality without acceleration limits. (comparable to Klipper's approach).

  • Smooth linear advance is managed by a new ISR that runs at a constant interval.
  • Smoothing is calculated from planned extrusion rate instead of acceleration. This improves nozzle pressure control by making the algorithm aware of XY jerk and line width changes, and results in higher print quality compared to 'classic LA'.
  • Instead of using moving window averaging (like Klipper) or instantaneous speed changes (like "classic" marlin linear advance), this PR uses an efficient approximation of gaussian filtering. The approximation consists of higher order (5) exponential smoothing corrected for delay.
  • Delay correction is achieved by looking ahead in the block (even into future blocks). The smoothing factors are automatically calculated from the lookahead offset (TAU) to ensure delay compensation is precise and requires no calibration.
  • TAU is somewhat analogous to Klipper's pressure_advance_smooth_time and can be configured in the LCD or via GCODE. The lower the better, as long as the extruder stepper doesn't skip steps.

Enabling SMOOTH_LIN_ADV results in faster and higher quality prints in 32 bit MCUs

The new ISR allows for a second second feature, INPUT_SHAPING_E_SYNCH, which synchronises the extruder with the input shaped x and y axes. This results in very accurate extrusion during acceleration phases. Synchronizing E to input shaping improves seams and top surfaces significantly, even at high accelerations (e.g nice seams and top surfaces at 15k mm/s^2).

Requirements

32 bit MCU

Benefits

Enables higher acceleration without extrusion artifacts

  • Improves top surfaces and seam quality
  • Reduces pressure variations in high-speed printing

Configurations

  #define SMOOTH_LIN_ADV          // Removes motion acceleration limitation by allowing to gradual ramp up of nozzle pressure
  #if ENABLED(SMOOTH_LIN_ADV)
    #define ADVANCE_TAU 0.01      // (secs) Smoothing time to reduce extruder acceleration due to linear advance.
                                  // It is also the time ahead the smoother needs to look in the planner
                                  // so the planner needs to have enough blocks loaded.
                                  // for k=0.04 at 10k acceleration and an orbiter 2, it can be as low as 0.0075.
                                  // The lower the better until stepper skipps
                                  // Higher k and higher print accelerations may require larger tau to avoid skipping steps
    #define SMOOTH_LIN_ADV_HZ 5000   // How often to update extruder speed
    #define INPUT_SHAPING_E_SYNCH    // Synchronize the extruder shaped xy axes (increrses precision)
  #endif

Related Issues

This is a further evolution of- and closes #27352. Now with more solid mathematical foundations and improved precision.

Misc

I have a fast 32 bit MCU with FPU so I made liberal use of floats. Further optimisations (e.g. fixed-point arithmetic, planner pre-computations) are possible. However, given the significant speed and quality improvements, I propose addressing those in a follow-up PR after merging this foundational implementation. I'm getting the speed and quality of a Voron or bambulab in my Ultimaker 2 with a direct drive extruder.

@tombrazier mentioned that, at least in theory, extrusion synchronisation could be done at step level. If implemented, it would replace my version of INPUT_SHAPING_E_SYNCH.

Validation of this approach

Analysed stepper control signals with a logic analyzer and performed extensive testing (>1kg of prints)

Thanks @oliof and @tombrazier for the early feedback and discussions in discord.

(cherry picked from commit 28300f8)
@tombrazier
Copy link
Contributor

First thought: what about a name change at this point? "Linear advance" isn't as good name as "pressure advance" and everyone knows "smooth pressure advance" from Klipper, so just the name would communicate a lot if we changed "linear" to "pressure". @thinkyhead

(cherry picked from commit 0f10d91)
(cherry picked from commit 2d74be5)
(cherry picked from commit 3722520)
(cherry picked from commit 17ec816)
(cherry picked from commit 3b5a4a6baffa31e1f92d7ed93b7911bc8a15f1e4)
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.

5 participants