diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-10-22 23:35:16 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-10-22 23:35:16 +0300 |
commit | 8a9e12718b8161283dba0d54907e5586b560993b (patch) | |
tree | 552c1be769028da59b9007af67e9ee8b9f15f5ef /src/GCodes | |
parent | 89e64be0cb6b8fb9f39a5fac0c47fc8d91ce137d (diff) |
Reduce acceleration when homing using stall detection
Diffstat (limited to 'src/GCodes')
-rw-r--r-- | src/GCodes/GCodes.cpp | 18 | ||||
-rw-r--r-- | src/GCodes/GCodes.h | 14 | ||||
-rw-r--r-- | src/GCodes/GCodes3.cpp | 12 |
3 files changed, 24 insertions, 20 deletions
diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index 8ba9a2c8..874088c3 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -1604,7 +1604,7 @@ bool GCodes::LockMovementAndWaitForStandstill(GCodeBuffer& gb) noexcept } // Save (some of) the state of the machine for recovery in the future. -bool GCodes::Push(GCodeBuffer& gb, bool withinSameFile) +bool GCodes::Push(GCodeBuffer& gb, bool withinSameFile) noexcept { const bool ok = gb.PushState(withinSameFile); if (!ok) @@ -1616,7 +1616,7 @@ bool GCodes::Push(GCodeBuffer& gb, bool withinSameFile) } // Recover a saved state -void GCodes::Pop(GCodeBuffer& gb) +void GCodes::Pop(GCodeBuffer& gb) noexcept { // FIXME If withinSameFile is false, we should pop all stack levels that have the same file (ID) // and output a warning message is the stack is popped more than once @@ -1631,7 +1631,7 @@ void GCodes::Pop(GCodeBuffer& gb) // 'moveBuffer.moveType' and 'moveBuffer.isCoordinated' must be set up before calling this // 'isPrintingMove' is true if there is any axis movement // Returns nullptr if this gcode is valid so far, or an error message if it should be discarded -const char * GCodes::LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingMove) +const char * GCodes::LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingMove) THROWS(GCodeException) { // Deal with feed rate, also determine whether M220 and M221 speed and extrusion factors apply to this move if (moveState.isCoordinated || machineType == MachineType::fff) @@ -1804,7 +1804,7 @@ bool GCodes::CheckEnoughAxesHomed(AxesBitmap axesMoved) noexcept // If we can't execute the move, return true with 'err' set to the error message // Else return true with 'err' left alone (it is set to nullptr on entry) // We have already acquired the movement lock and waited for the previous move to be taken. -bool GCodes::DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& err) +bool GCodes::DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& err) THROWS(GCodeException) { if (moveFractionToSkip > 0.0) { @@ -1997,10 +1997,14 @@ bool GCodes::DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& e // no break case 1: case 4: - if (!platform.GetEndstops().EnableAxisEndstops(axesMentioned & AxesBitmap::MakeLowestNBits(numTotalAxes), moveState.moveType == 1)) { - err = "Failed to enable endstops"; - return true; + bool reduceAcceleration; + if (!platform.GetEndstops().EnableAxisEndstops(axesMentioned & AxesBitmap::MakeLowestNBits(numTotalAxes), moveState.moveType == 1, reduceAcceleration)) + { + err = "Failed to enable endstops"; + return true; + } + moveState.reduceAcceleration = reduceAcceleration; } moveState.checkEndstops = true; break; diff --git a/src/GCodes/GCodes.h b/src/GCodes/GCodes.h index add5506e..e06bf300 100644 --- a/src/GCodes/GCodes.h +++ b/src/GCodes/GCodes.h @@ -377,8 +377,8 @@ private: GCodeResult TryMacroFile(GCodeBuffer& gb) noexcept; // Try to find a macro file that implements a G or M command - bool DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& err) SPEED_CRITICAL; // Execute a straight move - bool DoArcMove(GCodeBuffer& gb, bool clockwise, const char *& err) // Execute an arc move + bool DoStraightMove(GCodeBuffer& gb, bool isCoordinated, const char *& err) THROWS(GCodeException) SPEED_CRITICAL; // Execute a straight move + bool DoArcMove(GCodeBuffer& gb, bool clockwise, const char *& err) THROWS(GCodeException) // Execute an arc move pre(segmentsLeft == 0; resourceOwners[MoveResource] == &gb); void FinaliseMove(GCodeBuffer& gb) noexcept; // Adjust the move parameters to account for segmentation and/or part of the move having been done already bool CheckEnoughAxesHomed(AxesBitmap axesMoved) noexcept; // Check that enough axes have been homed @@ -414,12 +414,12 @@ private: bool ProcessWholeLineComment(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); // Process a whole-line comment - const char *LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingMove); // Set up the extrusion of a move + const char *LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingMove) THROWS(GCodeException); // Set up the extrusion of a move - bool Push(GCodeBuffer& gb, bool withinSameFile); // Push feedrate etc on the stack - void Pop(GCodeBuffer& gb); // Pop feedrate etc - void DisableDrives() noexcept; // Turn the motors off - bool SendConfigToLine(); // Deal with M503 + bool Push(GCodeBuffer& gb, bool withinSameFile) noexcept; // Push feedrate etc on the stack + void Pop(GCodeBuffer& gb) noexcept; // Pop feedrate etc + void DisableDrives() noexcept; // Turn the motors off + bool SendConfigToLine(); // Deal with M503 GCodeResult OffsetAxes(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); // Set/report offsets diff --git a/src/GCodes/GCodes3.cpp b/src/GCodes/GCodes3.cpp index 13a72f9e..b5ac630d 100644 --- a/src/GCodes/GCodes3.cpp +++ b/src/GCodes/GCodes3.cpp @@ -960,6 +960,7 @@ GCodeResult GCodes::ProbeTool(GCodeBuffer& gb, const StringRef& reply) THROWS(GC // Return true if successful, else SetError has been called to save the error message bool GCodes::SetupM585ProbingMove(GCodeBuffer& gb) noexcept { + bool reduceAcceleration; if (m585Settings.useProbe) { const auto zp = platform.GetZProbeOrDefault(currentZProbeNumber); @@ -973,20 +974,19 @@ bool GCodes::SetupM585ProbingMove(GCodeBuffer& gb) noexcept gb.LatestMachineState().SetError("Failed to enable probe"); return false; } + reduceAcceleration = true; } - else + else if (!platform.GetEndstops().EnableAxisEndstops(AxesBitmap::MakeFromBits(m585Settings.axisNumber), false, reduceAcceleration)) { - if (!platform.GetEndstops().EnableAxisEndstops(AxesBitmap::MakeFromBits(m585Settings.axisNumber), false)) - { - gb.LatestMachineState().SetError("Failed to enable endstop"); - return false; - } + gb.LatestMachineState().SetError("Failed to enable endstop"); + return false; } SetMoveBufferDefaults(); ToolOffsetTransform(moveState.currentUserPosition, moveState.coords); moveState.feedRate = m585Settings.feedRate; moveState.coords[m585Settings.axisNumber] = m585Settings.probingLimit; + moveState.reduceAcceleration = reduceAcceleration; moveState.checkEndstops = true; moveState.canPauseAfter = false; zProbeTriggered = false; |