Loading, unloading and cooling reworked, new filament parameters regarding cooling were added

This commit is contained in:
Lukas Matena 2018-04-24 13:02:08 +02:00
parent a154fd34ee
commit 8c77b9645c
7 changed files with 99 additions and 73 deletions

View File

@ -219,6 +219,17 @@ public:
Writer& retract(float e, float f = 0.f)
{ return load(-e, f); }
// Loads filament while also moving towards given points in x-axis (x feedrate is limited by cutting the distance short if necessary)
Writer& load_move_x_advanced(float farthest_x, float loading_dist, float loading_speed, float max_x_speed = 50.f)
{
float time = std::abs(loading_dist / loading_speed);
float x_speed = std::min(max_x_speed, std::abs(farthest_x - x()) / time);
float feedrate = 60.f * std::hypot(x_speed, loading_speed);
float end_point = x() + (farthest_x > x() ? 1.f : -1.f) * x_speed * time;
return extrude_explicit(end_point, y(), loading_dist, feedrate);
}
// Elevate the extruder head above the current print_z position.
Writer& z_hop(float hop, float f = 0.f)
{
@ -786,58 +797,43 @@ void WipeTowerPrusaMM::toolchange_Unload(
}
WipeTower::xy end_of_ramming(writer.x(),writer.y());
// Pull the filament end to the BEGINNING of the cooling tube while still moving the print head
float oldx = writer.x();
float turning_point = (!m_left_to_right ? std::max(xl,oldx-15.f) : std::min(xr,oldx+15.f) ); // so it's not too far
float xdist = std::abs(oldx-turning_point);
float edist = -(m_cooling_tube_retraction+m_cooling_tube_length/2.f-42);
// Retraction:
float old_x = writer.x();
float turning_point = (!m_left_to_right ? xl : xr );
float total_retraction_distance = m_cooling_tube_retraction + m_cooling_tube_length/2.f - 15.f; // the 15mm is reserved for the first part after ramming
writer.suppress_preview()
.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * 83 ); // fixed speed after ramming
// now an ugly hack: unload the filament with a check that the x speed is 50 mm/s
const float speed = m_filpar[m_current_tool].unloading_speed;
xdist = std::min(xdist, std::abs( 50 * edist / speed ));
const float feedrate = std::abs( std::hypot(edist, xdist) / ((edist / speed) / 60.f));
writer.load_move_x(writer.x() + (m_left_to_right ? -1.f : 1.f) * xdist ,edist, feedrate );
xdist = std::abs(oldx-turning_point); // recover old value of xdist
writer.load_move_x(turning_point,-15 , 60.f * std::hypot(xdist,15)/15 * m_filpar[m_current_tool].unloading_speed*0.55f )
.load_move_x(oldx ,-12 , 60.f * std::hypot(xdist,12)/12 * m_filpar[m_current_tool].unloading_speed*0.35f )
.load_move_x_advanced(turning_point, -15.f, 83.f, 50.f) // this is done at fixed speed
.load_move_x_advanced(old_x, -0.70f * total_retraction_distance, 1.0f * m_filpar[m_current_tool].unloading_speed)
.load_move_x_advanced(turning_point, -0.20f * total_retraction_distance, 0.5f * m_filpar[m_current_tool].unloading_speed)
.load_move_x_advanced(old_x, -0.10f * total_retraction_distance, 0.3f * m_filpar[m_current_tool].unloading_speed)
.travel(old_x, writer.y()) // in case previous move was shortened to limit feedrate
.resume_preview();
if (new_temperature != 0) // Set the extruder temperature, but don't wait.
if (new_temperature != 0) // Set the extruder temperature, but don't wait.
writer.set_extruder_temp(new_temperature, false);
// cooling:
writer.suppress_preview();
writer.travel(writer.x(), writer.y() + y_step);
const float start_x = writer.x();
turning_point = ( xr-start_x > start_x-xl ? xr : xl );
const float max_x_dist = 2*std::abs(start_x-turning_point);
const unsigned int N = 4 + std::max(0.f, (m_filpar[m_current_tool].cooling_time-14)/3);
float time = m_filpar[m_current_tool].cooling_time / float(N);
// Cooling:
const unsigned number_of_moves = 3;
if (number_of_moves > 0) {
const float initial_speed = 2.2f; // mm/s
const float final_speed = 3.4f;
i = 0;
while (i<N) {
const float speed = std::min(3.4,2.2 + i*0.3 + (i==0 ? 0 : 0.3)); // mm per second: 2.2, 2.8, 3.1, 3.4, 3.4, 3.4, ...
const float e_dist = std::min(speed * time,2*m_cooling_tube_length); // distance to travel
// this move is the last one at this speed or someone set tube_length to zero
if (speed * time < 2*m_cooling_tube_length || m_cooling_tube_length<WT_EPSILON) {
++i;
time = m_filpar[m_current_tool].cooling_time / float(N);
}
else
time -= e_dist / speed; // subtract time this part will really take
float speed_inc = (final_speed - initial_speed) / (2.f * number_of_moves - 1.f);
// as for x, we will make sure the feedrate is at most 2000
float x_dist = (turning_point - WT_EPSILON < xl ? -1.f : 1.f) * std::min(e_dist * (float)sqrt(pow(2000 / (60 * speed), 2) - 1),max_x_dist);
const float feedrate = std::hypot(e_dist, x_dist) / ((e_dist / speed) / 60.f);
writer.cool(start_x+x_dist/2.f,start_x,e_dist/2.f,-e_dist/2.f, feedrate);
}
writer.suppress_preview()
.travel(writer.x(), writer.y() + y_step);
old_x = writer.x();
turning_point = xr-old_x > old_x-xl ? xr : xl;
for (unsigned i=0; i<number_of_moves; ++i) {
float speed = initial_speed + speed_inc * 2*i;
writer.load_move_x_advanced(turning_point, m_cooling_tube_length, speed);
speed += speed_inc;
writer.load_move_x_advanced(old_x, -m_cooling_tube_length, speed);
}
}
// let's wait is necessary
// let's wait is necessary:
writer.wait(m_filpar[m_current_tool].delay);
// we should be at the beginning of the cooling tube again - let's move to parking position:
writer.retract(-m_cooling_tube_length/2.f+m_parking_pos_retraction-m_cooling_tube_retraction, 2000);
@ -881,17 +877,16 @@ void WipeTowerPrusaMM::toolchange_Load(
float oldx = writer.x(); // the nozzle is in place to do the first wiping moves, we will remember the position
// Load the filament while moving left / right, so the excess material will not create a blob at a single position.
float loading_speed = m_filpar[m_current_tool].loading_speed; // mm/s in e axis
float turning_point = ( oldx-xl < xr-oldx ? xr : xl );
float dist = std::abs(oldx-turning_point);
//float edist = m_parking_pos_retraction-50-2; // loading is 2mm shorter that previous retraction, 50mm reserved for acceleration/deceleration
float edist = m_parking_pos_retraction-50+m_extra_loading_move; // 50mm reserved for acceleration/deceleration
writer.append("; CP TOOLCHANGE LOAD\n")
float edist = m_parking_pos_retraction+m_extra_loading_move;
writer.append("; CP TOOLCHANGE LOAD\n")
.suppress_preview()
.load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Acceleration
.load_move_x(oldx,edist,std::abs( 60*std::hypot(dist,edist)/edist * loading_speed) ) // Fast phase
.load_move_x(turning_point, 20, 60*std::hypot(dist,20.f)/20.f * loading_speed*0.3f) // Slowing down
.load_move_x(oldx, 10, 60*std::hypot(dist,10.f)/10.f * loading_speed*0.1f) // Super slow
.load_move_x_advanced(turning_point, 0.2f * edist, 0.3f * m_filpar[m_current_tool].loading_speed) // Acceleration
.load_move_x_advanced(oldx, 0.5f * edist, m_filpar[m_current_tool].loading_speed) // Fast phase
.load_move_x_advanced(turning_point, 0.2f * edist, 0.3f * m_filpar[m_current_tool].loading_speed) // Slowing down
.load_move_x_advanced(oldx, 0.1f * edist, 0.1f * m_filpar[m_current_tool].loading_speed) // Super slow
.travel(oldx, writer.y()) // in case last move was shortened to limit x feedrate
.resume_preview();
// Reset the extruder current to the normal value.

View File

@ -68,7 +68,8 @@ public:
// Set the extruder properties.
void set_extruder(size_t idx, material_type material, int temp, int first_layer_temp, float loading_speed,
float unloading_speed, float delay, float cooling_time, std::string ramming_parameters, float nozzle_diameter)
float unloading_speed, float delay, int cooling_moves, float cooling_initial_speed,
float cooling_final_speed, std::string ramming_parameters, float nozzle_diameter)
{
//while (m_filpar.size() < idx+1) // makes sure the required element is in the vector
m_filpar.push_back(FilamentParameters());
@ -79,7 +80,9 @@ public:
m_filpar[idx].loading_speed = loading_speed;
m_filpar[idx].unloading_speed = unloading_speed;
m_filpar[idx].delay = delay;
m_filpar[idx].cooling_time = cooling_time;
m_filpar[idx].cooling_moves = cooling_moves;
m_filpar[idx].cooling_initial_speed = cooling_initial_speed;
m_filpar[idx].cooling_final_speed = cooling_final_speed;
m_filpar[idx].nozzle_diameter = nozzle_diameter; // to be used in future with (non-single) multiextruder MM
m_perimeter_width = nozzle_diameter * Width_To_Nozzle_Ratio; // all extruders are now assumed to have the same diameter
@ -213,7 +216,9 @@ private:
float loading_speed = 0.f;
float unloading_speed = 0.f;
float delay = 0.f ;
float cooling_time = 0.f;
int cooling_moves = 0;
float cooling_initial_speed = 0.f;
float cooling_final_speed = 0.f;
float ramming_line_width_multiplicator = 0.f;
float ramming_step_multiplicator = 0.f;
std::vector<float> ramming_speed;

View File

@ -186,7 +186,9 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
|| opt_key == "filament_loading_speed"
|| opt_key == "filament_unloading_speed"
|| opt_key == "filament_toolchange_delay"
|| opt_key == "filament_cooling_time"
|| opt_key == "filament_cooling_moves"
|| opt_key == "filament_cooling_initial_speed"
|| opt_key == "filament_cooling_final_speed"
|| opt_key == "filament_ramming_parameters"
|| opt_key == "gcode_flavor"
|| opt_key == "single_extruder_multi_material"
@ -1093,7 +1095,9 @@ void Print::_make_wipe_tower()
this->config.filament_loading_speed.get_at(i),
this->config.filament_unloading_speed.get_at(i),
this->config.filament_toolchange_delay.get_at(i),
this->config.filament_cooling_time.get_at(i),
this->config.filament_cooling_moves.get_at(i),
this->config.filament_cooling_initial_speed.get_at(i),
this->config.filament_cooling_final_speed.get_at(i),
this->config.filament_ramming_parameters.get_at(i),
this->config.nozzle_diameter.get_at(i));

