Skip to content

Commit

Permalink
Correct time estimation, calculate firmware retractions.
Browse files Browse the repository at this point in the history
  • Loading branch information
vovodroid committed May 10, 2024
1 parent 76824c9 commit 28252cd
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/libslic3r/GCode/GCodeProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ void GCodeProcessor::TimeMachine::calculate_time(size_t keep_last_n_blocks, floa
size_t n_blocks_process = blocks.size() - keep_last_n_blocks;
for (size_t i = 0; i < n_blocks_process; ++i) {
const TimeBlock& block = blocks[i];
float block_time = block.time();
float block_time = block.time() + this->estimated_time_correction / 1000;
if (i == 0)
block_time += additional_time;

Expand Down Expand Up @@ -660,6 +660,7 @@ void GCodeProcessor::apply_config(const PrintConfig& config)
}
m_time_processor.machines[i].max_travel_acceleration = max_travel_acceleration;
m_time_processor.machines[i].travel_acceleration = (max_travel_acceleration > 0.0f) ? max_travel_acceleration : DEFAULT_TRAVEL_ACCELERATION;
m_time_processor.machines[i].estimated_time_correction = config.estimated_time_correction;
}

m_time_processor.export_remaining_time_enabled = config.remaining_times.value;
Expand Down Expand Up @@ -3148,13 +3149,23 @@ void GCodeProcessor::process_G10(const GCodeReader::GCodeLine& line)
}

// stores retract move
store_move_vertex(EMoveType::Retract);
//store_move_vertex(EMoveType::Retract);

std::array<std::optional<double>, 4> g1_axes = { std::nullopt, std::nullopt, std::nullopt, std::nullopt };
g1_axes[E] = - this->m_parser.config().retract_length.get_at(m_extruder_id);
float g1_feedrate = this->m_parser.config().retract_speed.get_at(m_extruder_id) * 60;
process_G1(g1_axes, g1_feedrate);
}

void GCodeProcessor::process_G11(const GCodeReader::GCodeLine& line)
{
// stores unretract move
store_move_vertex(EMoveType::Unretract);
//store_move_vertex(EMoveType::Unretract);

std::array<std::optional<double>, 4> g1_axes = { std::nullopt, std::nullopt, std::nullopt, std::nullopt };
g1_axes[E] = this->m_parser.config().retract_length.get_at(m_extruder_id) + this->m_parser.config().retract_restart_extra.get_at(m_extruder_id);
float g1_feedrate = this->m_parser.config().deretract_speed.get_at(m_extruder_id) * 60;
process_G1(g1_axes, g1_feedrate);
}

void GCodeProcessor::process_G20(const GCodeReader::GCodeLine& line)
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/GCode/GCodeProcessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ namespace Slic3r {
float extrude_factor_override_percentage;
float time; // s
float travel_time; // s
float estimated_time_correction;
struct StopTime
{
unsigned int g1_line_id;
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/GCodeReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ class GCodeReader {
char extrusion_axis() const { return m_extrusion_axis; }
// void set_extrusion_axis(char axis) { m_extrusion_axis = axis; }

GCodeConfig& config() { return m_config; };

private:
template<typename ParseLineCallback, typename LineEndCallback>
bool parse_file_raw_internal(const std::string &filename, ParseLineCallback parse_line_callback, LineEndCallback line_end_callback);
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/Preset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,7 @@ static std::vector<std::string> s_Preset_printer_options {
"cooling_tube_length", "high_current_on_filament_swap", "parking_pos_retraction", "extra_loading_move", "multimaterial_purging",
"max_print_height", "default_print_profile", "inherits",
"remaining_times", "silent_mode",
"estimated_time_correction",
"machine_limits_usage", "thumbnails", "thumbnails_format"
};

Expand Down
8 changes: 8 additions & 0 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1973,6 +1973,14 @@ void PrintConfigDef::init_fff_params()
def->mode = comExpert;
def->set_default_value(new ConfigOptionBool(true));

def = this->add("estimated_time_correction", coFloat);
def->label = L("Increase each move time by");
def->tooltip = L("Increase each move time by this miliseconds value, to make it it more close to the real one. "
"Sane value could be about 1-10 milliseconds.");
def->sidetext = L("miliseconds");
def->mode = comExpert;
def->set_default_value(new ConfigOptionFloat(0));

def = this->add("binary_gcode", coBool);
def->label = L("Supports binary G-code");
def->tooltip = L("Enable, if the firmware supports binary G-code format (bgcode). "
Expand Down
1 change: 1 addition & 0 deletions src/libslic3r/PrintConfig.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -809,6 +809,7 @@ PRINT_CONFIG_CLASS_DEFINE(
((ConfigOptionBool, high_current_on_filament_swap))
((ConfigOptionFloat, parking_pos_retraction))
((ConfigOptionBool, remaining_times))
((ConfigOptionFloat, estimated_time_correction))
((ConfigOptionBool, silent_mode))
((ConfigOptionFloat, extra_loading_move))
((ConfigOptionFloat, multimaterial_purging))
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 @@ -2844,6 +2844,7 @@ void TabPrinter::build_fff()
optgroup->append_single_option_line("use_firmware_retraction");
optgroup->append_single_option_line("use_volumetric_e");
optgroup->append_single_option_line("variable_layer_height");
optgroup->append_single_option_line("estimated_time_correction");

const int gcode_field_height = 15; // 150
const int notes_field_height = 25; // 250
Expand Down

0 comments on commit 28252cd

Please sign in to comment.