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
path: root/src
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2021-07-24 22:26:37 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-07-24 22:26:37 +0300
commit5bc2241603812ed77d4a266b5c696916eac90d3c (patch)
treee0254f91905e2da730076fd402d8df403fd67c2a /src
parentdef6d8e577eac030a674a27962f1b93a8f86fe09 (diff)
Corrected pressure advance for new time units
Diffstat (limited to 'src')
-rw-r--r--src/Movement/DDA.cpp6
-rw-r--r--src/Movement/DriveMovement.cpp8
-rw-r--r--src/Movement/ExtruderShaper.h9
-rw-r--r--src/Movement/Move.cpp6
-rw-r--r--src/Movement/Move.h6
-rw-r--r--src/Platform/Platform.cpp2
6 files changed, 20 insertions, 17 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp
index 173a2989..741ae844 100644
--- a/src/Movement/DDA.cpp
+++ b/src/Movement/DDA.cpp
@@ -388,11 +388,11 @@ bool DDA::InitStandardMove(DDARing& ring, const RawMove &nextMove, bool doMotorM
}
if (flags.xyMoving && nextMove.usePressureAdvance)
{
- const float compensationTime = reprap.GetMove().GetPressureAdvance(LogicalDriveToExtruder(drive));
- if (compensationTime > 0.0)
+ const float compensationClocks = reprap.GetMove().GetPressureAdvanceClocks(LogicalDriveToExtruder(drive));
+ if (compensationClocks > 0.0)
{
// Compensation causes instant velocity changes equal to acceleration * k, so we may need to limit the acceleration
- accelerations[drive] = min<float>(accelerations[drive], reprap.GetPlatform().GetInstantDv(drive)/compensationTime);
+ accelerations[drive] = min<float>(accelerations[drive], reprap.GetPlatform().GetInstantDv(drive)/compensationClocks);
}
}
}
diff --git a/src/Movement/DriveMovement.cpp b/src/Movement/DriveMovement.cpp
index 0d63df0f..e8b13466 100644
--- a/src/Movement/DriveMovement.cpp
+++ b/src/Movement/DriveMovement.cpp
@@ -67,8 +67,8 @@ void DriveMovement::DebugPrint() const noexcept
}
else if (isExtruder)
{
- debugPrintf(" pa=%.1f eed=%.3f ep=%.3f\n",
- (double)mp.cart.pressureAdvanceK, (double)mp.cart.extraExtrusionDistance, (double)reprap.GetMove().GetExtruderShaper(LogicalDriveToExtruder(drive)).GetK());
+ debugPrintf(" pa=%.1f eed=%.3f ep=%" PRIu32 "\n",
+ (double)mp.cart.pressureAdvanceK, (double)mp.cart.extraExtrusionDistance, (uint32_t)reprap.GetMove().GetExtruderShaper(LogicalDriveToExtruder(drive)).GetKclocks());
}
else
{
@@ -379,10 +379,10 @@ bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params) no
float forwardDistance = distanceSoFar;
float reverseDistance;
- if (dda.flags.usePressureAdvance && shaper.GetK() > 0.0)
+ if (dda.flags.usePressureAdvance && shaper.GetKclocks() > 0.0)
{
// We are using nonzero pressure advance. Movement must be forwards.
- mp.cart.pressureAdvanceK = shaper.GetK() * StepClockRate;
+ mp.cart.pressureAdvanceK = shaper.GetKclocks();
mp.cart.extraExtrusionDistance = mp.cart.pressureAdvanceK * dda.acceleration * params.accelClocks;
forwardDistance += mp.cart.extraExtrusionDistance;
diff --git a/src/Movement/ExtruderShaper.h b/src/Movement/ExtruderShaper.h
index 75594e9a..8bd68a1a 100644
--- a/src/Movement/ExtruderShaper.h
+++ b/src/Movement/ExtruderShaper.h
@@ -8,6 +8,8 @@
#ifndef SRC_MOVEMENT_EXTRUDERSHAPER_H_
#define SRC_MOVEMENT_EXTRUDERSHAPER_H_
+#include <RepRapFirmware.h>
+
class DDA;
class BasicPrepParams;
class MoveSegment;
@@ -21,13 +23,14 @@ public:
ExtruderShaper() : k(0.0), extrusionPending(0.0) /*, lastSpeed(0.0)*/ { }
// Temporary functions until we support more sophisticated pressure advance
- float GetK() const noexcept { return k; }
- void SetK(float val) noexcept { k = val; }
+ float GetKclocks() const noexcept { return k; } // get pressure advance in step clocks
+ float GetKseconds() const noexcept { return k * StepClockRate; }
+ void SetKseconds(float val) noexcept { k = val * (1.0/StepClockRate); } // set pressure advance in seconds
float GetExtrusionPending() const noexcept { return extrusionPending; }
void SetExtrusionPending(float ep) noexcept { extrusionPending = ep; }
private:
- float k; // the pressure advance constant in seconds
+ float k; // the pressure advance constant in step clocks
float extrusionPending; // extrusion we have been asked to do but haven't because it is less than one microstep, in mm
// float lastSpeed; // the speed we were moving at at the end of the last extrusion, needed to implement pressure advance
};
diff --git a/src/Movement/Move.cpp b/src/Movement/Move.cpp
index 08c8761f..3ad5350a 100644
--- a/src/Movement/Move.cpp
+++ b/src/Movement/Move.cpp
@@ -1038,7 +1038,7 @@ GCodeResult Move::ConfigurePressureAdvance(GCodeBuffer& gb, const StringRef& rep
rslt = GCodeResult::error;
break;
}
- extruderShapers[extruder].SetK(advance);
+ extruderShapers[extruder].SetKseconds(advance);
#if SUPPORT_CAN_EXPANSION
const DriverId did = platform.GetExtruderDriver(extruder);
if (did.IsRemote())
@@ -1072,7 +1072,7 @@ GCodeResult Move::ConfigurePressureAdvance(GCodeBuffer& gb, const StringRef& rep
#else
ct->IterateExtruders([this, advance](unsigned int extruder)
{
- extruderShapers[extruder].SetK(advance);
+ extruderShapers[extruder].SetKseconds(advance);
}
);
#endif
@@ -1090,7 +1090,7 @@ GCodeResult Move::ConfigurePressureAdvance(GCodeBuffer& gb, const StringRef& rep
char c = ':';
for (size_t i = 0; i < reprap.GetGCodes().GetNumExtruders(); ++i)
{
- reply.catf("%c %.3f", c, (double)extruderShapers[i].GetK());
+ reply.catf("%c %.3f", c, (double)extruderShapers[i].GetKseconds());
c = ',';
}
return GCodeResult::ok;
diff --git a/src/Movement/Move.h b/src/Movement/Move.h
index 5bca6653..85c66b32 100644
--- a/src/Movement/Move.h
+++ b/src/Movement/Move.h
@@ -96,7 +96,7 @@ public:
GCodeResult ConfigureMovementQueue(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); // process M595
GCodeResult ConfigurePressureAdvance(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException); // process M572
- float GetPressureAdvance(size_t extruder) const noexcept;
+ float GetPressureAdvanceClocks(size_t extruder) const noexcept;
#if SUPPORT_REMOTE_COMMANDS
GCodeResult EutSetRemotePressureAdvance(const CanMessageMultipleDrivesRequest<float>& msg, size_t dataLength, const StringRef& reply) noexcept;
@@ -337,9 +337,9 @@ inline void Move::ResetExtruderPositions() noexcept
mainDDARing.ResetExtruderPositions();
}
-inline float Move::GetPressureAdvance(size_t extruder) const noexcept
+inline float Move::GetPressureAdvanceClocks(size_t extruder) const noexcept
{
- return (extruder < MaxExtruders) ? extruderShapers[extruder].GetK() : 0.0;
+ return (extruder < MaxExtruders) ? extruderShapers[extruder].GetKclocks() : 0.0;
}
#if HAS_SMART_DRIVERS
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp
index e2c4091a..8c580323 100644
--- a/src/Platform/Platform.cpp
+++ b/src/Platform/Platform.cpp
@@ -294,7 +294,7 @@ constexpr ObjectModelTableEntry Platform::objectModelTable[] =
{ "microstepping", OBJECT_MODEL_FUNC(self, 8), ObjectModelEntryFlags::none },
{ "nonlinear", OBJECT_MODEL_FUNC(self, 5), ObjectModelEntryFlags::none },
{ "position", OBJECT_MODEL_FUNC_NOSELF(ExpressionValue(reprap.GetMove().LiveCoordinate(ExtruderToLogicalDrive(context.GetLastIndex()), reprap.GetCurrentTool()), 1)), ObjectModelEntryFlags::live },
- { "pressureAdvance", OBJECT_MODEL_FUNC_NOSELF(reprap.GetMove().GetPressureAdvance(context.GetLastIndex()), 2), ObjectModelEntryFlags::none },
+ { "pressureAdvance", OBJECT_MODEL_FUNC_NOSELF(reprap.GetMove().GetPressureAdvanceClocks(context.GetLastIndex()) * StepClockRate, 2), ObjectModelEntryFlags::none },
{ "rawPosition", OBJECT_MODEL_FUNC_NOSELF(ExpressionValue(reprap.GetGCodes().GetRawExtruderTotalByDrive(context.GetLastIndex()), 1)), ObjectModelEntryFlags::live },
{ "speed", OBJECT_MODEL_FUNC(InverseConvertSpeedToMmPerMin(self->MaxFeedrate(ExtruderToLogicalDrive(context.GetLastIndex()))), 1), ObjectModelEntryFlags::none },
{ "stepsPerMm", OBJECT_MODEL_FUNC(self->driveStepsPerUnit[ExtruderToLogicalDrive(context.GetLastIndex())], 2), ObjectModelEntryFlags::none },