Skip to content

Commit

Permalink
[FEATURE] Add filament max speed override
Browse files Browse the repository at this point in the history
  • Loading branch information
mjonuschat committed Dec 30, 2024
1 parent e8968e9 commit 7660c49
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3268,6 +3268,10 @@ double cap_speed(
if (filament_volumetric_cap > 0) {
speed = std::min(speed, filament_volumetric_cap / path_attr.mm3_per_mm);
}
const double filament_max_speed{config.filament_max_speed.get_at(extruder_id)};
if (filament_max_speed > 0) {
speed = std::min(speed, filament_max_speed);
}
if (path_attr.role == ExtrusionRole::InternalInfill) {
const double infill_cap{
path_attr.maybe_self_crossing ?
Expand Down
11 changes: 10 additions & 1 deletion src/libslic3r/GCode/WipeTower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ WipeTower::ToolChangeResult WipeTower::construct_tcr(WipeTowerWriter& writer,


WipeTower::WipeTower(const Vec2f& pos, double rotation_deg, const PrintConfig& config, const PrintRegionConfig& default_region_config, const std::vector<std::vector<float>>& wiping_matrix, size_t initial_tool) :
m_config(&config),
m_semm(config.single_extruder_multi_material.value),
m_wipe_tower_pos(pos),
m_wipe_tower_width(float(config.wipe_tower_width)),
Expand Down Expand Up @@ -644,6 +645,10 @@ void WipeTower::set_extruder(size_t idx, const PrintConfig& config)
float nozzle_diameter = float(config.nozzle_diameter.get_at(idx));
m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM

float max_speed = float(config.filament_max_speed.get_at(idx));
if (max_speed > 0.f)
m_filpar[idx].max_speed = max_speed;

float max_vol_speed = float(config.filament_max_volumetric_speed.get_at(idx));
if (max_vol_speed!= 0.f)
m_filpar[idx].max_e_speed = (max_vol_speed / filament_area());
Expand Down Expand Up @@ -1161,7 +1166,11 @@ void WipeTower::toolchange_Wipe(
float dy = (is_first_layer() ? m_extra_flow : m_extra_spacing_wipe) * m_perimeter_width; // Don't use the extra spacing for the first layer, but do use the spacing resulting from increased flow.
// All the calculations in all other places take the spacing into account for all the layers.

const float target_speed = is_first_layer() ? m_first_layer_speed * 60.f : m_infill_speed * 60.f;
float max_speed = std::numeric_limits<float>::max();
if (m_config->filament_max_speed.get_at(m_current_tool) > 0) {
max_speed = float(m_config->filament_max_speed.get_at(m_current_tool));
}
const float target_speed = std::min(max_speed, (is_first_layer() ? m_first_layer_speed * 60.f : m_infill_speed * 60.f));
float wipe_speed = 0.33f * target_speed;

// if there is less than 2.5*line_width to the edge, advance straightaway (there is likely a blob anyway)
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/GCode/WipeTower.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class WipeTower
float cooling_final_speed = 0.f;
float ramming_line_width_multiplicator = 1.f;
float ramming_step_multiplicator = 1.f;
float max_speed = std::numeric_limits<float>::max();
float max_e_speed = std::numeric_limits<float>::max();
std::vector<float> ramming_speed;
float nozzle_diameter;
Expand All @@ -275,6 +276,7 @@ class WipeTower
}


const PrintConfig* m_config;
bool m_semm = true; // Are we using a single extruder multimaterial printer?
bool m_is_mk4mmu3 = false;
bool m_switch_filament_monitoring = false;
Expand Down
4 changes: 3 additions & 1 deletion src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,9 @@ static std::vector<std::string> s_Preset_filament_options {
// Shrinkage compensation
"filament_shrinkage_compensation_xy", "filament_shrinkage_compensation_z",
// Seams overrides
"filament_seam_gap_distance"
"filament_seam_gap_distance",
// BOSS
"filament_max_speed",
};

static std::vector<std::string> s_Preset_machine_limits_options {
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ bool Print::invalidate_state_by_config_options(const ConfigOptionResolver & /* n
|| opt_key == "filament_multitool_ramming"
|| opt_key == "filament_multitool_ramming_volume"
|| opt_key == "filament_multitool_ramming_flow"
|| opt_key == "filament_max_speed"
|| opt_key == "filament_max_volumetric_speed"
|| opt_key == "filament_infill_max_speed"
|| opt_key == "filament_infill_max_crossing_speed"
Expand Down
10 changes: 10 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,16 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionStrings { "" });

def = this->add("filament_max_speed", coFloats);
def->label = L("Max speed");
def->tooltip = L("Maximum speed allowed for this filament. Limits the maximum "
"speed of a print to the minimum of the print speed and the filament speed. "
"Set zero for no limit.");
def->sidetext = L("mm/s");
def->min = 0;
def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloats{ 0. });

def = this->add("filament_max_volumetric_speed", coFloats);
def->label = L("Max volumetric speed");
def->tooltip = L("Maximum volumetric speed allowed for this filament. Limits the maximum volumetric "
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,8 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionFloat, small_area_infill_flow_compensation_compensation_factor_7))
((ConfigOptionFloat, small_area_infill_flow_compensation_compensation_factor_8))
((ConfigOptionFloat, small_area_infill_flow_compensation_compensation_factor_9))
// BOSS
((ConfigOptionFloats, filament_max_speed))
)

static inline std::string get_extrusion_axis(const GCodeConfig &cfg)
Expand Down
1 change: 1 addition & 0 deletions src/slic3r/GUI/Tab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2374,6 +2374,7 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_abrasive");

optgroup = page->new_optgroup(L("Print speed override"));
optgroup->append_single_option_line("filament_max_speed", "max-speed_127176");
optgroup->append_single_option_line("filament_max_volumetric_speed", "max-volumetric-speed_127176");

line = { "", "" };
Expand Down

0 comments on commit 7660c49

Please sign in to comment.