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:
authorManuel Coenen <manuel@duet3d.com>2021-01-21 17:56:14 +0300
committerManuel Coenen <manuel@duet3d.com>2021-01-21 17:56:14 +0300
commit583e44c3db6c7d384644bd4a05b5b28bd12641d7 (patch)
tree60e1cfb478602dcb24a59bbd5e5b4be84f1101a6 /src/Movement
parent5ec01da718095400c6fd77e04f4c0a1ab0103e5c (diff)
parentcb414c464db7167c51df3dad89121f5050eeeafc (diff)
Merge remote-tracking branch 'origin/3.3-dev' into wil-convert-same70-to-coren2g
Diffstat (limited to 'src/Movement')
-rw-r--r--src/Movement/DDA.cpp16
-rw-r--r--src/Movement/DriveMovement.cpp8
-rw-r--r--src/Movement/DriveMovement.h2
-rw-r--r--src/Movement/StepperDrivers/TMC22xx.cpp7
4 files changed, 21 insertions, 12 deletions
diff --git a/src/Movement/DDA.cpp b/src/Movement/DDA.cpp
index 6cf3fd34..7859545e 100644
--- a/src/Movement/DDA.cpp
+++ b/src/Movement/DDA.cpp
@@ -655,7 +655,7 @@ bool DDA::InitFromRemote(const CanMessageMovementLinear& msg) noexcept
params.topSpeedTimesCdivD = (uint32_t)roundU32(topSpeed/deceleration);
afterPrepare.topSpeedTimesCdivDPlusDecelStartClocks = params.topSpeedTimesCdivD + msg.accelerationClocks + msg.steadyClocks;
afterPrepare.extraAccelerationClocks = msg.accelerationClocks - roundS32(params.accelDistance/topSpeed);
- params.compFactor = (topSpeed - startSpeed)/topSpeed;
+ params.accelCompFactor = (topSpeed - startSpeed)/topSpeed;
activeDMs = nullptr;
@@ -1299,12 +1299,12 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
#if SUPPORT_CAN_EXPANSION
params.accelTime = accelStopTime;
params.steadyTime = steadyTime;
- params.decelTime = (topSpeed - endSpeed)/acceleration;
+ params.decelTime = (topSpeed - endSpeed)/deceleration;
params.initialSpeedFraction = startSpeed/topSpeed;
params.finalSpeedFraction = endSpeed/topSpeed;
- params.compFactor = 1.0 - params.initialSpeedFraction;
+ params.accelCompFactor = 1.0 - params.initialSpeedFraction;
#else
- params.compFactor = (topSpeed - startSpeed)/topSpeed;
+ params.accelCompFactor = (topSpeed - startSpeed)/topSpeed;
#endif
const float decelStartTime = accelStopTime + steadyTime;
afterPrepare.startSpeedTimesCdivA = (uint32_t)roundU32((startSpeed * StepTimer::StepClockRate)/acceleration);
@@ -1578,7 +1578,13 @@ void DDA::Prepare(uint8_t simMode, float extrusionPending[]) noexcept
}
#if SUPPORT_CAN_EXPANSION
- CanMotion::FinishMovement(afterPrepare.moveStartTime);
+ const uint32_t canClocksNeeded = CanMotion::FinishMovement(afterPrepare.moveStartTime);
+ if (canClocksNeeded > clocksNeeded)
+ {
+ // Due to rounding error in the calculations, we quite often calculate the CAN move as being longer than our previously-calculated value, normally by just one clock.
+ // Extend our move time in this case so that the expansion boards don't need to catch up.
+ clocksNeeded = canClocksNeeded;
+ }
#endif
if (reprap.Debug(moduleDda) && reprap.Debug(moduleMove)) // temp show the prepared DDA if debug enabled for both modules
{
diff --git a/src/Movement/DriveMovement.cpp b/src/Movement/DriveMovement.cpp
index 0f5cb627..f3de6447 100644
--- a/src/Movement/DriveMovement.cpp
+++ b/src/Movement/DriveMovement.cpp
@@ -223,7 +223,7 @@ bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params, fl
compensationTime = reprap.GetPlatform().GetPressureAdvance(extruder);
const float compensationClocks = compensationTime * (float)StepTimer::StepClockRate;
mp.cart.compensationClocks = roundU32(compensationClocks);
- mp.cart.accelCompensationClocks = roundU32(compensationClocks * params.compFactor);
+ mp.cart.accelCompensationClocks = roundU32(compensationClocks * params.accelCompFactor);
#ifdef COMPENSATE_SPEED_CHANGES
// If there is a speed change at the start of the move, theoretically we should instantly advance or retard the filament by the associated compensation amount.
@@ -267,7 +267,7 @@ bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params, fl
if (params.decelDistance * effectiveStepsPerMm < 0.5) // if less than 1 deceleration step
{
totalSteps = (uint32_t)max<int32_t>(netSteps, 0);
- mp.cart.decelStartStep = reverseStartStep = netSteps + 1;
+ mp.cart.decelStartStep = reverseStartStep = totalSteps + 1;
mp.cart.fourMaxStepDistanceMinusTwoDistanceToStopTimesCsquaredDivD = 0;
twoDistanceToStopTimesCsquaredDivD = 0;
}
@@ -298,8 +298,8 @@ bool DriveMovement::PrepareExtruder(const DDA& dda, const PrepParams& params, fl
{
netSteps = (int32_t)stepsBeforeReverse;
}
- reverseStartStep = netSteps + 1;
totalSteps = (uint32_t)max<int32_t>(netSteps, 0);
+ reverseStartStep = totalSteps + 1;
mp.cart.fourMaxStepDistanceMinusTwoDistanceToStopTimesCsquaredDivD = 0;
}
}
@@ -323,7 +323,7 @@ bool DriveMovement::PrepareRemoteExtruder(const DDA& dda, const PrepParams& para
const float compensationTime = reprap.GetPlatform().EutGetRemotePressureAdvance(drive);
const float compensationClocks = compensationTime * (float)StepTimer::StepClockRate;
mp.cart.compensationClocks = roundU32(compensationClocks);
- mp.cart.accelCompensationClocks = roundU32(compensationClocks * params.compFactor);
+ mp.cart.accelCompensationClocks = roundU32(compensationClocks * params.accelCompFactor);
// Recalculate the net total step count to allow for compensation. It may be negative.
const float compensationDistance = (dda.endSpeed - dda.startSpeed) * compensationTime;
diff --git a/src/Movement/DriveMovement.h b/src/Movement/DriveMovement.h
index 1816898d..3223844f 100644
--- a/src/Movement/DriveMovement.h
+++ b/src/Movement/DriveMovement.h
@@ -102,7 +102,7 @@ struct PrepParams
uint32_t topSpeedTimesCdivD;
// Parameters used only for extruders
- float compFactor;
+ float accelCompFactor;
#if SUPPORT_CAN_EXPANSION
// Parameters used by CAN expansion
diff --git a/src/Movement/StepperDrivers/TMC22xx.cpp b/src/Movement/StepperDrivers/TMC22xx.cpp
index 27623a33..7236a3fc 100644
--- a/src/Movement/StepperDrivers/TMC22xx.cpp
+++ b/src/Movement/StepperDrivers/TMC22xx.cpp
@@ -1023,7 +1023,9 @@ pre(!driversPowered)
void TmcDriverState::SetStallDetectThreshold(int sgThreshold) noexcept
{
- const uint32_t sgthrs = (uint32_t)(constrain<int>(sgThreshold, -64, 63) + 64);
+ // M915 was originally defined for Stallguard 2, which uses values of -64 (most sensitive) to +63 (least sensitive)
+ // Stallguard 4 on the TMC2209 uses 0 (least sensitive) to 255 (most sensitive). So we map values -128..+127 to 255..0
+ const uint32_t sgthrs = (uint32_t)(127 - constrain<int>(sgThreshold, -128, 127));
UpdateRegister(WriteSgthrs, sgthrs);
}
@@ -1034,7 +1036,8 @@ void TmcDriverState::SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond)
void TmcDriverState::AppendStallConfig(const StringRef& reply) const noexcept
{
- const int threshold = (int)(writeRegisters[WriteSgthrs] - 64);
+ // Map stall sensitivity value 0..255 to 128..-128
+ const int threshold = 127 - (int)writeRegisters[WriteSgthrs];
reply.catf("stall threshold %d, steps/sec %" PRIu32 ", coolstep %" PRIx32,
threshold, 12000000 / (256 * writeRegisters[WriteTcoolthrs]), writeRegisters[WriteCoolconf] & 0xFFFF);
}