Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/Movement')
-rw-r--r--src/Movement/DDA.cpp24
-rw-r--r--src/Movement/DDA.h3
-rw-r--r--src/Movement/Move.cpp22
3 files changed, 17 insertions, 32 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp
index a8cc3515..efe6186a 100644
--- a/src/Movement/DDA.cpp
+++ b/src/Movement/DDA.cpp
@@ -1442,7 +1442,7 @@ pre(state == frozen)
return true; // schedule another interrupt immediately
}
-uint32_t DDA::maxReps = 0; // this holds he maximum ISR loop count
+uint32_t DDA::numHiccups = 0;
uint32_t DDA::lastStepLowTime = 0;
uint32_t DDA::lastDirChangeTime = 0;
@@ -1454,8 +1454,8 @@ bool DDA::Step()
{
Platform& platform = reprap.GetPlatform();
uint32_t lastStepPulseTime = lastStepLowTime;
- bool repeat;
- uint32_t numReps = 0;
+ bool repeat = false;
+ uint32_t isrStartTime;
do
{
// Keep this loop as fast as possible, in the case that there are no endstops to check!
@@ -1471,12 +1471,16 @@ bool DDA::Step()
}
// 2. Determine which drivers are due for stepping, overdue, or will be due very shortly
+ const uint32_t iClocks = Platform::GetInterruptClocks();
+ if (!repeat)
+ {
+ isrStartTime = iClocks; // first time through, so make a note of the ISR start time
+ }
+ const uint32_t elapsedTime = (iClocks - moveStartTime) + MinInterruptInterval;
DriveMovement* dm = firstDM;
- const uint32_t elapsedTime = (Platform::GetInterruptClocks() - moveStartTime) + MinInterruptInterval;
uint32_t driversStepping = 0;
while (dm != nullptr && elapsedTime >= dm->nextStepTime) // if the next step is due
{
- ++numReps;
driversStepping |= platform.GetDriversBitmap(dm->drive);
dm = dm->nextDM;
@@ -1485,7 +1489,7 @@ bool DDA::Step()
//if (t3 < minCalcTime) minCalcTime = t3;
}
- if ((driversStepping & platform.GetSlowDriversBitmap()) == 0) // if not using any external drivers
+ if ((driversStepping & platform.GetSlowDriversBitmap()) == 0) // if not using any external drivers
{
// 3. Step the drivers
Platform::StepDriversHigh(driversStepping); // generate the steps
@@ -1537,14 +1541,10 @@ bool DDA::Step()
}
// 7. Schedule next interrupt, or if it would be too soon, generate more steps immediately
- repeat = platform.ScheduleStepInterrupt(firstDM->nextStepTime + moveStartTime);
+ // If we have already spent too much time in the ISR, delay the interrupt
+ repeat = platform.ScheduleStepInterruptWithLimit(firstDM->nextStepTime + moveStartTime, isrStartTime);
} while (repeat);
- if (numReps > maxReps)
- {
- maxReps = numReps;
- }
-
if (state == completed)
{
// The following finish time is wrong if we aborted the move because of endstop or Z probe checks.
diff --git a/src/Movement/DDA.h b/src/Movement/DDA.h
index 5c340c8a..45f085c4 100644
--- a/src/Movement/DDA.h
+++ b/src/Movement/DDA.h
@@ -119,6 +119,7 @@ public:
static constexpr uint32_t MinCalcIntervalCartesian = (60 * stepClockRate)/1000000; // same as delta for now, but could be lower
static constexpr uint32_t MinInterruptInterval = 4; // about 6us minimum interval between interrupts, in step clocks
#endif
+ static constexpr uint32_t MaxStepInterruptTime = 10 * MinInterruptInterval; // the maximum time we spend looping in the ISR , in step clocks
static void PrintMoves(); // print saved moves for debugging
@@ -128,7 +129,7 @@ public:
static int32_t loggedProbePositions[XYZ_AXES * MaxLoggedProbePositions];
#endif
- static uint32_t maxReps; // maximum number of times that the ISR looped
+ static uint32_t numHiccups; // how many times we delayed an interrupt to avoid using too much CPU time in interrupts
static uint32_t lastStepLowTime; // when we last completed a step pulse to a slow driver
static uint32_t lastDirChangeTime; // when we last change the DIR signal to a slow driver
diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp
index 34c952af..0949a043 100644
--- a/src/Movement/Move.cpp
+++ b/src/Movement/Move.cpp
@@ -584,19 +584,13 @@ bool Move::LowPowerPause(RestorePoint& rp)
#endif
-#if 0
-// For debugging
-extern uint32_t sqSum1, sqSum2, sqCount, sqErrors, lastRes1, lastRes2;
-extern uint64_t lastNum;
-#endif
-
void Move::Diagnostics(MessageType mtype)
{
Platform& p = reprap.GetPlatform();
p.Message(mtype, "=== Move ===\n");
- p.MessageF(mtype, "MaxReps: %" PRIu32 ", StepErrors: %u, LaErrors: %u, FreeDm: %d, MinFreeDm %d, MaxWait: %" PRIu32 "ms, Underruns: %u, %u\n",
- DDA::maxReps, stepErrors, numLookaheadErrors, DriveMovement::NumFree(), DriveMovement::MinFree(), longestGcodeWaitInterval, numLookaheadUnderruns, numPrepareUnderruns);
- DDA::maxReps = 0;
+ p.MessageF(mtype, "Hiccups: %" PRIu32 ", StepErrors: %u, LaErrors: %u, FreeDm: %d, MinFreeDm %d, MaxWait: %" PRIu32 "ms, Underruns: %u, %u\n",
+ DDA::numHiccups, stepErrors, numLookaheadErrors, DriveMovement::NumFree(), DriveMovement::MinFree(), longestGcodeWaitInterval, numLookaheadUnderruns, numPrepareUnderruns);
+ DDA::numHiccups = 0;
numLookaheadUnderruns = numPrepareUnderruns = numLookaheadErrors = 0;
longestGcodeWaitInterval = 0;
DriveMovement::ResetMinFree();
@@ -644,16 +638,6 @@ void Move::Diagnostics(MessageType mtype)
}
p.Message(mtype, "\n");
#endif
-
-#if 0
- // For debugging
- if (sqCount != 0)
- {
- p.AppendMessage(GenericMessage, "Average sqrt times %.2f, %.2f, count %u, errors %u, last %" PRIu64 " %u %u\n",
- (float)sqSum1/sqCount, (float)sqSum2/sqCount, sqCount, sqErrors, lastNum, lastRes1, lastRes2);
- sqSum1 = sqSum2 = sqCount = sqErrors = 0;
- }
-#endif
}
// Set the current position to be this