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

Improve pressure equalizer so that it's less aggressive #4264

Merged

Conversation

Noisyfox
Copy link
Collaborator

@Noisyfox Noisyfox commented Feb 29, 2024

Current pressure equalizer will slow down the print too much when the extrusion rate differs a lot:
image
bridge test.3mf.txt

This PR fixes the issue:
image

Some detailed explaination:

float rate_start = rate_end + rate_slope * line.time_corrected(); calculates the max rate possible at the beginning of the segment, so that the rate changes between rate_start and rate_end across the segment extrusion time does not exceed the rate_slope.

However, this formula ignores the fact that the segment extrusion time will be longer than line.time_corrected() if the rate_start decreased, which means the actual max extrusion rate should be larger than rate_start calculated here.

The new formula fixes the problem:
image

This also fixes #3208

@Noisyfox
Copy link
Collaborator Author

This also fixes #3839 (comment) and #3839 (comment)

@igiannakas
Copy link
Contributor

Fantastic, thank you for fixing this! It had been driving me nuts specifically by being too aggressive after gap fill!

@HakunMatat4
Copy link

HakunMatat4 commented Feb 29, 2024

@Noisyfox , as you know I run 120mm3/s 1 segment length.
The speed is increased where slowing down is not really necessary.
I tested 10mm3/s like you and got the same result, below is my custom profile.
Can post some print test tomorrow but looks 10/10 to me.

Before

20240229_213758

This PR

20240229_214114

@HakunMatat4
Copy link

@Noisyfox I forgot to check the main issue in my case: screw holes
In my test, screw holes were the holes setting printing speed to 0.0000001mm/s 😅
Can check that tomorrow.

@SoftFever
Copy link
Owner

SoftFever commented Mar 2, 2024

This is fantastic!

Shall we update the tips of the option too?
The recommended value(300-350) seems a bit too high with the new formula. @Noisyfox @igiannakas
Also what's your usually settings when you use this feature? @HakunMatat4

"For a high speed, high flow direct drive printer (like the Bambu lab or Voron) this value is usually not needed. "
"However it can provide some marginal benefit in certain cases where feature speeds vary greatly. For example, "
"when there are aggressive slowdowns due to overhangs. In these cases a high value of around 300-350mm3/s2 is "
"recommended as this allows for just enough smoothing to assist pressure advance achieve a smoother flow transition.\n\n"
"For slower printers without pressure advance, the value should be set much lower. A value of 10-15mm3/s2 is a "
"good starting point for direct drive extruders and 5-10mm3/s2 for Bowden style. \n\n"

@HakunMatat4
Copy link

This is fantastic!

Shall we update the tips of the option too?
The recommended value(300-350) seems a bit too high with the new formula. @Noisyfox @igiannakas
Also what's your usually settings when you use this feature? @HakunMatat4

120mm3/s with segment length 1
But I'm a lonely wolf haha so idk if that is the best settings, I find it a decent balance and have been using it that way since the start.

Segment length 3 should be fine also and IIRC mandatory for some printer, I don't bother the gcode size that it allegedly gets bigger with length 1 but I never bothered to confirm that.

@igiannakas
Copy link
Contributor

igiannakas commented Mar 2, 2024

Yeap the tool tip could do with an update. I've written up my thoughts below (sorry for the post length!!!) but may be wrong as this is a pretty complicated topic, especially how it interacts with internal motion planners, PA and PA smooth time in the klipper/BBL firmwares.

To start the conversation, see image below:
Left: BBL with 200mm/sec external wall speed
ERS is set to 300
Right: V2.4 with 120mm/sec external wall speed
ERS is set to 120
Screenshot 2024-03-02 at 12 26 04

That is expected as a higher speed transition results in a higher flow change, meaning you need a higher ERS value to maintain the same smoothing over the same distance.

However this may not be the right answer as we are trying to fight:

  1. The limits of the extruder system - how fast can it change pressure in the nozzle
  2. The configured pressure advance values - that also affect pressure changes in the nozzle
  3. The acceleration profile of the printer - higher accelerations mean higher pressure changes
  4. The pressure advance smooth time - higher smooth time means higher deviation from ideal extrusion, hence more opportunity for this feature to be useful.