View File

@ -481,15 +481,31 @@ PrintConfigDef::PrintConfigDef()
def->cli = "filament-toolchange-delay=f@";
def->min = 0;
def->default_value = new ConfigOptionFloats { 0. };
def = this->add("filament_cooling_time", coFloats);
def->label = L("Cooling time");
def->tooltip = L("The filament is slowly moved back and forth after retraction into the cooling tube "
"for this amount of time.");
def->cli = "filament_cooling_time=i@";
def->sidetext = L("s");
def = this->add("filament_cooling_moves", coInts);
def->label = L("Number of cooling moves");
def->tooltip = L("Filament is cooled by being moved back and forth in the "
"cooling tubes. Specify desired number of these moves ");
def->cli = "filament-cooling-moves=i@";
def->max = 0;
def->max = 20;
def->default_value = new ConfigOptionInts { 6 };
def = this->add("filament_cooling_initial_speed", coFloats);
def->label = L("Speed of the first cooling move");
def->tooltip = L("Cooling moves are gradually accelerating beginning at this speed. ");
def->cli = "filament-cooling-initial-speed=i@";
def->sidetext = L("mm/s");
def->min = 0;
def->default_value = new ConfigOptionFloats { 14.f };
def->default_value = new ConfigOptionFloats { 2.2f };
def = this->add("filament_cooling_final_speed", coFloats);
def->label = L("Speed of the last cooling move");
def->tooltip = L("Cooling moves are gradually accelerating towards this speed. ");
def->cli = "filament-cooling-final-speed=i@";
def->sidetext = L("mm/s");
def->min = 0;
def->default_value = new ConfigOptionFloats { 3.4f };
def = this->add("filament_ramming_parameters", coStrings);
def->label = L("Ramming parameters");

