Klipper has an implementation of a pressure advance algorithm that synchronizes filament extrusion with the toolhead motion and eliminates many artifacts. Input shaping alters toolhead motion in an attempt to reduce vibration and ringing. However, the problem is that pressure advance today is not synchronized with input shaping.
FWIW, the problem isn’t too bad because Klipper has pressure advance smoothing. While it’s not really the same as input shaping, it still introduces changes to extruder motion that exhibit similar behavior as input shaping. So, PA smoothing synchronizes extruder with input shaping to some degree, though this synchronization is mostly accidental and is not perfect. It can be especially noticeable if X and Y have very different resonance frequencies, and/or if the PA smooth time deviates significantly from the input shaper duration. So, I attempted to implement PA synchronization with input shaping.
The implementation is available in this branch. In a nutshell, it calculates the toolhead motion over X, Y and Z axes, applies input shaping to X and Y, and uses linearization to project the motion of individual axes onto E. If the input shaper is the same for X and Y axis (e.g. some 2hump_ei or 3hump_ei input shaper), then the result is precise for XY motion. Otherwise, it is a linear approximation over X/Y deviations, but still, hopefully, better than the current state. Here’s a demonstration of the extruder kinematics with the baseline and my implementation:
This shows some extrusion moves followed by a wipe. Left is the current extruder PA code, right is the PA with the input shaping enabled. On the top graphs, the blue line is the extruder velocity from its move queue, and the orange line is the extruder stepper velocity. The charts also show the velocity of X and Y steppers for the reference (after input shaping, which is ei@45 Hz for X and mzv@41Hz in this case). Pressure advance in both cases is set to smooth_time = 0.01 s and advance=0.04.
One could observe from the charts a bit less erratic behavior of PA during extrusion moves for extruder input shaping branch - fewer retractions and deretractions during decelerations/accelerations. The extruder velocity is also more stable and changes less - apparently because the actual toolhead velocity (looking at the steppers velocities) changes less with time due to input shaping. As a result, there is less pressure on the extruder to maintain the extrusion. The behavior of the wipe (first, larger retraction when the toolhead is at still, followed by a toolhead move combined with some retraction, followed by a small retraction when the toolhead isn’t moving) is also better, in my opinion, as the extruder maintains more stable retraction velocity throughout the wipe. Note that I generated the charts from the code based on my improved stepcompress code, but that’s because the stepper velocity charts aren’t particularly legible otherwise, but I didn’t observe any noticeable change in the extruder code performance when based on the improved stepcompress code vs the regular Klipper mainline.
So far, I have been testing this branch for over a couple of months, and overall I think it offers small improvements in quality of the real prints. Overall, I’d expect it to have most of the effect on the direct drive extruders with a relatively short filament paths, where PA smooth time might be desirable to reduce (more on PA tuning for it in the next post). I wouldn’t expect noticeable improvements on bowden extruders (though likely there shouldn’t be degradation in quality either). If you want to give it a try, please do and report back your experience (whether the changes in prints are positive, negative or neutral). If you happen to be using my stepcompress branch, you may continue to do so by using this branch for extruder input shaping instead of the regular one, so that you don’t have to reflash the MCU back. Things to keep an eye on (where the quality may improve or degrade) are when the toolhead velocity changes: corners of the model, starts and ends of the bridges, infill connecting to perimeters, etc.
Note that you should really change/retune PA for this branch. I’ll make a follow-up post with more details, but at the very least, you should try to reduce the pressure_advance_smooth_time from the default 0.04 to 0.02 or even better 0.01 (assuming direct drive extruder and non-flex filaments). That will likely result in a different (smaller) choice of PA value, especially if you’ve been using the Klipper PA tuning tower to choose the PA advance value.