NEW:reducing purge through retracting filament

1.reducing purge through retracting filament.Currently only
applicable to X&P series

github: PR#3100

Signed-off-by: XunZhangBambu <xun.zhang@bambulab.com>
Change-Id: Ie328039872e50e699dc5e5082fa99f68ac5f5fd1
This commit is contained in:
Leon Fisher-Skipper 2024-03-21 12:16:38 +08:00 committed by Lane.Wei
parent 74f60c47ef
commit 0cd8e00df3
16 changed files with 102 additions and 8 deletions

View File

@ -1,7 +1,7 @@
{
"name": "Bambulab",
"url": "http://www.bambulab.com/Parameters/vendor/BBL.json",
"version": "01.09.00.01",
"version": "01.09.00.02",
"force_update": "0",
"description": "the initial version of BBL configurations",
"machine_model_list": [

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -2648,6 +2648,10 @@ int CLI::run(int argc, char **argv)
m_print_config.option<ConfigOptionFloat>("flush_multiplier", true)->set(new ConfigOptionFloat(1.f));
ConfigOption* extra_flush_volume_opt = m_print_config.option("nozzle_volume");
int extra_flush_volume = extra_flush_volume_opt ? (int)extra_flush_volume_opt->getFloat() : 0;
bool activate = m_print_config.option<ConfigOptionBool>("enable_long_retraction_when_cut")->value && m_print_config.option<ConfigOptionBool>("long_retraction_when_cut")->value;
float extra_retract_length = activate && m_print_config.option<ConfigOptionBool>("long_retraction_when_cut")->value ? m_print_config.option<ConfigOptionFloat>("retraction_distance_when_cut")->value : 0;
float extra_retract_volume = PI * 1.75 * 1.75 / 4 * extra_retract_length;
extra_flush_volume = (int)std::max(0.f, extra_flush_volume - extra_retract_volume);
if (filament_is_support->size() != project_filament_count)
{

View File

@ -88,7 +88,11 @@ int FlushVolCalculator::calc_flush_vol(unsigned char src_a, unsigned char src_r,
float hs_flush = 230.f * hs_dist;
float flush_volume = calc_triangle_3rd_edge(hs_flush, lumi_flush, 120.f);
flush_volume = std::max(flush_volume, 60.f);
constexpr int standard_nozzle_volume = 107;
auto formula = [](float rate) {
return 1.13 / (1 + 5.24*exp(-4 * rate)) - 0.031;
};
flush_volume = std::max(flush_volume, 60.f) *formula(float( m_min_flush_vol) / standard_nozzle_volume);
//float flush_multiplier = std::atof(m_flush_multiplier_ebox->GetValue().c_str());
flush_volume += m_min_flush_vol;

View File

@ -1262,6 +1262,8 @@ void GCode::do_export(Print* print, const char* path, GCodeProcessorResult* resu
m_processor.result().timelapse_warning_code = m_timelapse_warning_code;
m_processor.result().support_traditional_timelapse = m_support_traditional_timelapse;
m_processor.result().long_retraction_when_cut = m_config.long_retraction_when_cut;
{ //BBS:check bed and filament compatible
const ConfigOptionDef *bed_type_def = print_config_def.get("curr_bed_type");
assert(bed_type_def != nullptr);

View File

@ -841,6 +841,7 @@ void GCodeProcessorResult::reset() {
toolpath_outside = false;
//BBS: add label_object_enabled
label_object_enabled = false;
long_retraction_when_cut = false;
timelapse_warning_code = 0;
printable_height = 0.0f;
settings_ids.reset();
@ -4445,6 +4446,14 @@ void GCodeProcessor::update_slice_warnings()
}
}
warning.params.clear();
warning.level = 1;
if (m_result.long_retraction_when_cut) {
warning.msg = LONG_RETRACTION_WHEN_CUT;
warning.error_code = "1001C004";
m_result.warnings.push_back(warning);
}
m_result.warnings.shrink_to_fit();
}

View File

@ -22,6 +22,7 @@ namespace Slic3r {
#define BED_TEMP_TOO_HIGH_THAN_FILAMENT "bed_temperature_too_high_than_filament"
#define NOT_SUPPORT_TRADITIONAL_TIMELAPSE "not_support_traditional_timelapse"
#define NOT_GENERATE_TIMELAPSE "not_generate_timelapse"
#define LONG_RETRACTION_WHEN_CUT "activate_long_retration_when_cut"
enum class EMoveType : unsigned char
{
@ -195,6 +196,8 @@ namespace Slic3r {
bool toolpath_outside;
//BBS: add object_label_enabled
bool label_object_enabled;
//BBS : extra retraction when change filament,experiment func
bool long_retraction_when_cut {0};
int timelapse_warning_code {0};
bool support_traditional_timelapse{true};
float printable_height;
@ -230,6 +233,7 @@ namespace Slic3r {
bed_exclude_area = other.bed_exclude_area;
toolpath_outside = other.toolpath_outside;
label_object_enabled = other.label_object_enabled;
long_retraction_when_cut = other.long_retraction_when_cut;
timelapse_warning_code = other.timelapse_warning_code;
printable_height = other.printable_height;
settings_ids = other.settings_ids;

View File

@ -899,7 +899,8 @@ static std::vector<std::string> s_Preset_printer_options {
"print_host_webui",
"printhost_cafile","printhost_port","printhost_authorization_type",
"printhost_user", "printhost_password", "printhost_ssl_ignore_revoke",
"use_relative_e_distances", "extruder_type","use_firmware_retraction"
"use_relative_e_distances", "extruder_type","use_firmware_retraction",
"long_retraction_when_cut","retraction_distance_when_cut","enable_long_retraction_when_cut"
};
static std::vector<std::string> s_Preset_sla_print_options {

View File

@ -2689,6 +2689,26 @@ void PrintConfigDef::init_fff_params()
def->mode = comSimple;
def->set_default_value(new ConfigOptionFloats { 0.8 });
def = this->add("enable_long_retraction_when_cut",coBool);
def->mode = comDevelop;
def->set_default_value(new ConfigOptionBool {false});
def = this->add("long_retraction_when_cut", coBool);
def->label = L("Long retraction when cut(experimental)");
def->tooltip = L("Experimental feature.Retracting and cutting off the filament at a longer distance during changes to minimize purge."
"While this reduces flush significantly, it may also raise the risk of nozzle clogs or other printing problems.");
def->mode = comDevelop;
def->set_default_value(new ConfigOptionBool {false});
def = this->add("retraction_distance_when_cut",coFloat);
def->label = L("Retraction distance when cut");
def->tooltip = L("Experimental feature.Retraction length before cutting off during filament change");
def->mode = comDevelop;
def->min = 10;
def->max = 20;
def->set_default_value(new ConfigOptionFloat {20});
def = this->add("retract_length_toolchange", coFloats);
def->label = L("Length");
//def->full_label = L("Retraction Length (Toolchange)");

View File

@ -915,6 +915,9 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionPercents, retract_before_wipe))
((ConfigOptionFloats, retraction_length))
((ConfigOptionFloats, retract_length_toolchange))
((ConfigOptionBool, enable_long_retraction_when_cut))
((ConfigOptionBool, long_retraction_when_cut))
((ConfigOptionFloat, retraction_distance_when_cut))
((ConfigOptionFloats, z_hop))
// BBS
((ConfigOptionEnumsGeneric, z_hop_types))

View File

@ -783,6 +783,10 @@ Sidebar::Sidebar(Plater *parent)
const std::vector<double>& init_extruders = (project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values;
ConfigOption* extra_flush_volume_opt = printer_config.option("nozzle_volume");
int extra_flush_volume = extra_flush_volume_opt ? (int)extra_flush_volume_opt->getFloat() : 0;
bool activate = printer_config.option<ConfigOptionBool>("enable_long_retraction_when_cut")->value && printer_config.option<ConfigOptionBool>("long_retraction_when_cut")->value;
float extra_retract_length = activate && printer_config.option<ConfigOptionBool>("long_retraction_when_cut")->value ? printer_config.option<ConfigOptionFloat>("retraction_distance_when_cut")->value : 0;
float extra_retract_volume = PI * 1.75 * 1.75 / 4 * extra_retract_length;
extra_flush_volume = (int)std::max(0.f, extra_flush_volume - extra_retract_volume);
ConfigOptionFloat* flush_multi_opt = project_config.option<ConfigOptionFloat>("flush_multiplier");
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
@ -1935,6 +1939,11 @@ void Sidebar::auto_calc_flushing_volumes(const int modify_id)
const std::vector<double>& init_extruders = (project_config.option<ConfigOptionFloats>("flush_volumes_vector"))->values;
ConfigOption* extra_flush_volume_opt = printer_config.option("nozzle_volume");
int extra_flush_volume = extra_flush_volume_opt ? (int)extra_flush_volume_opt->getFloat() : 0;
bool activate = printer_config.option<ConfigOptionBool>("enable_long_retraction_when_cut")->value && printer_config.option<ConfigOptionBool>("long_retraction_when_cut")->value;
float extra_retract_length = activate && printer_config.option<ConfigOptionBool>("long_retraction_when_cut")->value ? printer_config.option<ConfigOptionFloat>("retraction_distance_when_cut")->value : 0;
float extra_retract_volume = PI * 1.75 * 1.75 / 4 * extra_retract_length;
extra_flush_volume = (int)std::max(0.f, extra_flush_volume - extra_retract_volume);
ConfigOptionFloat* flush_multi_opt = project_config.option<ConfigOptionFloat>("flush_multiplier");
float flush_multiplier = flush_multi_opt ? flush_multi_opt->getFloat() : 1.f;
std::vector<double> matrix = init_matrix;
@ -6303,6 +6312,12 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
view3D->deselect_all();
}
// update flush matrix
auto& project_config = wxGetApp().preset_bundle->project_config;
const std::vector<double>& init_matrix = (project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values;
for (size_t idx = 0; idx < init_matrix.size(); ++idx)
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
}
#ifdef __WXMSW__

View File

@ -1537,6 +1537,27 @@ void Tab::on_value_change(const std::string& opt_key, const boost::any& value)
}
}
auto update_flush_volume = []() {
auto& project_config = wxGetApp().preset_bundle->project_config;
const std::vector<double>& init_matrix = (project_config.option<ConfigOptionFloats>("flush_volumes_matrix"))->values;
for (size_t idx = 0; idx < init_matrix.size(); ++idx)
wxGetApp().plater()->sidebar().auto_calc_flushing_volumes(idx);
};
if(opt_key == "long_retraction_when_cut"){
bool activate = boost::any_cast<bool>(value);
if (activate) {
MessageDialog dialog(wxGetApp().plater(),
"Experimental feature: Retracting and cutting off the filament at a greater distance during filament changes to minimize flush."
"Although it can notably reduce flush, it may also elevate the risk of nozzle clogs or other printing complications.", "", wxICON_WARNING | wxOK);
dialog.ShowModal();
}
update_flush_volume();
}
if (opt_key == "retraction_distance_when_cut") {
update_flush_volume();
}
// BBS
#if 0
if (opt_key == "extruders_count")
@ -3885,6 +3906,8 @@ void TabPrinter::build_unregular_pages(bool from_initial_build/* = false*/)
optgroup = page->new_optgroup(L("Retraction when switching material"), L"param_retraction", -1, true);
optgroup->append_single_option_line("retract_length_toolchange", "", extruder_idx);
optgroup->append_single_option_line("retract_restart_extra_toolchange", "", extruder_idx);
optgroup->append_single_option_line("long_retraction_when_cut", "");
optgroup->append_single_option_line("retraction_distance_when_cut", "");
#if 0
//optgroup = page->new_optgroup(L("Preview"), -1, true);
@ -4123,6 +4146,10 @@ void TabPrinter::toggle_options()
bool toolchange_retraction = m_config->opt_float("retract_length_toolchange", i) > 0;
toggle_option("retract_restart_extra_toolchange", have_multiple_extruders && toolchange_retraction, i);
toggle_option("long_retraction_when_cut", !use_firmware_retraction && m_config->opt_bool("enable_long_retraction_when_cut"));
toggle_line("retraction_distance_when_cut", m_config->opt_bool("long_retraction_when_cut"));
}
if (m_active_page->title() == "Motion ability") {