Implement separate travel acceleration (M204 T)

Allow to separate extrusion and travel acceleration settings using M204,
as Marlin 1.1.x and 2.x does using M204 T.

This allows to reduce the number of instructions required during
printing, since resetting the acceleration for travel moves is no longer
required and can be done a single time during the print.

Provision for this parameter was pre-existing, but not implemented.
M204 has two forms: the lagacy format (Marlin <1.1):

  M204 S[print-acc] T[retract-acc]

and the newer format:

  M204 P[print-acc] R[retract-acc] T[travel-acc]

The distinction in the MK3 FW is done based on the presence of the P
parameter. If P is seen, the new format is adoped. In the new format
however, M204 T was ignored until this change.

To keep backward compatibility, M204 S[acc] will set both print and
travel acceleration, which is identical in behavior to recent versions
of Marlin.
This commit is contained in:
Yuri D'Elia 2020-09-20 18:15:27 +02:00
parent 0bda4504c1
commit 1c76152e62
4 changed files with 8 additions and 10 deletions

View File

@ -184,7 +184,7 @@ static_assert (false, "zprobe_zoffset was not initialized in printers in field t
"0.0, if this is not acceptable, increment EEPROM_VERSION to force use default_conf"); "0.0, if this is not acceptable, increment EEPROM_VERSION to force use default_conf");
#endif #endif
static_assert (sizeof(M500_conf) == 192, "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, " static_assert (sizeof(M500_conf) == 196, "sizeof(M500_conf) has changed, ensure that EEPROM_VERSION has been incremented, "
"or if you added members in the end of struct, ensure that historically uninitialized values will be initialized." "or if you added members in the end of struct, ensure that historically uninitialized values will be initialized."
"If this is caused by change to more then 8bit processor, decide whether make this struct packed to save EEPROM," "If this is caused by change to more then 8bit processor, decide whether make this struct packed to save EEPROM,"
"leave as it is to keep fast code, or reorder struct members to pack more tightly."); "leave as it is to keep fast code, or reorder struct members to pack more tightly.");
@ -232,6 +232,7 @@ static const M500_conf default_conf PROGMEM =
#else // TMC2130 #else // TMC2130
{16,16,16,16}, {16,16,16,16},
#endif #endif
DEFAULT_TRAVEL_ACCELERATION,
}; };
//! @brief Read M500 configuration //! @brief Read M500 configuration

View File

@ -38,6 +38,7 @@ typedef struct
float max_feedrate_silent[4]; //!< max speeds for silent mode float max_feedrate_silent[4]; //!< max speeds for silent mode
unsigned long max_acceleration_units_per_sq_second_silent[4]; unsigned long max_acceleration_units_per_sq_second_silent[4];
unsigned char axis_ustep_resolution[4]; unsigned char axis_ustep_resolution[4];
float travel_acceleration; //!< travel acceleration mm/s^2
} M500_conf; } M500_conf;
extern M500_conf cs; extern M500_conf cs;

View File

@ -7258,7 +7258,7 @@ Sigma_Exit:
// Legacy acceleration format. This format is used by the legacy Marlin, MK2 or MK3 firmware, // 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 // 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). // (there is a separate acceleration settings in Slicer for perimeter, first layer etc).
cs.acceleration = code_value(); cs.acceleration = cs.travel_acceleration = code_value();
// Interpret the T value as retract acceleration in the old Marlin format. // Interpret the T value as retract acceleration in the old Marlin format.
if(code_seen('T')) if(code_seen('T'))
cs.retract_acceleration = code_value(); cs.retract_acceleration = code_value();
@ -7268,13 +7268,8 @@ Sigma_Exit:
cs.acceleration = code_value(); cs.acceleration = code_value();
if(code_seen('R')) if(code_seen('R'))
cs.retract_acceleration = code_value(); cs.retract_acceleration = code_value();
if(code_seen('T')) { if(code_seen('T'))
// Interpret the T value as the travel acceleration in the new Marlin format. cs.travel_acceleration = code_value();
/*!
@todo Prusa3D firmware currently does not support travel acceleration value independent from the extruding acceleration value.
*/
// travel_acceleration = code_value();
}
} }
} }
break; break;

View File

@ -1082,7 +1082,8 @@ Having the real displacement of the head, we can calculate the total movement le
} }
else else
{ {
block->acceleration_st = ceil(cs.acceleration * steps_per_mm); // convert to: acceleration steps/sec^2 float acceleration = (block->steps_e.wide == 0? cs.travel_acceleration: cs.acceleration);
block->acceleration_st = ceil(acceleration * steps_per_mm); // convert to: acceleration steps/sec^2
#ifdef LIN_ADVANCE #ifdef LIN_ADVANCE
/** /**