View File

@ -476,7 +476,9 @@ public:
ConfigOptionFloats filament_loading_speed;
ConfigOptionFloats filament_unloading_speed;
ConfigOptionFloats filament_toolchange_delay;
ConfigOptionFloats filament_cooling_time;
ConfigOptionInts filament_cooling_moves;
ConfigOptionFloats filament_cooling_initial_speed;
ConfigOptionFloats filament_cooling_final_speed;
ConfigOptionStrings filament_ramming_parameters;
ConfigOptionBool gcode_comments;
ConfigOptionEnum<GCodeFlavor> gcode_flavor;
@ -535,7 +537,9 @@ protected:
OPT_PTR(filament_loading_speed);
OPT_PTR(filament_unloading_speed);
OPT_PTR(filament_toolchange_delay);
OPT_PTR(filament_cooling_time);
OPT_PTR(filament_cooling_moves);
OPT_PTR(filament_cooling_initial_speed);
OPT_PTR(filament_cooling_final_speed);
OPT_PTR(filament_ramming_parameters);
OPT_PTR(gcode_comments);
OPT_PTR(gcode_flavor);

View File

@ -209,10 +209,10 @@ const std::vector<std::string>& Preset::filament_options()
static std::vector<std::string> s_opts {
"filament_colour", "filament_diameter", "filament_type", "filament_soluble", "filament_notes", "filament_max_volumetric_speed",
"extrusion_multiplier", "filament_density", "filament_cost", "filament_loading_speed", "filament_unloading_speed", "filament_toolchange_delay",
"filament_cooling_time", "filament_ramming_parameters", "temperature", "first_layer_temperature", "bed_temperature",
"first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed", "bridge_fan_speed", "disable_fan_first_layers",
"fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed", "start_filament_gcode", "end_filament_gcode","compatible_printers",
"compatible_printers_condition", "inherits"
"filament_cooling_moves", "filament_cooling_initial_speed", "filament_cooling_final_speed", "filament_ramming_parameters", "temperature",
"first_layer_temperature", "bed_temperature", "first_layer_bed_temperature", "fan_always_on", "cooling", "min_fan_speed", "max_fan_speed",
"bridge_fan_speed", "disable_fan_first_layers", "fan_below_layer_time", "slowdown_below_layer_time", "min_print_speed",
"start_filament_gcode", "end_filament_gcode","compatible_printers", "compatible_printers_condition", "inherits"
};
return s_opts;
}

View File

@ -1287,7 +1287,9 @@ void TabFilament::build()
optgroup->append_single_option_line("filament_loading_speed");
optgroup->append_single_option_line("filament_unloading_speed");
optgroup->append_single_option_line("filament_toolchange_delay");
optgroup->append_single_option_line("filament_cooling_time");
optgroup->append_single_option_line("filament_cooling_moves");
optgroup->append_single_option_line("filament_cooling_initial_speed");
optgroup->append_single_option_line("filament_cooling_final_speed");
line = { _(L("Ramming")), "" };
line.widget = [this](wxWindow* parent){
auto ramming_dialog_btn = new wxButton(parent, wxID_ANY, _(L("Ramming settings"))+"\u2026", wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);