Implemented new acceleration control behaviour for the new Marlin firmware flavor:
- show extra travel acceleration settings in 'Machine limits' page in Printer Settings when the new firmware flavor is selected - updated tooltips on the config values (they were basically wrong even in the current version) - 'Marlin (legacy)' firmware flavor behaviour should not change: it exports M204 Pa Rb Ta (where a, b are the values from machine limits) at the beginning of gcode and it uses M204 S... for feature type dependent acceleration settings (legacy variant of M204 P.. T..) - new Marlin Firmware exports M204 Pa Rb Tc (where a,b,c are the values from machine limits). Feature type dependent acceleration is set using M204 P..., not overriding the travel acceleration.
This commit is contained in:
parent
f0e9ad46ec
commit
8c89bf748b
7 changed files with 57 additions and 11 deletions
|
@ -1571,10 +1571,20 @@ void GCode::print_machine_envelope(FILE *file, Print &print)
|
|||
int(print.config().machine_max_feedrate_y.values.front() + 0.5),
|
||||
int(print.config().machine_max_feedrate_z.values.front() + 0.5),
|
||||
int(print.config().machine_max_feedrate_e.values.front() + 0.5));
|
||||
|
||||
// Now M204 - acceleration. This one is quite hairy thanks to how Marlin guys care about
|
||||
// backwards compatibility: https://github.com/prusa3d/PrusaSlicer/issues/1089
|
||||
// Legacy Marlin should export travel acceleration the same as printing acceleration.
|
||||
// MarlinFirmware has the two separated.
|
||||
int travel_acc = print.config().gcode_flavor == gcfMarlinLegacy
|
||||
? int(print.config().machine_max_acceleration_extruding.values.front() + 0.5)
|
||||
: int(print.config().machine_max_acceleration_travel.values.front() + 0.5);
|
||||
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));
|
||||
travel_acc);
|
||||
|
||||
|
||||
fprintf(file, "M205 X%.2lf Y%.2lf Z%.2lf E%.2lf ; sets the jerk limits, mm/sec\n",
|
||||
print.config().machine_max_jerk_x.values.front(),
|
||||
print.config().machine_max_jerk_y.values.front(),
|
||||
|
|
|
@ -207,8 +207,12 @@ std::string GCodeWriter::set_acceleration(unsigned int acceleration)
|
|||
// M202: Set max travel acceleration
|
||||
gcode << "M202 X" << acceleration << " Y" << acceleration;
|
||||
} else if (FLAVOR_IS(gcfRepRapFirmware)) {
|
||||
// M204: Set default acceleration
|
||||
gcode << "M204 P" << acceleration;
|
||||
// M204: Set default acceleration
|
||||
gcode << "M204 P" << acceleration;
|
||||
} else if (FLAVOR_IS(gcfMarlinFirmware)) {
|
||||
// This is new MarlinFirmware with separated print/retraction/travel acceleration.
|
||||
// Use M204 P, we don't want to override travel acc by M204 S (which is deprecated anyway).
|
||||
gcode << "M204 P" << acceleration;
|
||||
} else {
|
||||
// M204: Set default acceleration
|
||||
gcode << "M204 S" << acceleration;
|
||||
|
|
|
@ -468,7 +468,7 @@ const std::vector<std::string>& Preset::machine_limits_options()
|
|||
static std::vector<std::string> s_opts;
|
||||
if (s_opts.empty()) {
|
||||
s_opts = {
|
||||
"machine_max_acceleration_extruding", "machine_max_acceleration_retracting",
|
||||
"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",
|
||||
|
|
|
@ -1469,21 +1469,34 @@ void PrintConfigDef::init_fff_params()
|
|||
def->mode = comAdvanced;
|
||||
def->set_default_value(new ConfigOptionFloats{ 0., 0. });
|
||||
|
||||
// M204 S... [mm/sec^2]
|
||||
// M204 P... [mm/sec^2]
|
||||
def = this->add("machine_max_acceleration_extruding", coFloats);
|
||||
def->full_label = L("Maximum acceleration when extruding");
|
||||
def->category = L("Machine limits");
|
||||
def->tooltip = L("Maximum acceleration when extruding (M204 S)");
|
||||
def->tooltip = L("Maximum acceleration when extruding (M204 P)\n\n"
|
||||
"Marlin (legacy) firmware flavor will use this also "
|
||||
"as travel acceleration (M204 T).");
|
||||
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 = L("Machine 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 for travel moves");
|
||||
def->category = L("Machine limits");
|
||||
def->tooltip = L("Maximum acceleration when retracting (M204 T)");
|
||||
def->tooltip = L("Maximum acceleration for travel moves (M204 T)");
|
||||
def->sidetext = L("mm/s²");
|
||||
def->min = 0;
|
||||
def->mode = comAdvanced;
|
||||
|
|
|
@ -726,10 +726,12 @@ public:
|
|||
ConfigOptionFloats machine_max_feedrate_y;
|
||||
ConfigOptionFloats machine_max_feedrate_z;
|
||||
ConfigOptionFloats machine_max_feedrate_e;
|
||||
// M204 S... [mm/sec^2]
|
||||
|
||||
// M204 P... R... T...[mm/sec^2]
|
||||
ConfigOptionFloats machine_max_acceleration_extruding;
|
||||
// M204 T... [mm/sec^2]
|
||||
ConfigOptionFloats machine_max_acceleration_retracting;
|
||||
ConfigOptionFloats machine_max_acceleration_travel;
|
||||
|
||||
// M205 X... Y... Z... E... [mm/sec]
|
||||
ConfigOptionFloats machine_max_jerk_x;
|
||||
ConfigOptionFloats machine_max_jerk_y;
|
||||
|
@ -754,6 +756,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);
|
||||
|
|
|
@ -2264,6 +2264,13 @@ void TabPrinter::build_fff()
|
|||
m_use_silent_mode = val;
|
||||
}
|
||||
}
|
||||
if (opt_key == "gcode_flavor") {
|
||||
bool supports_travel_acceleration = (boost::any_cast<int>(value) == int(gcfMarlinFirmware));
|
||||
if (supports_travel_acceleration != m_supports_travel_acceleration) {
|
||||
m_rebuild_kinematics_page = true;
|
||||
m_supports_travel_acceleration = supports_travel_acceleration;
|
||||
}
|
||||
}
|
||||
build_unregular_pages();
|
||||
update_dirty();
|
||||
on_value_change(opt_key, value);
|
||||
|
@ -2560,6 +2567,8 @@ PageShp TabPrinter::build_kinematics_page()
|
|||
}
|
||||
append_option_line(optgroup, "machine_max_acceleration_extruding");
|
||||
append_option_line(optgroup, "machine_max_acceleration_retracting");
|
||||
if (m_supports_travel_acceleration)
|
||||
append_option_line(optgroup, "machine_max_acceleration_travel");
|
||||
|
||||
optgroup = page->new_optgroup(L("Jerk limits"));
|
||||
for (const std::string &axis : axes) {
|
||||
|
@ -2954,6 +2963,12 @@ void TabPrinter::update_fff()
|
|||
m_use_silent_mode = m_config->opt_bool("silent_mode");
|
||||
}
|
||||
|
||||
bool supports_travel_acceleration = (m_config->option<ConfigOptionEnum<GCodeFlavor>>("gcode_flavor")->value == gcfMarlinFirmware);
|
||||
if (m_supports_travel_acceleration != supports_travel_acceleration) {
|
||||
m_rebuild_kinematics_page = true;
|
||||
m_supports_travel_acceleration = supports_travel_acceleration;
|
||||
}
|
||||
|
||||
toggle_options();
|
||||
}
|
||||
|
||||
|
|
|
@ -425,6 +425,7 @@ class TabPrinter : public Tab
|
|||
private:
|
||||
bool m_has_single_extruder_MM_page = false;
|
||||
bool m_use_silent_mode = false;
|
||||
bool m_supports_travel_acceleration = false;
|
||||
void append_option_line(ConfigOptionsGroupShp optgroup, const std::string opt_key);
|
||||
bool m_rebuild_kinematics_page = false;
|
||||
ogStaticText* m_machine_limits_description_line {nullptr};
|
||||
|
|
Loading…
Reference in a new issue