mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-14 08:36:00 +08:00
#318 set travel acceleration
- now gocde-accel will try to change only the printing accel on the fly (for marlin and repetier only)
This commit is contained in:
parent
87840d0f7f
commit
65b3dd835a
@ -845,6 +845,7 @@ namespace DoExport {
|
||||
if (config.gcode_flavor.value == gcfMarlin || config.gcode_flavor.value == gcfLerdge) {
|
||||
normal_time_estimator.set_max_acceleration((float)config.machine_max_acceleration_extruding.values[0]);
|
||||
normal_time_estimator.set_retract_acceleration((float)config.machine_max_acceleration_retracting.values[0]);
|
||||
normal_time_estimator.set_max_travel_acceleration((float)config.machine_max_acceleration_travel.values[0]);
|
||||
normal_time_estimator.set_minimum_feedrate((float)config.machine_min_extruding_rate.values[0]);
|
||||
normal_time_estimator.set_minimum_travel_feedrate((float)config.machine_min_travel_rate.values[0]);
|
||||
normal_time_estimator.set_axis_max_acceleration(GCodeTimeEstimator::X, (float)config.machine_max_acceleration_x.values[0]);
|
||||
@ -1755,11 +1756,11 @@ void GCode::print_machine_envelope(FILE *file, Print &print)
|
||||
fprintf(file, "M204 P%d R%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n",
|
||||
int(print.config().machine_max_acceleration_extruding.values.front() + 0.5),
|
||||
int(print.config().machine_max_acceleration_retracting.values.front() + 0.5),
|
||||
int(print.config().machine_max_acceleration_extruding.values.front() + 0.5));
|
||||
int(print.config().machine_max_acceleration_travel.values.front() + 0.5));
|
||||
if (std::set<uint8_t>{gcfRepRap, gcfKlipper}.count(print.config().gcode_flavor.value) > 0)
|
||||
fprintf(file, "M204 P%d T%d ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2\n",
|
||||
fprintf(file, "M204 P%d T%d ; sets acceleration (P, T), mm/sec^2\n",
|
||||
int(print.config().machine_max_acceleration_extruding.values.front() + 0.5),
|
||||
int(print.config().machine_max_acceleration_retracting.values.front() + 0.5));
|
||||
int(print.config().machine_max_acceleration_travel.values.front() + 0.5));
|
||||
if (std::set<uint8_t>{gcfMarlin, gcfLerdge, gcfRepetier}.count(print.config().gcode_flavor.value) > 0)
|
||||
fprintf(file, "M566 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n",
|
||||
print.config().machine_max_jerk_x.values.front(),
|
||||
@ -3827,7 +3828,7 @@ std::string GCode::_before_extrude(const ExtrusionPath &path, const std::string
|
||||
acceleration = m_config.infill_acceleration.value;
|
||||
} else {
|
||||
acceleration = m_config.default_acceleration.value;
|
||||
}
|
||||
}//TODO: add travel accel?
|
||||
gcode += m_writer.set_acceleration((unsigned int)floor(acceleration + 0.5));
|
||||
}
|
||||
|
||||
|
@ -496,6 +496,31 @@ namespace Slic3r {
|
||||
return m_state.max_acceleration;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_max_travel_acceleration(float acceleration_mm_sec2)
|
||||
{
|
||||
m_state.max_travel_acceleration = acceleration_mm_sec2;
|
||||
if (acceleration_mm_sec2 > 0)
|
||||
m_state.travel_acceleration = acceleration_mm_sec2;
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::get_max_travel_acceleration() const
|
||||
{
|
||||
return m_state.max_travel_acceleration;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_travel_acceleration(float acceleration_mm_sec2)
|
||||
{
|
||||
m_state.travel_acceleration = (m_state.max_travel_acceleration == 0) ?
|
||||
acceleration_mm_sec2 :
|
||||
// Clamp the acceleration with the maximum.
|
||||
std::min(m_state.max_travel_acceleration, acceleration_mm_sec2);
|
||||
}
|
||||
|
||||
float GCodeTimeEstimator::get_travel_acceleration() const
|
||||
{
|
||||
return m_state.travel_acceleration;
|
||||
}
|
||||
|
||||
void GCodeTimeEstimator::set_retract_acceleration(float acceleration_mm_sec2)
|
||||
{
|
||||
m_state.retract_acceleration = acceleration_mm_sec2;
|
||||
@ -670,7 +695,9 @@ namespace Slic3r {
|
||||
// Setting the maximum acceleration to zero means that the there is no limit and the G-code
|
||||
// is allowed to set excessive values.
|
||||
set_max_acceleration(0);
|
||||
set_max_travel_acceleration(0);
|
||||
set_acceleration(DEFAULT_ACCELERATION);
|
||||
set_travel_acceleration(DEFAULT_ACCELERATION);
|
||||
set_retract_acceleration(DEFAULT_RETRACT_ACCELERATION);
|
||||
set_minimum_feedrate(DEFAULT_MINIMUM_FEEDRATE);
|
||||
set_minimum_travel_feedrate(DEFAULT_MINIMUM_TRAVEL_FEEDRATE);
|
||||
@ -1087,7 +1114,7 @@ namespace Slic3r {
|
||||
}
|
||||
|
||||
// calculates block acceleration
|
||||
float acceleration = block.is_extruder_only_move() ? get_retract_acceleration() : get_acceleration();
|
||||
float acceleration = block.is_extruder_only_move() ? get_retract_acceleration() : block.is_travel_move() ? get_travel_acceleration() : get_acceleration();
|
||||
|
||||
for (unsigned char a = X; a < Num_Axis; ++a)
|
||||
{
|
||||
@ -1406,8 +1433,7 @@ namespace Slic3r {
|
||||
set_retract_acceleration(value);
|
||||
if (line.has_value('T', value)) {
|
||||
// Interpret the T value as the travel acceleration in the new Marlin format.
|
||||
//FIXME Prusa3D firmware currently does not support travel acceleration value independent from the extruding acceleration value.
|
||||
// set_travel_acceleration(value);
|
||||
set_travel_acceleration(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,6 +84,9 @@ namespace Slic3r {
|
||||
float acceleration; // mm/s^2
|
||||
// hard limit for the acceleration, to which the firmware will clamp.
|
||||
float max_acceleration; // mm/s^2
|
||||
float travel_acceleration; // mm/s^2
|
||||
// hard limit for the travel_acceleration, to which the firmware will clamp.
|
||||
float max_travel_acceleration; // mm/s^2
|
||||
float retract_acceleration; // mm/s^2
|
||||
float additional_time; // s
|
||||
float minimum_feedrate; // mm/s
|
||||
@ -327,6 +330,13 @@ namespace Slic3r {
|
||||
void set_max_acceleration(float acceleration_mm_sec2);
|
||||
float get_max_acceleration() const;
|
||||
|
||||
void set_travel_acceleration(float acceleration_mm_sec2);
|
||||
float get_travel_acceleration() const;
|
||||
|
||||
// Maximum acceleration for the machine. The firmware simulator will clamp the M204 Txxx to this maximum.
|
||||
void set_max_travel_acceleration(float acceleration_mm_sec2);
|
||||
float get_max_travel_acceleration() const;
|
||||
|
||||
void set_retract_acceleration(float acceleration_mm_sec2);
|
||||
float get_retract_acceleration() const;
|
||||
|
||||
|
@ -61,7 +61,7 @@ std::string GCodeWriter::preamble()
|
||||
gcode << "G21 ; set units to millimeters\n";
|
||||
gcode << "G90 ; use absolute coordinates\n";
|
||||
}
|
||||
if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)
|
||||
if (FLAVOR_IS(gcfRepRap) || FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfLerdge) || FLAVOR_IS(gcfTeacup) || FLAVOR_IS(gcfRepetier) || FLAVOR_IS(gcfSmoothie)
|
||||
|| FLAVOR_IS(gcfKlipper) || FLAVOR_IS(gcfLerdge)) {
|
||||
if (this->config.use_relative_e_distances) {
|
||||
gcode << "M83 ; use relative distances for extrusion\n";
|
||||
@ -200,13 +200,13 @@ std::string GCodeWriter::set_acceleration(unsigned int acceleration)
|
||||
m_last_acceleration = acceleration;
|
||||
|
||||
std::ostringstream gcode;
|
||||
//try to set only printing acceleration, travel should be untouched if possible
|
||||
if (FLAVOR_IS(gcfRepetier)) {
|
||||
// M201: Set max printing acceleration
|
||||
gcode << "M201 X" << acceleration << " Y" << acceleration;
|
||||
if (this->config.gcode_comments) gcode << " ; adjust acceleration";
|
||||
gcode << "\n";
|
||||
// M202: Set max travel acceleration
|
||||
gcode << "M202 X" << acceleration << " Y" << acceleration;
|
||||
} else if(FLAVOR_IS(gcfMarlin) || FLAVOR_IS(gcfLerdge)){
|
||||
// M204: Set printing acceleration
|
||||
gcode << "M204 P" << acceleration;
|
||||
} else {
|
||||
// M204: Set default acceleration
|
||||
gcode << "M204 S" << acceleration;
|
||||
|
@ -335,7 +335,7 @@ void PrintConfigDef::init_fff_params()
|
||||
def->set_default_value(new ConfigOptionFloat(0));
|
||||
|
||||
def = this->add("brim_ears", coBool);
|
||||
def->label = L("");
|
||||
def->label = ("");
|
||||
def->full_label = L("Brim ears");
|
||||
def->category = OptionCategory::skirtBrim;
|
||||
def->tooltip = L("Only draw brim over the sharp edges of the model.");
|
||||
@ -1932,17 +1932,27 @@ void PrintConfigDef::init_fff_params()
|
||||
def = this->add("machine_max_acceleration_extruding", coFloats);
|
||||
def->full_label = L("Maximum acceleration when extruding");
|
||||
def->category = OptionCategory::limits;
|
||||
def->tooltip = L("Maximum acceleration when extruding (M204 S)");
|
||||
def->tooltip = L("Maximum acceleration when extruding (M204 P)");
|
||||
def->sidetext = L("mm/s²");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
|
||||
|
||||
// M204 R... [mm/sec^2]
|
||||
def = this->add("machine_max_acceleration_retracting", coFloats);
|
||||
def->full_label = L("Maximum acceleration when retracting");
|
||||
def->category = OptionCategory::limits;
|
||||
def->tooltip = L("Maximum acceleration when retracting (M204 R)");
|
||||
def->sidetext = L("mm/s²");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloats{ 1500., 1250. });
|
||||
|
||||
// M204 T... [mm/sec^2]
|
||||
def = this->add("machine_max_acceleration_retracting", coFloats);
|
||||
def->full_label = L("Maximum acceleration when retracting");
|
||||
def = this->add("machine_max_acceleration_travel", coFloats);
|
||||
def->full_label = L("Maximum acceleration when travelling");
|
||||
def->category = OptionCategory::limits;
|
||||
def->tooltip = L("Maximum acceleration when retracting (M204 T)");
|
||||
def->tooltip = L("Maximum acceleration when travelling (M204 T)");
|
||||
def->sidetext = L("mm/s²");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
|
@ -798,8 +798,10 @@ public:
|
||||
ConfigOptionFloats machine_max_feedrate_e;
|
||||
// M204 S... [mm/sec^2]
|
||||
ConfigOptionFloats machine_max_acceleration_extruding;
|
||||
// M204 T... [mm/sec^2]
|
||||
// M204 R... [mm/sec^2]
|
||||
ConfigOptionFloats machine_max_acceleration_retracting;
|
||||
// M204 T... [mm/sec^2]
|
||||
ConfigOptionFloats machine_max_acceleration_travel;
|
||||
// M205 X... Y... Z... E... [mm/sec]
|
||||
ConfigOptionFloats machine_max_jerk_x;
|
||||
ConfigOptionFloats machine_max_jerk_y;
|
||||
@ -823,6 +825,7 @@ protected:
|
||||
OPT_PTR(machine_max_feedrate_e);
|
||||
OPT_PTR(machine_max_acceleration_extruding);
|
||||
OPT_PTR(machine_max_acceleration_retracting);
|
||||
OPT_PTR(machine_max_acceleration_travel);
|
||||
OPT_PTR(machine_max_jerk_x);
|
||||
OPT_PTR(machine_max_jerk_y);
|
||||
OPT_PTR(machine_max_jerk_z);
|
||||
|
@ -607,6 +607,7 @@ const std::vector<std::string>& Preset::printer_options()
|
||||
"wipe_advanced_multiplier",
|
||||
"wipe_advanced_algo",
|
||||
"remaining_times", "silent_mode", "machine_max_acceleration_extruding", "machine_max_acceleration_retracting",
|
||||
"machine_max_acceleration_travel",
|
||||
"machine_max_acceleration_x", "machine_max_acceleration_y", "machine_max_acceleration_z", "machine_max_acceleration_e",
|
||||
"machine_max_feedrate_x", "machine_max_feedrate_y", "machine_max_feedrate_z", "machine_max_feedrate_e",
|
||||
"machine_min_extruding_rate", "machine_min_travel_rate",
|
||||
|
@ -2234,6 +2234,7 @@ PageShp TabPrinter::build_kinematics_page()
|
||||
}
|
||||
append_option_line_kinematics(optgroup, "machine_max_acceleration_extruding");
|
||||
append_option_line_kinematics(optgroup, "machine_max_acceleration_retracting");
|
||||
append_option_line_kinematics(optgroup, "machine_max_acceleration_travel");
|
||||
|
||||
optgroup = page->new_optgroup(_(L("Jerk limits")));
|
||||
for (const std::string &axis : axes) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user