Slic3r has been modified to propagate the following filament specific

values to GCode generator, one per active extruder:

bed_temperature
bridge_fan_speed
cooling
disable_fan_first_layers
fan_always_on
fan_below_layer_time
first_layer_bed_temperature
max_fan_speed
min_fan_speed
min_print_speed
slowdown_below_layer_time

Now it remains to extend Slic3r to correctly apply these values.
This commit is contained in:
bubnikv 2017-06-21 16:15:39 +02:00
parent 0bd2bb1e8e
commit f0325575c2
16 changed files with 180 additions and 135 deletions

View file

@ -445,14 +445,14 @@ bool GCode::do_export(FILE *file, Print &print)
m_placeholder_parser.update_timestamp();
// Disable fan.
if (print.config.cooling.value && print.config.disable_fan_first_layers.value)
if (print.config.cooling.values.front() && print.config.disable_fan_first_layers.values.front())
write(file, m_writer.set_fan(0, true));
// Set bed temperature if the start G-code does not contain any bed temp control G-codes.
if (print.config.first_layer_bed_temperature.value > 0 &&
if (print.config.first_layer_bed_temperature.values.front() > 0 &&
boost::ifind_first(print.config.start_gcode.value, std::string("M140")).empty() &&
boost::ifind_first(print.config.start_gcode.value, std::string("M190")).empty())
write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature.value, true));
write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature.values.front(), true));
// Get optimal tool ordering to minimize tool switches of a multi-exruder print.
// For a print by objects, find the 1st printing object.
@ -582,8 +582,8 @@ bool GCode::do_export(FILE *file, Print &print)
// Ff we are printing the bottom layer of an object, and we have already finished
// another one, set first layer temperatures. This happens before the Z move
// is triggered, so machine has more time to reach such temperatures.
if (print.config.first_layer_bed_temperature.value > 0)
write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature));
if (print.config.first_layer_bed_temperature.values.front() > 0)
write(file, m_writer.set_bed_temperature(print.config.first_layer_bed_temperature.values.front()));
// Set first layer extruder.
this->_print_first_layer_extruder_temperatures(file, print, initial_extruder_id, false);
}
@ -819,8 +819,8 @@ void GCode::process_layer(
if (temperature > 0 && temperature != print.config.first_layer_temperature.get_at(extruder.id))
gcode += m_writer.set_temperature(temperature, false, extruder.id);
}
if (print.config.bed_temperature.value > 0 && print.config.bed_temperature != print.config.first_layer_bed_temperature.value)
gcode += m_writer.set_bed_temperature(print.config.bed_temperature);
if (print.config.bed_temperature.values.front() > 0 && print.config.bed_temperature.values.front() != print.config.first_layer_bed_temperature.values.front())
gcode += m_writer.set_bed_temperature(print.config.bed_temperature.values.front());
// Mark the temperature transition from 1st to 2nd layer to be finished.
m_second_layer_things_done = true;
}
@ -1861,7 +1861,7 @@ std::string GCode::_extrude(const ExtrusionPath &path, std::string description,
this->set_last_pos(path.last_point());
if (m_config.cooling)
if (m_config.cooling.values.front())
m_elapsed_time += path_length / F * 60.f;
return gcode;
@ -1913,7 +1913,7 @@ std::string GCode::travel_to(const Point &point, ExtrusionRole role, std::string
factor on the whole elapsed time but only alters non-travel moves, thus the resulting
time is still shorter than the configured threshold. We could create a new
elapsed_travel_time but we would still need to account for bridges, retractions, wipe etc.
if (m_config.cooling)
if (m_config.cooling.values.front())
m_elapsed_time += unscale(travel.length()) / m_config.get_abs_value("travel_speed");
*/

View file

@ -59,25 +59,25 @@ std::string CoolingBuffer::flush()
m_gcode.clear();
m_elapsed_time = 0.;
int fan_speed = config.fan_always_on ? config.min_fan_speed.value : 0;
int fan_speed = config.fan_always_on.values.front() ? config.min_fan_speed.values.front() : 0;
float speed_factor = 1.0;
if (config.cooling) {
if (config.cooling.values.front()) {
#ifdef SLIC3R_DEBUG
printf("Layer %zu estimated printing time: %f seconds\n", m_layer_id, elapsed);
#endif
if (elapsed < (float)config.slowdown_below_layer_time) {
if (elapsed < (float)config.slowdown_below_layer_time.values.front()) {
// Layer time very short. Enable the fan to a full throttle and slow down the print
// (stretch the layer print time to slowdown_below_layer_time).
fan_speed = config.max_fan_speed;
speed_factor = elapsed / (float)config.slowdown_below_layer_time;
} else if (elapsed < (float)config.fan_below_layer_time) {
fan_speed = config.max_fan_speed.values.front();
speed_factor = elapsed / (float)config.slowdown_below_layer_time.values.front();
} else if (elapsed < (float)config.fan_below_layer_time.values.front()) {
// Layer time quite short. Enable the fan proportionally according to the current layer time.
fan_speed = config.max_fan_speed
- (config.max_fan_speed - config.min_fan_speed)
* (elapsed - (float)config.slowdown_below_layer_time)
/ (config.fan_below_layer_time - config.slowdown_below_layer_time);
fan_speed = config.max_fan_speed.values.front()
- (config.max_fan_speed.values.front() - config.min_fan_speed.values.front())
* (elapsed - (float)config.slowdown_below_layer_time.values.front())
/ (config.fan_below_layer_time.values.front() - config.slowdown_below_layer_time.values.front());
}
#ifdef SLIC3R_DEBUG
@ -92,7 +92,7 @@ std::string CoolingBuffer::flush()
std::istringstream ss(gcode);
std::string line;
bool bridge_fan_start = false;
float min_print_speed = float(config.min_print_speed * 60.);
float min_print_speed = float(config.min_print_speed.values.front() * 60.);
while (std::getline(ss, line)) {
if (boost::starts_with(line, "G1")
&& boost::contains(line, ";_EXTRUDE_SET_SPEED")
@ -107,17 +107,17 @@ std::string CoolingBuffer::flush()
gcode = new_gcode;
}
}
if (m_layer_id < config.disable_fan_first_layers)
if (m_layer_id < config.disable_fan_first_layers.values.front())
fan_speed = 0;
gcode = m_gcodegen.writer().set_fan(fan_speed) + gcode;
// bridge fan speed
if (!config.cooling || config.bridge_fan_speed == 0 || m_layer_id < config.disable_fan_first_layers) {
if (!config.cooling.values.front() || config.bridge_fan_speed.values.front() == 0 || m_layer_id < config.disable_fan_first_layers.values.front()) {
boost::replace_all(gcode, ";_BRIDGE_FAN_START", "");
boost::replace_all(gcode, ";_BRIDGE_FAN_END", "");
} else {
boost::replace_all(gcode, ";_BRIDGE_FAN_START", m_gcodegen.writer().set_fan(config.bridge_fan_speed, true));
boost::replace_all(gcode, ";_BRIDGE_FAN_START", m_gcodegen.writer().set_fan(config.bridge_fan_speed.values.front(), true));
boost::replace_all(gcode, ";_BRIDGE_FAN_END", m_gcodegen.writer().set_fan(fan_speed, true));
}
boost::replace_all(gcode, ";_WIPE", "");

View file

@ -26,14 +26,18 @@ PrintConfigDef::PrintConfigDef()
def->default_value = opt;
}
def = this->add("bed_temperature", coInt);
def = this->add("bed_temperature", coInts);
def->label = "Other layers";
def->tooltip = "Bed temperature for layers after the first one. Set this to zero to disable bed temperature control commands in the output.";
def->cli = "bed-temperature=i";
def->cli = "bed-temperature=i@";
def->full_label = "Bed temperature";
def->min = 0;
def->max = 300;
def->default_value = new ConfigOptionInt(0);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(0);
def->default_value = opt;
}
def = this->add("before_layer_gcode", coString);
def->label = "Before layer change G-code";
@ -61,14 +65,18 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionFloat(0);
def = this->add("bridge_fan_speed", coInt);
def = this->add("bridge_fan_speed", coInts);
def->label = "Bridges fan speed";
def->tooltip = "This fan speed is enforced during all bridges and overhangs.";
def->sidetext = "%";
def->cli = "bridge-fan-speed=i";
def->cli = "bridge-fan-speed=i@";
def->min = 0;
def->max = 100;
def->default_value = new ConfigOptionInt(100);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(100);
def->default_value = opt;
}
def = this->add("bridge_flow_ratio", coFloat);
def->label = "Bridge flow ratio";
@ -108,11 +116,15 @@ PrintConfigDef::PrintConfigDef()
def->cli = "complete-objects!";
def->default_value = new ConfigOptionBool(false);
def = this->add("cooling", coBool);
def = this->add("cooling", coBools);
def->label = "Enable auto cooling";
def->tooltip = "This flag enables the automatic cooling logic that adjusts print speed and fan speed according to layer printing time.";
def->cli = "cooling!";
def->default_value = new ConfigOptionBool(true);
{
ConfigOptionBools* opt = new ConfigOptionBools();
opt->values.push_back(true);
def->default_value = opt;
}
def = this->add("default_acceleration", coFloat);
def->label = "Default";
@ -122,14 +134,18 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionFloat(0);
def = this->add("disable_fan_first_layers", coInt);
def = this->add("disable_fan_first_layers", coInts);
def->label = "Disable fan for the first";
def->tooltip = "You can set this to a positive value to disable fan at all during the first layers, so that it does not make adhesion worse.";
def->sidetext = "layers";
def->cli = "disable-fan-first-layers=i";
def->cli = "disable-fan-first-layers=i@";
def->min = 0;
def->max = 1000;
def->default_value = new ConfigOptionInt(3);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(3);
def->default_value = opt;
}
def = this->add("dont_support_bridges", coBool);
def->label = "Don't support bridges";
@ -304,21 +320,29 @@ PrintConfigDef::PrintConfigDef()
def->cli = "extrusion-width=s";
def->default_value = new ConfigOptionFloatOrPercent(0, false);
def = this->add("fan_always_on", coBool);
def = this->add("fan_always_on", coBools);
def->label = "Keep fan always on";
def->tooltip = "If this is enabled, fan will never be disabled and will be kept running at least at its minimum speed. Useful for PLA, harmful for ABS.";
def->cli = "fan-always-on!";
def->default_value = new ConfigOptionBool(false);
{
ConfigOptionBools* opt = new ConfigOptionBools();
opt->values.push_back(false);
def->default_value = opt;
}
def = this->add("fan_below_layer_time", coInt);
def = this->add("fan_below_layer_time", coInts);
def->label = "Enable fan if layer print time is below";
def->tooltip = "If layer print time is estimated below this number of seconds, fan will be enabled and its speed will be calculated by interpolating the minimum and maximum speeds.";
def->sidetext = "approximate seconds";
def->cli = "fan-below-layer-time=i";
def->cli = "fan-below-layer-time=i@";
def->width = 60;
def->min = 0;
def->max = 1000;
def->default_value = new ConfigOptionInt(60);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(60);
def->default_value = opt;
}
def = this->add("filament_colour", coStrings);
def->label = "Color";
@ -516,13 +540,17 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionFloat(0);
def = this->add("first_layer_bed_temperature", coInt);
def = this->add("first_layer_bed_temperature", coInts);
def->label = "First layer";
def->tooltip = "Heated build plate temperature for the first layer. Set this to zero to disable bed temperature control commands in the output.";
def->cli = "first-layer-bed-temperature=i";
def->cli = "first-layer-bed-temperature=i@";
def->max = 0;
def->max = 300;
def->default_value = new ConfigOptionInt(0);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(0);
def->default_value = opt;
}
def = this->add("first_layer_extrusion_width", coFloatOrPercent);
def->label = "First layer";
@ -694,14 +722,18 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionFloat(0.3);
def = this->add("max_fan_speed", coInt);
def = this->add("max_fan_speed", coInts);
def->label = "Max";
def->tooltip = "This setting represents the maximum speed of your fan.";
def->sidetext = "%";
def->cli = "max-fan-speed=i";
def->cli = "max-fan-speed=i@";
def->min = 0;
def->max = 100;
def->default_value = new ConfigOptionInt(100);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(100);
def->default_value = opt;
}
def = this->add("max_layer_height", coFloats);
def->label = "Max";
@ -749,14 +781,18 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionFloat(0);
def = this->add("min_fan_speed", coInt);
def = this->add("min_fan_speed", coInts);
def->label = "Min";
def->tooltip = "This setting represents the minimum PWM your fan needs to work.";
def->sidetext = "%";
def->cli = "min-fan-speed=i";
def->cli = "min-fan-speed=i@";
def->min = 0;
def->max = 100;
def->default_value = new ConfigOptionInt(35);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(35);
def->default_value = opt;
}
def = this->add("min_layer_height", coFloats);
def->label = "Min";
@ -770,13 +806,17 @@ PrintConfigDef::PrintConfigDef()
def->default_value = opt;
}
def = this->add("min_print_speed", coFloat);
def = this->add("min_print_speed", coFloats);
def->label = "Min print speed";
def->tooltip = "Slic3r will not scale speed down below this speed.";
def->sidetext = "mm/s";
def->cli = "min-print-speed=f";
def->cli = "min-print-speed=f@";
def->min = 0;
def->default_value = new ConfigOptionFloat(10);
{
ConfigOptionFloats* opt = new ConfigOptionFloats();
opt->values.push_back(10.);
def->default_value = opt;
}
def = this->add("min_skirt_length", coFloat);
def->label = "Minimum extrusion length";
@ -1151,15 +1191,19 @@ PrintConfigDef::PrintConfigDef()
def->min = 0;
def->default_value = new ConfigOptionInt(1);
def = this->add("slowdown_below_layer_time", coInt);
def = this->add("slowdown_below_layer_time", coInts);
def->label = "Slow down if layer print time is below";
def->tooltip = "If layer print time is estimated below this number of seconds, print moves speed will be scaled down to extend duration to this value.";
def->sidetext = "approximate seconds";
def->cli = "slowdown-below-layer-time=i";
def->cli = "slowdown-below-layer-time=i@";
def->width = 60;
def->min = 0;
def->max = 1000;
def->default_value = new ConfigOptionInt(5);
{
ConfigOptionInts* opt = new ConfigOptionInts();
opt->values.push_back(5);
def->default_value = opt;
}
def = this->add("small_perimeter_speed", coFloatOrPercent);
def->label = "Small perimeters";

