Wipe tower uses correct gcodes for RepRap gcode flavor (M907->M906, M900->M572 - should fix #1843)

Also, fixed proper setting of the extruder current during toolchange (was broken since 6da83c7)
This commit is contained in:
Lukas Matena 2019-04-24 12:01:57 +02:00
parent 7185125f9c
commit 08cb5bc2c7
4 changed files with 20 additions and 13 deletions

View File

@ -184,7 +184,7 @@ std::string WipeTowerIntegration::append_tcr(GCode &gcodegen, const WipeTower::T
// Disable linear advance for the wipe tower operations.
gcode += "M900 K0\n";
gcode += (gcodegen.config().gcode_flavor == gcfRepRap ? std::string("M572 D0 S0\n") : std::string("M900 K0\n"));
// Move over the wipe tower.
// Retract for a tool change, using the toolchange retract value and setting the priming extra length.
gcode += gcodegen.retract(true);
@ -289,7 +289,7 @@ std::string WipeTowerIntegration::prime(GCode &gcodegen)
if (&m_priming != nullptr && ! m_priming.extrusions.empty()) {
// Disable linear advance for the wipe tower operations.
gcode += "M900 K0\n";
gcode += (gcodegen.config().gcode_flavor == gcfRepRap ? std::string("M572 D0 S0\n") : std::string("M900 K0\n"));
// Let the tool change be executed by the wipe tower class.
// Inform the G-code writer about the changes done behind its back.
gcode += m_priming.gcode;

View File

@ -40,7 +40,7 @@ namespace PrusaMultiMaterial {
class Writer
{
public:
Writer(float layer_height, float line_width) :
Writer(float layer_height, float line_width, GCodeFlavor flavor) :
m_current_pos(std::numeric_limits<float>::max(), std::numeric_limits<float>::max()),
m_current_z(0.f),
m_current_feedrate(0.f),
@ -48,7 +48,8 @@ public:
m_extrusion_flow(0.f),
m_preview_suppressed(false),
m_elapsed_time(0.f),
m_default_analyzer_line_width(line_width)
m_default_analyzer_line_width(line_width),
m_gcode_flavor(flavor)
{
// adds tag for analyzer:
char buf[64];
@ -333,7 +334,10 @@ public:
Writer& set_extruder_trimpot(int current)
{
char buf[128];
sprintf(buf, "M907 E%d\n", current);
if (m_gcode_flavor == gcfRepRap)
sprintf(buf, "M906 E%d\n", current);
else
sprintf(buf, "M907 E%d\n", current);
m_gcode += buf;
return *this;
};
@ -407,6 +411,7 @@ private:
int current_temp = -1;
const float m_default_analyzer_line_width;
float m_used_filament_length = 0.f;
GCodeFlavor m_gcode_flavor;
std::string set_format_X(float x)
{
@ -510,7 +515,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::prime(
const float prime_section_width = std::min(240.f / tools.size(), 60.f);
box_coordinates cleaning_box(xy(5.f, 0.01f + m_perimeter_width/2.f), prime_section_width, 100.f);
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width, m_gcode_flavor);
writer.set_extrusion_flow(m_extrusion_flow)
.set_z(m_z_pos)
.set_initial_tool(m_current_tool)
@ -612,7 +617,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
(tool != (unsigned int)(-1) ? /*m_layer_info->depth*/wipe_area+m_depth_traversed-0.5*m_perimeter_width
: m_wipe_tower_depth-m_perimeter_width));
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width, m_gcode_flavor);
writer.set_extrusion_flow(m_extrusion_flow)
.set_z(m_z_pos)
.set_initial_tool(m_current_tool)
@ -631,7 +636,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::tool_change(unsigned int tool, boo
// Increase the extruder driver current to allow fast ramming.
if (m_set_extruder_trimpot)
writer.set_extruder_trimpot(550);
writer.set_extruder_trimpot(750);
// Ram the hot material out of the melt zone, retract the filament into the cooling tubes and let it cool.
if (tool != (unsigned int)-1){ // This is not the last change.
@ -693,7 +698,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::toolchange_Brim(bool sideOnly, flo
m_wipe_tower_width,
m_wipe_tower_depth);
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width, m_gcode_flavor);
writer.set_extrusion_flow(m_extrusion_flow * 1.1f)
.set_z(m_z_pos) // Let the writer know the current Z position as a base for Z-hop.
.set_initial_tool(m_current_tool)
@ -1022,7 +1027,7 @@ WipeTower::ToolChangeResult WipeTowerPrusaMM::finish_layer()
// Otherwise the caller would likely travel to the wipe tower in vain.
assert(! this->layer_finished());
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width);
PrusaMultiMaterial::Writer writer(m_layer_height, m_perimeter_width, m_gcode_flavor);
writer.set_extrusion_flow(m_extrusion_flow)
.set_z(m_z_pos)
.set_initial_tool(m_current_tool)

View File

@ -8,6 +8,7 @@
#include <algorithm>
#include "WipeTower.hpp"
#include "PrintConfig.hpp"
namespace Slic3r
@ -46,7 +47,7 @@ public:
// wipe_area -- space available for one toolchange in mm
WipeTowerPrusaMM(float x, float y, float width, float rotation_angle, float cooling_tube_retraction,
float cooling_tube_length, float parking_pos_retraction, float extra_loading_move,
float bridging, bool set_extruder_trimpot,
float bridging, bool set_extruder_trimpot, GCodeFlavor flavor,
const std::vector<std::vector<float>>& wiping_matrix, unsigned int initial_tool) :
m_wipe_tower_pos(x, y),
m_wipe_tower_width(width),
@ -60,6 +61,7 @@ public:
m_extra_loading_move(extra_loading_move),
m_bridging(bridging),
m_set_extruder_trimpot(set_extruder_trimpot),
m_gcode_flavor(flavor),
m_current_tool(initial_tool),
wipe_volumes(wiping_matrix)
{}
@ -223,6 +225,7 @@ private:
bool m_set_extruder_trimpot = false;
bool m_retain_speed_override = true;
bool m_adhesion = true;
GCodeFlavor m_gcode_flavor;
float m_perimeter_width = 0.4f * Width_To_Nozzle_Ratio; // Width of an extrusion line, also a perimeter spacing for 100% infill.
float m_extrusion_flow = 0.038f; //0.029f;// Extrusion flow is derived from m_perimeter_width, layer height and filament diameter.

View File

@ -126,7 +126,6 @@ bool Print::invalidate_state_by_config_options(const std::vector<t_config_option
"first_layer_bed_temperature",
"first_layer_speed",
"gcode_comments",
"gcode_flavor",
"gcode_label_objects",
"infill_acceleration",
"layer_gcode",
@ -1777,7 +1776,7 @@ void Print::_make_wipe_tower()
float(m_config.wipe_tower_rotation_angle.value), float(m_config.cooling_tube_retraction.value),
float(m_config.cooling_tube_length.value), float(m_config.parking_pos_retraction.value),
float(m_config.extra_loading_move.value), float(m_config.wipe_tower_bridging),
m_config.high_current_on_filament_swap.value, wipe_volumes,
m_config.high_current_on_filament_swap.value, m_config.gcode_flavor, wipe_volumes,
m_wipe_tower_data.tool_ordering.first_extruder());
//wipe_tower.set_retract();