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:
authorDavid Crocker <dcrocker@eschertech.com>2019-01-16 19:00:19 +0300
committerDavid Crocker <dcrocker@eschertech.com>2019-01-16 19:00:19 +0300
commit057218b6af1482bbffedcd7e8a940b56075f4a7a (patch)
treed2ae6620ff9a2aaa8640ead7c7e2ea14cf17a8cd /src/FilamentMonitors
parentf2fe3669764ccd7df5fb6ae3a781912bd9c69d88 (diff)
Filament monitor and DDA changes
Removed code for early allocation of DriveMovement objects Removed arrays of DriveMovement objects from DDAs Fix for laser filament monitor overdue reports
Diffstat (limited to 'src/FilamentMonitors')
-rw-r--r--src/FilamentMonitors/Duet3DFilamentMonitor.cpp20
-rw-r--r--src/FilamentMonitors/Duet3DFilamentMonitor.h8
-rw-r--r--src/FilamentMonitors/LaserFilamentMonitor.cpp39
-rw-r--r--src/FilamentMonitors/LaserFilamentMonitor.h1
-rw-r--r--src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp37
-rw-r--r--src/FilamentMonitors/RotatingMagnetFilamentMonitor.h1
6 files changed, 58 insertions, 48 deletions
diff --git a/src/FilamentMonitors/Duet3DFilamentMonitor.cpp b/src/FilamentMonitors/Duet3DFilamentMonitor.cpp
index 1ac42435..e698f66e 100644
--- a/src/FilamentMonitors/Duet3DFilamentMonitor.cpp
+++ b/src/FilamentMonitors/Duet3DFilamentMonitor.cpp
@@ -13,7 +13,7 @@
// Constructors
Duet3DFilamentMonitor::Duet3DFilamentMonitor(unsigned int extruder, int type)
- : FilamentMonitor(extruder, type)
+ : FilamentMonitor(extruder, type), overrunErrorCount(0), polarityErrorCount(0)
{
InitReceiveBuffer();
}
@@ -37,6 +37,7 @@ bool Duet3DFilamentMonitor::Interrupt()
{
if ((writePointer & 1) == 0) // low-to-high transitions should occur on odd indices
{
+ ++polarityErrorCount;
return false;
}
if (state == RxdState::waitingForStartBit && writePointer == edgeCaptureReadPointer && !HaveIsrStepsCommanded())
@@ -48,6 +49,7 @@ bool Duet3DFilamentMonitor::Interrupt()
{
if ((writePointer & 1) != 0) // high-to-low transitions should occur on even indices
{
+ ++polarityErrorCount;
return false;
}
now -= 40; // partial correction for skew caused by debounce filter on older Duet endstop inputs (measured skew = 74)
@@ -56,6 +58,10 @@ bool Duet3DFilamentMonitor::Interrupt()
edgeCaptures[writePointer] = now; // record the time at which this edge was detected
edgeCaptureWritePointer = (writePointer + 1) % EdgeCaptureBufferSize;
}
+ else
+ {
+ ++overrunErrorCount;
+ }
return wantReading;
}
@@ -63,11 +69,11 @@ bool Duet3DFilamentMonitor::Interrupt()
Duet3DFilamentMonitor::PollResult Duet3DFilamentMonitor::PollReceiveBuffer(uint16_t& measurement)
{
// For the Duet3D sensors we need to decode the received data from the transition times recorded in the edgeCaptures array
- static constexpr uint32_t BitsPerSecond = 1000; // the nominal bit rate that the data is transmitted at
- static constexpr uint32_t NominalBitLength = StepTimer::StepClockRate/BitsPerSecond; // the nominal bit length in step clocks
- static constexpr uint32_t MinBitLength = (NominalBitLength * 10)/13; // allow 30% clock speed tolerance
- static constexpr uint32_t MaxBitLength = (NominalBitLength * 13)/10; // allow 30% clock speed tolerance
- static constexpr uint32_t ErrorRecoveryDelayBits = 8; // before a start bit we want the line to be low for this long
+ static constexpr uint32_t BitsPerSecond = 1000; // the nominal bit rate that the data is transmitted at
+ static constexpr uint32_t NominalBitLength = StepTimer::StepClockRate/BitsPerSecond; // the nominal bit length in step clocks
+ static constexpr uint32_t MinBitLength = (NominalBitLength * 10)/13; // allow 30% clock speed tolerance
+ static constexpr uint32_t MaxBitLength = (NominalBitLength * 13)/10; // allow 30% clock speed tolerance
+ static constexpr uint32_t ErrorRecoveryDelayBits = 8; // before a start bit we want the line to be low for this long
static constexpr uint32_t ErrorRecoveryTime = NominalBitLength * ErrorRecoveryDelayBits;
bool again;
@@ -118,7 +124,6 @@ Duet3DFilamentMonitor::PollResult Duet3DFilamentMonitor::PollReceiveBuffer(uint1
nibblesAssembled = 0;
state = RxdState::waitingForNibble;
again = true;
- //debugPrintf("sb %u\n", startBitLength);
}
else
{
@@ -153,6 +158,7 @@ Duet3DFilamentMonitor::PollResult Duet3DFilamentMonitor::PollReceiveBuffer(uint1
nextBitChangeIndex = (lastBitChangeIndex + 1u) % EdgeCaptureBufferSize;
if (nextBitChangeIndex != writePointer && edgeCaptures[nextBitChangeIndex] - nibbleStartTime < samplePoint)
{
+ // We recorded two edges within one sample period
edgeCaptureReadPointer = nextBitChangeIndex;
state = RxdState::errorRecovery3;
again = true;
diff --git a/src/FilamentMonitors/Duet3DFilamentMonitor.h b/src/FilamentMonitors/Duet3DFilamentMonitor.h
index 214f7d6c..4456a87e 100644
--- a/src/FilamentMonitors/Duet3DFilamentMonitor.h
+++ b/src/FilamentMonitors/Duet3DFilamentMonitor.h
@@ -32,6 +32,10 @@ protected:
bool IsReceiving() const;
bool IsWaitingForStartBit() const;
+protected:
+ uint32_t overrunErrorCount;
+ uint32_t polarityErrorCount;
+
private:
static constexpr size_t EdgeCaptureBufferSize = 64; // must be a power of 2
@@ -42,7 +46,7 @@ private:
enum class RxdState : uint8_t
{
- waitingForStartBit,
+ waitingForStartBit = 0,
waitingForEndOfStartBit,
waitingForNibble,
errorRecovery1,
@@ -51,12 +55,12 @@ private:
errorRecovery4
};
- RxdState state;
uint32_t startBitLength;
uint32_t errorRecoveryStartTime;
size_t lastBitChangeIndex;
uint16_t valueBeingAssembled;
uint8_t nibblesAssembled;
+ RxdState state;
};
#endif /* SRC_FILAMENTSENSORS_DUET3DFILAMENTMONITOR_H_ */
diff --git a/src/FilamentMonitors/LaserFilamentMonitor.cpp b/src/FilamentMonitors/LaserFilamentMonitor.cpp
index 31f4f8e4..84cf4f94 100644
--- a/src/FilamentMonitors/LaserFilamentMonitor.cpp
+++ b/src/FilamentMonitors/LaserFilamentMonitor.cpp
@@ -28,7 +28,7 @@ LaserFilamentMonitor::LaserFilamentMonitor(unsigned int extruder, int type)
void LaserFilamentMonitor::Init()
{
sensorValue = 0;
- parityErrorCount = framingErrorCount = 0;
+ parityErrorCount = framingErrorCount = overrunErrorCount = polarityErrorCount = overdueCount = 0;
lastMeasurementTime = 0;
imageQuality = shutter = brightness = lastErrorCode = 0;
version = 1;
@@ -287,7 +287,10 @@ FilamentSensorStatus LaserFilamentMonitor::Check(bool isPrinting, bool fromIsr,
ret = CheckFilament(extrusionCommandedThisSegment, movementMeasuredThisSegment, false);
extrusionCommandedThisSegment = movementMeasuredThisSegment = 0.0;
}
- else if (extrusionCommandedThisSegment + extrusionCommandedSinceLastSync >= minimumExtrusionCheckLength * 2 && millis() - lastMeasurementTime > 220 && !IsReceiving())
+ else if ( extrusionCommandedThisSegment + extrusionCommandedSinceLastSync >= minimumExtrusionCheckLength * 3
+ && millis() - lastMeasurementTime > 500
+ && !IsReceiving()
+ )
{
// A sync is overdue
ret = CheckFilament(extrusionCommandedThisSegment + extrusionCommandedSinceLastSync, movementMeasuredThisSegment + movementMeasuredSinceLastSync, true);
@@ -382,16 +385,9 @@ FilamentSensorStatus LaserFilamentMonitor::Clear()
Reset(); // call this first so that haveStartBitData and synced are false when we call HandleIncomingData
HandleIncomingData();
- FilamentSensorStatus ret = FilamentSensorStatus::ok;
- if (sensorError)
- {
- ret = FilamentSensorStatus::sensorError;
- }
- else if ((sensorValue & switchOpenMask) != 0)
- {
- ret = FilamentSensorStatus::noFilament;
- }
- return ret;
+ return (sensorError) ? FilamentSensorStatus::sensorError
+ : ((sensorValue & switchOpenMask) != 0) ? FilamentSensorStatus::noFilament
+ : FilamentSensorStatus::ok;
}
// Print diagnostic info for this sensor
@@ -401,14 +397,10 @@ void LaserFilamentMonitor::Diagnostics(MessageType mtype, unsigned int extruder)
: (sensorError) ? "error"
: ((sensorValue & switchOpenMask) != 0) ? "no filament"
: "ok";
- reprap.GetPlatform().MessageF(mtype, "Extruder %u sensor: position %.2f, %s, ", extruder, (double)GetCurrentPosition(), statusText);
- if (dataReceived)
- {
- reprap.GetPlatform().MessageF(mtype, "framing errors %" PRIu32 ", parity errors %" PRIu32 ", ", framingErrorCount, parityErrorCount);
- }
+ reprap.GetPlatform().MessageF(mtype, "Extruder %u: pos %.2f, %s, ", extruder, (double)GetCurrentPosition(), statusText);
if (laserMonitorState != LaserMonitorState::calibrating && totalExtrusionCommanded > 10.0)
{
- reprap.GetPlatform().MessageF(mtype, "measured minimum %ld%%, average %ld%%, maximum %ld%% over %.1fmm\n",
+ reprap.GetPlatform().MessageF(mtype, "measured min %ld%% avg %ld%% max %ld%% over %.1fmm",
lrintf(100 * minMovementRatio),
lrintf((100 * totalMovementMeasured)/totalExtrusionCommanded),
lrintf(100 * maxMovementRatio),
@@ -416,7 +408,16 @@ void LaserFilamentMonitor::Diagnostics(MessageType mtype, unsigned int extruder)
}
else
{
- reprap.GetPlatform().Message(mtype, "no calibration data\n");
+ reprap.GetPlatform().Message(mtype, "no calibration data");
+ }
+ if (dataReceived)
+ {
+ reprap.GetPlatform().MessageF(mtype, ", errs: frame %" PRIu32 " parity %" PRIu32 " ovrun %" PRIu32 " pol %" PRIu32 " ovdue %" PRIu32 "\n",
+ framingErrorCount, parityErrorCount, overrunErrorCount, polarityErrorCount, overdueCount);
+ }
+ else
+ {
+ reprap.GetPlatform().Message(mtype, "\n");
}
}
diff --git a/src/FilamentMonitors/LaserFilamentMonitor.h b/src/FilamentMonitors/LaserFilamentMonitor.h
index df03af13..4a441c2f 100644
--- a/src/FilamentMonitors/LaserFilamentMonitor.h
+++ b/src/FilamentMonitors/LaserFilamentMonitor.h
@@ -76,6 +76,7 @@ private:
// Other data
uint32_t framingErrorCount; // the number of framing errors we received
uint32_t parityErrorCount; // the number of words with bad parity we received
+ uint32_t overdueCount; // the number of times a position report was overdue
uint32_t candidateStartBitTime; // the time that we received a possible start bit
float extrusionCommandedAtCandidateStartBit; // the amount of extrusion commanded since the previous comparison when we received the possible start bit
diff --git a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp
index 1100a14e..2883bf7c 100644
--- a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp
+++ b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp
@@ -29,7 +29,7 @@ RotatingMagnetFilamentMonitor::RotatingMagnetFilamentMonitor(unsigned int extrud
void RotatingMagnetFilamentMonitor::Init()
{
sensorValue = 0;
- framingErrorCount = 0;
+ framingErrorCount = overrunErrorCount = polarityErrorCount = overdueCount = 0;
calibrationStarted = dataReceived = false;
lastMeasurementTime = 0;
InitReceiveBuffer();
@@ -211,7 +211,10 @@ FilamentSensorStatus RotatingMagnetFilamentMonitor::Check(bool isPrinting, bool
ret = CheckFilament(extrusionCommandedThisSegment, movementMeasuredThisSegment, false);
extrusionCommandedThisSegment = movementMeasuredThisSegment = 0.0;
}
- else if (extrusionCommandedThisSegment + extrusionCommandedSinceLastSync >= minimumExtrusionCheckLength * 2 && millis() - lastMeasurementTime > 220 && !IsReceiving())
+ else if ( extrusionCommandedThisSegment + extrusionCommandedSinceLastSync >= minimumExtrusionCheckLength * 3
+ && millis() - lastMeasurementTime > 500
+ && !IsReceiving()
+ )
{
// A sync is overdue
ret = CheckFilament(extrusionCommandedThisSegment + extrusionCommandedSinceLastSync, movementMeasuredThisSegment + movementMeasuredSinceLastSync, true);
@@ -288,19 +291,12 @@ FilamentSensorStatus RotatingMagnetFilamentMonitor::CheckFilament(float amountCo
// Clear the measurement state - called when we are not printing a file. Return the present/not present status if available.
FilamentSensorStatus RotatingMagnetFilamentMonitor::Clear()
{
- HandleIncomingData(); // to keep the diagnostics up to date
Reset();
+ HandleIncomingData(); // to keep the diagnostics up to date
- FilamentSensorStatus ret = FilamentSensorStatus::ok;
- if ((sensorValue & TypeMagnetErrorMask) != 0)
- {
- ret = FilamentSensorStatus::sensorError;
- }
- else if ((sensorValue & switchOpenMask) != 0)
- {
- ret = FilamentSensorStatus::noFilament;
- }
- return ret;
+ return ((sensorValue & TypeMagnetErrorMask) != 0) ? FilamentSensorStatus::sensorError
+ : ((sensorValue & switchOpenMask) != 0) ? FilamentSensorStatus::noFilament
+ : FilamentSensorStatus::ok;
}
// Print diagnostic info for this sensor
@@ -310,15 +306,11 @@ void RotatingMagnetFilamentMonitor::Diagnostics(MessageType mtype, unsigned int
: ((sensorValue & TypeMagnetErrorMask) != 0) ? "error"
: ((sensorValue & switchOpenMask) != 0) ? "no filament"
: "ok";
- reprap.GetPlatform().MessageF(mtype, "Extruder %u sensor: position %.2f, %s, ", extruder, (double)GetCurrentPosition(), statusText);
- if (dataReceived)
- {
- reprap.GetPlatform().MessageF(mtype, "%" PRIu32 " framing errors, ", framingErrorCount);
- }
+ reprap.GetPlatform().MessageF(mtype, "Extruder %u: pos %.2f, %s, ", extruder, (double)GetCurrentPosition(), statusText);
if (calibrationStarted && fabsf(totalMovementMeasured) > 1.0 && totalExtrusionCommanded > 20.0)
{
const float measuredMmPerRev = totalExtrusionCommanded/totalMovementMeasured;
- reprap.GetPlatform().MessageF(mtype, "measured sensitivity %.2fmm/rev, measured minimum %ld%%, maximum %ld%% over %.1fmm\n",
+ reprap.GetPlatform().MessageF(mtype, "measured sens %.2fmm/rev min %ld%% max %ld%% over %.1fmm",
(double)measuredMmPerRev,
lrintf(100 * minMovementRatio),
lrintf(100 * maxMovementRatio),
@@ -326,7 +318,12 @@ void RotatingMagnetFilamentMonitor::Diagnostics(MessageType mtype, unsigned int
}
else
{
- reprap.GetPlatform().Message(mtype, "no calibration data\n");
+ reprap.GetPlatform().Message(mtype, "no calibration data");
+ }
+ if (dataReceived)
+ {
+ reprap.GetPlatform().MessageF(mtype, ", errs: frame %" PRIu32 " ovrun %" PRIu32 " pol %" PRIu32 " ovdue %" PRIu32 "\n",
+ framingErrorCount, overrunErrorCount, polarityErrorCount, overdueCount);
}
}
diff --git a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h
index 2b6eb1be..72acbbdb 100644
--- a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h
+++ b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h
@@ -45,6 +45,7 @@ private:
// Other data
uint32_t framingErrorCount; // the number of framing errors we received
+ uint32_t overdueCount; // the number of times a position report was overdue
uint32_t candidateStartBitTime; // the time that we received a possible start bit
float extrusionCommandedAtCandidateStartBit; // the amount of extrusion commanded since the previous comparison when we received the possible start bit