prusa3d / PrusaSlicer

G-code generator for 3D printers (RepRap, Makerbot, Ultimaker etc.)
https://www.prusa3d.com/prusaslicer/
GNU Affero General Public License v3.0
7.78k stars 1.94k forks source link

Auto cooling does not support fan before slow down #1032

Open zbrozek opened 6 years ago

zbrozek commented 6 years ago

Version

1.40.1 beta

Operating system type + version

Windows 10 build 17134

Behavior

Slic3r turns on the fan at the layer time at which it should start slowing down, not the time specified for turning on the fan. One might be tempted to think it's a text generation problem in the summary, but it accurately describes the resulting gcode.

Is this a new feature request? No image

zbrozek commented 6 years ago

The bug appears to be in CoolingBuffer.cpp, in the if-block at line 623. The check is against slowing down, but the action is on fan.

if (EXTRUDER_CONFIG(cooling)) {
    if (layer_time < slowdown_below_layer_time) {
        // Layer time very short. Enable the fan to a full throttle.
        fan_speed_new = max_fan_speed;
    } else if (layer_time < fan_below_layer_time) {
        // Layer time quite short. Enable the fan proportionally according to the current layer time.
        assert(layer_time >= slowdown_below_layer_time);
        double t = (layer_time - slowdown_below_layer_time) / (fan_below_layer_time - slowdown_below_layer_time);
        fan_speed_new = int(floor(t * min_fan_speed + (1. - t) * max_fan_speed) + 0.5);
    }
}
bubnikv commented 6 years ago

The cooling logic does not expect you to set the "fan on" layer time lower than the "slow down" layer time. We either need to integrate a check for the "fan on time" >= "slow down time", or to modify the cooling logic.

zbrozek commented 6 years ago

I would imagine the correct thing to do would be to do the speed check first, slow down if necessary, then do the fan check. The checks needn't reference each other.