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-10-19 13:25:58 +0300
committerDavid Crocker <dcrocker@eschertech.com>2019-10-19 13:25:58 +0300
commit45383015b0a740ee77c41a75ed06ebe103c59b88 (patch)
tree9076004bfffb33d6d9fe070dbf458e5793ffe321 /src/FilamentMonitors
parent02c935062002ea863c3bb8c697b0a340eaf9f8ef (diff)
Added recent updates from 2.04RC4 release
Diffstat (limited to 'src/FilamentMonitors')
-rw-r--r--src/FilamentMonitors/LaserFilamentMonitor.cpp50
-rw-r--r--src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp73
-rw-r--r--src/FilamentMonitors/RotatingMagnetFilamentMonitor.h4
3 files changed, 68 insertions, 59 deletions
diff --git a/src/FilamentMonitors/LaserFilamentMonitor.cpp b/src/FilamentMonitors/LaserFilamentMonitor.cpp
index 5ee6a2a5..e6a5f5c8 100644
--- a/src/FilamentMonitors/LaserFilamentMonitor.cpp
+++ b/src/FilamentMonitors/LaserFilamentMonitor.cpp
@@ -103,22 +103,26 @@ bool LaserFilamentMonitor::Configure(GCodeBuffer& gb, const StringRef& reply, bo
{
reply.cat("no data received");
}
- else if (sensorError)
- {
- reply.cat("error");
- if (lastErrorCode != 0)
- {
- reply.catf(" %u", lastErrorCode);
- }
- }
else
{
- reply.catf("current pos %.1f, brightness %u, shutter %u, ", (double)GetCurrentPosition(), brightness, shutter);
+ reply.catf("version %u, ", version);
if (imageQuality != 0)
{
reply.catf("quality %u, ", imageQuality);
}
- if (laserMonitorState != LaserMonitorState::calibrating && totalExtrusionCommanded > 10.0)
+ if (version >= 2)
+ {
+ reply.catf("brightness %u, shutter %u, ", brightness, shutter);
+ }
+ if (sensorError)
+ {
+ reply.cat("error");
+ if (lastErrorCode != 0)
+ {
+ reply.catf(" %u", lastErrorCode);
+ }
+ }
+ else if (laserMonitorState != LaserMonitorState::calibrating && totalExtrusionCommanded > 10.0)
{
reply.catf("measured min %ld%% avg %ld%% max %ld%% over %.1fmm",
lrintf(100 * minMovementRatio),
@@ -391,32 +395,18 @@ FilamentSensorStatus LaserFilamentMonitor::Clear()
// Print diagnostic info for this sensor
void LaserFilamentMonitor::Diagnostics(MessageType mtype, unsigned int extruder)
{
- const char* const statusText = (!dataReceived) ? "no data received"
- : (sensorError) ? "error"
- : ((sensorValue & switchOpenMask) != 0) ? "no filament"
- : "ok";
- 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 min %ld%% avg %ld%% max %ld%% over %.1fmm",
- lrintf(100 * minMovementRatio),
- lrintf((100 * totalMovementMeasured)/totalExtrusionCommanded),
- lrintf(100 * maxMovementRatio),
- (double)totalExtrusionCommanded);
- }
- else
- {
- reprap.GetPlatform().Message(mtype, "no calibration data");
- }
+ String<FormatStringLength> buf;
+ buf.printf("Extruder %u: ", extruder);
if (dataReceived)
{
- reprap.GetPlatform().MessageF(mtype, ", errs: frame %" PRIu32 " parity %" PRIu32 " ovrun %" PRIu32 " pol %" PRIu32 " ovdue %" PRIu32 "\n",
- framingErrorCount, parityErrorCount, overrunErrorCount, polarityErrorCount, overdueCount);
+ buf.catf("pos %.2f, errs: frame %" PRIu32 " parity %" PRIu32 " ovrun %" PRIu32 " pol %" PRIu32 " ovdue %" PRIu32 "\n",
+ (double)GetCurrentPosition(), framingErrorCount, parityErrorCount, overrunErrorCount, polarityErrorCount, overdueCount);
}
else
{
- reprap.GetPlatform().Message(mtype, "\n");
+ buf.cat("no data received\n");
}
+ reprap.GetPlatform().Message(mtype, buf.c_str());
}
// End
diff --git a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp
index 374aabc3..9a0dfc2b 100644
--- a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp
+++ b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.cpp
@@ -34,6 +34,8 @@ void RotatingMagnetFilamentMonitor::Init()
lastMeasurementTime = 0;
lastErrorCode = 0;
version = 1;
+ magnitude = 0;
+ agc = 0;
backwards = false;
sensorError = false;
InitReceiveBuffer();
@@ -106,18 +108,22 @@ bool RotatingMagnetFilamentMonitor::Configure(GCodeBuffer& gb, const StringRef&
{
reply.cat("no data received");
}
- else if (sensorError)
+ else
{
- reply.cat("error");
- if (lastErrorCode != 0)
+ reply.catf("version %u, ", version);
+ if (version >= 3)
{
- reply.catf(" %u", lastErrorCode);
+ reply.catf("mag %u agc %u, ", magnitude, agc);
}
- }
- else
- {
- reply.catf("current pos %.1f, ", (double)GetCurrentPosition());
- if (magneticMonitorState != MagneticMonitorState::calibrating && totalExtrusionCommanded > 10.0)
+ if (sensorError)
+ {
+ reply.cat("error");
+ if (lastErrorCode != 0)
+ {
+ reply.catf(" %u", lastErrorCode);
+ }
+ }
+ else if (magneticMonitorState != MagneticMonitorState::calibrating && totalExtrusionCommanded > 10.0)
{
const float measuredMmPerRev = totalExtrusionCommanded/totalMovementMeasured;
reply.catf("measured sensitivity %.2fmm/rev, min %ld%% max %ld%% over %.1fmm\n",
@@ -167,6 +173,13 @@ void RotatingMagnetFilamentMonitor::HandleIncomingData()
// Data word: P00S 10pp pppppppp S = switch open, ppppppppppp = 10-bit filament position
// Error word: P010 0000 0000eeee eeee = error code
// Version word: P110 0000 vvvvvvvv vvvvvvvv = sensor/firmware version, at least 2
+ //
+ // Version 3 firmware:
+ // Data word: P00S 10pp pppppppp S = switch open, ppppppppppp = 10-bit filament position
+ // Error word: P010 0000 0000eeee eeee = error code
+ // Version word: P110 0000 vvvvvvvv vvvvvvvv = sensor/firmware version, at least 2
+ // Magnitude word P110 0010 mmmmmmmm mmmmmmmm = highest 8 bits of magnitude (cf. brightness of laser sensor)
+ // AGC word P110 0011 aaaaaaaa aaaaaaaa = AGC setting (cf. shutter of laser sensor)
if (version == 1)
{
if ((data8 & 1) == 0 && (val & 0x7F00) == 0x6000 && (val & 0x00FF) >= 2)
@@ -206,13 +219,26 @@ void RotatingMagnetFilamentMonitor::HandleIncomingData()
case TypeMagnetV2MessageTypeError:
lastErrorCode = val & 0x00FF;
- sensorError = true;
+ sensorError = (lastErrorCode != 0);
break;
case TypeMagnetV2MessageTypeInfo:
- if ((val & TypeMagnetV2InfoTypeMask) == TypeMagnetV2InfoTypeVersion)
+ switch (val & TypeMagnetV2InfoTypeMask)
{
+ case TypeMagnetV2InfoTypeVersion:
version = val & 0x00FF;
+ break;
+
+ case TypeMagnetV3InfoTypeMagnitude:
+ magnitude = val & 0x00FF;
+ break;
+
+ case TypeMagnetV3InfoTypeAgc:
+ agc = val & 0x00FF;
+ break;
+
+ default:
+ break;
}
break;
@@ -406,29 +432,18 @@ FilamentSensorStatus RotatingMagnetFilamentMonitor::Clear()
// Print diagnostic info for this sensor
void RotatingMagnetFilamentMonitor::Diagnostics(MessageType mtype, unsigned int extruder)
{
- const char* const statusText = (!dataReceived) ? "no data received"
- : (sensorError) ? "error"
- : ((sensorValue & switchOpenMask) != 0) ? "no filament"
- : "ok";
- reprap.GetPlatform().MessageF(mtype, "Extruder %u: pos %.2f, %s, ", extruder, (double)GetCurrentPosition(), statusText);
- if (magneticMonitorState != MagneticMonitorState::calibrating && totalExtrusionCommanded > 10.0)
+ String<FormatStringLength> buf;
+ buf.printf("Extruder %u: ", extruder);
+ if (dataReceived)
{
- const float measuredMmPerRev = totalExtrusionCommanded/totalMovementMeasured;
- reprap.GetPlatform().MessageF(mtype, "measured sens %.2fmm/rev min %ld%% max %ld%% over %.1fmm",
- (double)measuredMmPerRev,
- lrintf(100 * minMovementRatio * measuredMmPerRev),
- lrintf(100 * maxMovementRatio * measuredMmPerRev),
- (double)totalExtrusionCommanded);
+ buf.catf("pos %.2f, errs: frame %" PRIu32 " parity %" PRIu32 " ovrun %" PRIu32 " pol %" PRIu32 " ovdue %" PRIu32 "\n",
+ (double)GetCurrentPosition(), framingErrorCount, parityErrorCount, overrunErrorCount, polarityErrorCount, overdueCount);
}
else
{
- 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);
+ buf.cat("no data received\n");
}
+ reprap.GetPlatform().Message(mtype, buf.c_str());
}
// End
diff --git a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h
index 19b1f9c6..b3ed01a6 100644
--- a/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h
+++ b/src/FilamentMonitors/RotatingMagnetFilamentMonitor.h
@@ -45,6 +45,8 @@ private:
// Definitions for info message types
static constexpr uint16_t TypeMagnetV2InfoTypeMask = 0x1F00;
static constexpr uint16_t TypeMagnetV2InfoTypeVersion = 0x0000;
+ static constexpr uint16_t TypeMagnetV3InfoTypeMagnitude = 0x0200;
+ static constexpr uint16_t TypeMagnetV3InfoTypeAgc = 0x0300;
static constexpr uint16_t TypeMagnetAngleMask = 0x03FF; // we use a 10-bit sensor angle
@@ -78,6 +80,8 @@ private:
uint16_t switchOpenMask; // mask to isolate the switch open bit(s) from the sensor value
uint8_t version; // sensor/firmware version
uint8_t lastErrorCode; // the last error code received
+ uint8_t magnitude; // the last magnitude received (sensor firmware V3)
+ uint8_t agc; // the last agc received (sensor firmware V3)
bool sensorError; // true if received an error report (cleared by a position report)
bool wasPrintingAtStartBit;