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>2017-09-21 21:27:40 +0300
committerDavid Crocker <dcrocker@eschertech.com>2017-09-21 21:29:52 +0300
commit370060e84b9f30dd5d9edff817baaba154106c7c (patch)
treeaa399d680427189e6a8c62572c304b9b16118406 /src/Movement
parent77d6718860bd6ad383d29e0708c600fcba855116 (diff)
Version 1.20 alpha 2
Removed define of printf=iprintf in build settings Removed Platform::Time() function, use millis() or millis64() instead Added event logging to SD card. MessageType is now a bitmap. Implemented M929. Enable pullup resistors on endstops 10 and 11 SCARA printers can now use the manual bed levelling assistant When using the manual bed levelling assitant, don't give an error if the bed screw corrections were out of range, and always leave the first screw alone M552 now supports connection to a specified SSID M572 now allows multiple D values Thermocouple type letter in M305 command may now be in lower case Bug fix: G29 bed probing on a SCARA printer gave spurious "not reachable" warnings and skipped probe points Protect against a dud command line containing the letter M being interpreted as a M0 command Fix reference to towers in the error message when trying to move a SCARA printer before homing it When updating firmware, warn that USB will disconnect Fix duplicate error messatge when opening a gcode file fails
Diffstat (limited to 'src/Movement')
-rw-r--r--src/Movement/BedProbing/RandomProbePointSet.cpp13
-rw-r--r--src/Movement/BedProbing/RandomProbePointSet.h2
-rw-r--r--src/Movement/DDA.cpp4
-rw-r--r--src/Movement/Kinematics/Kinematics.cpp12
-rw-r--r--src/Movement/Kinematics/Kinematics.h10
-rw-r--r--src/Movement/Kinematics/LinearDeltaKinematics.cpp10
-rw-r--r--src/Movement/Kinematics/LinearDeltaKinematics.h2
-rw-r--r--src/Movement/Kinematics/ScaraKinematics.cpp8
-rw-r--r--src/Movement/Kinematics/ScaraKinematics.h5
-rw-r--r--src/Movement/Kinematics/ZLeadscrewKinematics.cpp56
-rw-r--r--src/Movement/Kinematics/ZLeadscrewKinematics.h6
-rw-r--r--src/Movement/Move.cpp61
-rw-r--r--src/Movement/Move.h12
13 files changed, 112 insertions, 89 deletions
diff --git a/src/Movement/BedProbing/RandomProbePointSet.cpp b/src/Movement/BedProbing/RandomProbePointSet.cpp
index c52c82f5..4dc03e04 100644
--- a/src/Movement/BedProbing/RandomProbePointSet.cpp
+++ b/src/Movement/BedProbing/RandomProbePointSet.cpp
@@ -72,15 +72,16 @@ void RandomProbePointSet::ClearProbeHeights()
}
}
-void RandomProbePointSet::SetProbedBedEquation(size_t numPoints, StringRef& reply)
+bool RandomProbePointSet::SetProbedBedEquation(size_t numPoints, StringRef& reply)
{
if (!GoodProbePointOrdering(numPoints))
{
- reply.printf("Error: probe points P0 to P%u must be in clockwise order starting near X=0 Y=0", min<unsigned int>(numPoints, 4) - 1);
+ reply.printf("Probe points P0 to P%u must be in clockwise order starting near X=0 Y=0", min<unsigned int>(numPoints, 4) - 1);
if (numPoints >= 5)
{
reply.cat(" and P4 must be near the centre");
}
+ return true;
}
else
{
@@ -141,8 +142,8 @@ void RandomProbePointSet::SetProbedBedEquation(size_t numPoints, StringRef& repl
break;
default:
- reprap.GetPlatform().MessageF(GENERIC_MESSAGE, "Bed calibration error: %d points provided but only 3, 4 and 5 supported\n", numPoints);
- return;
+ reply.printf("Bed calibration: %d points provided but only 3, 4 and 5 supported", numPoints);
+ return true;
}
numBedCompensationPoints = numPoints;
@@ -154,7 +155,7 @@ void RandomProbePointSet::SetProbedBedEquation(size_t numPoints, StringRef& repl
reply.catf(" [%.1f, %.1f, %.3f]", xBedProbePoints[point], yBedProbePoints[point], zBedProbePoints[point]);
}
}
- reply.cat("\n");
+ return false;
}
// Compute the interpolated height error at the specified point
@@ -295,7 +296,7 @@ float RandomProbePointSet::TriangleZ(float x, float y) const
return l1 * baryZBedProbePoints[i] + l2 * baryZBedProbePoints[j] + l3 * baryZBedProbePoints[4];
}
}
- reprap.GetPlatform().Message(GENERIC_MESSAGE, "Triangle interpolation: point outside all triangles!\n");
+ reprap.GetPlatform().Message(WarningMessage, "Triangle interpolation: point outside all triangles!\n");
return 0.0;
}
diff --git a/src/Movement/BedProbing/RandomProbePointSet.h b/src/Movement/BedProbing/RandomProbePointSet.h
index 8c09692f..67f0ce97 100644
--- a/src/Movement/BedProbing/RandomProbePointSet.h
+++ b/src/Movement/BedProbing/RandomProbePointSet.h
@@ -35,7 +35,7 @@ public:
void SetZBedProbePoint(size_t index, float z, bool wasXyCorrected, bool wasError); // Record the Z coordinate of a probe point
void ClearProbeHeights(); // Clear out the Z heights so that we don't re-use old points
- void SetProbedBedEquation(size_t numPoints, StringRef& reply); // When we have a full set of probed points, work out the bed's equation
+ bool SetProbedBedEquation(size_t numPoints, StringRef& reply); // When we have a full set of probed points, work out the bed's equation
void SetIdentity() { numBedCompensationPoints = 0; } // Set identity transform
float GetInterpolatedHeightError(float x, float y) const; // Compute the interpolated height error at the specified point
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp
index a25b9e9d..319a5341 100644
--- a/src/Movement/DDA.cpp
+++ b/src/Movement/DDA.cpp
@@ -12,7 +12,7 @@
#include "Kinematics/LinearDeltaKinematics.h" // for DELTA_AXES
#ifdef DUET_NG
-# define DDA_MOVE_DEBUG (1)
+# define DDA_MOVE_DEBUG (0)
#else
// On the wired Duets we don't have enough RAM to support this
# define DDA_MOVE_DEBUG (0)
@@ -48,7 +48,7 @@ static size_t savedMovePointer = 0;
for (size_t i = 0; i < NumSavedMoves; ++i)
{
const MoveParameters& m = savedMoves[savedMovePointer];
- reprap.GetPlatform().MessageF(DEBUG_MESSAGE, "%f,%f,%f,%f,%f,%f\n", m.accelDistance, m.steadyDistance, m.decelDistance, m.startSpeed, m.topSpeed, m.endSpeed);
+ reprap.GetPlatform().MessageF(DebugMessage, "%f,%f,%f,%f,%f,%f\n", m.accelDistance, m.steadyDistance, m.decelDistance, m.startSpeed, m.topSpeed, m.endSpeed);
savedMovePointer = (savedMovePointer + 1) % NumSavedMoves;
}
}
diff --git a/src/Movement/Kinematics/Kinematics.cpp b/src/Movement/Kinematics/Kinematics.cpp
index 7de5259b..7b6d0ce8 100644
--- a/src/Movement/Kinematics/Kinematics.cpp
+++ b/src/Movement/Kinematics/Kinematics.cpp
@@ -18,15 +18,9 @@
const char *Kinematics::HomeAllFileName = "homeall.g";
const char * const Kinematics::StandardHomingFileNames[] = AXES_("homex.g", "homey.g", "homez.g", "homeu.g", "homev.g", "homew.g", "homea.g", "homeb.g", "homec.g");
-// Constructor for non-segmented kinematics
-Kinematics::Kinematics(KinematicsType t)
- : useSegmentation(false), useRawG0(true), type(t)
-{
-}
-
-// Constructor for segmented kinematics
+// Constructor. Pass segsPerSecond <= 0.0 to get non-segmented kinematics.
Kinematics::Kinematics(KinematicsType t, float segsPerSecond, float minSegLength, bool doUseRawG0)
- : segmentsPerSecond(segsPerSecond), minSegmentLength(minSegLength), useSegmentation(true), useRawG0(doUseRawG0), type(t)
+ : segmentsPerSecond(segsPerSecond), minSegmentLength(minSegLength), useSegmentation(segsPerSecond > 0.0), useRawG0(doUseRawG0), type(t)
{
}
@@ -47,7 +41,7 @@ bool Kinematics::Configure(unsigned int mCode, GCodeBuffer& gb, StringRef& reply
}
// Return true if the specified XY position is reachable by the print head reference point.
-// This default implementation assumes a rectangular reachable area, so it just uses the bed dimensions give in the M280 command.
+// This default implementation assumes a rectangular reachable area, so it just uses the bed dimensions give in the M208 command.
bool Kinematics::IsReachable(float x, float y) const
{
const Platform& platform = reprap.GetPlatform();
diff --git a/src/Movement/Kinematics/Kinematics.h b/src/Movement/Kinematics/Kinematics.h
index 3ce7c256..91ec36e0 100644
--- a/src/Movement/Kinematics/Kinematics.h
+++ b/src/Movement/Kinematics/Kinematics.h
@@ -85,8 +85,9 @@ public:
virtual bool SupportsAutoCalibration() const { return false; }
// Perform auto calibration. Override this implementation in kinematics that support it. Caller already owns the movement lock.
- virtual void DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply)
- pre(SupportsAutoCalibration()) { }
+ // Return true if an error occurred.
+ virtual bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply)
+ pre(SupportsAutoCalibration()) { return false; }
// Set the default parameters that are changed by auto calibration back to their defaults.
// Do nothing if auto calibration is not supported.
@@ -166,10 +167,7 @@ public:
float GetMinSegmentLength() const pre(UseSegmentation()) { return minSegmentLength; }
protected:
- // This constructor is used by derived classes that implement non-segmented linear motion
- Kinematics(KinematicsType t);
-
- // This constructor is used by derived classes that implement segmented linear motion
+ // Constructor. Pass segsPerSecond <= 0.0 to get non-segmented motion.
Kinematics(KinematicsType t, float segsPerSecond, float minSegLength, bool doUseRawG0);
// Apply the M208 limits to the Cartesian position that the user wants to move to for all axes from the specified one upwards
diff --git a/src/Movement/Kinematics/LinearDeltaKinematics.cpp b/src/Movement/Kinematics/LinearDeltaKinematics.cpp
index 9acc9313..1a700bf6 100644
--- a/src/Movement/Kinematics/LinearDeltaKinematics.cpp
+++ b/src/Movement/Kinematics/LinearDeltaKinematics.cpp
@@ -12,7 +12,7 @@
#include "RepRap.h"
#include "Storage/FileStore.h"
-LinearDeltaKinematics::LinearDeltaKinematics() : Kinematics(KinematicsType::linearDelta)
+LinearDeltaKinematics::LinearDeltaKinematics() : Kinematics(KinematicsType::linearDelta, -1.0, 0.0, true)
{
Init();
}
@@ -224,15 +224,15 @@ void LinearDeltaKinematics::GetAssumedInitialPosition(size_t numAxes, float posi
}
// Auto calibrate from a set of probe points
-void LinearDeltaKinematics::DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply)
+bool LinearDeltaKinematics::DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply)
{
const size_t NumDeltaFactors = 9; // maximum number of delta machine factors we can adjust
const size_t numPoints = probePoints.NumberOfProbePoints();
if (numFactors < 3 || numFactors > NumDeltaFactors || numFactors == 5)
{
- reply.printf("Error: Delta calibration with %d factors requested but only 3, 4, 6, 7, 8 and 9 supported", numFactors);
- return;
+ reply.printf("Delta calibration with %d factors requested but only 3, 4, 6, 7, 8 and 9 supported", numFactors);
+ return true;
}
if (reprap.Debug(moduleMove))
@@ -396,8 +396,10 @@ void LinearDeltaKinematics::DoAutoCalibration(size_t numFactors, const RandomPro
reply.printf("Calibrated %d factors using %d points, deviation before %.3f after %.3f",
numFactors, numPoints, sqrt(initialSumOfSquares/numPoints), expectedRmsError);
+ reprap.GetPlatform().MessageF(LogMessage, "%s\n", reply.Pointer());
doneAutoCalibration = true;
+ return false;
}
// Return the type of motion computation needed by an axis
diff --git a/src/Movement/Kinematics/LinearDeltaKinematics.h b/src/Movement/Kinematics/LinearDeltaKinematics.h
index 4d54e486..df10a1b1 100644
--- a/src/Movement/Kinematics/LinearDeltaKinematics.h
+++ b/src/Movement/Kinematics/LinearDeltaKinematics.h
@@ -29,7 +29,7 @@ public:
bool CartesianToMotorSteps(const float machinePos[], const float stepsPerMm[], size_t numVisibleAxes, size_t numTotalAxes, int32_t motorPos[]) const override;
void MotorStepsToCartesian(const int32_t motorPos[], const float stepsPerMm[], size_t numVisibleAxes, size_t numTotalAxes, float machinePos[]) const override;
bool SupportsAutoCalibration() const override { return true; }
- void DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply) override;
+ bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply) override;
void SetCalibrationDefaults() override { Init(); }
bool WriteCalibrationParameters(FileStore *f) const override;
float GetTiltCorrection(size_t axis) const override;
diff --git a/src/Movement/Kinematics/ScaraKinematics.cpp b/src/Movement/Kinematics/ScaraKinematics.cpp
index 8fd1cad2..18674867 100644
--- a/src/Movement/Kinematics/ScaraKinematics.cpp
+++ b/src/Movement/Kinematics/ScaraKinematics.cpp
@@ -13,7 +13,7 @@
#include "Movement/DDA.h"
ScaraKinematics::ScaraKinematics()
- : Kinematics(KinematicsType::scara, DefaultSegmentsPerSecond, DefaultMinSegmentSize, true),
+ : ZLeadscrewKinematics(KinematicsType::scara, DefaultSegmentsPerSecond, DefaultMinSegmentSize, true),
proximalArmLength(DefaultProximalArmLength), distalArmLength(DefaultDistalArmLength), xOffset(0.0), yOffset(0.0)
{
thetaLimits[0] = DefaultMinTheta;
@@ -163,7 +163,7 @@ bool ScaraKinematics::Configure(unsigned int mCode, GCodeBuffer& gb, StringRef&
}
else
{
- return Kinematics::Configure(mCode, gb, reply, error);
+ return ZLeadscrewKinematics::Configure(mCode, gb, reply, error);
}
}
@@ -172,8 +172,8 @@ bool ScaraKinematics::Configure(unsigned int mCode, GCodeBuffer& gb, StringRef&
bool ScaraKinematics::IsReachable(float x, float y) const
{
// TODO The following isn't quite right, in particular it doesn't take account of the maximum arm travel
- const float r = sqrtf(fsquare(x) + fsquare(y));
- return r >= minRadius && r <= maxRadius && x > 0.0;
+ const float r = sqrtf(fsquare(x + xOffset) + fsquare(y + yOffset));
+ return r >= minRadius && r <= maxRadius && (x + xOffset) > 0.0;
}
// Limit the Cartesian position that the user wants to move to
diff --git a/src/Movement/Kinematics/ScaraKinematics.h b/src/Movement/Kinematics/ScaraKinematics.h
index 058ababf..248d9008 100644
--- a/src/Movement/Kinematics/ScaraKinematics.h
+++ b/src/Movement/Kinematics/ScaraKinematics.h
@@ -8,7 +8,7 @@
#ifndef SRC_MOVEMENT_KINEMATICS_SCARAKINEMATICS_H_
#define SRC_MOVEMENT_KINEMATICS_SCARAKINEMATICS_H_
-#include "Kinematics.h"
+#include "ZLeadscrewKinematics.h"
// Standard setup for SCARA machines assumed by this firmware
// The X motor output drives the proximal arm joint, unless remapped using M584
@@ -19,7 +19,7 @@
// Phi is the angle of the distal arm relative to the Cartesian X axis. Therefore the angle of the distal arm joint is (phi - theta).
// The M92 steps/mm settings for X and Y are interpreted as steps per degree of theta and phi respectively.
-class ScaraKinematics : public Kinematics
+class ScaraKinematics : public ZLeadscrewKinematics
{
public:
// Constructors
@@ -30,7 +30,6 @@ public:
bool Configure(unsigned int mCode, GCodeBuffer& gb, StringRef& reply, bool& error) override;
bool CartesianToMotorSteps(const float machinePos[], const float stepsPerMm[], size_t numVisibleAxes, size_t numTotalAxes, int32_t motorPos[]) const override;
void MotorStepsToCartesian(const int32_t motorPos[], const float stepsPerMm[], size_t numVisibleAxes, size_t numTotalAxes, float machinePos[]) const override;
- bool SupportsAutoCalibration() const override { return false; }
bool IsReachable(float x, float y) const override;
bool LimitPosition(float position[], size_t numAxes, AxesBitmap axesHomed) const override;
void GetAssumedInitialPosition(size_t numAxes, float positions[]) const override;
diff --git a/src/Movement/Kinematics/ZLeadscrewKinematics.cpp b/src/Movement/Kinematics/ZLeadscrewKinematics.cpp
index 00432ca2..7d3e6c93 100644
--- a/src/Movement/Kinematics/ZLeadscrewKinematics.cpp
+++ b/src/Movement/Kinematics/ZLeadscrewKinematics.cpp
@@ -12,7 +12,13 @@
const float M3ScrewPitch = 0.5;
-ZLeadscrewKinematics::ZLeadscrewKinematics(KinematicsType k) : Kinematics(k), numLeadscrews(0), maxCorrection(1.0), screwPitch(M3ScrewPitch)
+ZLeadscrewKinematics::ZLeadscrewKinematics(KinematicsType k)
+ : Kinematics(k, -1.0, 0.0, true), numLeadscrews(0), maxCorrection(1.0), screwPitch(M3ScrewPitch)
+{
+}
+
+ZLeadscrewKinematics::ZLeadscrewKinematics(KinematicsType k, float segsPerSecond, float minSegLength, bool doUseRawG0)
+ : Kinematics(k, segsPerSecond, minSegLength, doUseRawG0), numLeadscrews(0), maxCorrection(1.0), screwPitch(M3ScrewPitch)
{
}
@@ -84,16 +90,17 @@ bool ZLeadscrewKinematics::SupportsAutoCalibration() const
}
// Perform auto calibration. Override this implementation in kinematics that support it. Caller already owns the GCode movement lock.
-void ZLeadscrewKinematics::DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply)
+bool ZLeadscrewKinematics::DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply)
{
if (!SupportsAutoCalibration()) // should be checked by caller, but check it here too
{
- return;
+ return false;
}
if (numFactors != numLeadscrews)
{
- reply.printf("Error: Number of calibration factors (%u) not equal to number of leadscrews (%u)", numFactors, numLeadscrews);
+ reply.printf("Number of calibration factors (%u) not equal to number of leadscrews (%u)", numFactors, numLeadscrews);
+ return true;
}
const size_t numPoints = probePoints.NumberOfProbePoints();
@@ -262,44 +269,43 @@ void ZLeadscrewKinematics::DoAutoCalibration(size_t numFactors, const RandomProb
if (haveNaN)
{
- reply.printf("Error: calibration failed, computed corrections:");
- AppendCorrections(solution, reply);
- }
- else if (haveLargeCorrection)
- {
- reply.printf("Error: some computed corrections exceed configured limit of %.02fmm:", maxCorrection);
+ reply.printf("Calibration failed, computed corrections:");
AppendCorrections(solution, reply);
+ return true;
}
else
{
const size_t numZDrivers = reprap.GetPlatform().GetAxisDriversConfig(Z_AXIS).numDrivers;
if (numZDrivers == numLeadscrews)
{
- reprap.GetMove().AdjustLeadscrews(solution);
- reply.printf("Leadscrew adjustments made:");
- AppendCorrections(solution, reply);
- reply.catf(", points used %d, deviation before %.3f after %.3f",
- numPoints, sqrt(initialSumOfSquares/numPoints), sqrtf(sumOfSquares/numPoints));
+ if (haveLargeCorrection)
+ {
+ reply.printf("Some computed corrections exceed configured limit of %.02fmm:", maxCorrection);
+ AppendCorrections(solution, reply);
+ return true;
+ }
+ else
+ {
+ reprap.GetMove().AdjustLeadscrews(solution);
+ reply.printf("Leadscrew adjustments made:");
+ AppendCorrections(solution, reply);
+ reply.catf(", points used %d, deviation before %.3f after %.3f",
+ numPoints, sqrt(initialSumOfSquares/numPoints), sqrtf(sumOfSquares/numPoints));
+ reprap.GetPlatform().MessageF(LogMessage, "%s\n", reply.Pointer());
+ }
}
else
{
// User wants manual corrections for bed levelling screws.
- // Pick the one with the smallest adjustment to leave alone.
- float smallestCorrection = solution[0];
- for (size_t i = 1; i < numLeadscrews; ++i)
- {
- if (fabs(solution[i]) < fabs(smallestCorrection))
- {
- smallestCorrection = solution[i];
- }
- }
+ // Leave the first one alone.
reply.printf("Manual corrections required:");
for (size_t i = 0; i < numLeadscrews; ++i)
{
- const float netAdjustment = solution[i] - smallestCorrection;
+ const float netAdjustment = solution[i] - solution[0];
reply.catf(" %.2f turn %s (%.2fmm)", fabs(netAdjustment)/screwPitch, (netAdjustment > 0) ? "down" : "up", netAdjustment);
}
}
+ return false;
}
}
diff --git a/src/Movement/Kinematics/ZLeadscrewKinematics.h b/src/Movement/Kinematics/ZLeadscrewKinematics.h
index b7a00596..a6caa4a5 100644
--- a/src/Movement/Kinematics/ZLeadscrewKinematics.h
+++ b/src/Movement/Kinematics/ZLeadscrewKinematics.h
@@ -10,13 +10,17 @@
#include "Kinematics.h"
+// This is used as the base class for any kinematic that supports auto or manual bed levelling (as distinct from bed compensation)
+// using leadscrews or bed adjusting screws.
class ZLeadscrewKinematics : public Kinematics
{
public:
ZLeadscrewKinematics(KinematicsType k);
+ ZLeadscrewKinematics(KinematicsType t, float segsPerSecond, float minSegLength, bool doUseRawG0);
+
bool Configure(unsigned int mCode, GCodeBuffer& gb, StringRef& reply, bool& error) override;
bool SupportsAutoCalibration() const override;
- void DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply) override;
+ bool DoAutoCalibration(size_t numFactors, const RandomProbePointSet& probePoints, StringRef& reply) override;
#ifdef DUET_NG
bool WriteResumeSettings(FileStore *f) const override;
diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp
index 7bfee5ee..29166bb6 100644
--- a/src/Movement/Move.cpp
+++ b/src/Movement/Move.cpp
@@ -72,8 +72,8 @@ void Move::Init()
usingMesh = false;
useTaper = false;
- longWait = reprap.GetPlatform().Time();
- idleTimeout = DEFAULT_IDLE_TIMEOUT;
+ longWait = millis();
+ idleTimeout = DefaultIdleTimeout;
iState = IdleState::idle;
idleCount = 0;
@@ -256,7 +256,7 @@ void Move::Spin()
}
else
{
- Platform::DisableStepInterrupt(); // should be disabled already because we weren't executing a move, but make sure
+ Platform::DisableStepInterrupt(); // should be disabled already because we weren't executing a move, but make sure
if (StartNextMove(Platform::GetInterruptClocks())) // start the next move
{
Interrupt();
@@ -264,15 +264,18 @@ void Move::Spin()
}
iState = IdleState::busy;
}
- else if (!simulationMode != 0 && iState == IdleState::busy && !reprap.GetGCodes().IsPaused() && idleTimeout > 0.0)
+ else if (simulationMode != 0)
{
- lastMoveTime = reprap.GetPlatform().Time(); // record when we first noticed that the machine was idle
- iState = IdleState::timing;
- }
- else if (!simulationMode != 0 && iState == IdleState::timing && reprap.GetPlatform().Time() - lastMoveTime >= idleTimeout)
- {
- reprap.GetPlatform().SetDriversIdle(); // put all drives in idle hold
- iState = IdleState::idle;
+ if (iState == IdleState::busy && !reprap.GetGCodes().IsPaused())
+ {
+ lastMoveTime = millis(); // record when we first noticed that the machine was idle
+ iState = IdleState::timing;
+ }
+ else if (iState == IdleState::timing && millis() - lastMoveTime >= idleTimeout)
+ {
+ reprap.GetPlatform().SetDriversIdle(); // put all drives in idle hold
+ iState = IdleState::idle;
+ }
}
}
}
@@ -534,7 +537,7 @@ void Move::Diagnostics(MessageType mtype)
// For debugging
if (sqCount != 0)
{
- p.AppendMessage(GENERIC_MESSAGE, "Average sqrt times %.2f, %.2f, count %u, errors %u, last %" PRIu64 " %u %u\n",
+ 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;
}
@@ -560,7 +563,7 @@ void Move::SetPositions(const float move[DRIVES])
}
else
{
- reprap.GetPlatform().Message(GENERIC_MESSAGE, "SetPositions called when DDA ring not empty\n");
+ reprap.GetPlatform().Message(ErrorMessage, "SetPositions called when DDA ring not empty\n");
}
}
@@ -809,11 +812,12 @@ void Move::SetAxisCompensation(unsigned int axis, float tangent)
}
}
-// Calibrate or set the bed equation after probing.
+// Calibrate or set the bed equation after probing, returning true if an error occurred
// sParam is the value of the S parameter in the G30 command that provoked this call.
// Caller already owns the GCode movement lock.
-void Move::FinishedBedProbing(int sParam, StringRef& reply)
+bool Move::FinishedBedProbing(int sParam, StringRef& reply)
{
+ bool error = false;
const size_t numPoints = probePoints.NumberOfProbePoints();
if (sParam < 0)
@@ -823,7 +827,8 @@ void Move::FinishedBedProbing(int sParam, StringRef& reply)
}
else if (numPoints < (size_t)sParam)
{
- reprap.GetPlatform().MessageF(GENERIC_MESSAGE, "Bed calibration error: %d factor calibration requested but only %d points provided\n", sParam, numPoints);
+ reply.printf("Bed calibration : %d factor calibration requested but only %d points provided\n", sParam, numPoints);
+ error = true;
}
else
{
@@ -839,21 +844,23 @@ void Move::FinishedBedProbing(int sParam, StringRef& reply)
if (!probePoints.GoodProbePoints(numPoints))
{
- reply.cat("Compensation or calibration cancelled due to probing errors");
+ reply.copy("Compensation or calibration cancelled due to probing errors");
+ error = true;
}
else if (kinematics->SupportsAutoCalibration())
{
- kinematics->DoAutoCalibration(sParam, probePoints, reply);
+ error = kinematics->DoAutoCalibration(sParam, probePoints, reply);
}
else
{
- probePoints.SetProbedBedEquation(sParam, reply);
+ error = probePoints.SetProbedBedEquation(sParam, reply);
}
}
// Clear out the Z heights so that we don't re-use old points.
// This allows us to use different numbers of probe point on different occasions.
probePoints.ClearProbeHeights();
+ return error;
}
// Perform motor endpoint adjustment
@@ -1031,7 +1038,7 @@ void Move::SetXYBedProbePoint(size_t index, float x, float y)
{
if (index >= MaxProbePoints)
{
- reprap.GetPlatform().Message(GENERIC_MESSAGE, "Z probe point index out of range.\n");
+ reprap.GetPlatform().Message(ErrorMessage, "Z probe point index out of range.\n");
}
else
{
@@ -1043,7 +1050,7 @@ void Move::SetZBedProbePoint(size_t index, float z, bool wasXyCorrected, bool wa
{
if (index >= MaxProbePoints)
{
- reprap.GetPlatform().Message(GENERIC_MESSAGE, "Z probe point Z index out of range.\n");
+ reprap.GetPlatform().Message(ErrorMessage, "Z probe point Z index out of range.\n");
}
else
{
@@ -1093,6 +1100,18 @@ void Move::AdjustLeadscrews(const floatc_t corrections[])
specialMoveAvailable = true;
}
+// Return the idle timeout in seconds
+float Move::IdleTimeout() const
+{
+ return (float)idleTimeout * 0.001;
+}
+
+// Set the idle timeout in seconds
+void Move::SetIdleTimeout(float timeout)
+{
+ idleTimeout = (uint32_t)lrintf(timeout * 1000.0);
+}
+
#ifdef DUET_NG
// Write settings for resuming the print
diff --git a/src/Movement/Move.h b/src/Movement/Move.h
index 7e65c8bd..68273194 100644
--- a/src/Movement/Move.h
+++ b/src/Movement/Move.h
@@ -56,7 +56,7 @@ public:
void SetXYBedProbePoint(size_t index, float x, float y); // Record the X and Y coordinates of a probe point
void SetZBedProbePoint(size_t index, float z, bool wasXyCorrected, bool wasError); // Record the Z coordinate of a probe point
float GetProbeCoordinates(int count, float& x, float& y, bool wantNozzlePosition) const; // Get pre-recorded probe coordinates
- void FinishedBedProbing(int sParam, StringRef& reply); // Calibrate or set the bed equation after probing
+ bool FinishedBedProbing(int sParam, StringRef& reply); // Calibrate or set the bed equation after probing
void SetAxisCompensation(unsigned int axis, float tangent); // Set an axis-pair compensation angle
float AxisCompensation(unsigned int axis) const; // The tangent value
void SetIdentityTransform(); // Cancel the bed equation; does not reset axis angle compensation
@@ -92,8 +92,8 @@ public:
void CurrentMoveCompleted(); // Signal that the current move has just been completed
bool TryStartNextMove(uint32_t startTime); // Try to start another move, returning true if Step() needs to be called immediately
- float IdleTimeout() const { return idleTimeout; } // Returns the idle timeout in seconds
- void SetIdleTimeout(float timeout) { idleTimeout = timeout; } // Set the idle timeout in seconds
+ float IdleTimeout() const; // Returns the idle timeout in seconds
+ void SetIdleTimeout(float timeout); // Set the idle timeout in seconds
void Simulate(uint8_t simMode); // Enter or leave simulation mode
float GetSimulationTime() const { return simulationTime; } // Get the accumulated simulation time
@@ -171,9 +171,9 @@ private:
bool usingMesh; // true if we are using the height map, false if we are using the random probe point set
float taperHeight; // Height over which we taper
- float idleTimeout; // How long we wait with no activity before we reduce motor currents to idle
- float lastMoveTime; // The approximate time at which the last move was completed, or 0
- float longWait; // A long time for things that need to be done occasionally
+ uint32_t idleTimeout; // How long we wait with no activity before we reduce motor currents to idle, in milliseconds
+ uint32_t lastMoveTime; // The approximate time at which the last move was completed
+ uint32_t longWait; // A long time for things that need to be done occasionally
IdleState iState; // whether the idle timer is active
Kinematics *kinematics; // What kinematics we are using