When I ported it, I targeted BBL printers mostly which, because of the fast external perimeter speed and high accelerations and less than ideal PA smoothing implementation, needed high ERS values to take the "edge" off PA artefacting. Basically providing a small "ramp" to slow down and ramp up speeds to cover for the deficiency in its internal jerk implementation which is worse in my view compared to the Klipper SCV implementation and aggressive PA smoothing. Hence the high value recommendation for BBL stock profiles. Experimentally it worked well - taking the edge off the artefacts.

However, this feature won't make a difference if the extrusion rate smoothing slope results in speed changes that are less than what the internal motion planner of the firmware plans during acceleration/deceleration moves. For example, when transitioning from a high speed area to a low speed area there is no "sudden" stop as you're bound by the print acceleration, so what you see on the speed view in Orca isn't exactly what is happening when printing the model. For a BBL printer printing at 10k+ speeds the ERS value can be afforded to be higher as the deceleration-> acceleration slope will result in more sudden extrusion rate changes compared to a print with more moderate accelerations.

Then the matter of Pressure Advance smooth time comes in. This is the amount of time allowed to the extruder to smooth out a newly requested extrusion rate value in Klipper. (https://klipper.discourse.group/t/pressure-advance-smooth-time-on-direct-extruders-with-short-filament-path/1971/6) This results in deviations from the ideal nozzle pressure, as the extruder cannot move instantaneously, hence why its extrusion rate change is smoothed over time. This deviation is what we are trying to mitigate here in areas of sudden speed change.

Ideally, I think that you'd want extrusion rate smoothing to be resulting in extrusion rate changes that are smaller than the PA smooth time value for it to have any meaningful effect (hence speed changes that are larger than what the planner would produce). I think that if the ERS flow changes are over the PA smooth time threshold the look ahead planner will reduce extrusion rate faster than the ERS smoothing moves hence making it redundant.

So in summary it may make more sense to go conservative in this value to allow it to have an effect on the print. For a fast accelerating printer with PA smoothing that is close to 0, as is the BBL printers (which result in artefacts when slowing down quickly), it may make sense to keep the value high, like 200/300 or so.

For a Klipper printer, especially if you have PA smooth time of 0.04 which is the default and are printing with more conservative accelerations (like 2-6k), maybe it makes sense to keep the value at a more moderate level, like 100 or so or even lower.

For a slower printer with no PA and limited accelerations, a much lower value makes more sense - like 10-15 or so.

This should be solvable with math, however it makes my head spin just thinking of it :) You have a speed ramp due to the acceleration profile, that results in an extrusion rate ramp based on the PA value which is smoothed out over PA smooth time. Ideally you want the ERS value to be below the computed flow changes from the above.

So where does this leave us? Lower values are more likely to produce a meaningful result, but going too low will slow down the print more than needed to take the edge off these artefacts...

Personally I use it on occasion on the BBL X1C where models show the need for it (sharp speed changes on external walls) but in these cases I may just print the perimeter slower anyway to get better quality as loosing arcs is a bigger issue quality wise on that printer (steppers exhibit more VFA without arc moves). When I do use it I have settled on a value of 200 with 3 as a segment (to avoid overloading the MCU).

On the V2.4 I dont use it most of the time as I haven't seen the same level of artefacts as on the X1C on external perimeters but then I am using danger klipper with extrusion rate sync to IS and a low PA smooth time value of 0.01s and a nozzle that doesnt take much to pressurise (not a UHF style nozzle that needs to push plenty of material to ramp up pressure). When I do use it on the 2.4 I have settled on a value of around 100 with 1 segment.

With the above in mind, a new tool tip could be:

This parameter smooths out sudden extrusion rate changes that happen when the printer transitions from printing a high flow (high speed/larger width) extrusion to a lower flow (lower speed/smaller width) extrusion and vice versa.

It defines the maximum rate by which the extruded volumetric flow in mm3/sec can change over time. Higher values mean higher extrusion rate changes are allowed, resulting in faster speed transitions.

A value of 0 disables the feature.

For a high speed, high flow direct drive printer (like the Bambu lab or Voron), especially with a well tuned PA and PA smooth time settings, this value is usually not needed. However, it can provide some marginal benefit in certain cases where feature speeds vary greatly, such as in overhangs or where the extruder and/or hot end cannot keep up with the requested flow changes as a result of pressure advance.

