DDA: Move axis calculations into loops, part 7.

Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.

Part 7 is, turn update_current_position() in dda.c partially into
a loop. Surprise, surprise, this changes neither binary size nor
performance. Looking into the generated assembly, the loop is
indeed completely unrolled. Apparently that's smaller than a
real loop.

    SIZES             ATmega...  '168    '328(P)    '644(P)    '1280
    FLASH : 20270 bytes          142%       66%        32%       16%
    RAM   :  2302 bytes          225%      113%        57%       29%
    EEPROM:    32 bytes            4%        2%         2%        1%

short-moves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 888.
Sum of all LED on time: 279945 clock cycles.
LED on time minimum: 306 clock cycles.
LED on time maximum: 722 clock cycles.
LED on time average: 315.253 clock cycles.

smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 3297806 clock cycles.
LED on time minimum: 311 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 361.443 clock cycles.

triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 546946 clock cycles.
LED on time minimum: 306 clock cycles.
LED on time maximum: 712 clock cycles.
LED on time average: 334.319 clock cycles.
This commit is contained in:
Phil Hord 2013-11-25 18:06:43 -05:00 committed by Markus Hitter
parent 32481e2799
commit 80b29b727b
1 changed files with 4 additions and 4 deletions

8
dda.c
View File

@ -847,12 +847,12 @@ void dda_clock() {
/// update global current_position struct
void update_current_position() {
DDA *dda = &movebuffer[mb_tail];
enum axis_e i;
if (queue_empty()) {
current_position.axis[X] = startpoint.axis[X];
current_position.axis[Y] = startpoint.axis[Y];
current_position.axis[Z] = startpoint.axis[Z];
current_position.axis[E] = startpoint.axis[E];
for (i = X; i < AXIS_COUNT; i++) {
current_position.axis[i] = startpoint.axis[i];
}
}
else if (dda->live) {
if (dda->x_direction)