Skip to content

Commit

Permalink
Enhance ACCELERATION_RAMPING on short moves.
Browse files Browse the repository at this point in the history
Problem was: For short moves, you have to ramp down before
reaching target speed. The point of return was set to half
of the number of total steps.

Now, what happens is there's an uneven number of steps? In
integer math, 3 / 2 = 1, so the move would ramp one step up,
one step down and ... well, one step even further down, resulting
in a really sloooow step. Slow, like a full second or so.

Adding one to the first half, the movement ramps two steps up,
one down and would do another step at minimum speed, if it wasn't
already at target position. This is about as accurate as we
can get it without introducing more code at interrupt time.
  • Loading branch information
Traumflug committed Sep 25, 2010
1 parent 903baad commit f6f2b7f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dda.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ void dda_create(DDA *dda, TARGET *target) {
else
dda->accel = 0;
#elif defined ACCELERATION_RAMPING
dda->ramp_steps = dda->total_steps / 2;
// add the last bit of dda->total_steps to always round up
dda->ramp_steps = dda->total_steps / 2 + (dda->total_steps & 1);
dda->step_no = 0;
// c is initial step time in IOclk ticks
dda->c = ACCELERATION_STEEPNESS << 8;
Expand Down

0 comments on commit f6f2b7f

Please sign in to comment.