DDA: revert recent dda_start() changes.

Neither of them brought a performance improvement, so we revert
both. Commits as well as revert kept to preserve the knowledge
gained.

This reverts commits

  "DDA, dda_start(): use mb_tail_dda directly." and
  "DDA, dda_start(): don't pass mb_tail_dda as parameter."

Performance and binary size is back to what we had before:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19270 bytes      135%       63%       31%       15%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%

  short-moves.gcode statistics:
  LED on occurences: 888.
  LED on time minimum: 218 clock cycles.
  LED on time maximum: 395 clock cycles.
  LED on time average: 249.051 clock cycles.

  smooth-curves.gcode statistics:
  LED on occurences: 23648.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 438 clock cycles.
  LED on time average: 272.216 clock cycles.

  triangle-odd.gcode statistics:
  LED on occurences: 1636.
  LED on time minimum: 237 clock cycles.
  LED on time maximum: 395 clock cycles.
  LED on time average: 262.572 clock cycles.
This commit is contained in:
Markus Hitter 2016-12-06 19:34:33 +01:00
parent e28afeca7d
commit 7726b3179c
3 changed files with 19 additions and 17 deletions

30
dda.c
View File

@ -482,6 +482,7 @@ void dda_create(DDA *dda, const TARGET *target) {
} }
/*! Start a prepared DDA /*! Start a prepared DDA
\param *dda pointer to entry in dda_queue to start
This function actually begins the move described by the passed DDA entry. This function actually begins the move described by the passed DDA entry.
@ -491,51 +492,52 @@ void dda_create(DDA *dda, const TARGET *target) {
Called both inside and outside of interrupts. Called both inside and outside of interrupts.
*/ */
void dda_start() { void dda_start(DDA *dda) {
// called from interrupt context: keep it simple!
if (DEBUG_DDA && (debug_flags & DEBUG_DDA)) if (DEBUG_DDA && (debug_flags & DEBUG_DDA))
sersendf_P(PSTR("Start: X %lq Y %lq Z %lq F %lu\n"), sersendf_P(PSTR("Start: X %lq Y %lq Z %lq F %lu\n"),
mb_tail_dda->endpoint.axis[X], mb_tail_dda->endpoint.axis[Y], dda->endpoint.axis[X], dda->endpoint.axis[Y],
mb_tail_dda->endpoint.axis[Z], mb_tail_dda->endpoint.F); dda->endpoint.axis[Z], dda->endpoint.F);
// get ready to go // get ready to go
psu_timeout = 0; psu_timeout = 0;
#ifdef Z_AUTODISABLE #ifdef Z_AUTODISABLE
if (mb_tail_dda->delta[Z]) if (dda->delta[Z])
z_enable(); z_enable();
#endif #endif
if (mb_tail_dda->endstop_check) if (dda->endstop_check)
endstops_on(); endstops_on();
// set direction outputs // set direction outputs
x_direction(mb_tail_dda->x_direction); x_direction(dda->x_direction);
y_direction(mb_tail_dda->y_direction); y_direction(dda->y_direction);
z_direction(mb_tail_dda->z_direction); z_direction(dda->z_direction);
e_direction(mb_tail_dda->e_direction); e_direction(dda->e_direction);
#ifdef DC_EXTRUDER #ifdef DC_EXTRUDER
if (mb_tail_dda->delta[E]) if (dda->delta[E])
heater_set(DC_EXTRUDER, DC_EXTRUDER_PWM); heater_set(DC_EXTRUDER, DC_EXTRUDER_PWM);
#endif #endif
// initialise state variable // initialise state variable
move_state.counter[X] = move_state.counter[Y] = move_state.counter[Z] = \ move_state.counter[X] = move_state.counter[Y] = move_state.counter[Z] = \
move_state.counter[E] = -(mb_tail_dda->total_steps >> 1); move_state.counter[E] = -(dda->total_steps >> 1);
move_state.endstop_stop = 0; move_state.endstop_stop = 0;
#ifdef ACCELERATION_RAMPING #ifdef ACCELERATION_RAMPING
move_state.step_no = 0; move_state.step_no = 0;
#endif #endif
#ifdef ACCELERATION_TEMPORAL #ifdef ACCELERATION_TEMPORAL
memcpy(&move_state.steps[X], &mb_tail_dda->delta[X], sizeof(uint32_t) * 4); memcpy(&move_state.steps[X], &dda->delta[X], sizeof(uint32_t) * 4);
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;
#endif #endif
// ensure this dda starts // ensure this dda starts
mb_tail_dda->live = 1; dda->live = 1;
// set timeout for first step // set timeout for first step
timer_set(mb_tail_dda->c, 0); timer_set(dda->c, 0);
} }
/** /**

2
dda.h
View File

@ -187,7 +187,7 @@ void dda_new_startpoint(void);
void dda_create(DDA *dda, const TARGET *target); void dda_create(DDA *dda, const TARGET *target);
// start a created DDA (called from timer interrupt) // start a created DDA (called from timer interrupt)
void dda_start(void); void dda_start(DDA *dda);
// DDA takes one step (called from timer interrupt) // DDA takes one step (called from timer interrupt)
void dda_step(DDA *dda); void dda_step(DDA *dda);

View File

@ -71,7 +71,7 @@ void queue_step() {
if (mb_tail != mb_head) { if (mb_tail != mb_head) {
mb_tail = MB_NEXT(mb_tail); mb_tail = MB_NEXT(mb_tail);
mb_tail_dda = &(movebuffer[mb_tail]); mb_tail_dda = &(movebuffer[mb_tail]);
dda_start(); dda_start(mb_tail_dda);
} }
else { else {
mb_tail_dda = NULL; mb_tail_dda = NULL;
@ -123,7 +123,7 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) {
timer_reset(); timer_reset();
mb_tail = mb_head; // Valid ONLY if the queue was empty before! mb_tail = mb_head; // Valid ONLY if the queue was empty before!
mb_tail_dda = new_movebuffer; // Dito! mb_tail_dda = new_movebuffer; // Dito!
dda_start(); dda_start(mb_tail_dda);
// Compensate for the cli() in timer_set(). // Compensate for the cli() in timer_set().
sei(); sei();
} }