Do not overflow during LA acceleration limiting

Perform the check one step earlier, avoiding 32bit overflow for very low
compression factors.

Fixes  (although for K15 to have effect the conversion probably
needs to be adjusted on the low end)
This commit is contained in:
Yuri D'Elia 2020-04-09 22:34:30 +02:00
parent 02a36c498c
commit 13b0e27cd7

View file

@ -1081,9 +1081,9 @@ Having the real displacement of the head, we can calculate the total movement le
if (e_D_ratio > 3.0)
block->use_advance_lead = false;
else if (e_D_ratio > 0) {
const uint32_t max_accel_steps_per_s2 = cs.max_jerk[E_AXIS] / (extruder_advance_K * e_D_ratio) * steps_per_mm;
if (block->acceleration_st > max_accel_steps_per_s2) {
block->acceleration_st = max_accel_steps_per_s2;
const float max_accel_per_s2 = cs.max_jerk[E_AXIS] / (extruder_advance_K * e_D_ratio);
if (cs.acceleration > max_accel_per_s2) {
block->acceleration_st = ceil(max_accel_per_s2 * steps_per_mm);
#ifdef LA_DEBUG
SERIAL_ECHOLNPGM("LA: Block acceleration limited due to max E-jerk");
#endif