DDA: Move axis calculations into loops, part 6a.
Clean up code to reduce duplication by consolidating code into
loops for per-axis actions.
Part 6a is putting stuff inside the step interrupt into a loop,
too. do_step() is put into the "tidiest" place. Binary size goes
down a remarkable 374 bytes, but stepping performance suffers by
almost 30%.
Traumflug's performance measurements:
SIZES ATmega... '168 '328(P) '644(P) '1280
FLASH : 19908 bytes 139% 65% 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: 354537 clock cycles.
LED on time minimum: 390 clock cycles.
LED on time maximum: 806 clock cycles.
LED on time average: 399.253 clock cycles.
smooth-curves.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 9124.
Sum of all LED on time: 4268896 clock cycles.
LED on time minimum: 395 clock cycles.
LED on time maximum: 807 clock cycles.
LED on time average: 467.875 clock cycles.
triangle-odd.gcode
Statistics (assuming a 20 MHz clock):
LED on occurences: 1636.
Sum of all LED on time: 706846 clock cycles.
LED on time minimum: 390 clock cycles.
LED on time maximum: 807 clock cycles.
LED on time average: 432.057 clock cycles.
This commit is contained in:
parent
ad82907b98
commit
b83449d8c3
90
dda.c
90
dda.c
|
|
@ -482,78 +482,26 @@ void dda_start(DDA *dda) {
|
|||
Finally we de-assert any asserted step pins.
|
||||
*/
|
||||
void dda_step(DDA *dda) {
|
||||
enum axis_e i;
|
||||
|
||||
#if ! defined ACCELERATION_TEMPORAL
|
||||
if (move_state.steps[X]) {
|
||||
move_state.counter[X] -= dda->delta[X];
|
||||
if (move_state.counter[X] < 0) {
|
||||
x_step();
|
||||
move_state.steps[X]--;
|
||||
move_state.counter[X] += dda->total_steps;
|
||||
}
|
||||
}
|
||||
#else // ACCELERATION_TEMPORAL
|
||||
if (dda->axis_to_step == X) {
|
||||
x_step();
|
||||
move_state.steps[X]--;
|
||||
move_state.time[X] += dda->step_interval[X];
|
||||
move_state.all_time = move_state.time[X];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ! defined ACCELERATION_TEMPORAL
|
||||
if (move_state.steps[Y]) {
|
||||
move_state.counter[Y] -= dda->delta[Y];
|
||||
if (move_state.counter[Y] < 0) {
|
||||
y_step();
|
||||
move_state.steps[Y]--;
|
||||
move_state.counter[Y] += dda->total_steps;
|
||||
}
|
||||
}
|
||||
#else // ACCELERATION_TEMPORAL
|
||||
if (dda->axis_to_step == Y) {
|
||||
y_step();
|
||||
move_state.steps[Y]--;
|
||||
move_state.time[Y] += dda->step_interval[Y];
|
||||
move_state.all_time = move_state.time[Y];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ! defined ACCELERATION_TEMPORAL
|
||||
if (move_state.steps[Z]) {
|
||||
move_state.counter[Z] -= dda->delta[Z];
|
||||
if (move_state.counter[Z] < 0) {
|
||||
z_step();
|
||||
move_state.steps[Z]--;
|
||||
move_state.counter[Z] += dda->total_steps;
|
||||
}
|
||||
}
|
||||
#else // ACCELERATION_TEMPORAL
|
||||
if (dda->axis_to_step == Z) {
|
||||
z_step();
|
||||
move_state.steps[Z]--;
|
||||
move_state.time[Z] += dda->step_interval[Z];
|
||||
move_state.all_time = move_state.time[Z];
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ! defined ACCELERATION_TEMPORAL
|
||||
if (move_state.steps[E]) {
|
||||
move_state.counter[E] -= dda->delta[E];
|
||||
if (move_state.counter[E] < 0) {
|
||||
e_step();
|
||||
move_state.steps[E]--;
|
||||
move_state.counter[E] += dda->total_steps;
|
||||
}
|
||||
}
|
||||
#else // ACCELERATION_TEMPORAL
|
||||
if (dda->axis_to_step == E) {
|
||||
e_step();
|
||||
move_state.steps[E]--;
|
||||
move_state.time[E] += dda->step_interval[E];
|
||||
move_state.all_time = move_state.time[E];
|
||||
}
|
||||
#endif
|
||||
#if ! defined ACCELERATION_TEMPORAL
|
||||
for (i = X; i < AXIS_COUNT; i++) {
|
||||
if (move_state.steps[i]) {
|
||||
move_state.counter[i] -= dda->delta[i];
|
||||
if (move_state.counter[i] < 0) {
|
||||
do_step(i);
|
||||
move_state.steps[i]--;
|
||||
move_state.counter[i] += dda->total_steps;
|
||||
}
|
||||
}
|
||||
}
|
||||
#else // ACCELERATION_TEMPORAL
|
||||
i = dda->axis_to_step;
|
||||
do_step(i);
|
||||
move_state.steps[i]--;
|
||||
move_state.time[i] += dda->step_interval[i];
|
||||
move_state.all_time = move_state.time[i];
|
||||
#endif
|
||||
|
||||
#if STEP_INTERRUPT_INTERRUPTIBLE && ! defined ACCELERATION_RAMPING
|
||||
// Since we have sent steps to all the motors that will be stepping
|
||||
|
|
|
|||
13
pinio.c
13
pinio.c
|
|
@ -42,3 +42,16 @@ void power_off() {
|
|||
|
||||
ps_is_on = 0;
|
||||
}
|
||||
|
||||
// step the 'n' axis
|
||||
void do_step(enum axis_e n) {
|
||||
if (n == X)
|
||||
x_step();
|
||||
else if (n == Y)
|
||||
y_step();
|
||||
else if (n == Z)
|
||||
z_step();
|
||||
else if (n == E)
|
||||
e_step();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue