diff options
Diffstat (limited to 'src/Movement/DDA.h')
-rw-r--r-- | src/Movement/DDA.h | 51 |
1 files changed, 33 insertions, 18 deletions
diff --git a/src/Movement/DDA.h b/src/Movement/DDA.h index ebb560dc..83a8fc9c 100644 --- a/src/Movement/DDA.h +++ b/src/Movement/DDA.h @@ -41,14 +41,13 @@ public: bool Init(GCodes::RawMove &nextMove, bool doMotorMapping) __attribute__ ((hot)); // Set up a new move, returning true if it represents real movement bool Init(const float_t steps[DRIVES]); // Set up a raw (unmapped) motor move void Init(); // Set up initial positions for machine startup - bool Start(uint32_t tim); // Start executing the DDA, i.e. move the move. + bool Start(uint32_t tim) __attribute__ ((hot)); // Start executing the DDA, i.e. move the move. bool Step() __attribute__ ((hot)); // Take one step of the DDA, called by timed interrupt. void SetNext(DDA *n) { next = n; } void SetPrevious(DDA *p) { prev = p; } void Complete() { state = completed; } bool Free(); void Prepare(uint8_t simMode) __attribute__ ((hot)); // Calculate all the values and freeze this DDA - float CalcTime() const; // Calculate the time needed for this move (used for simulation) bool HasStepError() const; bool CanPauseAfter() const { return canPauseAfter; } bool CanPauseBefore() const { return canPauseBefore; } @@ -71,8 +70,15 @@ public: bool IsHomingAxes() const { return (endStopsToCheck & HomeAxes) != 0; } uint32_t GetXAxes() const { return xAxes; } uint32_t GetYAxes() const { return yAxes; } + float GetTotalDistance() const { return totalDistance; } + void LimitSpeedAndAcceleration(float maxSpeed, float maxAcceleration); // Limit the speed an acceleration of this move int32_t GetStepsTaken(size_t drive) const; + float GetProportionDone() const; // Return the proportion of extrusion for the complete multi-segment move already done + + void MoveAborted(); + + bool IsGoodToPrepare() const; #if SUPPORT_IOBITS uint32_t GetMoveStartTime() const { return moveStartTime; } @@ -91,14 +97,14 @@ public: // the calculation can just be managed in time at speeds of 15000mm/min (step interval 50us), but not at 20000mm/min (step interval 37.5us). // Therefore, where the step interval falls below 60us, we don't calculate on every step. // Note: the above measurements were taken some time ago, before some firmware optimisations. -#ifdef DUET_NG +#if SAM4E || SAM4S static constexpr int32_t MinCalcIntervalDelta = (40 * stepClockRate)/1000000; // the smallest sensible interval between calculations (40us) in step timer clocks static constexpr int32_t MinCalcIntervalCartesian = (40 * stepClockRate)/1000000; // same as delta for now, but could be lower - static constexpr uint32_t minInterruptInterval = 6; // about 2us minimum interval between interrupts, in clocks + static constexpr uint32_t minInterruptInterval = 6; // about 6us minimum interval between interrupts, in step clocks #else static constexpr int32_t MinCalcIntervalDelta = (60 * stepClockRate)/1000000; // the smallest sensible interval between calculations (60us) in step timer clocks static constexpr int32_t MinCalcIntervalCartesian = (60 * stepClockRate)/1000000; // same as delta for now, but could be lower - static constexpr uint32_t minInterruptInterval = 6; // about 2us minimum interval between interrupts, in clocks + static constexpr uint32_t minInterruptInterval = 4; // about 6us minimum interval between interrupts, in step clocks #endif static void PrintMoves(); // print saved moves for debugging @@ -109,14 +115,15 @@ public: static int32_t loggedProbePositions[XYZ_AXES * MaxLoggedProbePositions]; #endif + static uint32_t maxReps; + private: void RecalculateMove() __attribute__ ((hot)); void CalcNewSpeeds() __attribute__ ((hot)); void ReduceHomingSpeed(); // called to reduce homing speed when a near-endstop is triggered void StopDrive(size_t drive); // stop movement of a drive and recalculate the endpoint - void MoveAborted(); void InsertDM(DriveMovement *dm) __attribute__ ((hot)); - DriveMovement *RemoveDM(size_t drive) __attribute__ ((hot)); + void RemoveDM(size_t drive); void ReleaseDMs(); bool IsDecelerationMove() const; // return true if this move is or have been might have been intended to be a deceleration-only move void DebugPrintVector(const char *name, const float *vec, size_t len) const; @@ -135,16 +142,25 @@ private: DDA *prev; // The previous one in the ring volatile DDAState state; // What state this DDA is in - uint8_t endCoordinatesValid : 1; // True if endCoordinates can be relied on - uint8_t isDeltaMovement : 1; // True if this is a delta printer movement - uint8_t canPauseAfter : 1; // True if we can pause at the end of this move - uint8_t canPauseBefore : 1; // True if we can pause just before this move - uint8_t isPrintingMove : 1; // True if this move includes XY movement and extrusion - uint8_t usePressureAdvance : 1; // True if pressure advance should be applied to any forward extrusion - uint8_t hadLookaheadUnderrun : 1; // True if the lookahead queue was not long enough to optimise this move - uint8_t xyMoving : 1; // True if movement along an X axis or the Y axis was requested, even it if's too small to do - uint8_t goingSlow : 1; // True if we have slowed the movement because the Z probe is approaching its threshold - uint8_t isLeadscrewAdjustmentMove : 1; // True if this is a leadscrews adjustment move + uint8_t proportionRemaining; // What proportion of the extrusion in the G1 or G0 move of which this is a part remains to be done after this segment is complete + // - we use a uint8_t instead of a float to save space because it only affects the extrusion amount, so ~0.4% error is acceptable + union + { + struct + { + uint8_t endCoordinatesValid : 1; // True if endCoordinates can be relied on + uint8_t isDeltaMovement : 1; // True if this is a delta printer movement + uint8_t canPauseAfter : 1; // True if we can pause at the end of this move + uint8_t canPauseBefore : 1; // True if we can pause just before this move + uint8_t isPrintingMove : 1; // True if this move includes XY movement and extrusion + uint8_t usePressureAdvance : 1; // True if pressure advance should be applied to any forward extrusion + uint8_t hadLookaheadUnderrun : 1; // True if the lookahead queue was not long enough to optimise this move + uint8_t xyMoving : 1; // True if movement along an X axis or the Y axis was requested, even it if's too small to do + uint8_t goingSlow : 1; // True if we have slowed the movement because the Z probe is approaching its threshold + uint8_t isLeadscrewAdjustmentMove : 1; // True if this is a leadscrews adjustment move + }; + uint16_t flags; // so that we can print all the flags at once for debugging + }; EndstopChecks endStopsToCheck; // Which endstops we are checking on this move AxesBitmap xAxes; // Which axes are behaving as X axes @@ -161,7 +177,6 @@ private: float virtualExtruderPosition; // the virtual extruder position at the end of this move, used for pause/resume // These are used only in delta calculations - float a2plusb2; // Sum of the squares of the X and Y movement fractions int32_t cKc; // The Z movement fraction multiplied by Kc and converted to integer // These vary depending on how we connect the move with its predecessor and successor, but remain constant while the move is being executed |