In these cases, if printing with high accelerations (10k+) and high speeds (200mm/sec+) a value of around 200-300mm3/sec2 is recommended as it allows for just enough smoothing to assist pressure advance achieve a smoother flow transition.

In cases where more moderate accelerations are used (2-5k) and moderate speeds (100mm/sec) a value of around 90-120mm3/sec2 is recommended.

Finally for printers not utilising pressure advance a low value of around 10-15mm3/s2 is a good starting point. These printers will benefit the most from this feature due to the lack of pressure advance in the firmware.

This feature is known as Pressure Equalizer in Prusa slicer.

Note: this parameter disables arc fitting.

@igiannakas
Copy link
Contributor

For example, the below is with klipper on the v2.4 printing at 120mm/sec external without ERS.

Here PA and smooth time have done a good job of eliminating the extrusion rate issue, together with the G2E extruder that can respond fast enough to the filament flow changes.

so I think the “recommendation” that this feature should not really be needed for klipper at least and if it is, maybe a borderline high value will give the most benefit, as long as it’s beneath the acceleration curve, pa smooth time and corresponding speed ramps.

IMG_3188

@SoftFever
Copy link
Owner

Then the matter of Pressure Advance smooth time comes in. This is the amount of time allowed to the extruder to smooth out a newly requested extrusion rate value in Klipper. (https://klipper.discourse.group/t/pressure-advance-smooth-time-on-direct-extruders-with-short-filament-path/1971/6) This results in deviations from the ideal nozzle pressure, as the extruder cannot move instantaneously, hence why its extrusion rate change is smoothed over time. This deviation is what we are trying to mitigate here in areas of sudden speed change.

Ideally, I think that you'd want extrusion rate smoothing to be resulting in extrusion rate changes that are smaller than the PA smooth time value for it to have any meaningful effect (hence speed changes that are larger than what the planner would produce). I think that if the ERS flow changes are over the PA smooth time threshold the look ahead planner will reduce extrusion rate faster than the ERS smoothing moves hence making it redundant.

This is an outstanding technical explanation! You've crafted a perfect document to detail the feature; it would be a shame for it to remain hidden in PR comments. Would you be interested in writing a WIKI page for this option? That way, when users click on the option in Orca, it will automatically direct them to the corresponding WIKI page.

Regarding the tooltips, I’m considering keeping them concise and focused on explaining the effects(with little bit of "how" if it's must).
Also rather than mentioning specific machines like BBL or Klipper, how about we talk about options for high-speed or low-speed printing? After all, machines can go fast or slow 😉
For optimized values tailored to specific machines, we can integrate those directly into the profiles.

@igiannakas
Copy link
Contributor

Then the matter of Pressure Advance smooth time comes in. This is the amount of time allowed to the extruder to smooth out a newly requested extrusion rate value in Klipper. (https://klipper.discourse.group/t/pressure-advance-smooth-time-on-direct-extruders-with-short-filament-path/1971/6) This results in deviations from the ideal nozzle pressure, as the extruder cannot move instantaneously, hence why its extrusion rate change is smoothed over time. This deviation is what we are trying to mitigate here in areas of sudden speed change.
Ideally, I think that you'd want extrusion rate smoothing to be resulting in extrusion rate changes that are smaller than the PA smooth time value for it to have any meaningful effect (hence speed changes that are larger than what the planner would produce). I think that if the ERS flow changes are over the PA smooth time threshold the look ahead planner will reduce extrusion rate faster than the ERS smoothing moves hence making it redundant.

This is an outstanding technical explanation! You've crafted a perfect document to detail the feature; it would be a shame for it to remain hidden in PR comments. Would you be interested in writing a WIKI page for this option? That way, when users click on the option in Orca, it will automatically direct them to the corresponding WIKI page.

Regarding the tooltips, I’m considering keeping them concise and focused on explaining the effects(with little bit of "how" if it's must). Also rather than mentioning specific machines like BBL or Klipper, how about we talk about options for high-speed or low-speed printing? After all, machines can go fast or slow 😉 For optimized values tailored to specific machines, we can integrate those directly into the profiles.

Of course!! Does the wiki work the same way as regular code PRs? Sorry stupid question I know :)

@SoftFever
Copy link
Owner

Then the matter of Pressure Advance smooth time comes in. This is the amount of time allowed to the extruder to smooth out a newly requested extrusion rate value in Klipper. (https://klipper.discourse.group/t/pressure-advance-smooth-time-on-direct-extruders-with-short-filament-path/1971/6) This results in deviations from the ideal nozzle pressure, as the extruder cannot move instantaneously, hence why its extrusion rate change is smoothed over time. This deviation is what we are trying to mitigate here in areas of sudden speed change.
Ideally, I think that you'd want extrusion rate smoothing to be resulting in extrusion rate changes that are smaller than the PA smooth time value for it to have any meaningful effect (hence speed changes that are larger than what the planner would produce). I think that if the ERS flow changes are over the PA smooth time threshold the look ahead planner will reduce extrusion rate faster than the ERS smoothing moves hence making it redundant.

This is an outstanding technical explanation! You've crafted a perfect document to detail the feature; it would be a shame for it to remain hidden in PR comments. Would you be interested in writing a WIKI page for this option? That way, when users click on the option in Orca, it will automatically direct them to the corresponding WIKI page.
Regarding the tooltips, I’m considering keeping them concise and focused on explaining the effects(with little bit of "how" if it's must). Also rather than mentioning specific machines like BBL or Klipper, how about we talk about options for high-speed or low-speed printing? After all, machines can go fast or slow 😉 For optimized values tailored to specific machines, we can integrate those directly into the profiles.

Of course!! Does the wiki work the same way as regular code PRs? Sorry stupid question I know :)

Yes!

@SoftFever
Copy link
Owner

Meanwhile, I will merge this PR first

@SoftFever SoftFever changed the title Fix too aggressive pressure equalizer Improve pressure equalizer so that it's less aggressive Mar 2, 2024
@SoftFever SoftFever merged commit ab1b0e0 into SoftFever:main Mar 2, 2024
12 checks passed
@Noisyfox Noisyfox deleted the bugfox/correct-pressure-equalizer branch March 2, 2024 16:27
@igiannakas
Copy link
Contributor

Meanwhile, I will merge this PR first

I’ll get a PR going over the next couple of days with a bit more documentation on this ;)

@SoftFever
Copy link
Owner

Meanwhile, I will merge this PR first

I’ll get a PR going over the next couple of days with a bit more documentation on this ;)

Awesome 👍

@igiannakas
Copy link
Contributor

https://github.com/SoftFever/OrcaSlicer/blob/9b4acc911f7981366179af27046810c6c0161b9a/doc/Extrusion-rate-smoothing.md

Did some of the math which seem to back the empirical tests by @HakunMatat4 on the Voron and mine on the BBL. Turns out if you’re accelerating at 4k+ a high value is enough to take the edge off (200+). If you’re accelerating at 2k or so which is more typical of Voron external perimeter accelerations a value of 70-100 is more appropriate. This setting basically reduces the deviation as a result of smooth time in klipper and covers for the mechanical limits of the hot end on the Bambu!!

@HakunMatat4
Copy link

https://github.com/SoftFever/OrcaSlicer/blob/9b4acc911f7981366179af27046810c6c0161b9a/doc/Extrusion-rate-smoothing.md

Did some of the math which seem to back the empirical tests by @HakunMatat4 on the Voron and mine on the BBL. Turns out if you’re accelerating at 4k+ a high value is enough to take the edge off (200+). If you’re accelerating at 2k or so which is more typical of Voron external perimeter accelerations a value of 70-100 is more appropriate. This setting basically reduces the deviation as a result of smooth time in klipper and covers for the mechanical limits of the hot end on the Bambu!!

I've two use cases in case this change anything.
For ASA prints which you shouldn't use too much cooling or overhang looks like 💩 and weak prints, I've the walls set to 80mm/s
As you know I've a better toolhead now on my Voron but haven't tested/improved the profile yet, way too many backlog projects to test that right now.

PXL_20240204_035803835~2.jpg

When printing PLA tho, I'm cruising at 200mm/s on the walls, 5k acceleration while pushing filament at 20-25mm3/s while keeping the same 120mm3/s and segment length 1
Test prints with the new toolhead with the speed above and quality I'm "okay" so idk if this influences anything.

PXL_20240226_021149293.jpg

PXL_20240226_021127196.jpg

In all cases, I cannot complain about the seam left because of this feature. Also, I don't have seam gap enabled because I believe it will destroy PA logic.

@igiannakas
Copy link
Contributor

@HakunMatat4 whst acceleration are you using for your print moves? External, internal perimeter, infill and sparse?

@igiannakas
Copy link
Contributor

igiannakas commented Mar 5, 2024

Reason I’m asking is because having done some of the math it appears that:

  1. The value that you select for ERS is independent of print speed
  2. It’s optimal value is directly proportional to layer height and line width - larger the flow the greater the value should be
  3. It is proportional to the acceleration speed of your printer

basically there is an upper value where ERS does nothing for your print as your printer is slowing down on its own more than the ERS value would make it slow down - at .2 LH with 5k accel for external perimeters that value is 406mm3/s2.

setting an ERS value at 100 you’re basically simulating at the points of sharp speed changes what the printer would do on its own if you’re printing at 1.2 k accel or so and 0.2 LH with this feature off.

maybe that is also why I haven’t seen the need for it much as I’m printing with 1-2k external wall speeds, so basically running the same extrusion smooth rates as you but from within the printer if that makes sense.

@HakunMatat4
Copy link

@HakunMatat4 whst acceleration are you using for your print moves? External, internal perimeter, infill and sparse?

These are the same profiles I used when this feature was released ages ago.
The only major change I made by having better cooling was to increase travel speed slightly.

This is my "normal profile" for everything.

20240305_204448

This is my slowest profile for ASA Voron parts or ASA anything that goes into the printer.
Especial attention to the outer/inner walls speed and 40-50% cooling.
The only other change I make when printing models with little details is to enable "Slow printing down for better layer cooling" and speed set to 70mm/s

20240305_204511

@HakunMatat4
Copy link

@igiannakas

I didn't provide the most important details: seam
All printed with the speed profiles shared above.

ASA-CF

image

Polymaker PolyTerra Matte PLA, all the way

image

eSun PLA+ x5 zoom, not the best place to have a seam, I know, not the worse either.
image

Same eSun PLA+
image

@igiannakas
Copy link
Contributor

igiannakas commented Mar 5, 2024

@HakunMatat4 perfect thank you!

What I dont understand is why your seams are improved compared to the no ers setup. Especially since the perimeter speeds are not different between internal and external. If they were I understand it, but as they are not, there is no deviation in extrusion pressure. I dont think ERS does anything there now as there is no speed change before and after your seams. :S There may be a tiny bit of smoothing due to extrusion line width, but that is tiny in comparison to the print speed changes

What do you think? Have you tried recently with the feature off and check the seam performance?

Perimeters with varying speeds: - significant ERS influence
image

Perimeters with same speeds: - limited ERS influence
image

@HakunMatat4
Copy link

there is no deviation in extrusion pressure. I dont think ERS does anything there now as there is no speed change before and after your seams

I believe there is.
Please, keep in mind that the original request comes from PrusaSlicer Pressure Equalizer.

Let's use my 200mm/s 5k accell profile as example.
The nozzle is coming hot at 200mm/s and needs to "perform a seam" within milliseconds.

  1. Nozzle is flying at 200mm/s
  2. Sudden stop: Here lies the problem, all the pressure within the nozzle
  3. Retract/Detract
  4. Seam
  5. Start again from 0mm/s to 200mm/s

It is gonna leave an ugly seam, I mean, I magine you driving at 100km and then boom, full stop, another boom, from 0-100km/s
Now comes Smoothing.

  1. Nozzle is flying at 200mm/s
  2. The speed and pressure within the nozzle is gracefully reduced
  3. Full stop, retract, detract: The nozzle does not have all the crazy pressure within it anymore
  4. Seam
  5. The speed and pressure within the nozzle is gracefully increase

This is PrusaSlicer Pressure Equalizer in action on my MK3S+ back then.
This is a lid with a circle in the middle so why three section, two seams you cannot see from the side, only from the top where you see the speed change which was set to 2mm3/s under those circumstances and worked like a dream.
But again, I was printing at what, 50-70mm/s tops

209047964-f63a51b0-074f-4408-bddb-7299628a5296

@HakunMatat4
Copy link

@igiannakas

@Ro3Deee
Copy link

Ro3Deee commented Sep 12, 2024

copied to PrusaSlicer prusa3d/PrusaSlicer@b4fadc1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

extrusion rate smoothing not taken into acount when print sequence is in object mode
5 participants