ENH: read pre cooling temp from config
jira: NONE Signed-off-by: xun.zhang <xun.zhang@bambulab.com> Change-Id: I8447fb5e091d95648871efc4b4ac61094acefc54
This commit is contained in:
parent
9486b6df23
commit
8890900f30
|
@ -1051,7 +1051,7 @@ void GCodeProcessor::TimeProcessor::post_process(const std::string& filename, st
|
||||||
context.physical_extruder_map,
|
context.physical_extruder_map,
|
||||||
valid_machine_id,
|
valid_machine_id,
|
||||||
context.inject_time_threshold,
|
context.inject_time_threshold,
|
||||||
context.post_extrusion_cooling_threshold,
|
context.pre_cooling_temp,
|
||||||
context.cooling_rate,
|
context.cooling_rate,
|
||||||
context.heating_rate,
|
context.heating_rate,
|
||||||
machine_start_gcode_end_line_id,
|
machine_start_gcode_end_line_id,
|
||||||
|
@ -1681,6 +1681,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
|
||||||
|
|
||||||
m_hotend_cooling_rate = config.hotend_cooling_rate.values;
|
m_hotend_cooling_rate = config.hotend_cooling_rate.values;
|
||||||
m_hotend_heating_rate = config.hotend_heating_rate.values;
|
m_hotend_heating_rate = config.hotend_heating_rate.values;
|
||||||
|
m_filament_pre_cooling_temp = config.filament_pre_cooling_temperature.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;
|
||||||
|
|
||||||
|
@ -1796,6 +1797,11 @@ void GCodeProcessor::apply_config(const DynamicPrintConfig& config)
|
||||||
m_hotend_heating_rate = hotend_heating_rate->values;
|
m_hotend_heating_rate = hotend_heating_rate->values;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const ConfigOptionIntsNullable* filament_pre_cooling_temp = config.option<ConfigOptionIntsNullable>("filament_pre_cooling_temperature");
|
||||||
|
if (filament_pre_cooling_temp != nullptr) {
|
||||||
|
m_filament_pre_cooling_temp = filament_pre_cooling_temp->values;
|
||||||
|
}
|
||||||
|
|
||||||
const ConfigOptionBool* enable_pre_heating = config.option<ConfigOptionBool>("enable_pre_heating");
|
const ConfigOptionBool* enable_pre_heating = config.option<ConfigOptionBool>("enable_pre_heating");
|
||||||
if (enable_pre_heating != nullptr) {
|
if (enable_pre_heating != nullptr) {
|
||||||
m_enable_pre_heating = enable_pre_heating->value;
|
m_enable_pre_heating = enable_pre_heating->value;
|
||||||
|
@ -2357,6 +2363,7 @@ void GCodeProcessor::finalize(bool post_process)
|
||||||
m_layer_id,
|
m_layer_id,
|
||||||
m_hotend_cooling_rate,
|
m_hotend_cooling_rate,
|
||||||
m_hotend_heating_rate,
|
m_hotend_heating_rate,
|
||||||
|
m_filament_pre_cooling_temp,
|
||||||
inject_time_threshold,
|
inject_time_threshold,
|
||||||
m_enable_pre_heating
|
m_enable_pre_heating
|
||||||
);
|
);
|
||||||
|
@ -5940,10 +5947,16 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
|
||||||
return buffer;
|
return buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
auto is_tpu_filament = [&filament_types = this->filament_types](int idx) {
|
auto is_pre_cooling_valid = [&nozzle_temps = this->filament_nozzle_temps, &pre_cooling_temps = this->filament_pre_cooling_temps](int idx) ->bool {
|
||||||
if (idx == -1)
|
if(idx < 0)
|
||||||
return false;
|
return false;
|
||||||
return filament_types[idx] == "TPU";
|
return pre_cooling_temps[idx] > 0 && pre_cooling_temps[idx] < nozzle_temps[idx];
|
||||||
|
};
|
||||||
|
|
||||||
|
auto get_partial_free_cooling_thres = [&nozzle_temps = this->filament_nozzle_temps, &pre_cooling_temps = this->filament_pre_cooling_temps](int idx) -> float{
|
||||||
|
if(idx < 0)
|
||||||
|
return 30.f;
|
||||||
|
return nozzle_temps[idx] - (float)(pre_cooling_temps[idx]);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto gcode_move_comp = [](const GCodeProcessorResult::MoveVertex& a, unsigned int gcode_id) {
|
auto gcode_move_comp = [](const GCodeProcessorResult::MoveVertex& a, unsigned int gcode_id) {
|
||||||
|
@ -5969,7 +5982,7 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
|
||||||
if (move_iter_lower >= move_iter_upper)
|
if (move_iter_lower >= move_iter_upper)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool apply_cooling_when_partial_free = is_tpu_filament(block.last_filament_id) && pre_cooling;
|
bool apply_cooling_when_partial_free = is_pre_cooling_valid(block.last_filament_id) && pre_cooling;
|
||||||
|
|
||||||
float partial_free_time_gap = partial_free_move_upper->time[valid_machine_id] - partial_free_move_lower->time[valid_machine_id]; // time of partial free
|
float partial_free_time_gap = partial_free_move_upper->time[valid_machine_id] - partial_free_move_lower->time[valid_machine_id]; // time of partial free
|
||||||
float complete_free_time_gap = move_iter_upper->time[valid_machine_id] - move_iter_lower->time[valid_machine_id]; // time of complete free
|
float complete_free_time_gap = move_iter_upper->time[valid_machine_id] - move_iter_lower->time[valid_machine_id]; // time of complete free
|
||||||
|
@ -5983,9 +5996,9 @@ void GCodeProcessor::PreCoolingInjector::inject_cooling_heating_command(TimeProc
|
||||||
float ext_heating_rate = heating_rate[block.extruder_id];
|
float ext_heating_rate = heating_rate[block.extruder_id];
|
||||||
float ext_cooling_rate = cooling_rate[block.extruder_id];
|
float ext_cooling_rate = cooling_rate[block.extruder_id];
|
||||||
|
|
||||||
if (is_tpu_filament(block.last_filament_id) && pre_cooling) {
|
if (apply_cooling_when_partial_free) {
|
||||||
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 * ext_cooling_rate));
|
float max_cooling_temp = std::min(curr_temp, std::min(get_partial_free_cooling_thres(block.last_filament_id), 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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -693,8 +693,8 @@ namespace Slic3r {
|
||||||
size_t total_layer_num;
|
size_t total_layer_num;
|
||||||
std::vector<double> cooling_rate{ 2.f }; // Celsius degree per second
|
std::vector<double> cooling_rate{ 2.f }; // Celsius degree per second
|
||||||
std::vector<double> heating_rate{ 2.f }; // Celsius degree per second
|
std::vector<double> heating_rate{ 2.f }; // Celsius degree per second
|
||||||
|
std::vector<int> pre_cooling_temp{ 0 };
|
||||||
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
|
|
||||||
bool enable_pre_heating{ false };
|
bool enable_pre_heating{ false };
|
||||||
|
|
||||||
TimeProcessContext(
|
TimeProcessContext(
|
||||||
|
@ -707,6 +707,7 @@ namespace Slic3r {
|
||||||
const size_t total_layer_num_,
|
const size_t total_layer_num_,
|
||||||
const std::vector<double>& cooling_rate_,
|
const std::vector<double>& cooling_rate_,
|
||||||
const std::vector<double>& heating_rate_,
|
const std::vector<double>& heating_rate_,
|
||||||
|
const std::vector<int>& pre_cooling_temp_,
|
||||||
const float inject_time_threshold_,
|
const float inject_time_threshold_,
|
||||||
const bool enable_pre_heating_
|
const bool enable_pre_heating_
|
||||||
) :
|
) :
|
||||||
|
@ -719,6 +720,7 @@ namespace Slic3r {
|
||||||
total_layer_num(total_layer_num_),
|
total_layer_num(total_layer_num_),
|
||||||
cooling_rate(cooling_rate_),
|
cooling_rate(cooling_rate_),
|
||||||
heating_rate(heating_rate_),
|
heating_rate(heating_rate_),
|
||||||
|
pre_cooling_temp(pre_cooling_temp_),
|
||||||
enable_pre_heating(enable_pre_heating_),
|
enable_pre_heating(enable_pre_heating_),
|
||||||
inject_time_threshold(inject_time_threshold_)
|
inject_time_threshold(inject_time_threshold_)
|
||||||
{
|
{
|
||||||
|
@ -809,7 +811,7 @@ namespace Slic3r {
|
||||||
const std::vector<int>& physical_extruder_map_,
|
const std::vector<int>& physical_extruder_map_,
|
||||||
int valid_machine_id_,
|
int valid_machine_id_,
|
||||||
float inject_time_threshold_,
|
float inject_time_threshold_,
|
||||||
float partial_free_cooling_thres_,
|
const std::vector<int> & pre_cooling_temp_,
|
||||||
const std::vector<double>& cooling_rate_,
|
const std::vector<double>& cooling_rate_,
|
||||||
const std::vector<double>& heating_rate_,
|
const std::vector<double>& heating_rate_,
|
||||||
unsigned int machine_start_gcode_end_id_,
|
unsigned int machine_start_gcode_end_id_,
|
||||||
|
@ -822,7 +824,7 @@ namespace Slic3r {
|
||||||
physical_extruder_map(physical_extruder_map_),
|
physical_extruder_map(physical_extruder_map_),
|
||||||
valid_machine_id(valid_machine_id_),
|
valid_machine_id(valid_machine_id_),
|
||||||
inject_time_threshold(inject_time_threshold_),
|
inject_time_threshold(inject_time_threshold_),
|
||||||
partial_free_cooling_thres(partial_free_cooling_thres_),
|
filament_pre_cooling_temps(pre_cooling_temp_),
|
||||||
cooling_rate(cooling_rate_),
|
cooling_rate(cooling_rate_),
|
||||||
heating_rate(heating_rate_),
|
heating_rate(heating_rate_),
|
||||||
machine_start_gcode_end_id(machine_start_gcode_end_id_),
|
machine_start_gcode_end_id(machine_start_gcode_end_id_),
|
||||||
|
@ -839,9 +841,9 @@ namespace Slic3r {
|
||||||
const std::vector<int>& physical_extruder_map;
|
const std::vector<int>& physical_extruder_map;
|
||||||
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 std::vector<double>& cooling_rate;
|
const std::vector<double>& cooling_rate;
|
||||||
const std::vector<double>& heating_rate;
|
const std::vector<double>& heating_rate;
|
||||||
|
const std::vector<int>& filament_pre_cooling_temps; // target cooling temp during post extrusion
|
||||||
|
|
||||||
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;
|
||||||
|
@ -1014,6 +1016,7 @@ namespace Slic3r {
|
||||||
std::vector<std::string> m_filament_types;
|
std::vector<std::string> m_filament_types;
|
||||||
std::vector<double> m_hotend_cooling_rate{ 2.f };
|
std::vector<double> m_hotend_cooling_rate{ 2.f };
|
||||||
std::vector<double> m_hotend_heating_rate{ 2.f };
|
std::vector<double> m_hotend_heating_rate{ 2.f };
|
||||||
|
std::vector<int> m_filament_pre_cooling_temp{ 0 };
|
||||||
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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue