Extruder PA synchronization with input shaping

Overall, the current Klipper PA tuning process is a bit of a hit and miss. In my experience, after comparing the results with a different approach, I think the default PA tuning process often gives too large PA values. I suspect this is primarily due to the following reasons:

  1. It is difficult to inspect corners for quality to find the good point.
  2. Using low acceleration value means that PA acts less and over longer distance (it takes 10 mm to decelerate from 100 mm/sec at 500 mm/sec^2 acceleration), so PA values that are already too aggressive may be difficult to identify as such.
  3. Using too low square corner velocity setting means that the toolhead must decelerate very much, and it is likely that PA isn’t working great at this velocity (1 mm/sec), so the corners bulge too much, giving a false sense that PA value “isn’t yet large enough”, when it actually already is.

These reasons, especially (3) combined with (2), make a user likely to select a PA value that is actually too large for the given printer, filament and printing parameters. A better test model could be something like this:


Basically, a 1-2 walls tower with a velocity change from fast to slow and back. Notice that

  • A user can print it with a regular acceleration, making a test more representative of the real prints.
  • Velocity change happens not at the corners (at them too, but one shouldn’t inspect them), but when the toolhead moves in a straight line. This isolates PA effects from everything else (e.g. input shaping, square corner velocity, etc.).
  • It is actually quite easy to inspect the lines where velocity changes to find the best PA value.

My experience is that I get a PA value of 0.044 for the baseline Klipper (and smooth_time=0.04) for some PLA using the default test, and a value of 0.02 - for exactly the same filament for this different tower test. Incidentally, the improved test shows that 0.044 PA value would really be too much for the real prints and could create gaps in the model (a mark on the model, printed with TUNING_TOWER COMMAND=SET_PRESSURE_ADVANCE PARAMETER=ADVANCE START=0 STEP_DELTA=0.002 STEP_HEIGHT=2, the total model height is 50 mm):

I suspect this defect doesn’t happen in practice often because near corners, the toolhead decelerates a lot more and moves slowly around a corner, and so perhaps some extra material can flow from the nozzle and compensate for the defect a bit; it can be observed that the corner of the model isn’t that bad here too. However, when decelerating from 100 to 20 mm/sec, the toolhead still moves sufficiently fast and the defect appears. This kind of defect can appear in real prints near bridges, because the toolhead may experience a similar pattern of deceleration and subsequent acceleration.

Then, using this improved test, I observed that if I reduce the smooth_time to 0.02, the ideal PA value reduces to 0.012 (from 0.02), and then reducing it further to 0.01 does not change PA value further (so the ideal value stays around 0.012).

Now, with the extruder input shaping branch and smooth_time 0.01 sec, I get the same PA value of 0.012. However, with the extruder shaping enabled, I think I can now choose a more optimal point such that the defects during acceleration and deceleration are minimal, in contrast with the mainline Klipper, where some defects are still present at the same height - during acceleration, deceleration or both:


Here left to right are baseline smooth_time = 0.04, baseline smooth_time = 0.02, baseline smooth_time = 0.01 and extruder shaping smooth_time = 0.01.

And one more test, 30x30 mm square printed with those smooth_time(s) and the optimal PA values as described above:

Here, counter-clockwise, starting from the bottom-left corner are baseline smooth_time = 0.04, baseline smooth_time = 0.02, baseline smooth_time = 0.01 and extruder shaping smooth_time = 0.01 (so extruder shaping test is at the top left). I put together the same corner from all 4 test models by rotating them appropriately. Overall this confirms that the choice of PA values is good (and PA values are smaller than from the default Klipper PA test - so those values would be actually excessive). Then, the individual differences between the corners are admittedly not large. I find the corner from the extruder shaping code a bit more crisp and geometrically accurate, but that may be subjective and you can judge for yourself from the picture.

So, if you will be testing my extruder input shaping branch, please make sure to reduce the pressure_advance_smooth_time in the config and tune the PA value appropriately.

Sadly, it is not possible to generate the desired PA tuning tower test in PrusaSlicer/Superslicer using model modifiers (it is a known bug that’s unfixed):

And unfortunately, the GCode generator that I have used to generate a test GCode has some bugs, so I cannot really link it here, and required some code/gcode fixes. If you have some good ideas how to generate a test model/gcode like that - please share them, I’d be happy to hear. Maybe there’s some good generator out there. For the reference, the GCode that I ended up using is this one (for 0.4 mm nozzle):
KF_0.28mm_50mm.zip (15.7 KB)