View file

@ -425,35 +425,35 @@ class PrintConfig : public GCodeConfig
public:
ConfigOptionBool avoid_crossing_perimeters;
ConfigOptionPoints bed_shape;
ConfigOptionInt bed_temperature;
ConfigOptionInts bed_temperature;
ConfigOptionFloat bridge_acceleration;
ConfigOptionInt bridge_fan_speed;
ConfigOptionInts bridge_fan_speed;
ConfigOptionFloat brim_width;
ConfigOptionBool complete_objects;
ConfigOptionBool cooling;
ConfigOptionBools cooling;
ConfigOptionFloat default_acceleration;
ConfigOptionInt disable_fan_first_layers;
ConfigOptionInts disable_fan_first_layers;
ConfigOptionFloat duplicate_distance;
ConfigOptionFloat extruder_clearance_height;
ConfigOptionFloat extruder_clearance_radius;
ConfigOptionStrings extruder_colour;
ConfigOptionPoints extruder_offset;
ConfigOptionBool fan_always_on;
ConfigOptionInt fan_below_layer_time;
ConfigOptionBools fan_always_on;
ConfigOptionInts fan_below_layer_time;
ConfigOptionStrings filament_colour;
ConfigOptionStrings filament_notes;
ConfigOptionFloat first_layer_acceleration;
ConfigOptionInt first_layer_bed_temperature;
ConfigOptionInts first_layer_bed_temperature;
ConfigOptionFloatOrPercent first_layer_extrusion_width;
ConfigOptionFloatOrPercent first_layer_speed;
ConfigOptionInts first_layer_temperature;
ConfigOptionFloat infill_acceleration;
ConfigOptionBool infill_first;
ConfigOptionInt max_fan_speed;
ConfigOptionInts max_fan_speed;
ConfigOptionFloats max_layer_height;
ConfigOptionInt min_fan_speed;
ConfigOptionInts min_fan_speed;
ConfigOptionFloats min_layer_height;
ConfigOptionFloat min_print_speed;
ConfigOptionFloats min_print_speed;
ConfigOptionFloat min_skirt_length;
ConfigOptionString notes;
ConfigOptionFloats nozzle_diameter;
@ -469,7 +469,7 @@ public:
ConfigOptionFloat skirt_distance;
ConfigOptionInt skirt_height;
ConfigOptionInt skirts;
ConfigOptionInt slowdown_below_layer_time;
ConfigOptionInts slowdown_below_layer_time;
ConfigOptionBool spiral_vase;
ConfigOptionInt standby_temperature_delta;
ConfigOptionInts temperature;