look-ahead: take F_end into account on acceleration calculations.

This commit is contained in:
Markus Hitter 2013-12-05 13:17:01 +01:00
parent 83433cb071
commit da77b678e3
3 changed files with 13 additions and 2 deletions

7
dda.c
View File

@ -101,6 +101,7 @@ void dda_create(DDA *dda, TARGET *target, DDA *prev_dda) {
dda->F_start = 0; dda->F_start = 0;
dda->start_steps = 0; dda->start_steps = 0;
dda->F_end = 0; dda->F_end = 0;
dda->end_steps = 0;
// Give this move an identifier. // Give this move an identifier.
dda->id = idcnt++; dda->id = idcnt++;
#endif #endif
@ -796,7 +797,11 @@ void dda_clock() {
recalc_speed = 1; recalc_speed = 1;
} }
else if (move_step_no >= dda->rampdown_steps) { else if (move_step_no >= dda->rampdown_steps) {
dda->n = dda->total_steps - move_step_no; #ifdef LOOKAHEAD
dda->n = dda->total_steps - move_step_no + dda->end_steps;
#else
dda->n = dda->total_steps - move_step_no;
#endif
recalc_speed = 1; recalc_speed = 1;
} }
if (recalc_speed) { if (recalc_speed) {

1
dda.h
View File

@ -149,6 +149,7 @@ typedef struct {
uint32_t F_start; uint32_t F_start;
uint32_t start_steps; ///< steps to reach F_start uint32_t start_steps; ///< steps to reach F_start
uint32_t F_end; uint32_t F_end;
uint32_t end_steps; ///< steps to stop from F_end
// Displacement vector, in um, based between the difference of the starting // Displacement vector, in um, based between the difference of the starting
// point and the target. Required to obtain the jerk between 2 moves. // point and the target. Required to obtain the jerk between 2 moves.
// Note: x_delta and co are in steps, not um. // Note: x_delta and co are in steps, not um.

View File

@ -171,7 +171,8 @@ void dda_join_moves(DDA *prev, DDA *current) {
// Calculating the look-ahead settings can take a while; before modifying // Calculating the look-ahead settings can take a while; before modifying
// the previous move, we need to locally store any values and write them // the previous move, we need to locally store any values and write them
// when we are done (and the previous move is not already active). // when we are done (and the previous move is not already active).
uint32_t prev_F, prev_F_start, prev_F_end, prev_rampup, prev_rampdown, prev_total_steps; uint32_t prev_F, prev_F_start, prev_F_end, prev_end;
uint32_t prev_rampup, prev_rampdown, prev_total_steps;
uint8_t prev_id; uint8_t prev_id;
// Similarly, we only want to modify the current move if we have the results of the calculations; // Similarly, we only want to modify the current move if we have the results of the calculations;
// until then, we do not want to touch the current move settings. // until then, we do not want to touch the current move settings.
@ -341,6 +342,7 @@ void dda_join_moves(DDA *prev, DDA *current) {
prev_rampup = up; prev_rampup = up;
prev_rampdown = prev_total_steps - down; prev_rampdown = prev_total_steps - down;
prev_F_end = crossF; prev_F_end = crossF;
prev_end = ACCELERATE_RAMP_LEN(prev_F_end);
#ifdef LOOKAHEAD_DEBUG #ifdef LOOKAHEAD_DEBUG
// Sanity check: make sure the speed limits are maintained // Sanity check: make sure the speed limits are maintained
@ -437,6 +439,7 @@ void dda_join_moves(DDA *prev, DDA *current) {
prev_rampup = up2; prev_rampup = up2;
prev_rampdown = prev_total_steps - down2; prev_rampdown = prev_total_steps - down2;
prev_F_end = crossF; prev_F_end = crossF;
prev_end = ACCELERATE_RAMP_LEN(prev_F_end);
} }
#ifdef LOOKAHEAD_DEBUG #ifdef LOOKAHEAD_DEBUG
@ -463,11 +466,13 @@ void dda_join_moves(DDA *prev, DDA *current) {
// move, we compare the DDA id. // move, we compare the DDA id.
if(prev->live == 0 && prev->id == prev_id) { if(prev->live == 0 && prev->id == prev_id) {
prev->F_end = prev_F_end; prev->F_end = prev_F_end;
prev->end_steps = prev_end;
prev->rampup_steps = prev_rampup; prev->rampup_steps = prev_rampup;
prev->rampdown_steps = prev_rampdown; prev->rampdown_steps = prev_rampdown;
current->rampup_steps = this_rampup; current->rampup_steps = this_rampup;
current->rampdown_steps = this_rampdown; current->rampdown_steps = this_rampdown;
current->F_end = 0; current->F_end = 0;
current->end_steps = 0;
current->F_start = this_F_start; current->F_start = this_F_start;
current->start_steps = this_start; current->start_steps = this_start;
la_cnt++; la_cnt++;