From 1326db002f582c0ad67b58d8a8744a9387e2dbca Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Mon, 21 Nov 2016 18:59:32 +0100 Subject: [PATCH] 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. --- dda.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/dda.c b/dda.c index db3c17f..be43087 100644 --- a/dda.c +++ b/dda.c @@ -566,25 +566,33 @@ void dda_start(DDA *dda) { void dda_step(DDA *dda) { #if ! defined ACCELERATION_TEMPORAL - move_state.counter[X] -= dda->delta[X]; - if (move_state.counter[X] < 0) { - x_step(); - move_state.counter[X] += dda->total_steps; + if (dda->delta[X]) { + move_state.counter[X] -= dda->delta[X]; + if (move_state.counter[X] < 0) { + x_step(); + move_state.counter[X] += dda->total_steps; + } } - move_state.counter[Y] -= dda->delta[Y]; - if (move_state.counter[Y] < 0) { - y_step(); - move_state.counter[Y] += dda->total_steps; + if (dda->delta[Y]) { + move_state.counter[Y] -= dda->delta[Y]; + if (move_state.counter[Y] < 0) { + y_step(); + move_state.counter[Y] += dda->total_steps; + } } - move_state.counter[Z] -= dda->delta[Z]; - if (move_state.counter[Z] < 0) { - z_step(); - move_state.counter[Z] += dda->total_steps; + if (dda->delta[Z]) { + move_state.counter[Z] -= dda->delta[Z]; + if (move_state.counter[Z] < 0) { + z_step(); + move_state.counter[Z] += dda->total_steps; + } } - move_state.counter[E] -= dda->delta[E]; - if (move_state.counter[E] < 0) { - e_step(); - move_state.counter[E] += dda->total_steps; + if (dda->delta[E]) { + move_state.counter[E] -= dda->delta[E]; + if (move_state.counter[E] < 0) { + e_step(); + move_state.counter[E] += dda->total_steps; + } } move_state.step_no++; #endif