diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-10-21 21:27:25 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-10-21 21:27:25 +0300 |
commit | 111fae6e2184e5f8fde1b3487e8f50478c51541e (patch) | |
tree | 1aa4ee243ed12646bcfaf326237f2b852363652c /src/Movement | |
parent | 2f48d9f7be0d063eafbe85e137b6290d22a1fca2 (diff) |
Implemented most filament monitor support in expansion mode
Lookup of accumulated extrusion is still wrong when in expansion mode
Diffstat (limited to 'src/Movement')
-rw-r--r-- | src/Movement/DDARing.cpp | 23 | ||||
-rw-r--r-- | src/Movement/DDARing.h | 4 | ||||
-rw-r--r-- | src/Movement/Move.cpp | 6 |
3 files changed, 20 insertions, 13 deletions
diff --git a/src/Movement/DDARing.cpp b/src/Movement/DDARing.cpp index cc8af5b0..23270b35 100644 --- a/src/Movement/DDARing.cpp +++ b/src/Movement/DDARing.cpp @@ -85,9 +85,9 @@ void DDARing::Init2() noexcept SetPositions(pos); } - for (size_t i = 0; i < MaxExtruders; ++i) + for (volatile int32_t& macc : movementAccumulators) { - extrusionAccumulators[i] = 0; + macc = 0; } extrudersPrinting = false; simulationTime = 0.0; @@ -571,11 +571,18 @@ void DDARing::CurrentMoveCompleted() noexcept // Save the current motor coordinates, and the machine Cartesian coordinates if known liveCoordinatesValid = cdda->FetchEndPosition(const_cast<int32_t*>(liveEndPoints), const_cast<float *>(liveCoordinates)); liveCoordinatesChanged = true; - const size_t numExtruders = reprap.GetGCodes().GetNumExtruders(); - for (size_t extruder = 0; extruder < numExtruders; ++extruder) + + // In the following it doesn't currently matter whether we process all drives or just the extruders + // Instead of looping through extruders, we could loop through DMs. { - extrusionAccumulators[extruder] += cdda->GetStepsTaken(LogicalDriveToExtruder(extruder)); + const size_t numExtruders = reprap.GetGCodes().GetNumExtruders(); + for (size_t extruder = 0; extruder < numExtruders; ++extruder) + { + const size_t drv = ExtruderToLogicalDrive(extruder); + movementAccumulators[drv] += cdda->GetStepsTaken(drv); + } } + currentDda = nullptr; if (cdda->IsCheckingEndstops()) { @@ -598,13 +605,13 @@ bool DDARing::SetWaitingToEmpty() noexcept return ret; } -int32_t DDARing::GetAccumulatedExtrusion(size_t extruder, size_t drive, bool& isPrinting) noexcept +int32_t DDARing::GetAccumulatedMovement(size_t drive, bool& isPrinting) noexcept { const uint32_t basepri = ChangeBasePriority(NvicPriorityStep); - const int32_t ret = extrusionAccumulators[extruder]; + const int32_t ret = movementAccumulators[drive]; const DDA * const cdda = currentDda; // capture volatile variable const int32_t adjustment = (cdda == nullptr) ? 0 : cdda->GetStepsTaken(drive); - extrusionAccumulators[extruder] = -adjustment; + movementAccumulators[drive] = -adjustment; isPrinting = extrudersPrinting; RestoreBasePriority(basepri); return ret + adjustment; diff --git a/src/Movement/DDARing.h b/src/Movement/DDARing.h index 1bae00c8..bd654828 100644 --- a/src/Movement/DDARing.h +++ b/src/Movement/DDARing.h @@ -41,7 +41,7 @@ public: void CurrentMoveCompleted() noexcept SPEED_CRITICAL; // Signal that the current move has just been completed uint32_t ExtruderPrintingSince() const noexcept { return extrudersPrintingSince; } // When we started doing normal moves after the most recent extruder-only move - int32_t GetAccumulatedExtrusion(size_t extruder, size_t drive, bool& isPrinting) noexcept; + int32_t GetAccumulatedMovement(size_t drive, bool& isPrinting) noexcept; uint32_t GetScheduledMoves() const noexcept { return scheduledMoves; } // How many moves have been scheduled? uint32_t GetCompletedMoves() const noexcept { return completedMoves; } // How many moves have been completed? @@ -127,7 +127,7 @@ private: unsigned int stepErrors; // count of step errors, for diagnostics float simulationTime; // Print time since we started simulating - volatile int32_t extrusionAccumulators[MaxExtruders]; // Accumulated extruder motor steps + volatile int32_t movementAccumulators[MaxAxesPlusExtruders]; // Accumulated motor steps, used by filament monitors volatile uint32_t extrudersPrintingSince; // The milliseconds clock time when extrudersPrinting was set to true volatile bool extrudersPrinting; // Set whenever an extruder starts a printing move, cleared by a non-printing extruder move diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp index ff9a5d48..7ec39faa 100644 --- a/src/Movement/Move.cpp +++ b/src/Movement/Move.cpp @@ -895,12 +895,12 @@ void Move::GetCurrentUserPosition(float m[MaxAxes], uint8_t moveType, const Tool } // Get the accumulated extruder motor steps taken by an extruder since the last call. Used by the filament monitoring code. -// Returns the number of motor steps moves since the last call, and isPrinting is true unless we are currently executing an extruding but non-printing move +// Returns the number of motor steps moves since the last call, and sets isPrinting true unless we are currently executing an extruding but non-printing move int32_t Move::GetAccumulatedExtrusion(size_t extruder, bool& isPrinting) noexcept { if (extruder < reprap.GetGCodes().GetNumExtruders()) { - return mainDDARing.GetAccumulatedExtrusion(extruder, ExtruderToLogicalDrive(extruder), isPrinting); + return mainDDARing.GetAccumulatedMovement(ExtruderToLogicalDrive(extruder), isPrinting); } isPrinting = false; @@ -923,7 +923,7 @@ void Move::SetZBedProbePoint(size_t index, float z, bool wasXyCorrected, bool wa { if (index >= MaxProbePoints) { - reprap.GetPlatform().Message(ErrorMessage, "Z probe point Z index out of range\n"); + reprap.GetPlatform().Message(ErrorMessage, "Z probe point index out of range\n"); } else { |