diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-10-28 23:17:27 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-10-28 23:17:27 +0300 |
commit | 9dfad056245fa2a202b1e18e6f03c3c9ce17d064 (patch) | |
tree | 602db14d8095fba4874d0ad646d95ae455b539de /src | |
parent | 5e44de8b0a7782670cb014c37e09f3af7d4b7b07 (diff) |
Fixed issue with small extruder moves and filament monitors
Diffstat (limited to 'src')
-rw-r--r-- | src/Movement/DDA.cpp | 38 | ||||
-rw-r--r-- | src/Movement/DDARing.cpp | 13 | ||||
-rw-r--r-- | src/Movement/DriveMovement.cpp | 6 |
3 files changed, 33 insertions, 24 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp index 6c08ce0f..315a3eec 100644 --- a/src/Movement/DDA.cpp +++ b/src/Movement/DDA.cpp @@ -2336,28 +2336,32 @@ void DDA::UpdateMovementAccumulators(volatile int32_t *accumulators) const noexc #if 1 // Loop through DMs, checking whether each associated drive is an extruder and updating the movement accumulator if so. // We could omit the check that the drive is an accumulator so that we update all accumulators, but we would still need to check for leadscrew adjustment moves. - const unsigned int firstExtruderDrive = ExtruderToLogicalDrive(reprap.GetGCodes().GetNumExtruders() - 1); - for (const DriveMovement* dm = activeDMs; dm != nullptr; ) + const size_t numExtruders = reprap.GetGCodes().GetNumExtruders(); + if (numExtruders != 0) { - const uint8_t drv = dm->drive; - if ( drv >= firstExtruderDrive // check that it's an extruder (to save the call to GetStepsTaken) - && drv < MaxAxesPlusExtruders // check that it's not a direct leadscrew move - ) + const unsigned int firstExtruderDrive = ExtruderToLogicalDrive(numExtruders - 1); + for (const DriveMovement* dm = activeDMs; dm != nullptr; ) { - accumulators[drv] += dm->GetNetStepsTaken(); + const uint8_t drv = dm->drive; + if ( drv >= firstExtruderDrive // check that it's an extruder (to save the call to GetStepsTaken) + && drv < MaxAxesPlusExtruders // check that it's not a direct leadscrew move + ) + { + accumulators[drv] += dm->GetNetStepsTaken(); + } + dm = dm->nextDM; } - dm = dm->nextDM; - } - for (const DriveMovement* dm = completedDMs; dm != nullptr; ) - { - const uint8_t drv = dm->drive; - if ( drv >= firstExtruderDrive // check that it's an extruder (to save the call to GetStepsTaken) - && drv < MaxAxesPlusExtruders // check that it's not a direct leadscrew move - ) + for (const DriveMovement* dm = completedDMs; dm != nullptr; ) { - accumulators[drv] += dm->GetNetStepsTaken(); + const uint8_t drv = dm->drive; + if ( drv >= firstExtruderDrive // check that it's an extruder (to save the call to GetStepsTaken) + && drv < MaxAxesPlusExtruders // check that it's not a direct leadscrew move + ) + { + accumulators[drv] += dm->GetNetStepsTaken(); + } + dm = dm->nextDM; } - dm = dm->nextDM; } #else // Loop through extruders diff --git a/src/Movement/DDARing.cpp b/src/Movement/DDARing.cpp index 4aeb39a7..27cd1aa7 100644 --- a/src/Movement/DDARing.cpp +++ b/src/Movement/DDARing.cpp @@ -171,7 +171,7 @@ GCodeResult DDARing::ConfigureMovementQueue(GCodeBuffer& gb, const StringRef& re void DDARing::RecycleDDAs() noexcept { // Recycle the DDAs for completed moves, checking for DDA errors to print if Move debug is enabled - while (checkPointer->GetState() == DDA::completed) + while (checkPointer->GetState() == DDA::completed && checkPointer != currentDda) // we haven't finished with a completed DDA until it is no longer the current DDA! { // Check for step errors and record/print them if we have any, before we lose the DMs if (checkPointer->HasStepError()) @@ -576,11 +576,11 @@ void DDARing::CurrentMoveCompleted() noexcept { AtomicCriticalSectionLocker lock; cdda->UpdateMovementAccumulators(movementAccumulators); - currentDda = nullptr; - } - if (cdda->IsCheckingEndstops()) - { - Move::WakeMoveTaskFromISR(); // wake the Move task if we were checking endstops + if (cdda->IsCheckingEndstops()) + { + Move::WakeMoveTaskFromISR(); // wake the Move task if we were checking endstops + } + currentDda = nullptr; // once we have done this, the DDA can be recycled by the Move task } getPointer = getPointer->GetNext(); @@ -599,6 +599,7 @@ bool DDARing::SetWaitingToEmpty() noexcept return ret; } +// Get the number of steps taken by an extruder drive since the last time we called this function for that drive int32_t DDARing::GetAccumulatedMovement(size_t drive, bool& isPrinting) noexcept { AtomicCriticalSectionLocker lock; diff --git a/src/Movement/DriveMovement.cpp b/src/Movement/DriveMovement.cpp index 3ae424b2..e110adb1 100644 --- a/src/Movement/DriveMovement.cpp +++ b/src/Movement/DriveMovement.cpp @@ -611,6 +611,7 @@ bool DriveMovement::PrepareDeltaAxis(const DDA& dda, const PrepParams& params) n } // Prepare this DM for an extruder move, returning true if there are steps to do +// If there are no steps to do, set nextStep = 0 so that DDARing::CurrentMoveCompleted doesn't add any steps to the movement accumulator // We have already generated the extruder segments and we know that there are some bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params) noexcept { @@ -802,6 +803,8 @@ bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params) no if (netSteps == 0 && iFwdSteps == 0) { // No movement at all + nextStep = totalSteps = 0; + reverseStartStep = 1; shaper.SetExtrusionPending(netDistance * dda.directionVector[drive]); return false; } @@ -837,7 +840,8 @@ bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params) no else { // No steps at all, or negative forward steps which I think should be impossible unless the steps/mm is changed - totalSteps = 0; + nextStep = totalSteps = 0; + reverseStartStep = 1; shaper.SetExtrusionPending(forwardDistance * dda.directionVector[drive]); return false; } |