PrusaSlicer
PrusaSlicer copied to clipboard
Improve Pressure Equalizer and fix related bugs
Hello all, this is my first PR so forgive me if I screw something up!
The pressure equalizer wasn't working as well as I hoped, so went on a journey to improve it, fixing things along the way.
Bugs fixed:
Pressure equalizer and cooling adjustments broken when using dynamic speed(dynamic overhangs)
Cooling markers were missing on lines drawn using dynamic speed. This prevents both the pressure equalizer and cooling code from adjusting the speed on these lines. This bug can be seen in uneven slowing of different parts of print to meet layer time because the model walls are not adjusted.
My fix may resolve https://github.com/prusa3d/PrusaSlicer/issues/9594
Example
broken
fixed
Chaos when auto speed enabled for perimeters when dynamic overhangs are also on and specified using percentages
When using this combination, the overhang speed calculation was using the perimeter speed (zero) as a basis for % speed slowdown. Which results in garbage speeds. I fixed this by using speed calculated by code above it, which already takes into account volumetric speed and appears to work properly in all cases.
My fix may resolve https://github.com/prusa3d/PrusaSlicer/issues/9485 and https://github.com/prusa3d/PrusaSlicer/issues/9563 (my issue lol)
Example
broken
fixed
Improving pressure equalizer
Finally, what I set out to accomplish.
Small improvements
Re-enabled pressure equalizer for gap filling and external perimeters.
In my printing experience, abrupt flow changes in external perimeters cause the worst defects, and pressure equalizer was disabled where it would help the most. The pressure equalizer behaves better after my improvements. And enabling it for external perimeters allows us to slow down for overhang perimeters and dynamic overhangs. Many people, me included, didn't use dynamic overhangs because the rapid flow change causes artifacts and pressure equalizer couldn't help, I wanted to fix that.
Example
broken
fixed π
Lowered max_segment_length from 5->1 when subdividing.
This results in smoother flow changes
Example
broken
fixed
Main Contribution To Pressure Equalizer - Only equalize across near-contiguous extrusions
Shortcomings of previous approach
The main issue with existing code is not accounting for travel moves. You could travel move across whole build plate and pressure equalizer would still try to make a smooth transition from flow rates at each end. Extruder pressure drops to zero after a few mm of travel without extruding, and longer moves will retract on top of that. So it doesn't make sense to smooth flow between extrusions separated by a travel move more than a few mm. I believe this shortcoming is why pressure equalization was originally disabled for outer perimeters here https://github.com/prusa3d/PrusaSlicer/commit/9c07218d820985a2c8cd3a606392c9317ad8b466 by @hejllukas , and why I feel confident turning it back on.
Changes
I've added some processing between the layer parsing and pressure adjustments. This new middle stage splits the lines into groups of continuous (or near continuous) extrusions. Each time there's a travel move of more than a few mm, it resets the pressure equalizer. This prevents smoothing of flow transitions between discontinuous areas of the print connected by a long (non-extruding) travel move.
What pressure equalization looked like before I added detection for contiguous line segments
You can see it is happily equalizing pressure between unconnected line ends many centimeters apart. This is because they're sequential in the gcode with a travel move between them, and the old code was blind to travel between extrusions.
These artifacts are an artificial best-case. Slicing with a normal slope smears these spurious pressure adjustments across most of the layer and I can't demonstrate whats happening. With the new contiguous segment detection shown below, spurious flow adjustments are no longer present.
Final Results
The hook from above, without spurious flow adjustments (and with dynamic overhangs fixed)
πππThose are some nice overhangs! πππ
Additional recommendation - Update pressure equalizer docs
I found the maximum recommended slopes too low. Modern printers don't need several seconds to transition between min and max flow... They just need a little help from non-instant flow changes and Linear Advance can take care of the rest.
The document states We suggest using values between 2-10. in https://help.prusa3d.com/article/pressure-equalizer-_331504
Instead, I recommend the following:
- Direct drive - 5-10X your maximum volumetric flow. So 0.2 to 0.1 seconds of smoothing between zero and max flow.
- Bowden - 2-4X your maximum volumetric flow. So 0.50 to 0.25 seconds of smoothing between zero and max flow.
For example, my main printer is direct drive, and hot end can handle 20mm^3/sec of flow. So I would use a slope between 100 and 200
Can someone update that doc page for me or show me where to do it?
cheers
EDIT: The maximum slope could use test prints and tuning procedures in the future. The pressure equalizer trades between axis acceleration and flow rate of change. If you choose a volumetric slope too low, you can end up exceeding the printer's axis acceleration limits, which introduces its own artifacts. Paradoxically, I found high slope values to be "safer" since Linear Advance will help even out abrupt flow changes. But there's nothing to compensate for rapid axis acceleration that comes with low slope values.
@MGunlogson, despite I, have closed your issue :D, I appreciate of your work with PR and descriptive documentation. @Godrak can you please check it?
This seems like an incredibly useful PR they solves many of the shortcomings of pressure equaliser. What are the chances this will be moderated into the next alpha?
PS. Im using this PR in a locally built version of alpha v3 and works great!
Thank you for this PR. Regarding the bugs and issues around dynamic overhang speed, especially those that cause violation of speed limits, we have fixed them into the next Alpha4 release, although a bit differently. The changes in pressure equaliser need further investigation.
Thank you for this PR. Regarding the bugs and issues around dynamic overhang speed, especially those that cause violation of speed limits, we have fixed them into the next Alpha4 release, although a bit differently. The changes in pressure equaliser need further investigation.
Alpha 4 still does not respect the volumetric slope limits on external perimeters when transitioning to a slower overhang speed I am afraid.
This issue will be fixed in Alpha5.
@MGunlogson can you try our progress on dynamic overhang speed in new PS 2.6.0-alpha5? Thanks
@MGunlogson can you try our progress on dynamic overhang speed in new PS 2.6.0-alpha5? Thanks
Sure, when I have some time, possibly next week. Sorry, lots going on for me this month
I've been pretty busy. I can re-base and test your fix for dynamic overhang speeds if there's still interest in my PR.
The changes in pressure equaliser need further investigation.
I'll be frank, does the Prusa team want my changes to pressure equalizer?
Currently, the equalizer tries to smooth flow between consecutive extrusion lines even if they're 200mm apart, separated by a long travel move and retraction. This doesn't make sense because extruder pressure obviously drops to zero during the move, and is arguably a bug in the current implementation.
Said a different way: The current implementation of pressure equalizer actually increases the number and slope of pressure/flow changes on parts with many travel moves because it doesn't account for extruder pressure dropping to zero during travel. The opposite of what it's meant to do.
If the team is interested in my pressure equalizer improvements I can re-base, test, and remove bug fixes no longer needed. Otherwise, I don't want to spend a bunch more time on it.
@Godrak @bubnikv @kubispe1
I've tested your fixes for dynamic overhangs and they work great so far!
I can rebase and split out my PR for pressure equalizer improvements, removing bug fixes that are no longer needed. If y'all are interested.
If you're not interested in my pressure equalizer improvements, lets close this PR.
Merged into PrusaSlicer 2.7.3-alpha1, thanks for the implementation. Closing.
Merged into PrusaSlicer 2.7.3-alpha1, thanks for the implementation. Closing.
Just something to be aware off: https://github.com/SoftFever/OrcaSlicer/pull/4264 The code in this PR (and possibly the original pressure equalizer implementation) has a bug where the rate start calculation 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.
In addition, a bug where pressure equalizer could cause a zero speed extrusion to be emitted was identified (https://github.com/SoftFever/OrcaSlicer/pull/4398) causing the print to stall.
@lukasmatena for your info - please take a look on the items above to make sure these bugs are not carried forward into the prusa code merge.
thank you!