Skip to content

Conversation

igiannakas
Copy link
Contributor

@igiannakas igiannakas commented Jun 6, 2024

Official wiki write up and instructions are here: https://github.com/SoftFever/OrcaSlicer/wiki/adaptive-pressure-advance

———
How picky are you about getting your PA tuning absolutely nailed for sharp corners but also no gaps between perimeters? This feature aims to bring PA tuning closer to perfection by reducing the compromises made when picking a single ideal PA value. The benefits are not earth shattering, but if you are picky about print quality, they are there.

I will leave this PR at this stage of development for now and would love your feedback and observations. It works, doesn’t appear to be causing any bugs, it’s just not fully optimised code wise yet

This PR is a long read but hopefully it will be useful :)

EDIT: Feature has been revamped to cater for accelerations and volumetric print speeds together, creating a 3 dimensional PA model that is used to derive the most appropriate PA against both different accelerations, print speeds, layer heights and line widths!

Testing is needed to demonstrate value and any adverse effects and whether we can mitigate them.

The description below has been updated with the revised workflow.

Feature Description and approach

What I and others have noticed is that the PA value needed to avoid artefacts is less the faster you print and the higher the print acceleration is. (see credits in the end and user submitted test results in this PR).

To demonstrate this I've run a series of tests from 50mm/sec to 200mm/sec at 3k acceleration, 0.2 LH and 0.015 and 0.005 smooth time.

From left to right at 50-100-150 & 200 mm/sec and 200mm/sec at 0.005 smooth time with constant acceleration at 3k.
IMG_3874

Next I run a series of tests for the same speeds (50-100-150mm/sec) with constant acceleration at 10k

IMG_3907

What this means is that we never get ideal PA values for each print feature. We can tune PA for a faster print speed but compromise on corner sharpness for slower speeds or tune PA for corner sharpness and deal with slight corner perimeter separation in faster speeds. Same for accelerations.

This compromise usually means that we tune for an "in between" PA value between slower external features and faster internal features so we don't get gaps but also not get too much bulging in external perimeters.

In this PR I am aiming to address this limitation of the current way to use Pressure Advance by proposing a completely different method of setting pressure advance.

In this PR we are enabling the slicer to model the extrusion behaviour for different PA values vs. volumetric flow speed vs. accelerations and use that model to emit the best fit PA for any arbitrary feature used in the print process.

As a bonus, depending on the profiles created it may mean that you only have to tune this feature once and print across different layer heights and different nozzle sizes with good PA performance.

What is volumetric speed?

In this model we are using the volumetric print speed - this is basically calculated as

  1. The amount of filament in mm3 that is extruded from the nozzle per mm of movement
  2. Multiplied by the speed the toolhead is printing at.

Luckily Orca displays the volumetric speed in the sliced model so there is no need to do any calculations. It's called "Flow". This is proportional to the print speed as well as layer height and line width. So by keeping the layer height and line width constant in testing we can vary the print speed to get the PA results for different flow speeds.

image

PA testing workflow:

  1. The user runs at a minimum 6 PA tests for a filament and submit them to Orca.
  2. The tests should be run to cover the slowest volumetric flow speeds, the fastest ones as well as the slowest and fastest print accelerations the user is typically using. Typically these are the external wall accelerations, sparse infill accelerations and a value in between as well as the slowest and fastest print speed and one in between.
  3. In my example below I have used 50mm/sec, 100mm/sec, 150mm/sec and 200mm/sec across 3k and 10k accelerations.
  4. The user takes note of the optimal PA values, the corresponding volumetric flow speeds that the test was executed at and the acceleration used. To find the volumetric flow speeds, check the screenshot below.
  5. The user submits the pairs of PA values and volumetric speeds to Orca, in a new text box in the filament settings.
  6. Orca uses the PCHIP (Piecewise Cubic Hermite Interpolating Polynomial) curve to fit against the submitted PA values and volumetric speeds. It then uses the same model to fit between different accelerations. The models are calculated at slice time and the resulting PA for a given volumetric speed and acceleration is emitted to the printer ahead of commencing printing that feature.

Screenshots of the workflow:

Step 1: Enable "Enable adaptive pressure advance (beta)" in the filament section
Step 2: Run the above PA tests for your filament
Step 3: Add them to the box, one test at a time - PA value,coma (,),tested flow speed,coma (,), tested acceleration. Save the filament profile. Make sure the value set in the pressure advance box above the options is a reasonable default as it's still used if the model fails for any reason.
image

Step 4 Add a model & slice. Observe the PA values changing when there is a change to the extrusion role (i.e. when printing internal perimeters and then going to external, when going from perimeter to bridge, etc). The PA value is then calculated based on the upcoming feature print volumetric speed and acceleration.

For example:
All features having the same / similar volumetric speed but different accelerations
image

Now with all features having the same acceleration but drastically different volumetric speeds:
image

Now for a combo of both - notice how the fast accelerating and high speed internal sparse infill has significantly lower PA than the walls which are slow accelerating and printing slightly slower too.
image

Now lets try a lower layer height:
PA set to 0.029 for the internal wall vs. 0.026 before :)
image

Why create a model instead of simply 4-5 PA pairs?

An alternative approach would be to submit a list of values (PA & speed) and let orca use these if the printed feature speed matches exactly.

The approach in this PR is more flexible. If the values match exactly, the exact PA will be used (due to the choice of regression model there is no deviation from the provided values). However, if they don't match exactly, because the user has picked a different speed and acceleration than the one PA was calibrated to, this approach will still estimate a reasonable PA value to use, granting more flexibility.

What interpolation model to use?

PCHIP is the preferred model as it has zero delta error from the submitted values (ie there is no deviation from the submitted PA/speed value pairs and the model response). It also will always return a value that is never higher than a linear interpolation between the two consecutive data points. This is important, as we don't want unpredictably higher values than if a straight line was drawn between the two samples, which can happen with spline/cubic etc modelling.

A set of models that were run through fitting is below for my initial tests:
50B5324C-4B28-4666-B5E9-BF668221B8C8

We can indeed see that PCHIP is the preferred model as it doesn't over shoot from the general data trend, always returns the given PA value if the speeds match and smooths out the "curve" between the sampled points.

Preliminary conclusions and testing next steps:

It appears that adaptive PA can marginally improve print quality by better matching PA to the printed feature speed and acceleration. The largest benefits come from

  1. Marginally improved corner performance
  2. Marginally improved surface finish
  3. No pin hole gaps between perimeters when cornering if your PA was tuned too high.
  4. More leeway when using printers that do not control the extrusion as well as the examples above - for example nozzles with large melt zones may have a much steeper PA curve than mine (all tests done with a revo 0.4 HF obxidian nozzle which has excellent extrusion control due to the limited melt zone).

This feature will NOT benefit the widest audience as the standard implementation of PA is meeting 95% of user's expectations. However if you want the last 5% it may be for you.

It will also benefit users that have a less constrained filament path between the extruder and the hot end - as this would typically require higher PA values hence the delta would be amplified. In addition, anyone still using a Bowden printer should see a benefit as seen in the links in the credit section below.

However to really notice the difference your printer needs to be spot on - EM, extruder in good mechanical health and a good design and your printer mechanics working well.

As I am a big fan of developing features that I will be using daily - from my side this is something that I will enable across all my filaments. The benefits are marginal, but they are there. As I will be daily driving this I'll let you know if I observe anything further.

I will leave this PR at this development point for now and would love your feedback and observations.

Status & ToDo:

MVP development

  • Validating hypothesis that different speeds require different optimal PA values - Done
  • Identify most suitable regression analysis model to fit experimental data. - Done
  • Develop option initial "plumbing" in the UI - Done
  • Develop regression analysis class (PCHIP). - Done & tested interpolation model with sample code
  • Integrate dynamic PA with slicing code - emit new PA values per speed change - Done
  • Integrate with filament settings instead of hard coded values - Done
  • Refactor code to reduce unnecessary emitting of PA changes if the PA value has not changed from the current one. - Done
  • Milestone 1 - Code is functional for POC testers Done

Testing:

  • Validate overall feature benefit or lack thereof with community support - Done. See below.
  • Validate whether dynamic PA would benefit print quality when speeds change while printing the same feature (eg. when slowing down for overhangs). Done. For results see above. This has now been removed as a feature as it is detrimental to print quality
  • Validate whether flow speed, acceleration or print speed is the dominant factor. Done - acceleration and flow speed have been identified as the dominant factors and the code has been updated to model a 3 dimensional PA profile that can interpolate between both.

Known potential issues:

  • When a perimeter starts at an overhang (ie. the seam is placed on an overhang) this feature will evaluate the PA based on the starting speed of the perimeter and will not adjust the PA later after the overhang is printed. While this avoids artefacts by not adjusting PA mid way through an external perimeter, it also results in that perimeter having a wrong PA value in its entirety. Fix approach is currently being thought through
  • There may be conflict between this feature and the small area flow compensation and/or scarf seams. More investigation is needed.

Refactoring and tuning

  • Convert the approach to injecting the PA values to the GCODE as a gcode slicer post processor. This is to address the fact that slowdown for layer cooling changes the print speeds after the initial gcode generation - Done
  • Milestone 2 - Code is ready for wider testing Done
  • Performance tune, optimise, fix bugs found by community testers, remove gcode debug statements, further refine error handling and prepare for release.

Credits:

Inspiration for this feature was taken from the below community conversations and implementations.

  1. https://www.reddit.com/r/klippers/comments/o98xes/pressure_advance_becomes_way_too_aggressive_when/?utm_medium=android_app&utm_source=share
  2. https://github.com/hadesz/v2blorgr-config/wiki/Dynamic-Pressure-Advance
  3. https://klipper.discourse.group/t/modification-of-pressure-advance-for-high-speed-bowden-printers/
  4. https://github.com/jjgraphix/KlipperSettingsPlugin

Testing:

Hypothesis 1 (and the main use case) - Prove or disprove whether adapting PA when printing using widely different speeds would result in sharper feature edges.

When printing infill with 250+mm/sec, internal walls at 200+mm/sec and external perimeters at 50mm/sec the PA needed to ensure sharp feature edges with no perimeter gaps is different (as illustrated from the PA tests above).

Therefore the hypothesis is that varying the PA based on feature speed would result in sharper edges with less perimeter gaps and remove the existing potential compromise.

Testing profile below for my Voron 2.4 350. Using poly terra grey PLA as its the most revealing filament I have :)
image
image
image
image

With adaptive PA enabled:
Testing for wall artefacts on overhangs
Test shows no artefacts where the slowdowns begin. That is expected as we are not changing the PA in those regions. However there is ever so slight bulging after the corner of the overhang, which could be attributed to needing even higher PA. However check Hypothesis 2 below for relevant test and results.
IMG_3882 2

Testing for corner performance
This looks exceedingly good to me. Absolutely no bulge in the corner. Just the smooth rounding caused by the SCV of 5mm/sec
No cover perimeter separation at all.
IMG_3883
IMG_3884

Testing for seam performance
Again this looks excellent. Absolutely no bulge at the seam.
IMG_3885

Testing for top surface performance
Again this looks excellent. Absolutely no gaps, pinholes, under extrusions or over extrusion.
IMG_3886

