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

Fan speed incorrect for first layer after filament change #7171

Closed
3 tasks done
psiberfunk opened this issue Oct 20, 2024 · 10 comments · Fixed by #7193 or #7215
Closed
3 tasks done

Fan speed incorrect for first layer after filament change #7171

psiberfunk opened this issue Oct 20, 2024 · 10 comments · Fixed by #7193 or #7215
Labels
bug Something isn't working

Comments

@psiberfunk
Copy link

psiberfunk commented Oct 20, 2024

Is there an existing issue for this problem?

  • I have searched the existing issues

OrcaSlicer Version

2.2.0

Operating System (OS)

macOS

OS Version

15.0.1

Additional system information

N/A , slicing issue, not crash/render issue.

Printer

Bambu X1C

How to reproduce

  1. Slice attached project.
  2. Inspect Layer 200, notice normal fan speed of 18%.
  3. Inspect layer 201 , with abnormal fan speed of 100%, which should be ~18-19%.

Actual results

Notice that layer 201 improperly has 100% fan speed, as inherited from the filament start GCODE sequence, but the normal "on layer change set fan speed" logic doesn't not appear to trigger, leaving the fan @ 100% for the whole layer, until the following layer. This results in very weak layer bonding in this PETG print (but problem also would apply to most non-PLA/TPU prints).
Screenshot 2024-10-20 at 11 23 23 AM

This is bad because it can result in prints looking like this, with an "easy break" layer inserted in by mistake, where the print will likely be extremely weak:
Screenshot 2024-10-20 at 11 43 12 AM

And here's the offending filament start GCODE that doesn't get clobbered (like it should) by a layer-change fan instruction:

Screenshot 2024-10-20 at 11 23 09 AM

Expected results

Fan speed should be normally set according to the filament cooling rules, not according to filament start code during a filament change. The proper result here would be a fan speed of ~18-19% based on subsequent layers.

Project file & Debug log uploads

FanSpeedLayerChangeIssue.3mf.zip

Checklist of files to include

  • Log file
  • Project file

Anything else?

Nasty bug that's hard to notice unless you happen to look at the fan speed preview!

@psiberfunk psiberfunk added the bug Something isn't working label Oct 20, 2024
@psiberfunk
Copy link
Author

psiberfunk commented Oct 21, 2024

Note: this test file was sliced originally in 2.2.0-beta2 , I just downloaded and verified that this is still a problem with 2.2.0-rc as well.

I also verified that this is pre-existing in the 2.1.1 release, so has apparently not been introduced/made worse by the 2.2.0 branch.

The model in this file is my own work, in case anyone cares.

@Noisyfox
Copy link
Collaborator

This is in fact caused by the difference in layer time, due to color change.

@psiberfunk
Copy link
Author

psiberfunk commented Oct 21, 2024

This is in fact caused by the difference in layer time, due to color change.

@Noisyfox, I think I disagree with you here.

From the simple perspective, it does not make any sense that you should get 100% fan here since the nominal layer time due to change of filament is LONGER , not shorter. Longer layer times result in less cooling... which is obviously not what's happening here.

From a precise tracing-the-code perspective:
The key is that there appears a couple bugs in setting the per-layer cooling in the GCODE so that the filament-change GCODE (useful during purging) is clobbering the intended layer-time based fan speed setting. To disambiguate, i've attached the exact GCODE i'm talking about here. This way we can go line-by-line to identify and agree on the issue. Let's play along with this file:

Fan_problem.gcode.zip

In the slice file, the slicer appears to try and set the fan speed for the layer to the min fan speed called for (10%) on line

159975: M106 S25

Note that this happens right before the toolchange sequence... so.. this then gets clobbered by the filament change routine here, on line:

160160: M106 P1 S255

