ENH: set cooling/heating rate as extruder param

jira:NONE

Signed-off-by: xun.zhang <xun.zhang@bambulab.com>
Change-Id: Ia5eb6ba5bea0351ebcc3867644a518fb5560e500
This commit is contained in:
xun.zhang 2025-03-12 16:06:54 +08:00 committed by lane.wei
parent f6a46d9b95
commit ccf58b3fc6
7 changed files with 60 additions and 32 deletions

View File

@ -27,7 +27,12 @@
"0x0,325x0,325x320,0x320", "0x0,325x0,325x320,0x320",
"25x0,350x0,350x320,25x320" "25x0,350x0,350x320,25x320"
], ],
"hotend_heating_rate": "3.6", "hotend_heating_rate": [
"3.6",
"3.6",
"3.6",
"3.6"
],
"machine_load_filament_time": "24", "machine_load_filament_time": "24",
"machine_max_acceleration_x": [ "machine_max_acceleration_x": [
"16000", "16000",

View File

@ -66,6 +66,18 @@
"0" "0"
], ],
"head_wrap_detect_zone": [], "head_wrap_detect_zone": [],
"hotend_cooling_rate": [
"2",
"2",
"2",
"2"
],
"hotend_heating_rate": [
"2",
"2",
"2",
"2"
],
"long_retractions_when_cut": [ "long_retractions_when_cut": [
"0", "0",
"0", "0",

View File

@ -24,8 +24,12 @@
"enable_long_retraction_when_cut" : "0", "enable_long_retraction_when_cut" : "0",
"enable_pre_heating": "0", "enable_pre_heating": "0",
"bed_temperature_formula" : "by_first_filament", "bed_temperature_formula" : "by_first_filament",
"hotend_cooling_rate": "2", "hotend_cooling_rate": [
"hotend_heating_rate": "2", "2"
],
"hotend_heating_rate": [
"2"
],
"extruder_offset": [ "extruder_offset": [
"0x0" "0x0"
], ],

View File

@ -1668,8 +1668,8 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
for (size_t idx = 0; idx < filament_count; ++idx) for (size_t idx = 0; idx < filament_count; ++idx)
m_filament_types[idx] = config.filament_type.get_at(idx); m_filament_types[idx] = config.filament_type.get_at(idx);
m_hotend_cooling_rate = config.hotend_cooling_rate.value; m_hotend_cooling_rate = config.hotend_cooling_rate.values;
m_hotend_heating_rate = config.hotend_heating_rate.value; m_hotend_heating_rate = config.hotend_heating_rate.values;
m_enable_pre_heating = config.enable_pre_heating; m_enable_pre_heating = config.enable_pre_heating;
m_physical_extruder_map = config.physical_extruder_map.values; m_physical_extruder_map = config.physical_extruder_map.values;
@ -1775,14 +1775,14 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
m_filament_types[idx] = filament_type->get_at(idx); m_filament_types[idx] = filament_type->get_at(idx);
} }
const ConfigOptionFloat* hotend_cooling_rate = config.option<ConfigOptionFloat>("hotend_cooling_rate"); const ConfigOptionFloatsNullable* hotend_cooling_rate = config.option<ConfigOptionFloatsNullable>("hotend_cooling_rate");
if (hotend_cooling_rate != nullptr) { if (hotend_cooling_rate != nullptr) {
m_hotend_cooling_rate = hotend_cooling_rate->value; m_hotend_cooling_rate = hotend_cooling_rate->values;
} }
const ConfigOptionFloat* hotend_heating_rate = config.option<ConfigOptionFloat>("hotend_heating_rate"); const ConfigOptionFloatsNullable* hotend_heating_rate = config.option<ConfigOptionFloatsNullable>("hotend_heating_rate");
if (hotend_heating_rate != nullptr) { if (hotend_heating_rate != nullptr) {
m_hotend_heating_rate = hotend_heating_rate->value; m_hotend_heating_rate = hotend_heating_rate->values;
} }
const ConfigOptionBool* enable_pre_heating = config.option<ConfigOptionBool>("enable_pre_heating"); const ConfigOptionBool* enable_pre_heating = config.option<ConfigOptionBool>("enable_pre_heating");
@ -2145,7 +2145,7 @@ void GCodeProcessor::reset()
m_physical_extruder_map.clear(); m_physical_extruder_map.clear();
m_filament_nozzle_temp.clear(); m_filament_nozzle_temp.clear();
m_enable_pre_heating = false; m_enable_pre_heating = false;
m_hotend_cooling_rate = m_hotend_heating_rate = 2.f; m_hotend_cooling_rate = m_hotend_heating_rate = { 2.f };
m_highest_bed_temp = 0; m_highest_bed_temp = 0;
@ -5969,9 +5969,12 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
if (!apply_cooling_when_partial_free && complete_free_time_gap < inject_time_threshold) if (!apply_cooling_when_partial_free && complete_free_time_gap < inject_time_threshold)
return; return;
float ext_heating_rate = heating_rate[block.extruder_id];
float ext_cooling_rate = cooling_rate[block.extruder_id];
if (is_tpu_filament(block.last_filament_id) && pre_cooling) { if (is_tpu_filament(block.last_filament_id) && pre_cooling) {
if (partial_free_move_lower < partial_free_move_upper) { if (partial_free_move_lower < partial_free_move_upper) {
float max_cooling_temp = std::min(curr_temp, std::min(partial_free_cooling_thres, partial_free_time_gap * cooling_rate)); float max_cooling_temp = std::min(curr_temp, std::min(partial_free_cooling_thres, partial_free_time_gap * ext_cooling_rate));
curr_temp -= max_cooling_temp; // set the temperature after doing cooling when post-extruding curr_temp -= max_cooling_temp; // set the temperature after doing cooling when post-extruding
inserted_operation_lines[partial_free_move_lower->gcode_id].emplace_back(format_line_M104(curr_temp, block.extruder_id, "Multi extruder pre cooling in post extrusion"), TimeProcessor::InsertLineType::PreCooling); inserted_operation_lines[partial_free_move_lower->gcode_id].emplace_back(format_line_M104(curr_temp, block.extruder_id, "Multi extruder pre cooling in post extrusion"), TimeProcessor::InsertLineType::PreCooling);
} }
@ -5988,7 +5991,7 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
// only perform heating // only perform heating
if (target_temp <= curr_temp) if (target_temp <= curr_temp)
return; return;
float heating_start_time = move_iter_upper->time[valid_machine_id] - (target_temp - curr_temp) / heating_rate; float heating_start_time = move_iter_upper->time[valid_machine_id] - (target_temp - curr_temp) / ext_heating_rate;
auto heating_move_iter = std::upper_bound(move_iter_lower, move_iter_upper + 1, heating_start_time, [valid_machine_id = this->valid_machine_id](float time, const GCodeProcessorResult::MoveVertex& a) {return time < a.time[valid_machine_id]; }); auto heating_move_iter = std::upper_bound(move_iter_lower, move_iter_upper + 1, heating_start_time, [valid_machine_id = this->valid_machine_id](float time, const GCodeProcessorResult::MoveVertex& a) {return time < a.time[valid_machine_id]; });
if (heating_move_iter == move_iter_upper + 1 || heating_move_iter == move_iter_lower) { if (heating_move_iter == move_iter_upper + 1 || heating_move_iter == move_iter_lower) {
inserted_operation_lines[block.free_lower_gcode_id].emplace_back(format_line_M104(target_temp, block.extruder_id, "Multi extruder pre heating"), TimeProcessor::InsertLineType::PreHeating); inserted_operation_lines[block.free_lower_gcode_id].emplace_back(format_line_M104(target_temp, block.extruder_id, "Multi extruder pre heating"), TimeProcessor::InsertLineType::PreHeating);
@ -6000,9 +6003,9 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
return; return;
} }
// perform cooling first and then perform heating // perform cooling first and then perform heating
float mid_temp = std::max(0.f, (curr_temp * heating_rate + target_temp * cooling_rate - complete_free_time_gap * cooling_rate * heating_rate) / (cooling_rate + heating_rate)); float mid_temp = std::max(0.f, (curr_temp * ext_heating_rate + target_temp * ext_cooling_rate - complete_free_time_gap * ext_cooling_rate * ext_heating_rate) / (ext_cooling_rate + ext_heating_rate));
float heating_temp = target_temp - mid_temp; float heating_temp = target_temp - mid_temp;
float heating_start_time = move_iter_upper->time[valid_machine_id] - heating_temp / heating_rate; float heating_start_time = move_iter_upper->time[valid_machine_id] - heating_temp / ext_heating_rate;
auto heating_move_iter = std::upper_bound(move_iter_lower, move_iter_upper + 1, heating_start_time, [valid_machine_id = this->valid_machine_id](float time, const GCodeProcessorResult::MoveVertex& a) {return time < a.time[valid_machine_id]; }); auto heating_move_iter = std::upper_bound(move_iter_lower, move_iter_upper + 1, heating_start_time, [valid_machine_id = this->valid_machine_id](float time, const GCodeProcessorResult::MoveVertex& a) {return time < a.time[valid_machine_id]; });
if (heating_move_iter == move_iter_lower || heating_move_iter == move_iter_upper + 1) if (heating_move_iter == move_iter_lower || heating_move_iter == move_iter_upper + 1)
return; return;
@ -6010,7 +6013,7 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
--heating_move_iter; --heating_move_iter;
// get the insert pos of heat cmd and recalculate time gap and delta temp // get the insert pos of heat cmd and recalculate time gap and delta temp
float real_cooling_time = heating_move_iter->time[valid_machine_id] - move_iter_lower->time[valid_machine_id]; float real_cooling_time = heating_move_iter->time[valid_machine_id] - move_iter_lower->time[valid_machine_id];
int real_delta_temp = std::min((int)(real_cooling_time * cooling_rate), (int)curr_temp); int real_delta_temp = std::min((int)(real_cooling_time * ext_cooling_rate), (int)curr_temp);
if (real_delta_temp == 0) if (real_delta_temp == 0)
return; return;
inserted_operation_lines[block.free_lower_gcode_id].emplace_back(format_line_M104(curr_temp - real_delta_temp, block.extruder_id, "Multi extruder pre cooling"), TimeProcessor::InsertLineType::PreCooling); inserted_operation_lines[block.free_lower_gcode_id].emplace_back(format_line_M104(curr_temp - real_delta_temp, block.extruder_id, "Multi extruder pre cooling"), TimeProcessor::InsertLineType::PreCooling);

View File

@ -691,8 +691,8 @@ namespace Slic3r {
std::vector<int> physical_extruder_map; std::vector<int> physical_extruder_map;
size_t total_layer_num; size_t total_layer_num;
float cooling_rate{ 2.f }; // Celsius degree per second std::vector<double> cooling_rate{ 2.f }; // Celsius degree per second
float heating_rate{ 2.f }; // Celsius degree per second std::vector<double> heating_rate{ 2.f }; // Celsius degree per second
float inject_time_threshold{ 30.f }; // only active pre cooling & heating if time gap is bigger than threshold float inject_time_threshold{ 30.f }; // only active pre cooling & heating if time gap is bigger than threshold
float post_extrusion_cooling_threshold{ 30.f }; // threshold of temp if do cooling in post extrusion float post_extrusion_cooling_threshold{ 30.f }; // threshold of temp if do cooling in post extrusion
bool enable_pre_heating{ false }; bool enable_pre_heating{ false };
@ -705,8 +705,8 @@ namespace Slic3r {
const std::vector<int>& filament_nozzle_temp_, const std::vector<int>& filament_nozzle_temp_,
const std::vector<int>& physical_extruder_map_, const std::vector<int>& physical_extruder_map_,
const size_t total_layer_num_, const size_t total_layer_num_,
const float cooling_rate_, const std::vector<double>& cooling_rate_,
const float heating_rate_, const std::vector<double>& heating_rate_,
const float inject_time_threshold_, const float inject_time_threshold_,
const bool enable_pre_heating_ const bool enable_pre_heating_
) : ) :
@ -810,8 +810,8 @@ namespace Slic3r {
int valid_machine_id_, int valid_machine_id_,
float inject_time_threshold_, float inject_time_threshold_,
float partial_free_cooling_thres_, float partial_free_cooling_thres_,
float cooling_rate_, const std::vector<double>& cooling_rate_,
float heating_rate_, const std::vector<double>& heating_rate_,
unsigned int machine_start_gcode_end_id_, unsigned int machine_start_gcode_end_id_,
unsigned int machine_end_gcode_start_id_ unsigned int machine_end_gcode_start_id_
) : ) :
@ -840,8 +840,8 @@ namespace Slic3r {
const int valid_machine_id; const int valid_machine_id;
const float inject_time_threshold; const float inject_time_threshold;
const float partial_free_cooling_thres; // threshold of cooling temp during post extrusion const float partial_free_cooling_thres; // threshold of cooling temp during post extrusion
const float cooling_rate; const std::vector<double>& cooling_rate;
const float heating_rate; const std::vector<double>& heating_rate;
const unsigned int machine_start_gcode_end_id; const unsigned int machine_start_gcode_end_id;
const unsigned int machine_end_gcode_start_id; const unsigned int machine_end_gcode_start_id;
@ -1012,8 +1012,8 @@ namespace Slic3r {
std::vector<Extruder> m_filament_lists; std::vector<Extruder> m_filament_lists;
std::vector<int> m_filament_nozzle_temp; std::vector<int> m_filament_nozzle_temp;
std::vector<std::string> m_filament_types; std::vector<std::string> m_filament_types;
float m_hotend_cooling_rate{ 2.f }; std::vector<double> m_hotend_cooling_rate{ 2.f };
float m_hotend_heating_rate{ 2.f }; std::vector<double> m_hotend_heating_rate{ 2.f };
float m_enable_pre_heating{ false }; float m_enable_pre_heating{ false };
std::vector<int> m_physical_extruder_map; std::vector<int> m_physical_extruder_map;

View File

@ -1772,11 +1772,13 @@ void PrintConfigDef::init_fff_params()
def->mode = comAdvanced; def->mode = comAdvanced;
def->set_default_value(new ConfigOptionFloat(5)); def->set_default_value(new ConfigOptionFloat(5));
def = this->add("hotend_cooling_rate", coFloat); def = this->add("hotend_cooling_rate", coFloats);
def->set_default_value(new ConfigOptionFloat(2)); def->nullable = true;
def->set_default_value(new ConfigOptionFloatsNullable{2});
def = this->add("hotend_heating_rate", coFloat); def = this->add("hotend_heating_rate", coFloats);
def->set_default_value(new ConfigOptionFloat(2)); def->nullable = true;
def->set_default_value(new ConfigOptionFloatsNullable{2});
def = this->add("enable_pre_heating", coBool); def = this->add("enable_pre_heating", coBool);
def->set_default_value(new ConfigOptionBool(false)); def->set_default_value(new ConfigOptionBool(false));
@ -5658,7 +5660,9 @@ std::set<std::string> printer_options_with_variant_1 = {
"nozzle_volume", "nozzle_volume",
"nozzle_type", "nozzle_type",
"printer_extruder_id", "printer_extruder_id",
"printer_extruder_variant" "printer_extruder_variant",
"hotend_cooling_rate",
"hotend_heating_rate"
}; };
//options with silient mode //options with silient mode

View File

@ -1050,8 +1050,8 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, enable_pre_heating)) ((ConfigOptionBool, enable_pre_heating))
((ConfigOptionEnum<BedTempFormula>, bed_temperature_formula)) ((ConfigOptionEnum<BedTempFormula>, bed_temperature_formula))
((ConfigOptionInts, physical_extruder_map)) ((ConfigOptionInts, physical_extruder_map))
((ConfigOptionFloat, hotend_cooling_rate)) ((ConfigOptionFloatsNullable, hotend_cooling_rate))
((ConfigOptionFloat, hotend_heating_rate)) ((ConfigOptionFloatsNullable, hotend_heating_rate))
((ConfigOptionFloats, filament_minimal_purge_on_wipe_tower)) ((ConfigOptionFloats, filament_minimal_purge_on_wipe_tower))
// BBS // BBS
((ConfigOptionBool, scan_first_layer)) ((ConfigOptionBool, scan_first_layer))