Add volumetric speed calibration

This commit is contained in:
QIDI TECH
2024-01-26 16:15:38 +08:00
parent 2b0652398d
commit 576389430c
8 changed files with 231 additions and 36079 deletions

View File

@@ -1655,6 +1655,14 @@ void MainFrame::init_menubar_as_editor()
m_pa_calib_dlg->ShowModal();
},
"", nullptr, [this]() { return m_plater->is_view3D_shown(); }, this);
append_menu_item(calibrationMenu, wxID_ANY, _L("Max Volumetric Speed"), _L("Max Volumetric Speed"),
[this](wxCommandEvent &) {
if (!m_mvs_calib_dlg)
m_mvs_calib_dlg = new MVS_Calibration_Dlg((wxWindow *) this, wxID_ANY, m_plater);
m_mvs_calib_dlg->ShowModal();
},
"", nullptr, [this]() { return m_plater->is_view3D_shown(); }, this);
}
// menubar

View File

@@ -217,6 +217,7 @@ public:
FRF_Calibration_Dlg *m_frf_calib_dlg{nullptr};
//B34
PA_Calibration_Dlg *m_pa_calib_dlg{nullptr};
MVS_Calibration_Dlg *m_mvs_calib_dlg{nullptr};
//B4
wxString tem_host;
PrinterWebView * m_printer_view{nullptr};

View File

@@ -5543,7 +5543,7 @@ void Plater::calib_pa_line(const double StartPA, double EndPA, double PAStep)
// Check step count
double step_spacing = 4.62;
const Vec2d plate_center = build_volume().bed_center();
int count = int((EndPA - StartPA) / PAStep);
int count = int((EndPA - StartPA) / PAStep + 0.0001);
int max_count = int(plate_center.y() / step_spacing * 2) - 4;
if (count > max_count) {
count = max_count;
@@ -5650,7 +5650,7 @@ void Plater::calib_pa_pattern(const double StartPA, double EndPA, double PAStep)
// Check step count
const Vec2d plate_center = build_volume().bed_center();
int count = int((EndPA - StartPA) / PAStep);
int count = int((EndPA - StartPA) / PAStep + 0.0001);
Tab *tab_printer = wxGetApp().get_tab(Preset::TYPE_PRINTER);
@@ -5793,8 +5793,8 @@ void Plater::calib_pa_tower(const double StartPA, double EndPA, double PAStep)
auto pa_end_gcode = printer_config->opt_string("before_layer_gcode");
// Check step count
double count = floor((EndPA - StartPA) / PAStep);
double max_count = floor(max_print_height/5) - 1;
double count = floor((EndPA - StartPA) / PAStep + 0.0001);
double max_count = floor(max_print_height/5 + 0.0001) - 1;
if (count > max_count) {
count = max_count;
}
@@ -5816,6 +5816,92 @@ void Plater::calib_pa_tower(const double StartPA, double EndPA, double PAStep)
std::string message = _u8L("NOTICE: The calibration function modifies some parameters. After calibration, record the best value and restore the other parameters.");
get_notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, message);
}
//Y22
void Plater::calib_max_volumetric_speed(const double StartVS, double EndVS, double VSStep)
{
new_project();
wxGetApp().mainframe->select_tab(size_t(0));
std::vector<fs::path> model_path;
model_path.emplace_back(Slic3r::resources_dir() + "/calib/VolumetricSpeed/volumetric_speed.stl");
load_files(model_path, true, false, false);
p->set_project_filename("Max Volumetric Speed");
DynamicPrintConfig *printer_config = &wxGetApp().preset_bundle->printers.get_edited_preset().config;
double nozzle_diameter = double(printer_config->opt_float("nozzle_diameter", 0));
double vs_layer_height = nozzle_diameter * 0.8;
double vs_external_perimeter_extrusion_width = nozzle_diameter * 1.75;
auto max_print_height = build_volume().max_print_height();
float res = float(vs_layer_height * (vs_external_perimeter_extrusion_width - vs_layer_height * (1. - 0.25 * PI)));
float start_speed = StartVS / res;
float end_speed = EndVS / res;
float step_speed = VSStep / res;
double count = floor((EndVS - StartVS) / VSStep + 1.0001);
double max_count = floor(max_print_height / vs_layer_height + 0.0001);
if (count > max_count) {
count = max_count;
}
DynamicPrintConfig new_config;
new_config.set_key_value("max_layer_height", new ConfigOptionFloats{vs_layer_height});
new_config.set_key_value("layer_height", new ConfigOptionFloat(vs_layer_height));
new_config.set_key_value("first_layer_height", new ConfigOptionFloatOrPercent(vs_layer_height, false));
new_config.set_key_value("perimeters", new ConfigOptionInt(1));
new_config.set_key_value("top_solid_layers", new ConfigOptionInt(0));
new_config.set_key_value("bottom_solid_layers", new ConfigOptionInt(0));
new_config.set_key_value("fill_density", new ConfigOptionPercent(0));
new_config.set_key_value("brim_width", new ConfigOptionFloat(5));
new_config.set_key_value("brim_separation", new ConfigOptionFloat(0));
new_config.set_key_value("first_layer_speed", new ConfigOptionFloatOrPercent(start_speed, false));
new_config.set_key_value("external_perimeter_extrusion_width", new ConfigOptionFloatOrPercent(vs_external_perimeter_extrusion_width, false));
new_config.set_key_value("first_layer_extrusion_width", new ConfigOptionFloatOrPercent(vs_external_perimeter_extrusion_width, false));
new_config.set_key_value("extrusion_multiplier", new ConfigOptionFloats{1});
Tab *tab_print = wxGetApp().get_tab(Preset::TYPE_PRINT);
Tab *tab_filament = wxGetApp().get_tab(Preset::TYPE_FILAMENT);
Tab *tab_printer = wxGetApp().get_tab(Preset::TYPE_PRINTER);
tab_print->load_config(new_config);
tab_filament->load_config(new_config);
tab_printer->load_config(new_config);
select_all();
sidebar().obj_manipul()->set_uniform_scaling(false);
sidebar().obj_manipul()->on_change("size", 2, count * vs_layer_height);
sidebar().obj_manipul()->set_uniform_scaling(true);
sidebar().obj_list()->layers_editing();
const int obj_idx = sidebar().obj_list()->get_selected_obj_idx();
auto& ranges = sidebar().obj_list()->object(obj_idx)->layer_config_ranges;
const auto layers_item = sidebar().obj_list()->GetSelection();
const t_layer_height_range default_range = {0.0, 2.0};
const t_layer_height_range first_range = {vs_layer_height, vs_layer_height * 2};
wxDataViewItem layer_item = sidebar().obj_list()->GetModel()->GetItemByLayerRange(obj_idx, default_range);
ModelConfig& model_config = sidebar().obj_list()->get_item_config(layer_item);
model_config.set_key_value("external_perimeter_speed", new ConfigOptionFloatOrPercent(start_speed + step_speed, false));
sidebar().obj_list()->show_settings(sidebar().obj_list()->add_settings_item(layer_item, &model_config.get()));
sidebar().obj_list()->edit_layer_range(default_range, first_range, true);
for (int n = 2; n < count; n++) {
const t_layer_height_range new_range = {2.0 * n, 2.0 * (n + 1)};
ranges[new_range].assign_config(sidebar().obj_list()->get_default_layer_config(obj_idx));
sidebar().obj_list()->add_layer_item(new_range, layers_item);
wxDataViewItem layer_item = sidebar().obj_list()->GetModel()->GetItemByLayerRange(obj_idx, new_range);
ModelConfig& model_config = sidebar().obj_list()->get_item_config(layer_item);
model_config.set_key_value("external_perimeter_speed", new ConfigOptionFloatOrPercent(start_speed + step_speed * n, false));
sidebar().obj_list()->show_settings(sidebar().obj_list()->add_settings_item(layer_item, &model_config.get()));
const t_layer_height_range range = {vs_layer_height * n, vs_layer_height * (n + 1)};
sidebar().obj_list()->edit_layer_range(new_range, range, true);
}
std::string message = _u8L("NOTICE: The calibration function modifies some parameters. After calibration, record the best value and restore the other parameters.");
get_notification_manager()->push_notification(NotificationType::CustomNotification, NotificationManager::NotificationLevel::PrintInfoNotificationLevel, message);
}
//B34
std::string Plater::move_to(const Vec2d &point, double speed, double retract_length, double retract_speed, double height, double retract_lift)
{

View File

@@ -176,6 +176,7 @@ public:
void calib_pa_tower(const double StartPA, double EndPA, double PAStep);
void calib_flowrate_coarse();
void calib_flowrate_fine(const double target_extrusion_multiplier);
void calib_max_volumetric_speed(const double StartVS, double EndVS, double VSStep);
std::string move_to(const Vec2d &point, double speed, double retract_length, double retract_speed, double height, double retract_lift);
std::string move_to(const Vec2d &point, double speed, double retract_length, double retract_speed);
std::string move_to(const Vec2d &point, double speed, double e);

View File

@@ -98,32 +98,47 @@ PA_Calibration_Dlg::PA_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater*
// start PA
auto start_PA_sizer = new wxBoxSizer(wxHORIZONTAL);
auto start_pa_text = new wxStaticText(this, wxID_ANY, _L("Start PA: "), wxDefaultPosition, wxSize(80, -1), wxALIGN_LEFT);
start_PA_sizer->Add(start_pa_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
m_tcStartPA = new wxTextCtrl(this, wxID_ANY, wxString::FromDouble(0.0), wxDefaultPosition, wxSize(100, -1), wxBORDER_SIMPLE);
m_tcStartPA->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
start_PA_sizer->Add(m_tcStartPA, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
auto start_PA_unit = new wxStaticText(this, wxID_ANY, _L("mm/s"), wxDefaultPosition, wxSize(40, -1), wxALIGN_LEFT);
start_PA_sizer->Add(start_PA_unit, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(start_PA_sizer);
// end PA
auto end_PA_sizer = new wxBoxSizer(wxHORIZONTAL);
auto end_pa_text = new wxStaticText(this, wxID_ANY, _L("End PA: "), wxDefaultPosition, wxSize(80, -1), wxALIGN_LEFT);
end_PA_sizer->Add(end_pa_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
m_tcEndPA = new wxTextCtrl(this, wxID_ANY, wxString::FromDouble(0.04), wxDefaultPosition, wxSize(100, -1), wxBORDER_SIMPLE);
m_tcStartPA->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
end_PA_sizer->Add(m_tcEndPA, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
auto end_PA_unit = new wxStaticText(this, wxID_ANY, _L("mm/s"), wxDefaultPosition, wxSize(40, -1), wxALIGN_LEFT);
end_PA_sizer->Add(end_PA_unit, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(end_PA_sizer);
// PA step
auto PA_step_sizer = new wxBoxSizer(wxHORIZONTAL);
auto PA_step_text = new wxStaticText(this, wxID_ANY, _L("PA step: "), wxDefaultPosition, wxSize(80, -1), wxALIGN_LEFT);
PA_step_sizer->Add(PA_step_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
m_tcPAStep = new wxTextCtrl(this, wxID_ANY, wxString::FromDouble(0.002), wxDefaultPosition, wxSize(100, -1), wxBORDER_SIMPLE);
m_tcStartPA->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
PA_step_sizer->Add(m_tcPAStep, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
auto PA_step_unit = new wxStaticText(this, wxID_ANY, _L("mm/s"), wxDefaultPosition, wxSize(40, -1), wxALIGN_LEFT);
PA_step_sizer->Add(PA_step_unit, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(PA_step_sizer);
v_sizer->Add(0, 5, 0, wxEXPAND, 5);
@@ -191,4 +206,103 @@ void PA_Calibration_Dlg::on_dpi_changed(const wxRect& suggested_rect) {
Fit();
}
MVS_Calibration_Dlg::MVS_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater* plater)
: DPIDialog(parent, id, _L("Max Volumetric Speed"), wxDefaultPosition, wxSize(-1, 280), wxDEFAULT_DIALOG_STYLE | wxNO_BORDER), m_plater(plater)
{
wxBoxSizer* v_sizer = new wxBoxSizer(wxVERTICAL);
SetSizer(v_sizer);
// Settings
wxStaticBoxSizer* settings_sizer = new wxStaticBoxSizer(wxVERTICAL, this, _L("Settings"));
// start VS
auto start_VS_sizer = new wxBoxSizer(wxHORIZONTAL);
auto start_VS_text = new wxStaticText(this, wxID_ANY, _L("Start Volumetric Speed: "), wxDefaultPosition, wxSize(160, -1), wxALIGN_LEFT);
start_VS_sizer->Add(start_VS_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
m_tcStartVS = new wxTextCtrl(this, wxID_ANY, wxString::FromDouble(5), wxDefaultPosition, wxSize(100, -1), wxBORDER_SIMPLE);
m_tcStartVS->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
start_VS_sizer->Add(m_tcStartVS, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
auto start_VS_unit = new wxStaticText(this, wxID_ANY, _L("mm³/s"), wxDefaultPosition, wxSize(40, -1), wxALIGN_LEFT);
start_VS_sizer->Add(start_VS_unit, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(start_VS_sizer);
// end VS
auto end_VS_sizer = new wxBoxSizer(wxHORIZONTAL);
auto end_VS_text = new wxStaticText(this, wxID_ANY, _L("End Volumetric Speed: "), wxDefaultPosition, wxSize(160, -1), wxALIGN_LEFT);
end_VS_sizer->Add(end_VS_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
m_tcEndVS = new wxTextCtrl(this, wxID_ANY, wxString::FromDouble(15), wxDefaultPosition, wxSize(100, -1), wxBORDER_SIMPLE);
m_tcStartVS->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
end_VS_sizer->Add(m_tcEndVS, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
auto end_VS_unit = new wxStaticText(this, wxID_ANY, _L("mm³/s"), wxDefaultPosition, wxSize(40, -1), wxALIGN_LEFT);
end_VS_sizer->Add(end_VS_unit, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(end_VS_sizer);
// VS step
auto VS_step_sizer = new wxBoxSizer(wxHORIZONTAL);
auto VS_step_text = new wxStaticText(this, wxID_ANY, _L("Volumetric Speed step: "), wxDefaultPosition, wxSize(160, -1), wxALIGN_LEFT);
VS_step_sizer->Add(VS_step_text, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
m_tcVSStep = new wxTextCtrl(this, wxID_ANY, wxString::FromDouble(0.1), wxDefaultPosition, wxSize(100, -1), wxBORDER_SIMPLE);
m_tcStartVS->SetValidator(wxTextValidator(wxFILTER_NUMERIC));
VS_step_sizer->Add(m_tcVSStep, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
auto VS_step_unit = new wxStaticText(this, wxID_ANY, _L("mm³/s"), wxDefaultPosition, wxSize(40, -1), wxALIGN_LEFT);
VS_step_sizer->Add(VS_step_unit, 0, wxALL | wxALIGN_CENTER_VERTICAL, 2);
settings_sizer->Add(VS_step_sizer);
v_sizer->Add(0, 5, 0, wxEXPAND, 5);
v_sizer->Add(settings_sizer, 0, wxRIGHT | wxLEFT | wxALIGN_CENTER_VERTICAL, 15);
v_sizer->Add(0, 5, 0, wxEXPAND, 5);
m_btnStart = new wxButton(this, wxID_ANY, _L("OK"));
m_btnStart->Bind(wxEVT_BUTTON, &MVS_Calibration_Dlg::on_start, this);
v_sizer->Add(m_btnStart, 0, wxRIGHT | wxALIGN_RIGHT, 15);
v_sizer->Add(0, 8, 0, wxEXPAND, 5);
m_btnStart->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MVS_Calibration_Dlg::on_start), NULL, this);
wxGetApp().UpdateDlgDarkUI(this);
Layout();
Fit();
}
MVS_Calibration_Dlg::~MVS_Calibration_Dlg() {
// Disconnect Events
m_btnStart->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(MVS_Calibration_Dlg::on_start), NULL, this);
}
void MVS_Calibration_Dlg::on_start(wxCommandEvent& event) {
bool read_double = false;
double start_vs;
double end_vs;
double vs_step;
read_double = m_tcStartVS->GetValue().ToDouble(&start_vs);
read_double = read_double && m_tcEndVS->GetValue().ToDouble(&end_vs);
read_double = read_double && m_tcVSStep->GetValue().ToDouble(&vs_step);
if (!read_double || start_vs < 0 || vs_step < 0.01 || end_vs < start_vs + vs_step) {
MessageDialog msg_dlg(nullptr, _L("Please input valid values:\nStart Volumetric Speed: >= 0.0\nEnd Volumetric Speed: > Start Volumetric Speed + Volumetric Speed step\nVolumetric Speed step: >= 0.01)"), wxEmptyString, wxICON_WARNING | wxOK);
msg_dlg.ShowModal();
return;
}
m_plater->calib_max_volumetric_speed( start_vs, end_vs, vs_step);
EndModal(wxID_OK);
}
void MVS_Calibration_Dlg::on_dpi_changed(const wxRect& suggested_rect) {
this->Refresh();
Fit();
}
}} // namespace Slic3r::GUI

View File

@@ -51,6 +51,23 @@ protected:
Plater* m_plater;
};
class MVS_Calibration_Dlg : public DPIDialog
{
public:
MVS_Calibration_Dlg(wxWindow* parent, wxWindowID id, Plater* plater);
~MVS_Calibration_Dlg();
void on_dpi_changed(const wxRect& suggested_rect) override;
protected:
virtual void on_start(wxCommandEvent& event);
wxTextCtrl* m_tcStartVS;
wxTextCtrl* m_tcEndVS;
wxTextCtrl* m_tcVSStep;
wxButton* m_btnStart;
Plater* m_plater;
};
}} // namespace Slic3r::GUI
#endif