diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-10-10 16:10:47 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-10-10 16:10:47 +0300 |
commit | b3bbc45ab098b3ca3790e12dc3fb6b0076d579bc (patch) | |
tree | 4625e037b62876d7961dab58010024d7ce5952e8 | |
parent | acae307fba86bab9088c71f1e79ea2bd6e82715e (diff) |
Started implementing delay after engaging motor brake
-rw-r--r-- | src/Platform/Platform.cpp | 24 | ||||
-rw-r--r-- | src/Platform/Platform.h | 3 |
2 files changed, 23 insertions, 4 deletions
diff --git a/src/Platform/Platform.cpp b/src/Platform/Platform.cpp index 7e003bf6..5dc74632 100644 --- a/src/Platform/Platform.cpp +++ b/src/Platform/Platform.cpp @@ -2677,12 +2677,30 @@ void Platform::SetDriversIdle() noexcept // Configure the brake port for a driver GCodeResult Platform::ConfigureDriverBrakePort(GCodeBuffer& gb, const StringRef& reply, size_t driver) noexcept { + bool seen = false; if (gb.Seen('C')) { - return GetGCodeResultFromSuccess(brakePorts[driver].AssignPort(gb, reply, PinUsedBy::gpout, PinAccess::write0)); + seen = true; + if (!brakePorts[driver].AssignPort(gb, reply, PinUsedBy::gpout, PinAccess::write0)) + { + return GCodeResult::error; + } + delayAfterBrakeOn[driver] = DefaultDelayAfterBrakeOn; + } + uint32_t val; + if (gb.TryGetLimitedUIValue('S', val, seen, 100)) + { + delayAfterBrakeOn[driver] = val; + } + + if (!seen) + { + reply.printf("Driver %u uses brake port ", driver); + brakePorts[driver].AppendPinName(reply); +#if 0 // don't print this bit until we have implemented it! + reply.catf(" and %ums delay after turning the brake on", delayAfterBrakeOn[driver]); +#endif } - reply.printf("Driver %u uses brake port ", driver); - brakePorts[driver].AppendPinName(reply); return GCodeResult::ok; } diff --git a/src/Platform/Platform.h b/src/Platform/Platform.h index f33c633a..d2d9ab6e 100644 --- a/src/Platform/Platform.h +++ b/src/Platform/Platform.h @@ -761,7 +761,8 @@ private: bool driverErrPinsActiveLow; #endif - IoPort brakePorts[NumDirectDrivers]; + IoPort brakePorts[NumDirectDrivers]; // the brake ports for each driver + uint16_t delayAfterBrakeOn[NumDirectDrivers]; // how many milliseconds we wait between turning the brake on and de-energising the driver float motorCurrents[MaxAxesPlusExtruders]; // the normal motor current for each stepper driver float motorCurrentFraction[MaxAxesPlusExtruders]; // the percentages of normal motor current that each driver is set to |