, and never set back to the proper part fan speed by layer (which ought to be a "M106 S48", which comes before the next layer @ line 160948.

There are actually TWO bugs here:

  1. The layer time fan speed for the layer after the swap gets clobbered by the filament-change routine, which causes the fan to be 100% until the second layer after the change starts, at which point it resumes the proper speed.
  2. For the purposes of calculating the cooling fan speed: the layer time of the layer AFTER the filament swap is incorrectly calculated as including the filament swap time (whereas it should be the layer prior that includes it, since it will have more cooling).

Obligatory screenshot showing the longer layer time being mis-attributed to the layer following the filament swap:

image

@psiberfunk
Copy link
Author

P.S. i'm happy to discuss this interactively on discord if you wish.

@Noisyfox
Copy link
Collaborator

Yeah you're right. Will take a closer look.

@Noisyfox
Copy link
Collaborator

Noisyfox commented Oct 22, 2024

The issue is actually caused by the fan mover.
Fan mover does not work properly for printers that control multiple fans with Mxxx commands.
If you look at

fan_speed = get_fan_speed(line.raw(), m_writer.config.gcode_flavor);
if (fan_speed >= 0) {
const auto fan_baseline = 255.0;
fan_speed = 100 * fan_speed / fan_baseline;
//speed change: stop kickstart reverting if any
m_current_kickstart.time = -1;
if (!m_is_custom_gcode) {
// if slow down => put in the queue. if not =>
if (m_back_buffer_fan_speed < fan_speed) {
if (nb_seconds_delay > 0 && (!only_overhangs || current_role == ExtrusionRole::erOverhangPerimeter)) {
//don't put this command in the queue

you will notice that it does not care about which fan the current command is changing, and for gcode sequence like

M106 P2 S25
M106 S25

it will think the second command is the same as the first one, then the second one get removed:
image
(Left: the gcode before fan mover, Right: the gcode after fan mover)

@Noisyfox
Copy link
Collaborator

image
Fan speed is correct now after disabling fan mover
image

@psiberfunk
Copy link
Author

psiberfunk commented Oct 22, 2024

Well, that's an evil bug! Is it easy to fix for the mover so that kickstart/speedup can still be used?

Even without the mover, however, It's still setting the cooling for the wrong layer though.. the long layer time (and hence no need for lots of cooling) should be for the layer before the change, right ?

@Noisyfox
Copy link
Collaborator

Well, that's an evil bug! Is it easy to fix for the mover so that kickstart/speedup can still be used?

Even without the mover, however, It's still setting the cooling for the wrong layer though.. the long layer time (and hence no need for lots of cooling) should be for the layer before the change, right ?

The plan is to exclude the toolchange time at the beginning of each layer, which should work relatively well. Though the better option will be to add that time into previous layer, but that's not possible at current situation due to how each layer is processed individually.

@psiberfunk
Copy link
Author

psiberfunk commented Oct 23, 2024

Well, that's an evil bug! Is it easy to fix for the mover so that kickstart/speedup can still be used?
Even without the mover, however, It's still setting the cooling for the wrong layer though.. the long layer time (and hence no need for lots of cooling) should be for the layer before the change, right ?

The plan is to exclude the toolchange time at the beginning of each layer, which should work relatively well. Though the better option will be to add that time into previous layer, but that's not possible at current situation due to how each layer is processed individually.

Yeah, I recall being told about this kind of linear GCODE generation approach that doesn’t allow look back easily. It would have to be some kind of post-processing hack or something , and that feels like a nasty bit of tech debt to add here. I agree that just blowing away the filament swap time from the current layer estimate is “good enough”.

thanks for taking the time to address the issue .. I try to be as specific and detailed with my bug reports as possible in the hope that it will make them easier to understand and address.

Noisyfox added a commit to Noisyfox/OrcaSlicer that referenced this issue Oct 24, 2024
…when dealing with layer cooling (SoftFever#7171)

If layer starts with a color change, the full layer time will be much longer, which will trick the slicer to think this layer has enough cooling time.
However the actual filament extrusion time (the real "printing" part) won't necessarily have enough time to cool down, so if we don't do extra slowing down
before starting next layer, the filament could still be soft and lead to worse surface quality.
Noisyfox added a commit to Noisyfox/OrcaSlicer that referenced this issue Nov 2, 2024
SoftFever pushed a commit that referenced this issue Dec 24, 2024
* Fan mover: Ignore non-part cooling fans (#7171)

* Update comment
SoftFever added a commit that referenced this issue Dec 25, 2024
…7215)

Fixes #7171

If layer starts with a color change, the full layer time will be much longer, which will trick the slicer to think this layer has enough cooling time. However the actual filament extrusion time (the real "printing" part) won't necessarily have enough time to cool down, so if we don't do extra slowing down before starting next layer, the filament could still be soft and lead to worse surface quality.

Please refer to #7171 for extra discussions and details.

![image](https://github.com/user-attachments/assets/b31e9e04-12bb-450e-8b9c-a560549ec35d)
Before:
![image](https://github.com/user-attachments/assets/627f767a-6f48-4317-be50-14e78293ef0a)
After:
![image](https://github.com/user-attachments/assets/376c2b92-e417-4e27-9dcd-db7f6300fc56)


The test project is modified from #7171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants