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

Enhancement: Adaptive Pressure advance #5609

Merged
merged 77 commits into from
Jul 28, 2024

Conversation

igiannakas
Copy link
Contributor

@igiannakas igiannakas commented Jun 6, 2024

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

Done code updated :)

Copy link
Owner

@SoftFever SoftFever left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good!
Thank you so much for another great feature!

@SoftFever SoftFever merged commit 529c44d into SoftFever:main Jul 28, 2024
16 checks passed
@CCS86
Copy link

CCS86 commented Jul 28, 2024

Very cool work guys.

Has anyone tested on Bambu printers to see how the firmware responds to rapid PA value changes?

@dewi-ny-je
Copy link
Contributor

Very cool work guys.

Has anyone tested on Bambu printers to see how the firmware responds to rapid PA value changes?

Ask on Discord, not here

@igiannakas
Copy link
Contributor Author

Very cool work guys.

Has anyone tested on Bambu printers to see how the firmware responds to rapid PA value changes?

I have an X1C but due to time constraints with work I haven’t managed to test it with it yet. The option is available (ie I didn’t limit it) so feel free to experiment with it and report back :)

celtare21 added a commit to celtare21/OrcaSlicer that referenced this pull request Jul 30, 2024
@yw4z
Copy link
Contributor

yw4z commented Jul 30, 2024

@igiannakas do you planning add a combined calibration test for this?

@igiannakas
Copy link
Contributor Author

Not in the immediate future (as in the next month or so) due to some family priorities this summer. But from autumn yes it makes sense

@yw4z
Copy link
Contributor

yw4z commented Jul 30, 2024

feature is really nice. thanks for your efforts on this but requires proper calibration
have a nice time with your family

@igiannakas igiannakas deleted the Adaptive-Pressure-Advance branch August 6, 2024 13:52
@GromovPeter
Copy link

hi how i can test this feature ? where i can download it or mey be some guide how to install this ))
thx

@igiannakas
Copy link
Contributor Author

hi how i can test this feature ? where i can download it or mey be some guide how to install this )) thx

It's in the latest nightly release. No need to install anything. Your printer needs to have the latest klipper version installed on it ideally to avoid artefacts.

You'll need to follow the instructions on the first post on how to calibrate your printer, but in general you want to run a bunch of PA tests, for different speeds (50-100-150-200) and accelerations (1k,2k,4k) typically is enough. The max acceleration you test needs to be below the max shaper value recommended by Klipper to avoid artefacts.

Finally take note of the PA value per acceleration and the corresponding volumetric flow rate at that speed and enter these values in the place shown above.

@GromovPeter
Copy link

GromovPeter commented Aug 16, 2024 via email

@Sidiusz
Copy link

Sidiusz commented Sep 14, 2024

I'd like to see a pre-made test so I don't have to create a lot of models and settings manually, thank you!

@CCS86
Copy link

CCS86 commented Sep 14, 2024

Yes, that would be great.

@gilbertgil36
Copy link

I'm using the translator to send this message, and this feature is really good. However, it's very tiring to use, especially for those with the Creality K1C. It's not quick to start printing, so imagine running this test 20 times. But what could help is if the ORCA allowed placing more than one test on the bed to speed up the process. I tried combining two G-codes, but I couldn't because the first layer of the second test doesn't adhere to the bed. Thank you so much for everything you do. You guys are doing an excellent job.

Let me know if you need any adjustments!

@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.

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.