Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: The issue of contamination during tool change in parallel multi-tool machines. #7480

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion resources/profiles/Snapmaker.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Snapmaker",
"version": "02.02.00.04",
"version": "02.02.00.06",
"force_update": "0",
"description": "Snapmaker configurations",
"machine_model_list": [
Expand Down
2 changes: 1 addition & 1 deletion resources/profiles/Snapmaker/machine/fdm_a400.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@
],
"machine_start_gcode": "; Model: Snapmaker Artisan ({nozzle_diameter[0]}/{nozzle_diameter[1]})\n; Update: 20240922\n; Maintained by https://github.com/macdylan/3dp-configs\n; Printer : [printer_preset]\n; Profile : [print_preset]\n; Plate : [plate_name]\n; --- initial_extruder: [initial_extruder]\n; --- has_wipe_tower: [has_wipe_tower]\n; --- total_toolchanges: [total_toolchanges]\n; --- T0: {is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - 1, 0))]}\n; --- T1: {is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - 0, 0))]}\n\nT[initial_extruder]\n\nM205 V[machine_max_jerk_x] ;Junction Deviation (mm)\n\nM140 S{first_layer_bed_temperature[initial_extruder]}\n\n; you can clean the nozzle\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))]}\n M104 T{(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))} S165\n {endif}\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))]}\n M104 T{(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))} S165\n {endif}\nM204 S100\nG28\nG0 Z266 F960.0\nG0 Y200.0 F6840.0\nG0 X200.0\n\n{if first_layer_print_min[0] >= 70 && first_layer_print_max[0] <= 330 && first_layer_print_min[1] >= 70 && first_layer_print_max[1] <= 330}\nM190 P0 R{first_layer_bed_temperature[initial_extruder]} ;only inner part of the bed\n{else}\nM190 R{first_layer_bed_temperature[initial_extruder]}\n{endif}\n\nG28\n{if 0==1} ; boundary check(for dual/quick swap kit), not recommanded if there are any clamps \n G0 X0\n G0 Z0.2 F960.0\n G0 Y0 F6840.0\n G0 X400\n G0 Y400\n G0 X0\n G0 Y0\n{endif}\n\nM83\n{if 1==1 && max(hot_plate_temp_initial_layer[initial_extruder], hot_plate_temp[initial_extruder]) >= 90}\nG0 Z0.06\nG92 Z0 ;reset z\n{endif}\n\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))]}\n; preheat 0\nM104 T{(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))} S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))] + 15))}\n {endif}\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))]}\n; preheat 1\nM104 T{(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))} S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))] + 15))}\n {endif}\n\n {if 1==1}\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))] and (initial_extruder % 2) != 0}\n; flush nozzle 0\nT{(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))}\nM104 S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))] + 15))}; common flush temp\nG0 Z1.6 F960.0\nG0 X{( 0 % 2 == 0 ? 185.0 : 215.0 )} F6840.0\nG0 Y0 F6840.0\n\nM109 S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))] + 15))} C2 W1\nG1 E20 F80.0\nG92 E0\n\nM106 S{min(255, (fan_max_speed[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))] + 10) * 2.55)}\n\nM104 S{nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))] + 5}\n\nG1 E12.0 F200\nG92 E0\nG1 E8.0 Z4.6 F200\nG92 E0\n\nG0 Z5.6 F200\nM107\n\nG0 X{( 0 % 2 == 0 ? 140.0 : 260.0 )} F6840.0\nG0 Z0.3 F960.0\nM109 S{nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))]} C3 W1\nG1 E3 F200\nG92 E0\nG1 X{( 0 % 2 == 0 ? 0 : 400 )} E8.73079 F6840.0\nG92 E0\n\nG1 E-{retract_length_toolchange[0]} F200\nG92 E0\nG0 Y20 F6840.0\n\nM104 S{temperature_vitrification[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))]}\n {endif}\n\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))] and (initial_extruder % 2) != 1}\n; flush nozzle 1\nT{(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))}\nM104 S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))] + 15))}; common flush temp\nG0 Z1.6 F960.0\nG0 X{( 1 % 2 == 0 ? 185.0 : 215.0 )} F6840.0\nG0 Y0 F6840.0\n\nM109 S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))] + 15))} C2 W1\nG1 E20 F80.0\nG92 E0\n\nM106 S{min(255, (fan_max_speed[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))] + 10) * 2.55)}\n\nM104 S{nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))] + 5}\n\nG1 E12.0 F200\nG92 E0\nG1 E8.0 Z4.6 F200\nG92 E0\n\nG0 Z5.6 F200\nM107\n\nG0 X{( 1 % 2 == 0 ? 140.0 : 260.0 )} F6840.0\nG0 Z0.3 F960.0\nM109 S{nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))]} C3 W1\nG1 E3 F200\nG92 E0\nG1 X{( 1 % 2 == 0 ? 0 : 400 )} E8.73079 F6840.0\nG92 E0\n\nG1 E-{retract_length_toolchange[1]} F200\nG92 E0\nG0 Y20 F6840.0\n\nM104 S{temperature_vitrification[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))]}\n {endif}\n\n {endif}\n; flush initial nozzle\nT[initial_extruder]\nM104 S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + initial_extruder, 63) : max(initial_extruder - (1-initial_extruder), 0))] + 15))}; common flush temp\nG0 Z1.6 F960.0\nG0 X{( initial_extruder % 2 == 0 ? 185.0 : 215.0 )} F6840.0\nG0 Y0 F6840.0\n\nM109 S{max(250, min(290, nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + initial_extruder, 63) : max(initial_extruder - (1-initial_extruder), 0))] + 15))} C2 W1\nG1 E20 F80.0\nG92 E0\n\nM106 S{min(255, (fan_max_speed[(initial_extruder % 2 == 0 ? min(initial_extruder + initial_extruder, 63) : max(initial_extruder - (1-initial_extruder), 0))] + 10) * 2.55)}\n\nM104 S{nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + initial_extruder, 63) : max(initial_extruder - (1-initial_extruder), 0))] + 5}\n\nG1 E12.0 F200\nG92 E0\nG1 E8.0 Z4.6 F200\nG92 E0\n\nG0 Z5.6 F200\nM107\n\nG0 X{( initial_extruder % 2 == 0 ? 140.0 : 260.0 )} F6840.0\nG0 Z0.3 F960.0\nM109 S{nozzle_temperature_initial_layer[(initial_extruder % 2 == 0 ? min(initial_extruder + initial_extruder, 63) : max(initial_extruder - (1-initial_extruder), 0))]} C3 W1\nG1 E3 F200\nG92 E0\nG1 X{( initial_extruder % 2 == 0 ? 0 : 400 )} E8.73079 F6840.0\nG92 E0\n\nG1 E-{retraction_length[initial_extruder]} F200\nG92 E0\nG0 Y20 F6840.0\n\n; ready [plate_name]",
"machine_end_gcode": "G92 E0\n\nG0 Z{max_layer_z + 2.0} F600\n; retract the filament to make it easier to replace\nG0 E-10 F200\nG28\n\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))]}\nM104 T{(initial_extruder % 2 == 0 ? min(initial_extruder + 0, 63) : max(initial_extruder - (1-0), 0))} S0\n {endif}\n{if is_extruder_used[(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))]}\nM104 T{(initial_extruder % 2 == 0 ? min(initial_extruder + 1, 63) : max(initial_extruder - (1-1), 0))} S0\n {endif}\nM140 S0\nM107\nM220 S100\nM84\n\n;\n; DON'T REMOVE these lines if you're using the smfix (https://github.com/macdylan/SMFix)\n; min_x = [first_layer_print_min_0]\n; min_y = [first_layer_print_min_1]\n; max_x = [first_layer_print_max_0]\n; max_y = [first_layer_print_max_1]\n; max_z = [max_layer_z]\n; total_layer_number = [layer_num]\n;",
"change_filament_gcode": ";***** Update: 20240823\n{if current_extruder != next_extruder}\n; Change T[current_extruder] -> T[next_extruder] (layer [layer_num]\n; layer\nT{next_extruder}\n\n{if layer_num == 1 &&\n ((filament_type[current_extruder] == \"PLA\" || filament_type[current_extruder] == \"TPU\")\n || (filament_type[next_extruder] == \"PLA\" || filament_type[next_extruder] == \"TPU\"))\n}\n ; set bed temp: {filament_type[current_extruder]}({bed_temperature[current_extruder]}) -> {filament_type[next_extruder]}({bed_temperature[next_extruder]})\n M140 S{min(bed_temperature[current_extruder], bed_temperature[next_extruder])}\n{endif}\n\nM109 T[next_extruder] S{if layer_num < 1}[nozzle_temperature_initial_layer]{else}[nozzle_temperature]{endif} C3 W1 ;wait T[next_extruder]\n{if layer_num == 1}\n G1 E{retraction_length[next_extruder]} F200;deretract\n{endif}\n\n{if layer_z > first_layer_height && layer_num >= close_fan_the_first_x_layers[next_extruder]}\n; M106 P[next_extruder] S{fan_min_speed[next_extruder] * 255.0 / 100.0} ;restore fan speed for T[next_extruder]\n{endif}\n; End Toolchange\n{endif}",
"change_filament_gcode": ";***** Update: 20230923\n{if current_extruder != next_extruder}\n; {if (next_wipe_x > 0) || (next_wipe_y > 0)}\n; use wipeTower\n; move to wipeTower before changing tool\nG0 X[next_wipe_x] Y[next_wipe_y]\n{endif}\n Change T[current_extruder] -> T[next_extruder] (layer [layer_num]\n; layer\nT{next_extruder}\n\nM107 P[current_extruder] ;fan off T[current_extruder]\n\n{if layer_num == 1 &&\n ((filament_type[current_extruder] == \"PLA\" || filament_type[current_extruder] == \"TPU\")\n || (filament_type[next_extruder] == \"PLA\" || filament_type[next_extruder] == \"TPU\"))\n}\n ; set bed temp: {filament_type[current_extruder]}({bed_temperature[current_extruder]}) -> {filament_type[next_extruder]}({bed_temperature[next_extruder]})\n M140 S{min(bed_temperature[current_extruder], bed_temperature[next_extruder])}\n{endif}\n\nM109 T[next_extruder] S{if layer_num < 1}[nozzle_temperature_initial_layer]{else}[nozzle_temperature]{endif} C3 W1 ;wait T[next_extruder]\n{if layer_num == 1}\n G1 E{retraction_length[next_extruder]} F200;deretract\n{endif}\n\n{if layer_z > first_layer_height && layer_num >= close_fan_the_first_x_layers[next_extruder]}\n; M106 P[next_extruder] S{fan_min_speed[next_extruder] * 255.0 / 100.0} ;restore fan speed for T[next_extruder]\n{endif}\n; End Toolchange\n{endif}",
"before_layer_change_gcode": "; layer_num: [layer_num]\nG92 E0"
}
8 changes: 7 additions & 1 deletion src/libslic3r/GCode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,11 @@ static std::vector<Vec2d> get_path_of_change_filament(const Print& print)
float wipe_tower_rotation = tcr.priming ? 0.f : alpha;
Vec2f plate_origin_2d(m_plate_origin(0), m_plate_origin(1));

