Enhance ACCELERATION_RAMPING on short moves.

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.
This commit is contained in:
Markus Hitter 2010-09-25 17:58:15 +02:00
parent 903baad3d1
commit f6f2b7f44f
1 changed files with 2 additions and 1 deletions

3
dda.c
View File

@ -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;