DDA, dda_step(): test for individual axes again.

This time we don't test for remaining steps, but wether the axis
moves at all. A much cheaper test, because this variable has to
be loaded into registers anyways.

Performance is now even better than without this test. Slowest
step down from 604 to 580 clock cycles.

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19610 bytes      137%       64%       31%       16%
     Data:   2175 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 280 clock cycles.
  LED on time maximum: 549 clock cycles.
  LED on time average: 286.273 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 580 clock cycles.
  LED on time average: 307.439 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 272 clock cycles.
  LED on time maximum: 539 clock cycles.
  LED on time average: 297.732 clock cycles.
This commit is contained in:
Markus Hitter 2016-11-21 18:59:32 +01:00
parent 437cb08e42
commit 1326db002f
1 changed files with 24 additions and 16 deletions

40
dda.c
View File

@ -566,25 +566,33 @@ void dda_start(DDA *dda) {
void dda_step(DDA *dda) { void dda_step(DDA *dda) {
#if ! defined ACCELERATION_TEMPORAL #if ! defined ACCELERATION_TEMPORAL
move_state.counter[X] -= dda->delta[X]; if (dda->delta[X]) {
if (move_state.counter[X] < 0) { move_state.counter[X] -= dda->delta[X];
x_step(); if (move_state.counter[X] < 0) {
move_state.counter[X] += dda->total_steps; x_step();
move_state.counter[X] += dda->total_steps;
}
} }
move_state.counter[Y] -= dda->delta[Y]; if (dda->delta[Y]) {
if (move_state.counter[Y] < 0) { move_state.counter[Y] -= dda->delta[Y];
y_step(); if (move_state.counter[Y] < 0) {
move_state.counter[Y] += dda->total_steps; y_step();
move_state.counter[Y] += dda->total_steps;
}
} }
move_state.counter[Z] -= dda->delta[Z]; if (dda->delta[Z]) {
if (move_state.counter[Z] < 0) { move_state.counter[Z] -= dda->delta[Z];
z_step(); if (move_state.counter[Z] < 0) {
move_state.counter[Z] += dda->total_steps; z_step();
move_state.counter[Z] += dda->total_steps;
}
} }
move_state.counter[E] -= dda->delta[E]; if (dda->delta[E]) {
if (move_state.counter[E] < 0) { move_state.counter[E] -= dda->delta[E];
e_step(); if (move_state.counter[E] < 0) {
move_state.counter[E] += dda->total_steps; e_step();
move_state.counter[E] += dda->total_steps;
}
} }
move_state.step_no++; move_state.step_no++;
#endif #endif