// Record the position that is about to wipe.
auto transformed_pos = Eigen::Rotation2Df(wipe_tower_rotation) * tcr.start_pos + wipe_tower_offset;
gcodegen.m_next_wipe_x = transformed_pos(0);
gcodegen.m_next_wipe_y = transformed_pos(1);


std::string tcr_rotated_gcode = post_process_wipe_tower_moves(tcr, wipe_tower_offset, wipe_tower_rotation);

Expand Down Expand Up @@ -6387,7 +6392,8 @@ std::string GCode::set_extruder(unsigned int extruder_id, double print_z, bool b
dyn_config.set_key_value("travel_point_3_y", new ConfigOptionFloat(float(travel_point_3.y())));

dyn_config.set_key_value("flush_length", new ConfigOptionFloat(wipe_length));

dyn_config.set_key_value("next_wipe_x", new ConfigOptionFloat(m_next_wipe_x));
dyn_config.set_key_value("next_wipe_y", new ConfigOptionFloat(m_next_wipe_y));
int flush_count = std::min(g_max_flush_count, (int)std::round(wipe_volume / g_purge_volume_one_time));
float flush_unit = wipe_length / flush_count;
int flush_idx = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/libslic3r/GCode.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ class GCode {
float m_last_layer_z{ 0.0f };
float m_max_layer_z{ 0.0f };
float m_last_width{ 0.0f };
float m_next_wipe_x {0.0f};
float m_next_wipe_y {0.0f};
#if ENABLE_GCODE_VIEWER_DATA_CHECKING
double m_last_mm3_per_mm;
#endif // ENABLE_GCODE_VIEWER_DATA_CHECKING
Expand Down
5 changes: 3 additions & 2 deletions src/libslic3r/PrintConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7723,7 +7723,7 @@ static std::map<t_custom_gcode_key, t_config_option_keys> s_CustomGcodeSpecificP
"new_retract_length_toolchange", "old_filament_e_feedrate", "old_filament_temp", "old_retract_length",
"old_retract_length_toolchange", "relative_e_axis", "second_flush_volume", "toolchange_count", "toolchange_z",
"travel_point_1_x", "travel_point_1_y", "travel_point_2_x", "travel_point_2_y", "travel_point_3_x",
"travel_point_3_y", "x_after_toolchange", "y_after_toolchange", "z_after_toolchange"}},
"travel_point_3_y", "x_after_toolchange", "y_after_toolchange", "z_after_toolchange", "next_wipe_x", "next_wipe_y"}},
{"change_extrusion_role_gcode", {"layer_num", "layer_z", "extrusion_role", "last_extrusion_role"}},
{"printing_by_object_gcode", {}},
{"machine_pause_gcode", {}},
Expand Down Expand Up @@ -7788,7 +7788,8 @@ CustomGcodeSpecificConfigDef::CustomGcodeSpecificConfigDef()
new_def("flush_length_2", coFloat, "Flush Length 2", "The second flush length");
new_def("flush_length_3", coFloat, "Flush Length 3", "The third flush length");
new_def("flush_length_4", coFloat, "Flush Length 4", "The fourth flush length");

new_def("next_wipe_x", coFloat, "Next Wipe X", "For Snapmaker Artision, next x after toolchange");
new_def("next_wipe_y", coFloat, "Next Wipe Y", "For Snapmaker Artision, next y after toolchange");
// change_extrusion_role_gcode
std::string extrusion_role_types = "Possible Values:\n[\"Perimeter\", \"ExternalPerimeter\", "
"\"OverhangPerimeter\", \"InternalInfill\", \"SolidInfill\", \"TopSolidInfill\", \"BottomSurface\", \"BridgeInfill\", \"GapFill\", \"Ironing\", "
Expand Down