From 96e9ae4dab92f3e94cbd2245ffc502c2ee842496 Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Fri, 4 Jul 2014 23:09:38 +0200 Subject: [PATCH] dda.h: comment on these direction flags and other things. --- dda.c | 28 +++++++++++++++++++--------- dda.h | 3 +++ 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/dda.c b/dda.c index ed4876e..3f4277f 100644 --- a/dda.c +++ b/dda.c @@ -483,15 +483,25 @@ void dda_start(DDA *dda) { current_position.F = dda->endpoint.F; } -/*! STEP - \param *dda the current move - - This is called from our timer interrupt every time a step needs to occur. Keep it as simple as possible! - We first work out which axes need to step, and generate step pulses for them - Then we re-enable global interrupts so serial data reception and other important things can occur while we do some math. - Next, we work out how long until our next step using the selected acceleration algorithm and set the timer. - Then we decide if this was the last step for this move, and if so mark this dda as dead so next timer interrupt we can start a new one. - Finally we de-assert any asserted step pins. +/** + \brief Do per-step movement maintenance. + + \param *dda the current move + + \details Most important task here is to update the Bresenham algorithm and + to generate step pulses accordingly, this guarantees geometrical accuracy + of the movement. Other tasks, like acceleration calculations, are moved + into dda_clock() as much as possible. + + This is called from our timer interrupt every time a step needs to occur. + Keep it as simple and fast as possible, this is most critical for the + achievable step frequency. + + Note: it was tried to do this in loops instead of straight, repeating code. + However, this resulted in at least 16% performance loss, no matter + how it was done. On how to measure, see commit "testcases: Add + config.h". On the various tries and measurement results, see commits + starting with "DDA: Move axis calculations into loops, part 6". */ void dda_step(DDA *dda) { diff --git a/dda.h b/dda.h index 8f04aab..cb7834a 100644 --- a/dda.h +++ b/dda.h @@ -106,6 +106,9 @@ typedef struct { uint8_t waitfor_temp :1; ///< bool: wait for temperatures to reach their set values // directions + // As we have muldiv() now, overflows became much less an issue and + // it's likely time to get rid of these flags and use int instead of + // uint for distance/speed calculations. --Traumflug 2014-07-04 uint8_t x_direction :1; ///< direction flag for X axis uint8_t y_direction :1; ///< direction flag for Y axis uint8_t z_direction :1; ///< direction flag for Z axis