Testing for solid infill performance
Again very good - very smooth and connected to the perimeters. My overlap for internal solid infill is at 10% so there are some expected pockmarks.
IMG_3893

Testing With Adaptive PA disabled and PA set to the value that gives good corner performance at slow speeds (50mm/sec)
In this "before" test I've disabled adaptive PA and set the static PA value for the filament to 0.04, which gave me the best corner performance when extruding at the external perimeter speeds.

As expected that PA value was too high for the faster internal features resulting in the typical issues you'll see happening from it.

Testing for corner performance
External corners look excellent; however slight perimeter separation on the faster internal perimeters. Typically this won't be visible to the outer shell as you can "hide" it using one wall top and bottom surfaces; however it is not performing as expected and won't pass the quality mark for something like PIF.
image
IMG_3890

Testing for top surface performance / solid infill performance
We can clearly see that the PA is too high for the faster internal solid infill here as there is under extrusion when the solid infill begins/ends
IMG_3891
image

Seam performance and overhang performance
This is unchanged as expected as we have tuned the PA for the slower external perimeter
IMG_3888
IMG_3892

Testing With Adaptive PA disabled and PA set to the value that gives good corner performance at fast speeds
The PA value for the below test was set to 0.026 which is the correct value when printing faster features in the range of 150-250mm/sec. This would be the value I would typically select when tuning the printer without this feature as it gives absolutely no perimeter gaps and a reasonably good external surface performance.

Observations:
So this is an interesting one.

Corner performance:
Admittedly this is very good and I would consider this as close to excellent too.
image

However upon closer inspection you'll notice the below:
image
The static PA test starts taking the corner later compared to the adaptive PA. This is incorrect due to the SCV being applied uniformly. You'd expect a perfect radius here. However this may give the appearance of a sharper part but the corners will not be uniform leading into them and moving away from them. They will always be sharper going into the corner than coming out of them, if that makes sense.

So adaptive PA takes the win here, but marginally. You can feel the difference in your hand but honestly, both parts are acceptable. Again, how picky are you about your PA....? :)

Seam performance:
Again another interesting test here - again the performance on first look appears great (and it is!).
IMG_3897

However what you'll notice if you compare the two seams side by side is that the adaptive PA has an ever so slightly better controlled seam where the arrow is.
image

Wall printing performance:
This I did not expect and we need to do more tests to verify this or disprove it. It appears that the adaptive PA gave a slightly better wall finish to the print, coming out from an overhang. This may be expected as the extruder is pushing out now closer to the correct volume of material compared to the speed its printing so there is less random over extrusion when accelerating? All in all the surface finish appears improved with the adaptive PA.

image

Hypothesis 2 - Prove or disprove whether adapting PA when transitioning from printing external walls at the external wall speed to a (slower) external wall overhang region would show any benefit by having the right PA for that overhang speed.

When printing an external wall surface, there can be significant variation in print speed when transitioning from a fast print move printing the external walls, to a slower print move printing an overhang region. This would mean that the overhang is printed using a sub optimal PA (too low) potentially causing corner edges to slightly bulge.

image

Test performed:
Printed the orca cube at 150mm/sec external perimeter speed and slowdown for overhangs enabled, going down to 20mm/sec for the 75-100% overhang region.

Print results below:
IMG_3880

Conclusion:
It appears that when changing PA when transitioning from a faster speed to a slower speed for an overhang causes feature bulging. This is the opposite of what is expected as the PA emitted is higher than the regular external wall PA. The assumption was that this would cause the opposite and "tighten" up the overhang regions.

After analysing some slow motion footage of the extruder I can see an ever so slight movement stop that is barely visible to the naked eye but is enough to cause that slight feature deformation.

This means that:

  1. We must NOT dynamically change PA when printing a specific feature as this may introduce artefacts immediately after PA was set.
  2. Extrapolating from this learning, we probably must exclude changing PA when transitioning to an overhang perimeter, even though that is an extrusion role change in addition to being a speed change. Testing for this scenario is needed.
    I have left this feature available for testing; but most likely it will be removed in the future unless tests to the contrary are provided.

After these results I have hidden this option in the GUI as it has adverse effects. If anyone wants to test this reach out.

Hypothesis 3 - Prove or disprove whether adapting PA when transitioning from printing a faster perimeter to an overhang perimeter or bridge could improve bridging performance and post bridge extrusion consistency

To be tested.

**Hypothesis 4 - The PA behaviour is tied to volumetric flow speed instead of print speed exclusively.

Initial tests seem to indicate that there is a positive correlation between flow speed and PA. The feature has now been revamped to use the volumetric flow speed instead of the print speed.

@igiannakas igiannakas marked this pull request as ready for review June 6, 2024 16:15
@igiannakas igiannakas changed the title Draft: Adaptive Pressure advance POC: Adaptive Pressure advance Jun 6, 2024
igiannakas and others added 3 commits June 6, 2024 18:17
Reduce the frequency of requested PA changes by introducing a "state" variable.
Implement user toggle for adapting PA for external walls for overhangs
@Eldenroot
Copy link
Contributor

Awesome

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 7, 2024

Awesome

Want to see how it performs. I have 2 use cases for this:

  1. Improved external perimeter corners as typically external perimeters are printed using slower speeds compared to infill
  2. Improved overhang performance as again these are printed slower than the perimeter speeds

Number (2) has been disproven as a benefit as klipper has a micro stutter when changing PA, causing the reverse effect.

I am now testing (1) as the micro stutter shouldn't matter when transitioning features anyway as you're starting to print from a stand still anyway. Hopeful that this will be the major use case but will see following testing. If (1) is also disproven then I will shelve the feature as not needed and having an approximate PA being good enough for most cases.

I'll be updating the original post with my test results, but always welcome community testing as I only have 2 printers :P

@SoftFever SoftFever added enhancement New feature or request Community testers wanted Looking for community testers and feedback labels Jun 7, 2024
@SoftFever
Copy link
Owner

This is awesome!
I thought it was more relevant to accel instead of speed.
But you testing seems indicate the speed affect more.

Do you use same accel for all the features in your tests?

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 7, 2024

This is awesome! I thought it was more relevant to accel instead of speed. But you testing seems indicate the speed affect more.

Do you use same accel for all the features in your tests?

Nope I'm using varying accelerations as below:
image

but I guess my accelerations are not sufficiently different between perimeters to show the effect of acceleration on PA. The only place I go high is internal solid infill. The rest are reasonably conservative (in order to remain within the klipper input shaper envelope).

The above PA profile was tuned for 3k accelerations. From the test I've done, higher acceleration does indeed affect PA but more likely than not it's a linear correlation. So what I suspect is happening in my test situation is that the faster speeds use lower PA anyway and that is good enough to prevent issues showing on the internal solid infill which also uses very high accelerations.

@cochcoder
Copy link
Contributor

I wonder if this would also improve performance for scarf seams due to the change in speed and flow rate. Does the changes in this PR affect scarf seams? If so, I'll try some tests targeting scarf seams :)

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 7, 2024

So... Digging a little more:

https://klipper.discourse.group/t/pressure-advance-smooth-time-skews-pressure-advance/

From Kevin:
Smooth time impact on PA

"It may be possible to come up with an alternative smoothing system [the smooth time approach] to reduce the amount of over-extrusion during slow speeds. (Possibly by giving greater weight to the desired extruder position at low toolhead speeds.) It’s not immediately clear how to do that though."

"It seems an acceptable (smooth time) value is dependent on acceleration - the higher the acceleration the lower the smooth time should be in order to get acceptable results."

So it appears we actually have a double whammy and this (the effect of smooth time) is what we are compensating for. I may extend the feature to also consume an acceleration profile for a specific speed value and use the two curves to interpolate between.

For reference I have the smooth time set to 0.01 on my printer and this may be the reason why the curve is not ridiculously steep or not as visible as variations between different feature accelerations

More research is necessary.....

@igiannakas
Copy link
Contributor Author

I wonder if this would also improve performance for scarf seams due to the change in speed and flow rate. Does the changes in this PR affect scarf seams? If so, I'll try some tests targeting scarf seams :)

No it won't as we must not be changing PA during a feature being printed as this causes proven scaring. So its a no go for this.

@SoftFever
Copy link
Owner

I'm also thinking it might make more sense to use volumetric speed instead of print speed here. At the end of the day, it's all about predicting and compensating for the pressure inside the nozzle. Wouldn't volumetric speed be more precise? If it works, it could make line width, layer height, and even nozzle size agnostic!

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 7, 2024

Test prints with a 10k acceleration target done.

At 50mm/sec there is no difference between the 3k and 10k acceleration PA test.

At 100mm/sec the optimal PA drops from 0.029 to 0.026

At 150mm/sec the optimal PA drops from 0.026-27 to 0.022

IMG_3907

image

So there is for sure another correlation there.

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 7, 2024

For volumetric speed I need to do PA tests for the same speed and acceleration using different layer heights - that should keep the time dimension constant (speed/acceleration) while only looking at the flow rate.

To be honest I'm still trying to triangulate where that non linearity is happening from - if we understand that then we can model it. So far candidates are:
1. The smooth time parameter - this introduces a deviation from optimal PA that can be expressed as a delay in the PA reacting, causing gaps/blobs. This appears as different PA values against speed & acceleration (I think)
2. A non linearity of the PA depending on nozzle pressure that is not linearly proportional to speed. Extruder position of a given PA value is linear to the speed right now in Klipper - pa_position(t) = (nominal_position(t) + pressure_advance * nominal_velocity(t)) then smoothed over the smooth time and integrated.

For number (2) this is interesting. I would expect that

  1. A higher PA is needed the higher the nozzle pressure.
  2. Higher speeds would create a higher nozzle pressure due to higher consequential flow rate.
  3. However what I'm seeing from my tests is the exact opposite - that a lower PA value is needed the higher the nozzle pressure for a given nozzle size

However from my experience with a 0.25 nozzle, I use a PA value there of 0.048 compared to the avg. of 0.030 or so for the 0.4 nozzle. Which makes sense as higher inherent pressure needs higher PA.

However look at this part of the curve here:

image

Maybe the reason it is flattening is because of the increase in pressure reducing the effect of smooth time on the needed PA compensation....

And maybe the reason the curve isn't flattening as much for higher accelerations is because the smooth time effect is larger than the pressure non linearity?

What I can tell for sure using experimental data so far:

  1. PA has a relationship with speed
  2. PA has a relationship with acceleration, but the effect appears to be near constant or slightly increasing above a certain speed.

We need more tests and I need more brains for this!!

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 7, 2024

So I’ve run a set of PA tests with varying flows (using different layer heights, keeping speed and acceleration constant) and there definitely is a correlation - lower flow needs higher PA or it looks that way.

It’s getting a bit late here so I’ll post results tomorrow

@cochcoder
Copy link
Contributor

cochcoder commented Jun 8, 2024

I ran a quick and dirty test, even though my printer is probably not the main audience for this feature as its a slightly modded ender 3, and I can see some marginal but promising results. My inner and outer walls have smaller/thiner gaps in between each other, there are smaller pinholes for my internal solid infill, and my initial layer is more consistent and no longer has a flattened out edge for the circle that makes the hole of the orca cube. I did also notice slightly worse overhang performance like you already mentioned.

@igiannakas
Copy link
Contributor Author

I ran a quick and dirty test, even though my printer is probably not the main audience for this feature as its a slightly modded ender 3, and I can see some marginal but promising results. My inner and outer walls have smaller/thiner gaps in between each other, there are smaller pinholes for my internal solid infill, and my initial layer is more consistent and no longer has a flattened out edge for the circle that makes the hole of the orca cube. I did also notice slightly worse overhang performance like you already mentioned.

You shouldn’t have a difference in overhang performance as I’ve disabled the code that was causing the Pa to change before and after an overhang. Curious to what you’ve seen so I can fix it - any chance of a before/after pic for the overhang region?

@igiannakas
Copy link
Contributor Author

igiannakas commented Jun 8, 2024

Good morning everyone!

A bit of an update on flow vs PA.

Below is a graph plotting the different PA values as a function of flow rate.
Volumetric Flow speed here was changed using variable speed.
image

Volumetric flow speed based changed using variable layer height:
image

A couple of observations:

  1. This graph tells us lower flow -> higher PA, higher flow -> lower PA.
  2. The lowest point in that graph is the 50mm/sec speed -> 3.96mm3/sec flow rate
  3. When reaching nozzle flow limits (for me its around 20mm/sec) PA appears to break down and reduce significantly
  4. There is some correlation between the two methods (even though this is based on a sample of just 2 points) - the 12.93 flow using LH to generate it results in 0.023 PA for 10k accel. The 11.87 flow using speed to generate it uses similar 0.023 value. Same for the 15.86 and 18.83 point -> they both are around the 0.021 mark. Please bear in mind that I can only get so accurate with the PA. we are talking 0.01 delta's here which are a bit subjective too.
  5. When using my 0.25 nozzle I noticed that my PA is around 0.42-0.45. This was calibrated at 140mm/sec which is 3. 12mm3/sec flow. This does show that this may actually work as a single PA curve across nozzles (?). The calibrated PA value and what I'm getting out of this model appears to be indeed very close for a lower flow nozzle even though the speeds are higher...

Community ask: It would be great if someone with a 0.6 nozzle could verify that their PA is correlated to nozzle size inversely. ie do you use a lower PA for a larger nozzle (with similar geometry) or not? What has the community observed?

PS. the only reference I've found related to PA and nozzle size scaling was here: https://www.reddit.com/r/klippers/comments/14dhj2y/comment/joq929v/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button and the user does indeed say that there is an inverse relationship -> larger nozzle -> lower PA which would validate the above results.

Converting the code to base the extrapolation on flow is a piece of cake (the interpolator doesn't care what values you put in anyway), so once we have some positive confirmation that this trend continues with larger nozzle sizes (reducing PA the larger the flow rate) I will convert the code from speed based to flow rate based which would have some very cool side benefits if the correlation holds:

  1. One PA calibration and use it across all nozzle sizes
  2. One PA calibration irrespective of Line width/Layer height

@Ataraxia-Mechanica
Copy link

Ataraxia-Mechanica commented Jun 8, 2024

I use significantly lower pressure advance with 0.6mm nozzle compared to 0.4 when printing. I mainly print PETG, and 0.6mm nozzles have a PA value of 0.012 while for 0.4mm it's 0.045. So seperate PA curves for each nozzle size is probably still needed, probably due to the viscosity of PETG so it has a much harder time going though 0.4mm nozzles?

@cochcoder
Copy link
Contributor

You shouldn’t have a difference in overhang performance as I’ve disabled the code that was causing the Pa to change before and after an overhang. Curious to what you’ve seen so I can fix it - any chance of a before/after pic for the overhang region?

It's probably because I didn't spend much time making sure that the PA values were the best ones to use and using an old and crappy filament. I'll do some more through tests once I have some good filament.

@igiannakas
Copy link
Contributor Author

I know I need to make a calibration test for it as it takes a while to run 16 or so PA tests to get a good profile.

in the mean time also check out the wiki page for the feature - it explains in detail how to run it.

https://github.com/SoftFever/OrcaSlicer/wiki/adaptive-pressure-advance

@simonvez
Copy link

oh im so happy to see this PR. great work ! i have been having this issue for a while. this will be awesome :)

@shyblower
Copy link

shyblower commented Sep 17, 2024

As from what I learned, printing speed is not the problem but acceleration.

Bambu's Pressure Advance Algorithm does in contrast to Marlin's Linear Advance not modify print acceleration but only extrusion (as far as I know).

Print acceleration also has to be reduced the higher you set the K value, to give the changes in extrusion speed enough time to compensate for the filament compression that happens between the feeder and the tip of the nozzle. This is why they've added this to Linear Advance. They had realized that modification of only the extrusion speed is not enough to compensate for higher filament compression, caused by soft filament and/or higher speeds respectively higher acceleration. I've read this in the comment to the commit where it was accomplished.

High K values are needed for flexible filament like TPU. I need depending on filament brand, shore hardness, nozzle temperature, hot end (E3D Obxidian e.g. is totally different from the stock hot end in this regard), nozzle diameter and layer height a K between about 0.15 and 2.5(!!!). This only works if I also reduce acceleration (and also jerk) radically.
E.g. for Recreus Filaflex 60A I have to reduce acceleration to about 200mm/s² and jerk to 3 otherwise PA would have no effect and also it would jam the extruder, but that's a different issue.
TPU
I'd suggest to just add some parametrizable curve function to the filament profile which modifies K depending on nozzle diameter and current layer height, because all the other parameters (printing temperature, hot end ...) usually seldomly change and also reduce acceleration the higher K gets to simulate what Linear Advance does.
This would also be easier to configure for the user than the current monstrosity ;) in OrcaSlicer 2.2.0 Beta.

