dda.h/.c: remove move_state.step_no
We don't need to save the step_no. We can easily calculate it when needed. Also some whitespace-work. In dda.h is only a delete of 'uint32_t step_no;'. Saves up to 16 clock cycles in dda_step(): short-moves.gcode statistics: LED on occurences: 888. LED on time minimum: 209 clock cycles. LED on time maximum: 504 clock cycles. LED on time average: 241.441 clock cycles. smooth-curves.gcode statistics: LED on occurences: 22589. LED on time minimum: 209 clock cycles. LED on time maximum: 521 clock cycles. LED on time average: 276.729 clock cycles. triangle-odd.gcode statistics: LED on occurences: 1636. LED on time minimum: 209 clock cycles. LED on time maximum: 504 clock cycles. LED on time average: 262.923 clock cycles.
This commit is contained in:
parent
89bb0ae3bb
commit
3592622414
31
dda.c
31
dda.c
|
|
@ -507,9 +507,6 @@ void dda_start(DDA *dda) {
|
||||||
move_state.counter[E] = -(dda->total_steps >> 1);
|
move_state.counter[E] = -(dda->total_steps >> 1);
|
||||||
move_state.endstop_stop = 0;
|
move_state.endstop_stop = 0;
|
||||||
memcpy(&move_state.steps[X], &dda->delta[X], sizeof(uint32_t) * 4);
|
memcpy(&move_state.steps[X], &dda->delta[X], sizeof(uint32_t) * 4);
|
||||||
#ifdef ACCELERATION_RAMPING
|
|
||||||
move_state.step_no = 0;
|
|
||||||
#endif
|
|
||||||
#ifdef ACCELERATION_TEMPORAL
|
#ifdef ACCELERATION_TEMPORAL
|
||||||
move_state.time[X] = move_state.time[Y] = \
|
move_state.time[X] = move_state.time[Y] = \
|
||||||
move_state.time[Z] = move_state.time[E] = 0UL;
|
move_state.time[Z] = move_state.time[E] = 0UL;
|
||||||
|
|
@ -577,7 +574,6 @@ void dda_step(DDA *dda) {
|
||||||
move_state.steps[E]--;
|
move_state.steps[E]--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
move_state.step_no++;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ACCELERATION_REPRAP
|
#ifdef ACCELERATION_REPRAP
|
||||||
|
|
@ -687,7 +683,7 @@ void dda_step(DDA *dda) {
|
||||||
// TODO: with ACCELERATION_TEMPORAL this duplicates some code. See where
|
// TODO: with ACCELERATION_TEMPORAL this duplicates some code. See where
|
||||||
// dda->live is zero'd, about 10 lines above.
|
// dda->live is zero'd, about 10 lines above.
|
||||||
#if ! defined ACCELERATION_TEMPORAL
|
#if ! defined ACCELERATION_TEMPORAL
|
||||||
if (move_state.step_no >= dda->total_steps ||
|
if (move_state.steps[dda->fast_axis] == 0 ||
|
||||||
(move_state.endstop_stop && dda->n <= 0))
|
(move_state.endstop_stop && dda->n <= 0))
|
||||||
#else
|
#else
|
||||||
if (move_state.steps[X] == 0 && move_state.steps[Y] == 0 &&
|
if (move_state.steps[X] == 0 && move_state.steps[Y] == 0 &&
|
||||||
|
|
@ -831,14 +827,16 @@ void dda_clock() {
|
||||||
// For always smooth operations, don't halt apruptly,
|
// For always smooth operations, don't halt apruptly,
|
||||||
// but start deceleration here.
|
// but start deceleration here.
|
||||||
ATOMIC_START
|
ATOMIC_START
|
||||||
|
move_step_no = dda->total_steps - move_state.steps[dda->fast_axis];
|
||||||
|
|
||||||
move_state.endstop_stop = 1;
|
move_state.endstop_stop = 1;
|
||||||
if (move_state.step_no < dda->rampup_steps) // still accelerating
|
if (move_step_no < dda->rampup_steps) // still accelerating
|
||||||
dda->total_steps = move_state.step_no * 2;
|
dda->total_steps = move_step_no * 2;
|
||||||
else
|
else
|
||||||
// A "-=" would overflow earlier.
|
// A "-=" would overflow earlier.
|
||||||
dda->total_steps = dda->total_steps - dda->rampdown_steps +
|
dda->total_steps = dda->total_steps - dda->rampdown_steps +
|
||||||
move_state.step_no;
|
move_step_no;
|
||||||
dda->rampdown_steps = move_state.step_no;
|
dda->rampdown_steps = move_step_no;
|
||||||
ATOMIC_END
|
ATOMIC_END
|
||||||
// Not atomic, because not used in dda_step().
|
// Not atomic, because not used in dda_step().
|
||||||
dda->rampup_steps = 0; // in case we're still accelerating
|
dda->rampup_steps = 0; // in case we're still accelerating
|
||||||
|
|
@ -856,7 +854,7 @@ void dda_clock() {
|
||||||
// and http://www.atmel.com/images/doc8017.pdf (Atmel app note AVR446)
|
// and http://www.atmel.com/images/doc8017.pdf (Atmel app note AVR446)
|
||||||
ATOMIC_START
|
ATOMIC_START
|
||||||
current_id = dda->id;
|
current_id = dda->id;
|
||||||
move_step_no = move_state.step_no;
|
move_step_no = dda->total_steps - move_state.steps[dda->fast_axis];
|
||||||
// All other variables are read-only or unused in dda_step(),
|
// All other variables are read-only or unused in dda_step(),
|
||||||
// so no need for atomic operations.
|
// so no need for atomic operations.
|
||||||
ATOMIC_END
|
ATOMIC_END
|
||||||
|
|
@ -951,16 +949,13 @@ void update_current_position() {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (dda != NULL) {
|
if (dda != NULL) {
|
||||||
uint32_t axis_steps, axis_um;
|
uint32_t axis_um;
|
||||||
|
|
||||||
for (i = X; i < AXIS_COUNT; i++) {
|
for (i = X; i < AXIS_COUNT; i++) {
|
||||||
#if ! defined ACCELERATION_TEMPORAL
|
axis_um = muldiv(move_state.steps[i],
|
||||||
axis_steps = muldiv(dda->total_steps - move_state.step_no,
|
1000000,
|
||||||
dda->delta[i], dda->total_steps);
|
pgm_read_dword(&steps_per_m_P[i]));
|
||||||
#else
|
|
||||||
axis_steps = move_state.steps[i];
|
|
||||||
#endif
|
|
||||||
axis_um = muldiv(axis_steps, 1000000, pgm_read_dword(&steps_per_m_P[i]));
|
|
||||||
current_position.axis[i] =
|
current_position.axis[i] =
|
||||||
dda->endpoint.axis[i] - (int32_t)get_direction(dda, i) * axis_um;
|
dda->endpoint.axis[i] - (int32_t)get_direction(dda, i) * axis_um;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
5
dda.h
5
dda.h
|
|
@ -56,10 +56,7 @@ typedef struct {
|
||||||
// bresenham counters
|
// bresenham counters
|
||||||
axes_int32_t counter; ///< counter for total_steps vs each axis
|
axes_int32_t counter; ///< counter for total_steps vs each axis
|
||||||
|
|
||||||
#if ! defined ACCELERATION_TEMPORAL
|
#ifdef ACCELERATION_TEMPORAL
|
||||||
/// counts actual steps done
|
|
||||||
uint32_t step_no;
|
|
||||||
#else
|
|
||||||
axes_uint32_t time; ///< time of the last step on each axis
|
axes_uint32_t time; ///< time of the last step on each axis
|
||||||
uint32_t last_time; ///< time of the last step of any axis
|
uint32_t last_time; ///< time of the last step of any axis
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue