Added support for the upstream Marlin interpretation of the M204 code.

Fix of https://github.com/prusa3d/Slic3r/issues/1089

M204 S.. T..:
T is interpreted by the firmware and Slic3r time estimator the old way
(as acceleration when retracting) only if an S code is found at the same line.
This allows PrusaResearch to interpret the legacy G-codes generated
by our older Slic3r with older Slic3r profiles.

M204 P.. R.. T..:
T is ignored, P is interpreted as acceleration when extruding,
R is interpreted as acceleration when retracting.
This will be the format the Slic3r 1.41.0 will produce from
the Machine Limits page.
In the future both MK3 firmware and Slic3r will likely be extended
to support the separate travel acceleration.

This change is in sync with the Prusa3D firmware:
dd4c4b39b4

Slic3r will now export
M204 P[machine_max_acceleration_extruding] R[machine_max_acceleration_retracting] T[machine_max_acceleration_extruding]
before the custom start G-code, which will be correctly interpreted
by both the new Prusa3D firmware and the Slic3r's time estimator.

To support our legacy MK2 firmware before we merge the commit above, we may
just insert the following line into the custom start G-code section to override
the block inserted by Slic3r automatically before the custom start G-code:
M204 S[machine_max_acceleration_extruding] T[machine_max_acceleration_retracting]
This commit is contained in:
bubnikv 2018-08-03 16:26:28 +02:00
parent 6fe2f963b1
commit 0454adc194
2 changed files with 21 additions and 6 deletions

View file

@ -1012,9 +1012,10 @@ 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));
fprintf(file, "M204 S%d T%d ; sets acceleration (S) and retract acceleration (T), mm/sec^2\n",
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_retracting.values.front() + 0.5),
int(print.config.machine_max_acceleration_extruding.values.front() + 0.5));
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(),

View file

@ -1164,11 +1164,25 @@ namespace Slic3r {
{
PROFILE_FUNC();
float value;
if (line.has_value('S', value))
if (line.has_value('S', value)) {
// Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware,
// and it is also generated by Slic3r to control acceleration per extrusion type
// (there is a separate acceleration settings in Slicer for perimeter, first layer etc).
set_acceleration(value);
if (line.has_value('T', value))
set_retract_acceleration(value);
if (line.has_value('T', value))
set_retract_acceleration(value);
} else {
// New acceleration format, compatible with the upstream Marlin.
if (line.has_value('P', value))
set_acceleration(value);
if (line.has_value('R', value))
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);
}
}
}
void GCodeTimeEstimator::_processM205(const GCodeReader::GCodeLine& line)