Skip to content

Commit

Permalink
Rework of fan speed control by extrusion type
Browse files Browse the repository at this point in the history
 . now easier to add new control and do complicate stuff in the cooling buffer.
 . less overall number of lines of code for better results.
 . add 6 new fan control.
 . now if the disable_fan_first_layers is at 0 and full_fan_speed_layer at more than 1, the first layer has some fan speed.
 . updated fan speeds that cannot be increased even with low layer time (top solid, ironing, support, support interface)
 . updated fan speeds that cannot be reduced by full_fan_speed_layer (bridge, infill bridge, overhangs, support interface)
 . updated extrusion speed that can't be reduced (overhang, bridge)
 . updated extrusion speed that shouldn't be reduced if possible (external, ironing, infill bridge, thin wall, support interface)
 . better name for CoolingBuffer::process_layer variables

#3735
#3608
#3568
#3415
#3408
#3380
#3367
#3361
#3271
#3152
#2872
#2696
#2419
#2326
  • Loading branch information
supermerill committed Nov 14, 2023
1 parent b3a2b6b commit 67b62c2
Show file tree
Hide file tree
Showing 12 changed files with 427 additions and 294 deletions.
30 changes: 21 additions & 9 deletions resources/ui_layout/default/filament.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ group:Temperature °C
group:Filament properties
setting:width$7:filament_type
setting:filament_soluble
setting:filament_shrink
setting:filament_shrink
setting:filament_max_overlap
group:Print speed override
setting:filament_max_speed
Expand All @@ -30,18 +30,30 @@ group:Print speed override
page:Cooling:time
group:Fan speed - default
setting:label$Run the fan at default speed when possible:fan_always_on
line:Disable fan for the first
setting:width$5:label$_:sidetext_width$7:disable_fan_first_layers
setting:width$5:label_width$12:full_fan_speed_layer
end_line
setting:min_fan_speed
line:Perimeter fan speed
setting:label$:perimeter_fan_speed
setting:label_width$12:label$External:external_perimeter_fan_speed
end_line
setting:overhang_perimeter_fan_speed
setting:infill_fan_speed
line:Solid Infill fan speed
setting:label$:solid_infill_fan_speed
setting:label_width$12:label$Top:top_fan_speed
end_line
line:Support Material fan speed
setting:label$:support_material_fan_speed
setting:label_width$12:label$Support Interface:support_material_interface_fan_speed
end_line
line:Bridges fan speed
setting:label$:bridge_fan_speed
setting:label$Infill bridges:bridge_internal_fan_speed
end_line
setting:top_fan_speed
setting:external_perimeter_fan_speed
setting:support_material_interface_fan_speed
line:Disable fan for the first
setting:label$_:sidetext_width$12:disable_fan_first_layers
setting:full_fan_speed_layer
setting:label_width$12:label$Infill bridges:bridge_internal_fan_speed
end_line
setting:gap_fill_fan_speed
group:Short layer time - began to increase base fan speed
setting:fan_below_layer_time
setting:label$Max fan speed:max_fan_speed
Expand Down
30 changes: 21 additions & 9 deletions resources/ui_layout/example/filament.ui
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ group:Temperature °C
group:Filament properties
setting:width$7:filament_type
setting:filament_soluble
setting:filament_shrink
setting:filament_shrink
setting:filament_max_overlap
group:Print speed override
setting:filament_max_speed
Expand All @@ -30,18 +30,30 @@ group:Print speed override
page:Cooling:time
group:Fan speed - default
setting:label$Run the fan at default speed when possible:fan_always_on
line:Disable fan for the first
setting:width$5:label$_:sidetext_width$7:disable_fan_first_layers
setting:width$5:label_width$12:full_fan_speed_layer
end_line
setting:min_fan_speed
line:Perimeter fan speed
setting:label$:perimeter_fan_speed
setting:label_width$12:label$External:external_perimeter_fan_speed
end_line
setting:overhang_perimeter_fan_speed
setting:infill_fan_speed
line:Solid Infill fan speed
setting:label$:solid_infill_fan_speed
setting:label_width$12:label$Top:top_fan_speed
end_line
line:Support Material fan speed
setting:label$:support_material_fan_speed
setting:label_width$12:label$Support Interface:support_material_interface_fan_speed
end_line
line:Bridges fan speed
setting:label$:bridge_fan_speed
setting:label$Infill bridges:bridge_internal_fan_speed
end_line
setting:top_fan_speed
setting:external_perimeter_fan_speed
setting:support_material_interface_fan_speed
line:Disable fan for the first
setting:label$_:sidetext_width$12:disable_fan_first_layers
setting:full_fan_speed_layer
setting:label_width$12:label$Infill bridges:bridge_internal_fan_speed
end_line
setting:gap_fill_fan_speed
group:Short layer time - began to increase base fan speed
setting:fan_below_layer_time
setting:label$Max fan speed:max_fan_speed
Expand Down
2 changes: 1 addition & 1 deletion src/libslic3r/ExtrusionEntity.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ enum ExtrusionRole : uint16_t {
};
*/
enum ExtrusionRole : uint8_t {
erNone,
erNone, // erNone needs to be 0 (for cooling and everything that use the role as index)
erPerimeter,
erExternalPerimeter,
erOverhangPerimeter,
Expand Down
63 changes: 38 additions & 25 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5386,8 +5386,38 @@ double_t GCode::_compute_speed_mm_per_sec(const ExtrusionPath& path, double spee
return speed;
}


void GCode::cooldown_marker_init() {
if (!_cooldown_marker_speed[ExtrusionRole::erExternalPerimeter].empty()) {
std::string allow_speed_change = ";CM_extrude_speed;_EXTRUDE_SET_SPEED";
//only change speed on external perimeter (and similar) speed if really necessary.
std::string maybe_allow_speed_change = ";CM_extrude_speed_external;_EXTRUDE_SET_SPEED_MAYBE";
_cooldown_marker_speed[erNone] = "";
_cooldown_marker_speed[erPerimeter] = allow_speed_change;
_cooldown_marker_speed[erExternalPerimeter] = maybe_allow_speed_change;
_cooldown_marker_speed[erOverhangPerimeter] = "";
_cooldown_marker_speed[erInternalInfill] = allow_speed_change;
_cooldown_marker_speed[erSolidInfill] = allow_speed_change;
_cooldown_marker_speed[erTopSolidInfill] = allow_speed_change;
_cooldown_marker_speed[erIroning] = maybe_allow_speed_change;
_cooldown_marker_speed[erBridgeInfill] = "";
_cooldown_marker_speed[erInternalBridgeInfill] = maybe_allow_speed_change;
_cooldown_marker_speed[erThinWall] = maybe_allow_speed_change;
_cooldown_marker_speed[erGapFill] = allow_speed_change;
_cooldown_marker_speed[erSkirt] = allow_speed_change;
_cooldown_marker_speed[erSupportMaterial] = allow_speed_change;
_cooldown_marker_speed[erSupportMaterialInterface] = maybe_allow_speed_change;
_cooldown_marker_speed[erWipeTower] = allow_speed_change;
_cooldown_marker_speed[erMilling] = "";
_cooldown_marker_speed[erCustom] = maybe_allow_speed_change;
_cooldown_marker_speed[erMixed] = maybe_allow_speed_change;
}
}


std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string &description_in, double speed) {
std::string gcode;
gcode.reserve(512);
std::string description{ description_in };


Expand Down Expand Up @@ -5730,20 +5760,10 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string

std::string comment;
if (m_enable_cooling_markers) {
if(path.role() == erInternalBridgeInfill)
gcode += ";_BRIDGE_INTERNAL_FAN_START\n";
else if (is_bridge(path.role()))
gcode += ";_BRIDGE_FAN_START\n";
else if (ExtrusionRole::erTopSolidInfill == path.role())
gcode += ";_TOP_FAN_START\n";
else if (ExtrusionRole::erSupportMaterialInterface == path.role())
gcode += ";_SUPP_INTER_FAN_START\n";
else
comment = ";_EXTRUDE_SET_SPEED";
if (path.role() == erExternalPerimeter)
comment += ";_EXTERNAL_PERIMETER";
if (path.role() == erThinWall)
comment += ";_EXTERNAL_PERIMETER";
// Send the current extrusion type to Coolingbuffer
gcode += ";_EXTRUDETYPE_"; gcode += char('A' + path.role()); gcode += "\n";
// comment to be on the same line as the speed command.
comment = GCode::_cooldown_marker_speed[path.role()];
}
// F is mm per minute.
// speed is mm per second
Expand All @@ -5753,17 +5773,10 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
}
std::string GCode::_after_extrude(const ExtrusionPath &path) {
std::string gcode;
if (m_enable_cooling_markers)
if (path.role() == erInternalBridgeInfill)
gcode += ";_BRIDGE_INTERNAL_FAN_END\n";
else if (is_bridge(path.role()))
gcode += ";_BRIDGE_FAN_END\n";
else if (ExtrusionRole::erTopSolidInfill == path.role())
gcode += ";_TOP_FAN_END\n";
else if (ExtrusionRole::erSupportMaterialInterface == path.role())
gcode += ";_SUPP_INTER_FAN_END\n";
else
gcode += ";_EXTRUDE_END\n";
if (m_enable_cooling_markers) {
// Notify Coolingbuffer that the current extrusion end.
gcode += ";_EXTRUDE_END\n";
}

if (path.role() != ExtrusionRole::erGapFill ) {
m_last_notgapfill_extrusion_role = path.role();
Expand Down
9 changes: 8 additions & 1 deletion src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ class GCode : ExtrusionVisitorConst {
m_silent_time_estimator_enabled(false),
m_last_obj_copy(nullptr, Point(std::numeric_limits<coord_t>::max(), std::numeric_limits<coord_t>::max())),
m_last_too_small(ExtrusionRole::erNone)
{}
{
cooldown_marker_init();
}
~GCode() = default;

// throws std::runtime_exception on error,
Expand Down Expand Up @@ -527,6 +529,11 @@ class GCode : ExtrusionVisitorConst {
friend class Wipe;
friend class WipeTowerIntegration;
friend class PressureEqualizer;

//utility for cooling markers
static inline std::string _cooldown_marker_speed[ExtrusionRole::erCount];
bool cooldwon_marker_no_slowdown_section = false;;
static void cooldown_marker_init();
};

std::vector<const PrintInstance*> sort_object_instances_by_model_order(const Print& print);
Expand Down
Loading

0 comments on commit 67b62c2

Please sign in to comment.