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>2021-10-22 12:19:53 +0300
committerDavid Crocker <dcrocker@eschertech.com>2021-10-22 12:19:53 +0300
commitbfdd16fc98afee821ec3db216d630b9a76a38e37 (patch)
tree7e7c9bf4b3216dcc9383f3a3d8e7c5505327dbb5
parent0a438e515f081a89a0bc2be56dc8a91079f20c99 (diff)
Fixes to TMC51xx driver
-rw-r--r--src/Movement/StepperDrivers/TMC51xx.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/Movement/StepperDrivers/TMC51xx.cpp b/src/Movement/StepperDrivers/TMC51xx.cpp
index a2cb4b11..ae673995 100644
--- a/src/Movement/StepperDrivers/TMC51xx.cpp
+++ b/src/Movement/StepperDrivers/TMC51xx.cpp
@@ -56,6 +56,7 @@ constexpr unsigned int DefaultMinimumStepsPerSecond = 200; // for stall detectio
constexpr uint32_t DefaultTcoolthrs = 2000; // max interval between 1/256 microsteps for stall detection to be enabled
constexpr uint32_t DefaultThigh = 200;
constexpr size_t TmcTaskStackWords = 140; // with 100 stack words, deckingman's M122 on the main board after a major axis shift showed just 10 words left
+constexpr uint32_t TmcClockSpeed = 12000000; // the rate at which the TMC driver is clocked, internally or externally
#if TMC_TYPE == 5130
constexpr float SenseResistor = 0.11; // 0.082R external + 0.03 internal
@@ -819,8 +820,8 @@ void TmcDriverState::SetStallDetectFilter(bool sgFilter) noexcept
void TmcDriverState::SetStallMinimumStepsPerSecond(unsigned int stepsPerSecond) noexcept
{
- maxStallStepInterval = StepClockRate/max<unsigned int>(stepsPerSecond, 1);
- UpdateRegister(WriteTcoolthrs, (12000000 + (128 * stepsPerSecond))/(256 * stepsPerSecond));
+ maxStallStepInterval = StepClockRate/max<unsigned int>(stepsPerSecond, 1u);
+ UpdateRegister(WriteTcoolthrs, (TmcClockSpeed + (128 * stepsPerSecond))/(256 * stepsPerSecond));
}
void TmcDriverState::AppendStallConfig(const StringRef& reply) const noexcept
@@ -835,7 +836,7 @@ void TmcDriverState::AppendStallConfig(const StringRef& reply) const noexcept
const float speed1 = ((fullstepsPerSecond << microstepShiftFactor)/reprap.GetPlatform().DriveStepsPerUnit(axisNumber));
const uint32_t tcoolthrs = writeRegisters[WriteTcoolthrs] & ((1ul << 20) - 1u);
bool bdummy;
- const float speed2 = (12000000.0 * GetMicrostepping(bdummy))/(256 * tcoolthrs * reprap.GetPlatform().DriveStepsPerUnit(axisNumber));
+ const float speed2 = ((float)TmcClockSpeed * GetMicrostepping(bdummy))/(256 * tcoolthrs * reprap.GetPlatform().DriveStepsPerUnit(axisNumber));
reply.catf("stall threshold %d, filter %s, steps/sec %" PRIu32 " (%.1f mm/sec), coolstep threshold %" PRIu32 " (%.1f mm/sec)",
threshold, ((filtered) ? "on" : "off"), fullstepsPerSecond, (double)speed1, tcoolthrs, (double)speed2);
}
@@ -940,9 +941,10 @@ void TmcDriverState::TransferSucceeded(const uint8_t *rcvDataBlock) noexcept
}
}
- // Deal with the stall status
+ // Deal with the stall status. Note that the TCoolThrs setting prevents us getting a DIAG output at low speeds, but it doesn't seem to affect the stall status
if ( (rcvDataBlock[0] & (1u << 2)) != 0 // if the status indicates stalled
&& interval != 0
+ && interval <= maxStallStepInterval // if the motor speed is high enough to get a reliable stall indication
)
{
readRegisters[ReadDrvStat] |= TMC_RR_SG;