@igiannakas
Copy link
Contributor Author

The algorithm looks at two parameters:
Volumetric flow rate
Acceleration

speed is used as a proxy in order to run the calibrations but the model is based off volumetric flow rate.

the higher the layer height, the greater the flow rate for the same speed and similarly with nozzle sizes. So I believe you can use the same model for this. You also have the option to completely disregard acceleration or flow rate from the calibrated model - if you set the values to be all the same the model ignores them.

@dury10
Copy link

dury10 commented Sep 17, 2024

I`m so curious if now with this features will have better seams when using 0.6 nozzle and 0.25 layer height

@igiannakas
Copy link
Contributor Author

Possibly. My seams have been absolutely perfect with it enabled but then I don’t have a 0.6 nozzle to test it. Below is with a 0.4

IMG_4059

@dury10
Copy link

dury10 commented Sep 17, 2024

it looks fantastic! nice job! what filament is that it looks beautiful!
I will test it with the .4 and black petg, this is what i have loaded, and after when i will switch nozzles i will post the results. thanks for the amassing work!

@shyblower
Copy link

shyblower commented Sep 17, 2024

The algorithm looks at two parameters: Volumetric flow rate Acceleration

In my understanding it's not the flow rate that affects the K parameter as the PA algorithm is designed to have a K parameter that's independent of the flow and thus the printing speed, but the resistance of the the filament to being pressed out of the nozzle.
I tested this by printing lines with different width but using the same nozzle diameter which does increase the flow rate but didn't influence K. It is mandatory that it works this way, because otherwise the Arachne wall generator would produce an utter mess.

Every parameter that increases that resistance causes a higher filament compression inside the extruder (between the feeder and the ground where the molten filament is laid on, like the plate or the previously printed layer). These parameters are mainly the liquidity of the molten filament which depends on the nozzle temperature, the nozzle diameter and the layer height, where with wider nozzles and higher layers K quickly converges towards zero.

PA tries to compensate for the extrusion latency caused by this filament compression. As I understand, it's not a physically correct implementation but only an approximation, but does not depend on the flow rate. The only issue is that the faster you print, the more visible will the defects from a not perfectly calibrated K parameter become, so optimally you should calibrate K using the maximum printing speed you will be using. This is also what Marlin's Linear Advance documentation essentially is saying ("Fast Printing Speed and Slow Printing Speed should be significantly different or the K-factor effect will barely be visible.").

During my testing I've never experienced the flow rate depending problems that caused this pull request and I was one of the first who embraced LA and later PA where other people laughed at me when I was trying to tell them that it's not possible to print a line that maintains a homogeneous cross section throughout its whole length without using and properly configuring one of those two algorithms.

So IMHO what we need is an implementation that accounts for just nozzle diameter and layer height and a function which reduces acceleration (and maybe also jerk) when K increases to simulate what Marlin's Linear Advance does but is missing in Pressure Advance so that PA will have enough time to compensate for very high filament compression (high K values) which happens when printing TPU and other flexible filaments.
I currently have to maintain one filament profile for each filament, nozzle diameter and layer height combination and many process profiles for TPUs with different softness just to use lower acceleration values depending on shore hardness.

@igiannakas
Copy link
Contributor Author

It’s Polyterra fossil grey PLA. It’s the most revealing filament I have for imperfections as it catches the light with any uniformity variation!!

here you go these are the pictures:

image

image

image

image

IMG_4205

@igiannakas
Copy link
Contributor Author

igiannakas commented Sep 17, 2024

0.16 LH/0.4 nozzle / 3k external accel / 150mm/sec external perimeters. Voron 2.4 350 with Galileo 2 extruder and Voron revo plus ERCF v2

@dewi-ny-je
Copy link
Contributor

This has been merged. Further discussion should take place in the Orca Discord server.

shyblower added a commit to shyblower/OrcaSlicer that referenced this pull request Jan 12, 2025
@KrisBigK
Copy link

I work with a Bambu P1S printer, have recently bought a roll of transparent PETG from R3D, and decided to go through the tedious process of calibrating adaptive pressure advance. I have already calibrated flow before dealing with PA, and used the pattern test for easier PA inspection. After ~4 hours of printing and the adaptive PA model fed into the slicer, I created a simple triangular test model to evaluate the effectiveness of my PA model. To my frustration, it appears that static PA yielded better print results.

Transparent & glossy filaments are difficult to visually inspect. To pick my PA value, I held up the part against my black phone screen, find a light spot, and basically look at the "shadow" of the part that I'm inspecting. I start with the larger PA values, where wall separation creates holes that the light could shine through. Then I look at the edge of the 90° turn, and find the one with a slight indentation like the one in the picture. I select this shape in particular because I have printed a 1cm^3 cube separately, and the bottom few layers look exactly like this sideways.
image

My filament has a max volumetric speed of 23 mm^3/s, and my slowest volumetric speed is around 5mm^3/s. Also I would like to cap my acceleration to 4000 during normal printing. Therefore, I have tested flow 5.5, 11, 22. The lowest acceleration that could be tested is calculated with v^2=2ax, and I used x=25mm given the herringbone length is around 30mm. Here is the PA values that I have come up with.
image

Besides the above 14 lower precision PA values, I also tested flow 15.96 and acceleration 5000 (the default PA pattern settings) with 0.001 step length, and got a PA value of 0.036.

For evaluation, I created a testing model by copied the dimensions of a single herringbone pattern, and connected the open endings to create a closed loop, shown below.
image

Then, I put 6 of the triangles in the same plate, with varying layer height and acceleration, to simulate actual print conditions. Print speed is the same across the triangles.
For easier identification I numbered them 1 to 6 (see pic). Triangle 1-4 have varying layer height and same acceleration (1500).

  • Triangle 1: model height 1.21mm (0.32mm * 3 + 0.25), flow 21.56 for outer wall, 21.56 for gap infill
  • Triangle 2: model height 1.05mm (0.20mm * 4 + 0.25), flow 14.78 for outer wall, 21.56 for gap infill
  • Triangle 3: model height 0.85mm (0.12mm * 5 + 0.25), flow 9.27 for outer wall, 12.67 for gap infill
  • Triangle 4: model height 0.73mm (0.08mm * 6 + 0.25), flow 6.32 for outer wall, 8.28 for gap infill

On the second row, triangle 5 have acceleration set to 500, triangle 2 set to 1500, and triangle 6 set to 4000. These three have the same layer height (0.20mm). I have set all other slicing parameters to match the ones used in the default PA pattern test.
image

In order to verify the effectiveness of adaptive PA, I printed the triangles with 1) adaptive PA and 2) static PA = 0.036.
I've photographed the 90° angle and the left 45° angle under 30x magnifying glass. The right 45° angle is affected by seam, thus I am not showing it here.

image
1st 90° is not sharp enough, 6th 90° has severe wall separation

image
constant PA 90° ones look more consistent

45deg_PA_1-6_annotated
6th one with adaptive PA is not sharp enough; constant PA 45° ones look more consistent; (The blue stuff is my marker)

Also, my evaluation project: (I have custom G-code, select your own printer preset or use at your own risk)
PETG_adaptive_PA_evaluation_KrisBigK_20250223.zip

Apparently static PA works better in this circumstance. Is it because of a bad PA model? Do Bambu firmware support this at all? Any help would be appreciated.

@igiannakas
Copy link
Contributor Author

Bambi doesn’t behave the same way as klipper for Pa. I think it adapts internally already but I may be wrong. Hence this feature is not needed for Bambu printers.

@CCS86
Copy link

CCS86 commented Feb 23, 2025

Here are some of my observations on the Bambu PA implementation, and how it could be improved:

https://www.youtube.com/watch?v=zZjimJ6Gp7w

And also this issue I opened up with them because the extruder seems to skip steps before reaching an ideal PA value in some cases:

bambulab/BambuStudio#2922

@lookypanda
Copy link

He, @igiannakas
I believe I may have found an inaccuracy in the previous dynamic PA implementation. After running more extensive tests using the PA tower method, it seems that PA is primarily influenced by layer height and acceleration, while the impact of volumetric flow might be indirect. I’ve opened a new issue with detailed test results and observations
#8878

@shyblower
Copy link

shyblower commented Mar 13, 2025

The PA K value, which is defined as the compression length of the filament inside the extruder between feeder and nozzle tip per velocity unit in mm/(mm/s) depends on everything that makes it harder for the feeder to push it through the nozzle and thus compresses it more and also on the tightness of the tubes where it has to go through after leaving the feeder, because the wider the tube the more the filament can be bent, which also counts as compression.

This in essence is the softness of the filament, the print temperature, the properties of the extruder like how the hotend is built, the nozzle diameter and last but not least the layer height.

But it neither depends on print speed nor acceleration and thus also not on the flow. This becomes clear when looking at the definition of K which is as I've already mentioned above the filament compression lenght per velocity unit in mm/(mm/s).

The reason why it may seem that it depends on speed and acceleration and thus flow is, that the faster and the higher accelerated you print and the higher the K factor of the filament, nozzle diameter and layer height combination is, the more the feeder has to compensate for the filament compression. This unfortunately puts too much strain on the extruder motor when the combination of acceleration, speed and K gets too high.
I'm not an expert on stepper motors but maybe the stepper driver keeps the movement of the motor within its limits or the motor begins to loose steps or whatever but either way PA will not work anymore and further increasing K will not have the desired effect.

The proper thing to do, would be to lower acceleration and probably also jerk when K gets higher to give the PA algorithm and thus the extruder motor enough time to properly compensate for the filament compression.
This is what Marlins Linerar Advance (LA) does, at least since LA15, because one of their developers recognized this fact and implemented the automatic reduction depending on K within LA in firmware.

To produce the same result I forked this Repo and implemented the automatic reduction of acceleration and jerk inside OrcaSlicer using hyperbolic curves based on values I've figured out by experimenting on my Bambu Lab X1C.
This works perfectly and also lets me e.g. print even quite soft TPU, which naturally needs very high K values, depending on softness of up to about 2.0(!) at quite high max speeds, because the automatic reduction of acceleration and jerk not only "repairs" PA for high K values but also prevents the extruder from clogging when printing flexible materials.

@igiannakas
Copy link
Contributor Author

igiannakas commented Mar 14, 2025

I’m not sure we are getting extruder skipping or slipping since we are decreasing Pa to compensate for filament compression / path constraining when printing at higher flows / accelerations.

Also in klipper setup the variance in Pa is not huge - closer to 0.035-0.028 or so which doesn’t indicate a “break point” in the system. I would have guessed a much bigger delta would happen if there was slippage.

Also the Pa is lower the more back pressure is encountered which to me indicates that the extruder is over compensating with higher accels. If the above hypothesis was correct it would need to increase the Pa value with higher accels as more compensation would be needed. Also because more Pa is needed with lower accels we can’t really further reduce accels as this would create a feedback loop further needing an increase in Pa!!

fyi Bambu uses a different algorithm vs klipper for Pa that based on experiments done over in the discord by users does not benefit from adaptive PA. Probably they are implementing a Pa adjustment internally in the firmware.

@shyblower
Copy link

@igiannakas you may of course be right that the Bambu PA implementacion is more correct than Klippers but then it's a Klipper Problem ans should be fixed there. I know it's funny, me writing this after having fixed the acceleration issue for high K values also inside OrcaSlicer (in my personal fork and I intentionally haven't pushed a PR since I know that it might be considered being an opinionated approach and my function curves might only be optimally tuned for the Bambu Lab X1C), since I cannot modify the Bambu firmware 😅. But otoh Klipper is open source.

Fact is, K must not depend on velocity or acceleration, if it does, PA is not correctly implemented.

If your adaptive PA implementation is needed for Klippers obviously not correctly enough implemented PA it's of course useful although it's imho too elaborate to be utilized by the average user since you have to do lots of time consuming calibrations to fill the table with enough data points for interpolation.

@igiannakas
Copy link
Contributor Author

igiannakas commented Mar 14, 2025

Correct that’s the theory. That PA tuning should be independent.

klipper implements a linear function to calculate the extruder movement based on speed. Also implements Pa smooth time which basically creates an error rate / deviation between ideal (calculated) extruder movement and actual movement - to prevent the extruder from performing too high too fast moves as extruder movements as a result of PA are unbound.

There is a fork of klipper where smooth Pa is being trialed and the general idea is to get feedback from the slicer implementation to basically identify the core variables and implement in klipper eventually.

What we are seeing though is in reality the slope of the linear model changes based on acceleration and acceleration and flow with a reducing factor / so a linear adjustment is likely not possible. Maybe with anything that changes the back pressure on the nozzle (flow, accel, layer height)

Probably because the filament gets more rigid the faster you print and the closer you get to the hotend melting ability.

My theory is that a higher flow -> more solid filament in the hotend -> less Pa needed to retract and advance it as the amount of molten plastic is reduced.

For the deviation based on acceleration I’m really not sure - but maybe a similar story as with the above as we are basically reducing the time window where the adjustment can happen (?).

But to do so we need data. And to figure out why the linear model is not good enough. And also how to test for it. Hope that makes sense?

@shyblower
Copy link

@igiannakas sure, this makes much sense!

I actually didn't intend to criticize your code but to make people aware that there is a PA issue when printing high K filaments at high speeds which has its roots in extruder motor limits and that this is not only my observation but has already been tackled by Marlins Linear Advance algorithm.
My workaround for this can be found in my OrcaSlicer fork but honestly I cannot tell if the acceleration and jerk values my easy to use feature, it's just ticking a checkbox in the process profile, generates, work equally well on other printers than my Bambu X1C.

I could only compare Bambus PA against Marlins LA (the Prusa implementation) since a Bambu X1C and a Prusa MK3 (which I've given away recently) are the only printers I had, for experimenting.

@shyblower
Copy link

@igiannakas Here you will find evidence for what I'm trying to explain. LA in Marlin FW handles it in contrast to Klipper and Bambu PA.
https://marlinfw.org/docs/features/lin_advance.html

@igiannakas
Copy link
Contributor Author

I know :) have read it. Marlin doesn’t have the smooth time concept. Klipper uses smooth time as a substitute for limiting extruder movements to the jerk limit.

@igiannakas
Copy link
Contributor Author

Btw Bambu is completely unbound on the extruder acceleration. I’ve had instances where I saw extruder stalling when pulling filament too fast out from the extruder during multi material changes. See here: #3094

maybe they have capped it for Pa, not sure; but for regular print moves jerk limits are not respected.

@shyblower
Copy link

@igiannakas but "smooth time" seems not to be working well for high K values which you need e.g. for TPU but also PETG, PCTG and CPE profit much from slightly lower accel and jerk.

There seem to be more than just the K parameter for use with the M900 GCode. Isn't one of them responsible for configuring the "smooth time". Maybe OrcaSlicee should try to modify this with increasing K values?

@igiannakas
Copy link
Contributor Author

For klipper, smooth time is a function to reduce and spread extruder motion over a specific time window.

Typically in klipper you want almost as close to 0 smooth time as possible (ie infinite jerk in marlin), to minimise delta between ideal extruder motion and actual motion. It was introduced as Bowden extruders needed to move too much (due to their high Pa) hence smoothing that motion over time acted as an effective acceleration cap on the extruder.

Basically the higher the Pa and higher the print accelerations, the bigger effect smooth time has.

for tpu / petg material in klipper you can mitigate the stretching of the material by printing with slower extruder transitions (by reducing printing accelerations) - which means lower extruder movements as a result of the needed Pa value to maintain ideal extrusion timing.

You can also further smooth that by applying extrusion rate smoothing in orca, which creates slowdown segments beyond the firmware commanded ones allowing Pa enough time to adjust.

there has been chatter about introducing a test to calibrate smooth time but nothing has come to being yet. Basically you want to reduce smooth time till the gap in a corner observed when you have borderline high Pa aligns with the edge of the corner.

too high smooth time will move that gap before the corner.

I don’t have as much insight on the marlin implementation, and much less so on the Bambu implementation so can’t offer any meaningful advice other than what I’ve seen with my X1C before I sold it :)

shyblower added a commit to shyblower/OrcaSlicer that referenced this pull request Mar 20, 2025
@gregmatic
Copy link

@igiannakas question: in Orca, the acceleration control is set by commands such as SET_VELOCITY_LIMIT ACCEL=1000, which as far as I understand applies to all axes including extruder when there is no AXIS argument. isn't this not ideal for PA which sometimes require higher accel on E vs XYZ?

@igiannakas
Copy link
Contributor Author

The set accel command doesn’t apply to E in klipper at least from what I understand. That is also the reason Pa smooth time exists - to cap acceleration on the extruder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community testers wanted Looking for community testers and feedback enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.