Fix missing deceleration steps

Marlin never reached final_speed after deceleration.
This commit is contained in:
Sebastianv650 2018-01-14 16:29:19 +01:00
parent a0bd811093
commit 4fa0937a55
2 changed files with 5 additions and 2 deletions

View File

@ -218,7 +218,7 @@ void Planner::calculate_trapezoid_for_block(block_t* const block, const float &e
// Steps required for acceleration, deceleration to/from nominal rate
int32_t accelerate_steps = CEIL(estimate_acceleration_distance(initial_rate, block->nominal_rate, accel)),
decelerate_steps = FLOOR(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel)),
decelerate_steps = CEIL(estimate_acceleration_distance(block->nominal_rate, final_rate, -accel)),
// Steps between acceleration and deceleration, if any
plateau_steps = block->step_event_count - accelerate_steps - decelerate_steps;

View File

@ -733,8 +733,11 @@ void Stepper::isr() {
#endif // LIN_ADVANCE
}
else if (step_events_completed > (uint32_t)current_block->decelerate_after) {
else if (step_events_completed >= (uint32_t)current_block->decelerate_after && current_block->step_event_count != (uint32_t)current_block->decelerate_after) {
uint16_t step_rate;
// If we are entering the deceleration phase for the first time, we have to see how long we have been decelerating up to now. Equals last acceleration time interval.
if (!deceleration_time)
deceleration_time = calc_timer_interval(acc_step_rate);
MultiU24X32toH16(step_rate, deceleration_time, current_block->acceleration_rate);
if (step_rate < acc_step_rate) { // Still decelerating?