Fixed error in calculation of future speed

This commit is contained in:
ksb 2007-02-24 15:26:02 +00:00
parent 20eaa31eff
commit 5af5a5a9a5

View File

@ -544,7 +544,7 @@ stepper_velocity(unsigned int stepper_index, unsigned long period)
seq = state->acceleration_sequence;
a = state->acceleration;
v = state->velocity;
t = stepper_context.period_count + 1;
t = stepper_context.period_count + 2;
while(seq && seq->period < period) {
v += a * (seq->period - t);
@ -588,7 +588,7 @@ stepper_state_at(unsigned int stepper_index, unsigned long period,
seq = state->acceleration_sequence;
a = state->acceleration;
v = state->velocity;
t = stepper_context.period_count + 1;
t = stepper_context.period_count + 2;
s = state->step_full * (long long)DIST_SCALE + state->step_frac;
while(seq && seq->period < period) {
dt = seq->period - t;
@ -613,6 +613,7 @@ stepper_set_velocity(unsigned int stepper_index, unsigned long *periodp,
{
long start_period = *periodp;
long v = stepper_velocity(stepper_index, start_period);
/* printf("%ld @ %ld\n", v, start_period); */
if (final_speed == v) {
return stepper_add_acc(stepper_index, start_period, 0);
} else {