diff options
author | David Crocker <dcrocker@eschertech.com> | 2019-12-12 22:00:33 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2019-12-12 22:00:33 +0300 |
commit | ebeaf0703a867f05d862ceede912987e368ffe44 (patch) | |
tree | 0e64d448a08e847e7f31da7dd5d4b1b44e55a907 | |
parent | 576607487423909f49f41dd8de6849e8f61ee6b3 (diff) |
3.0RC1 provisional
Implemented extruder stall detection for G1 H1 E moves
Fixed M119 crash when an axis had no endstop
Duet 3 build now loads IAP into RAM
-rw-r--r-- | .cproject | 8 | ||||
-rw-r--r-- | src/Duet3_V05/Pins_Duet3_V05.h | 27 | ||||
-rw-r--r-- | src/Duet3_V06/Pins_Duet3_V06.h | 10 | ||||
-rw-r--r-- | src/DuetM/Pins_DuetM.h | 5 | ||||
-rw-r--r-- | src/DuetNG/Pins_DuetNG.h | 5 | ||||
-rw-r--r-- | src/Endstops/EndstopDefs.h | 2 | ||||
-rw-r--r-- | src/Endstops/EndstopsManager.cpp | 68 | ||||
-rw-r--r-- | src/Endstops/EndstopsManager.h | 5 | ||||
-rw-r--r-- | src/Endstops/StallDetectionEndstop.cpp | 17 | ||||
-rw-r--r-- | src/Endstops/StallDetectionEndstop.h | 4 | ||||
-rw-r--r-- | src/Fans/Fan.cpp | 6 | ||||
-rw-r--r-- | src/Fans/LocalFan.cpp | 55 | ||||
-rw-r--r-- | src/GCodes/GCodes.cpp | 28 | ||||
-rw-r--r-- | src/Heating/Heat.cpp | 2 | ||||
-rw-r--r-- | src/Movement/StepTimer.cpp | 3 | ||||
-rw-r--r-- | src/Platform.cpp | 7 | ||||
-rw-r--r-- | src/RepRapFirmware.h | 17 | ||||
-rw-r--r-- | src/Version.h | 4 |
18 files changed, 162 insertions, 111 deletions
@@ -241,7 +241,7 @@ <option id="gnu.cpp.compiler.option.optimization.level.1835678360" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.more" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.debugging.level.737051102" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.other.verbose.1225557122" name="Verbose (-v)" superClass="gnu.cpp.compiler.option.other.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/> - <option id="gnu.cpp.compiler.option.other.other.1423466590" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fexceptions -nostdlib -Wundef -Wdouble-promotion -fsingle-precision-constant "-Wa,-ahl=$*.s"" valueType="string"/> + <option id="gnu.cpp.compiler.option.other.other.1423466590" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=hard -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions -nostdlib -Wundef -Wdouble-promotion -fsingle-precision-constant "-Wa,-ahl=$*.s"" valueType="string"/> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.1505018967" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value=""${workspace_loc:/${CoreName}/cores/arduino}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/${CoreName}/libraries/Flash}""/> @@ -397,7 +397,7 @@ <option id="gnu.cpp.compiler.option.optimization.level.1017091230" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.more" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.debugging.level.326047343" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.none" valueType="enumerated"/> <option id="gnu.cpp.compiler.option.other.verbose.1316817271" name="Verbose (-v)" superClass="gnu.cpp.compiler.option.other.verbose" useByScannerDiscovery="false" value="false" valueType="boolean"/> - <option id="gnu.cpp.compiler.option.other.other.434744183" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fexceptions -nostdlib -Wundef -Wdouble-promotion -fsingle-precision-constant "-Wa,-ahl=$*.s"" valueType="string"/> + <option id="gnu.cpp.compiler.option.other.other.434744183" name="Other flags" superClass="gnu.cpp.compiler.option.other.other" useByScannerDiscovery="false" value="-c -mcpu=cortex-m4 -mthumb -ffunction-sections -fdata-sections -fno-threadsafe-statics -fno-rtti -fno-exceptions -nostdlib -Wundef -Wdouble-promotion -fsingle-precision-constant "-Wa,-ahl=$*.s"" valueType="string"/> <option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="gnu.cpp.compiler.option.include.paths.1102345734" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath"> <listOptionValue builtIn="false" value=""${workspace_loc:/${CoreName}/cores/arduino}""/> <listOptionValue builtIn="false" value=""${workspace_loc:/${CoreName}/libraries/Flash}""/> @@ -1018,7 +1018,7 @@ <listOptionValue builtIn="false" value="__SAME70Q20B__"/> <listOptionValue builtIn="false" value="RTOS"/> <listOptionValue builtIn="false" value="DUET3_V05"/> - <listOptionValue builtIn="false" value="LWIP_GMAC_TASK=0"/> + <listOptionValue builtIn="false" value="LWIP_GMAC_TASK=1"/> </option> <option id="gnu.c.compiler.option.dialect.std.1184547155" name="Language standard" superClass="gnu.c.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.c.compiler.dialect.default" valueType="enumerated"/> <option id="gnu.c.compiler.option.dialect.flags.1834251763" name="Other dialect flags" superClass="gnu.c.compiler.option.dialect.flags" useByScannerDiscovery="true" value="-std=gnu99" valueType="string"/> @@ -1085,7 +1085,7 @@ <listOptionValue builtIn="false" value="__SAME70Q20B__"/> <listOptionValue builtIn="false" value="RTOS"/> <listOptionValue builtIn="false" value="DUET3_V05"/> - <listOptionValue builtIn="false" value="LWIP_GMAC_TASK=0"/> + <listOptionValue builtIn="false" value="LWIP_GMAC_TASK=1"/> <listOptionValue builtIn="false" value="_XOPEN_SOURCE"/> </option> <option id="gnu.cpp.compiler.option.dialect.std.264694574" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.default" valueType="enumerated"/> diff --git a/src/Duet3_V05/Pins_Duet3_V05.h b/src/Duet3_V05/Pins_Duet3_V05.h index 276394d3..4240767e 100644 --- a/src/Duet3_V05/Pins_Duet3_V05.h +++ b/src/Duet3_V05/Pins_Duet3_V05.h @@ -7,7 +7,21 @@ const size_t NumFirmwareUpdateModules = 1; #define IAP_FIRMWARE_FILE "Duet3Firmware_" BOARD_SHORT_NAME ".bin" -#define IAP_UPDATE_FILE "Duet3iap_sd_" BOARD_SHORT_NAME ".bin" + +#define IAP_IN_RAM 1 + +#if IAP_IN_RAM +# define IAP_UPDATE_FILE "Duet3_SDiap_" BOARD_SHORT_NAME ".bin" +constexpr uint32_t IAP_IMAGE_START = 0x20450000; // last 64kb of RAM +#else +# define IAP_UPDATE_FILE "Duet3iap_sd_" BOARD_SHORT_NAME ".bin" + +// SAME70 Flash locations +// These are designed to work with 1Mbyte flash processors as well as 2Mbyte +// We can only erase complete 128kb sectors on the SAME70, so we allow 128Kb for IAP +constexpr uint32_t IAP_IMAGE_START = 0x004E0000; +constexpr uint32_t IAP_IMAGE_END = 0x004FFFFF; +#endif // Features definition #define HAS_LWIP_NETWORKING 1 @@ -41,8 +55,6 @@ const size_t NumFirmwareUpdateModules = 1; #define USE_CACHE 0 // Cache controller disabled for now #define USE_MPU 1 -#define NO_EXTRUDER_ENDSTOPS 1 // Temporary!!! - // The physical capabilities of the machine constexpr size_t NumDirectDrivers = 6; // The maximum number of drives supported by the electronics inc. direct expansion @@ -52,8 +64,7 @@ constexpr size_t MaxCanBoards = 18; constexpr float MaxTmc5160Current = 3200.0; // The maximum current we allow the TMC5160/5161 drivers to be set to -constexpr size_t MaxSensorsInSystem = 64; -typedef uint64_t SensorsBitmap; +constexpr size_t MaxSensors = 64; constexpr size_t MaxHeaters = 12; constexpr size_t MaxExtraHeaterProtections = 8; // The number of extra heater protection instances @@ -248,12 +259,6 @@ constexpr unsigned int NumNamedPins = ARRAY_SIZE(PinTable); // Function to look up a pin name pass back the corresponding index into the pin table bool LookupPinName(const char *pn, LogicalPin& lpin, bool& hardwareInverted); -// SAME70 Flash locations -// These are designed to work with 1Mbyte flash processors as well as 2Mbyte -// We can only erase complete 128kb sectors on the SAME70, so we allow 128Kb for IAP -constexpr uint32_t IAP_FLASH_START = 0x004E0000; -constexpr uint32_t IAP_FLASH_END = 0x004FFFFF; - // Duet pin numbers for the Linux interface constexpr Pin LinuxTfrReadyPin = PortEPin(2); Spi * const LinuxSpi = SPI1; diff --git a/src/Duet3_V06/Pins_Duet3_V06.h b/src/Duet3_V06/Pins_Duet3_V06.h index 414d06a0..af228213 100644 --- a/src/Duet3_V06/Pins_Duet3_V06.h +++ b/src/Duet3_V06/Pins_Duet3_V06.h @@ -8,10 +8,10 @@ const size_t NumFirmwareUpdateModules = 1; #define IAP_FIRMWARE_FILE "Duet3Firmware_" BOARD_SHORT_NAME ".bin" -#define IAP_IN_RAM 0 +#define IAP_IN_RAM 1 #if IAP_IN_RAM -# define IAP_UPDATE_FILE "Duet3iap_sd_ram_" BOARD_SHORT_NAME ".bin" +# define IAP_UPDATE_FILE "Duet3_SDiap_" BOARD_SHORT_NAME ".bin" constexpr uint32_t IAP_IMAGE_START = 0x20450000; // last 64kb of RAM #else # define IAP_UPDATE_FILE "Duet3iap_sd_" BOARD_SHORT_NAME ".bin" @@ -23,7 +23,6 @@ constexpr uint32_t IAP_IMAGE_START = 0x004E0000; constexpr uint32_t IAP_IMAGE_END = 0x004FFFFF; #endif - // Features definition #define HAS_LWIP_NETWORKING 1 #define HAS_WIFI_NETWORKING 0 @@ -60,8 +59,6 @@ constexpr uint32_t IAP_IMAGE_END = 0x004FFFFF; #define USE_MPU 1 // Needed if USE_CACHE is set, so that we can have non-cacheable memory regions #define USE_CACHE 1 -#define NO_EXTRUDER_ENDSTOPS 1 // Temporary!!! - // The physical capabilities of the machine constexpr size_t NumDirectDrivers = 6; // The maximum number of drives supported by the electronics inc. direct expansion @@ -71,8 +68,7 @@ constexpr size_t MaxCanBoards = 18; constexpr float MaxTmc5160Current = 6300.0; // The maximum current we allow the TMC5160/5161 drivers to be set to -constexpr size_t MaxSensorsInSystem = 64; -typedef uint64_t SensorsBitmap; +constexpr size_t MaxSensors = 64; constexpr size_t MaxHeaters = 12; constexpr size_t MaxExtraHeaterProtections = 8; // The number of extra heater protection instances diff --git a/src/DuetM/Pins_DuetM.h b/src/DuetM/Pins_DuetM.h index 232c3c81..e6bd13ea 100644 --- a/src/DuetM/Pins_DuetM.h +++ b/src/DuetM/Pins_DuetM.h @@ -56,15 +56,12 @@ constexpr uint32_t IAP_IMAGE_END = 0x0047FFFF; // we allow a full 64K on #define SUPPORT_ASYNC_MOVES 1 #define ALLOCATE_DEFAULT_PORTS 1 -#define NO_EXTRUDER_ENDSTOPS 1 // Temporary!!! - // The physical capabilities of the machine constexpr size_t NumDirectDrivers = 7; // The maximum number of drives supported by the electronics constexpr size_t MaxSmartDrivers = 7; // The maximum number of smart drivers -constexpr size_t MaxSensorsInSystem = 32; -typedef uint32_t SensorsBitmap; +constexpr size_t MaxSensors = 32; constexpr size_t MaxHeaters = 4; // The maximum number of heaters in the machine constexpr size_t MaxExtraHeaterProtections = 4; // The number of extra heater protection instances diff --git a/src/DuetNG/Pins_DuetNG.h b/src/DuetNG/Pins_DuetNG.h index 6b90a9f4..310b7696 100644 --- a/src/DuetNG/Pins_DuetNG.h +++ b/src/DuetNG/Pins_DuetNG.h @@ -54,15 +54,12 @@ constexpr size_t NumFirmwareUpdateModules = 4; // 3 modules, plus one for manua #define USE_CACHE 1 // set nonzero to enable the cache #define USE_MPU 0 // set nonzero to enable the memory protection unit -#define NO_EXTRUDER_ENDSTOPS 1 // Temporary!!! - // The physical capabilities of the machine constexpr size_t NumDirectDrivers = 12; // The maximum number of drives supported directly by the electronics constexpr size_t MaxSmartDrivers = 10; // The maximum number of smart drivers -constexpr size_t MaxSensorsInSystem = 32; -typedef uint32_t SensorsBitmap; +constexpr size_t MaxSensors = 32; constexpr size_t MaxHeaters = 10; // The maximum number of heaters in the machine constexpr size_t MaxExtraHeaterProtections = 8; // The number of extra heater protection instances diff --git a/src/Endstops/EndstopDefs.h b/src/Endstops/EndstopDefs.h index b0797961..7ccdc1ef 100644 --- a/src/Endstops/EndstopDefs.h +++ b/src/Endstops/EndstopDefs.h @@ -26,7 +26,7 @@ enum class EndstopHitAction : uint8_t // Struct to return info about what endstop has been triggered and what to do about it struct EndstopHitDetails { - EndstopHitDetails() : action((uint32_t)EndstopHitAction::none), internalUse(0), axis(0), setAxisLow(false), setAxisHigh(false), isZProbe(false) + EndstopHitDetails() : action((uint32_t)EndstopHitAction::none), internalUse(0), axis(NO_AXIS), setAxisLow(false), setAxisHigh(false), isZProbe(false) { driver.Clear(); } diff --git a/src/Endstops/EndstopsManager.cpp b/src/Endstops/EndstopsManager.cpp index b525eba1..787c94b0 100644 --- a/src/Endstops/EndstopsManager.cpp +++ b/src/Endstops/EndstopsManager.cpp @@ -27,7 +27,7 @@ ReadWriteLock EndstopsManager::endstopsLock; // used to lock both endstops and Z probes -EndstopsManager::EndstopsManager() : activeEndstops(nullptr), isHomingMove(false) +EndstopsManager::EndstopsManager() : activeEndstops(nullptr), extrudersEndstop(nullptr), isHomingMove(false) { for (Endstop *& es : axisEndstops) { @@ -78,21 +78,20 @@ void EndstopsManager::AddToActive(EndstopOrZProbe& e) bool EndstopsManager::EnableAxisEndstops(AxesBitmap axes, bool forHoming) { activeEndstops = nullptr; - isHomingMove = forHoming; + isHomingMove = forHoming && axes != 0; const Kinematics& kin = reprap.GetMove().GetKinematics(); - for (size_t axis = 0; axis < reprap.GetGCodes().GetVisibleAxes(); ++axis) + while (axes != 0) { - if (IsBitSet(axes, axis)) + const unsigned int axis = LowestSetBit(axes); + ClearBit(axes, axis); + if (axisEndstops[axis] != nullptr && axisEndstops[axis]->Prime(kin, reprap.GetPlatform().GetAxisDriversConfig(axis))) { - if (axisEndstops[axis] != nullptr && axisEndstops[axis]->Prime(kin, reprap.GetPlatform().GetAxisDriversConfig(axis))) - { - AddToActive(*axisEndstops[axis]); - } - else - { - activeEndstops = nullptr; - return false; - } + AddToActive(*axisEndstops[axis]); + } + else + { + activeEndstops = nullptr; + return false; } } return true; @@ -111,19 +110,44 @@ bool EndstopsManager::EnableZProbe(size_t probeNumber, bool probingAway) return true; } -// Enable extruder endstops -bool EndstopsManager::EnableExtruderEndstop(size_t extruder) +// Enable extruder endstops. This adds to any existing axis endstops, so you must call EnableAxisEndstops before calling this. +bool EndstopsManager::EnableExtruderEndstops(ExtrudersBitmap extruders) { -#ifdef NO_EXTRUDER_ENDSTOPS - // not supported for now - return false; + if (extruders != 0) + { + if (extrudersEndstop == nullptr) + { + extrudersEndstop = new StallDetectionEndstop; + } + DriversBitmap drivers = 0; + while (extruders != 0) + { + const unsigned int extruder = LowestSetBit(extruders); + ClearBit(extruders, extruder); + const DriverId driver = reprap.GetPlatform().GetExtruderDriver(extruder); +#if SUPPORT_CAN_EXPANSION + if (driver.IsLocal()) + { + SetBit(drivers, driver.localDriver); + } + else + { + //TODO remote stall detect endstop + return false; + } #else - qq; //TODO + SetBit(drivers, driver.localDriver); #endif + } + + extrudersEndstop->SetDrivers(drivers); + AddToActive(*extrudersEndstop); + } + return true; } // Check the endstops. -// If an endstop has triggered, remove it from the active list, return its action, and return a pointer to it via 'es'. +// If an endstop has triggered, remove it from the active list and return its details EndstopHitDetails EndstopsManager::CheckEndstops(bool goingSlow) { EndstopHitDetails ret; // the default constructor will clear all fields @@ -345,7 +369,7 @@ void EndstopsManager::GetM119report(const StringRef& reply) reply.copy("Endstops - "); for (size_t axis = 0; axis < reprap.GetGCodes().GetTotalAxes(); ++axis) { - const char * const status = (axisEndstops == nullptr) + const char * const status = (axisEndstops[axis] == nullptr) ? "no endstop" : TranslateEndStopResult(axisEndstops[axis]->Stopped(), axisEndstops[axis]->GetAtHighEnd()); reply.catf("%c: %s, ", reprap.GetGCodes().GetAxisLetters()[axis], status); @@ -371,7 +395,7 @@ const char *EndstopsManager::TranslateEndStopResult(EndStopHit es, bool atHighEn ZProbe& EndstopsManager::GetCurrentZProbe() const { - ZProbe * const zp = zProbes[currentZProbeNumber]; + ZProbe * const zp = (currentZProbeNumber < MaxZProbes) ? zProbes[currentZProbeNumber] : nullptr; return (zp == nullptr) ? *defaultZProbe : *zp; } diff --git a/src/Endstops/EndstopsManager.h b/src/Endstops/EndstopsManager.h index 859ac8f2..1defb7fc 100644 --- a/src/Endstops/EndstopsManager.h +++ b/src/Endstops/EndstopsManager.h @@ -18,6 +18,8 @@ class CanMessageBuffer; #endif +class StallDetectionEndstop; + // Endstop manager class class EndstopsManager { @@ -36,7 +38,7 @@ public: bool EnableCurrentZProbe(bool probingAway = false) __attribute__ ((warn_unused_result)) { return EnableZProbe(currentZProbeNumber, probingAway); } // Enable extruder endstops - bool EnableExtruderEndstop(size_t extruder); + bool EnableExtruderEndstops(ExtrudersBitmap extruders); // Get the first endstop that has triggered and remove it from the active list if appropriate EndstopHitDetails CheckEndstops(bool goingSlow); @@ -87,6 +89,7 @@ private: size_t currentZProbeNumber; // which Z probe we are using Endstop *axisEndstops[MaxAxes]; // the endstops assigned to each axis (each one may have several switches), each may be null + StallDetectionEndstop *extrudersEndstop; // the endstop used for extruder stall detection, one will do for all extruders ZProbe *zProbes[MaxZProbes]; // the Z probes used. The first one is always non-null. ZProbe *defaultZProbe; diff --git a/src/Endstops/StallDetectionEndstop.cpp b/src/Endstops/StallDetectionEndstop.cpp index 6a566572..f47b5b8d 100644 --- a/src/Endstops/StallDetectionEndstop.cpp +++ b/src/Endstops/StallDetectionEndstop.cpp @@ -16,6 +16,11 @@ StallDetectionEndstop::StallDetectionEndstop(uint8_t axis, EndStopPosition pos, { } +StallDetectionEndstop::StallDetectionEndstop() + : Endstop(NO_AXIS, EndStopPosition::noEndStop), driversMonitored(0), individualMotors(false), stopAll(true) +{ +} + // Test whether we are at or near the stop EndStopHit StallDetectionEndstop::Stopped() const { @@ -46,7 +51,11 @@ EndstopHitDetails StallDetectionEndstop::CheckTriggered(bool goingSlow) if (relevantStalledDrivers != 0) { rslt.axis = GetAxis(); - if (stopAll) + if (rslt.axis == NO_AXIS) + { + rslt.SetAction(EndstopHitAction::stopAll); + } + else if (stopAll) { rslt.SetAction(EndstopHitAction::stopAll); if (GetAtHighEnd()) @@ -109,4 +118,10 @@ void StallDetectionEndstop::AppendDetails(const StringRef& str) str.cat((individualMotors) ? "motor stall (individual motors)" : "motor stall (any motor)"); } +void StallDetectionEndstop::SetDrivers(DriversBitmap extruderDrivers) +{ + driversMonitored = extruderDrivers; + stopAll = true; +} + // End diff --git a/src/Endstops/StallDetectionEndstop.h b/src/Endstops/StallDetectionEndstop.h index 56095772..08ea7f3b 100644 --- a/src/Endstops/StallDetectionEndstop.h +++ b/src/Endstops/StallDetectionEndstop.h @@ -17,7 +17,8 @@ public: void* operator new(size_t sz) { return Allocate<StallDetectionEndstop>(); } void operator delete(void* p) { Release<StallDetectionEndstop>(p); } - StallDetectionEndstop(uint8_t axis, EndStopPosition pos, bool p_individualMotors); + StallDetectionEndstop(uint8_t axis, EndStopPosition pos, bool p_individualMotors); // for creating axis endstops + StallDetectionEndstop(); // for creating the single extruders endstop EndStopInputType GetEndstopType() const override { return (individualMotors) ? EndStopInputType::motorStallIndividual : EndStopInputType::motorStallAny; } EndStopHit Stopped() const override; @@ -25,6 +26,7 @@ public: EndstopHitDetails CheckTriggered(bool goingSlow) override; bool Acknowledge(EndstopHitDetails what) override; void AppendDetails(const StringRef& str) override; + void SetDrivers(DriversBitmap extruderDrivers); // for setting which local extruder drives are active extruder endstops private: DriversBitmap driversMonitored; diff --git a/src/Fans/Fan.cpp b/src/Fans/Fan.cpp index 47fd5e9b..cec04f8b 100644 --- a/src/Fans/Fan.cpp +++ b/src/Fans/Fan.cpp @@ -79,7 +79,7 @@ bool Fan::Configure(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const St if (gb.Seen('H')) // Set thermostatically-controlled sensors { seen = true; - int32_t sensors[MaxSensorsInSystem]; // signed because we use H-1 to disable thermostatic mode + int32_t sensors[MaxSensors]; // signed because we use H-1 to disable thermostatic mode size_t numH = ARRAY_SIZE(sensors); gb.GetIntArray(sensors, numH, false); @@ -90,7 +90,7 @@ bool Fan::Configure(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const St const int hnum = sensors[h]; if (hnum >= 0) { - if (hnum < (int)MaxSensorsInSystem) + if (hnum < (int)MaxSensors) { SetBit(sensorsMonitored, (unsigned int)hnum); } @@ -144,7 +144,7 @@ bool Fan::Configure(unsigned int mcode, size_t fanNum, GCodeBuffer& gb, const St if (sensorsMonitored != 0) { reply.catf(", temperature: %.1f:%.1fC, sensors:", (double)triggerTemperatures[0], (double)triggerTemperatures[1]); - for (unsigned int i = 0; i < MaxSensorsInSystem; ++i) + for (unsigned int i = 0; i < MaxSensors; ++i) { if (IsBitSet(sensorsMonitored, i)) { diff --git a/src/Fans/LocalFan.cpp b/src/Fans/LocalFan.cpp index 77fb05e9..dab83bd9 100644 --- a/src/Fans/LocalFan.cpp +++ b/src/Fans/LocalFan.cpp @@ -81,39 +81,38 @@ void LocalFan::InternalRefresh() { reqVal = 0.0; const bool bangBangMode = (triggerTemperatures[1] <= triggerTemperatures[0]); - for (size_t sensorNum = 0; sensorNum < MaxSensorsInSystem; ++sensorNum) + SensorsBitmap copySensorsMonitored = sensorsMonitored; + while (copySensorsMonitored != 0) { - // Check if this sensor is both monitored by this fan and in use - if (IsBitSet(sensorsMonitored, sensorNum)) + unsigned int sensorNum = LowestSetBit(copySensorsMonitored); + ClearBit(copySensorsMonitored, sensorNum); + const auto sensor = reprap.GetHeat().FindSensor(sensorNum); + if (sensor.IsNotNull()) { - const auto sensor = reprap.GetHeat().FindSensor(sensorNum); - if (sensor.IsNotNull()) + //TODO we used to turn the fan on if the associated heater was being tuned + float ht; + const TemperatureError err = sensor->GetLatestTemperature(ht); + if (err != TemperatureError::success || ht < BadLowTemperature || ht >= triggerTemperatures[1]) { - //TODO we used to turn the fan on if the associated heater was being tuned - float ht; - const TemperatureError err = sensor->GetLatestTemperature(ht); - if (err != TemperatureError::success || ht < BadLowTemperature || ht >= triggerTemperatures[1]) - { - reqVal = max<float>(reqVal, (bangBangMode) ? max<float>(0.5, val) : 1.0); - } - else if (!bangBangMode && ht > triggerTemperatures[0]) - { - // We already know that ht < triggerTemperatures[1], therefore unless we have NaNs it is safe to divide by (triggerTemperatures[1] - triggerTemperatures[0]) - reqVal = max<float>(reqVal, (ht - triggerTemperatures[0])/(triggerTemperatures[1] - triggerTemperatures[0])); - } - else if (lastVal != 0.0 && ht + ThermostatHysteresis > triggerTemperatures[0]) // if the fan is on, add a hysteresis before turning it off - { - const float minFanSpeed = (bangBangMode) ? max<float>(0.5, val) : minVal; - reqVal = constrain<float>(reqVal, minFanSpeed, maxVal); - } + reqVal = max<float>(reqVal, (bangBangMode) ? max<float>(0.5, val) : 1.0); + } + else if (!bangBangMode && ht > triggerTemperatures[0]) + { + // We already know that ht < triggerTemperatures[1], therefore unless we have NaNs it is safe to divide by (triggerTemperatures[1] - triggerTemperatures[0]) + reqVal = max<float>(reqVal, (ht - triggerTemperatures[0])/(triggerTemperatures[1] - triggerTemperatures[0])); + } + else if (lastVal != 0.0 && ht + ThermostatHysteresis > triggerTemperatures[0]) // if the fan is on, add a hysteresis before turning it off + { + const float minFanSpeed = (bangBangMode) ? max<float>(0.5, val) : minVal; + reqVal = constrain<float>(reqVal, minFanSpeed, maxVal); + } #if HAS_SMART_DRIVERS - const int channel = sensor->GetSmartDriversChannel(); - if (channel >= 0) - { - driverChannelsMonitored |= 1 << (unsigned int)channel; - } -#endif + const int channel = sensor->GetSmartDriversChannel(); + if (channel >= 0) + { + driverChannelsMonitored |= 1 << (unsigned int)channel; } +#endif } } } diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index 6a1ffbaf..93732629 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -1433,6 +1433,8 @@ void GCodes::Pop(GCodeBuffer& gb, bool preserveLineNumber) // Returns true if this gcode is valid so far, false if it should be discarded bool GCodes::LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingMove) { + bool ok = true; + // Deal with feed rate if (moveBuffer.isCoordinated || machineType == MachineType::fff) { @@ -1459,6 +1461,7 @@ bool GCodes::LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingM } moveBuffer.hasExtrusion = false; moveBuffer.virtualExtruderPosition = virtualExtruderPosition; // save this before we update it + ExtrudersBitmap extrudersMoving = 0; // Check if we are extruding if (gb.Seen(extrudeLetter)) // DC 2018-08-07: at E3D's request, extrusion is now recognised even on uncoordinated moves @@ -1521,10 +1524,7 @@ bool GCodes::LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingM } moveBuffer.coords[ExtruderToLogicalDrive(extruder)] = extrusionAmount * extrusionFactors[extruder]; - if (moveBuffer.moveType == 1) - { - platform.GetEndstops().EnableExtruderEndstop(extruder); - } + SetBit(extrudersMoving, extruder); } } if (!isPrintingMove && moveBuffer.usingStandardFeedrate) @@ -1556,21 +1556,29 @@ bool GCodes::LoadExtrusionAndFeedrateFromGCode(GCodeBuffer& gb, bool isPrintingM rawExtruderTotal += extrusionAmount; } moveBuffer.coords[ExtruderToLogicalDrive(extruder)] = extrusionAmount * extrusionFactors[extruder] * volumetricExtrusionFactors[extruder]; - if (moveBuffer.moveType == 1) - { - platform.GetEndstops().EnableExtruderEndstop(extruder); - } + SetBit(extrudersMoving, extruder); } } } else { platform.Message(ErrorMessage, "Multiple E parameters in G1 commands are not supported in absolute extrusion mode\n"); + ok = false; } } } } - return true; + + if (moveBuffer.moveType == 1) + { + if (!platform.GetEndstops().EnableExtruderEndstops(extrudersMoving)) + { + platform.Message(ErrorMessage, "Failed to enable extruder endstops"); + ok = false; + } + } + + return ok; } // Check that enough axes have been homed, returning true if insufficient axes homed @@ -1775,7 +1783,7 @@ const char* GCodes::DoStraightMove(GCodeBuffer& gb, bool isCoordinated) break; } - LoadExtrusionAndFeedrateFromGCode(gb, axesMentioned != 0); + LoadExtrusionAndFeedrateFromGCode(gb, axesMentioned != 0); // for type 1 moves, this must be called after calling EnableAxisEndstops, because EnableExtruderEndstop assumes that // Set up the move. We must assign segmentsLeft last, so that when Move runs as a separate task the move won't be picked up by the Move process before it is complete. // Note that if this is an extruder-only move, we don't do axis movements to allow for tool offset changes, we defer those until an axis moves. diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp index ef148a5e..5fcbf771 100644 --- a/src/Heating/Heat.cpp +++ b/src/Heating/Heat.cpp @@ -950,7 +950,7 @@ GCodeResult Heat::ConfigureSensor(GCodeBuffer& gb, const StringRef& reply) if (gb.Seen('S')) { const unsigned sensorNum = gb.GetUIValue(); - if (sensorNum >= MaxSensorsInSystem) + if (sensorNum >= MaxSensors) { reply.copy("Sensor number out of range"); return GCodeResult::error; diff --git a/src/Movement/StepTimer.cpp b/src/Movement/StepTimer.cpp index 5c0fd23d..fc2b662b 100644 --- a/src/Movement/StepTimer.cpp +++ b/src/Movement/StepTimer.cpp @@ -138,9 +138,6 @@ bool StepTimer::ScheduleTimerInterrupt(uint32_t tim) noexcept STEP_TC->TC_CHANNEL[STEP_TC_CHAN].TC_IER = TC_IER_CPBS; // enable the interrupt #endif -#ifdef SOFT_TIMER_DEBUG - lastSoftTimerInterruptScheduledAt = GetTimerTicksInterruptsDisabled(); -#endif cpu_irq_restore(flags); return false; } diff --git a/src/Platform.cpp b/src/Platform.cpp index 6a0791b2..c0ad9c56 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -134,13 +134,6 @@ constexpr uint16_t driverV12OffAdcReading = V12VoltageToAdcReading(9.5); // v const float MinStepPulseTiming = 0.2; // we assume that we always generate step high and low times at least this wide without special action -//#define SOFT_TIMER_DEBUG - -#ifdef SOFT_TIMER_DEBUG -unsigned int numSoftTimerInterruptsExecuted = 0; -uint32_t lastSoftTimerInterruptScheduledAt = 0; -#endif - // Global variable for debugging in tricky situations e.g. within ISRs int debugLine = 0; diff --git a/src/RepRapFirmware.h b/src/RepRapFirmware.h index ef6c0f59..e0b40680 100644 --- a/src/RepRapFirmware.h +++ b/src/RepRapFirmware.h @@ -243,11 +243,25 @@ typedef float floatc_t; // type of matrix element used for calibration #endif typedef uint16_t AxesBitmap; // Type of a bitmap representing a set of axes -typedef uint32_t DriversBitmap; // Type of a bitmap representing a set of driver numbers +typedef uint32_t ExtrudersBitmap; // Type of a bitmap representing a set of extruder drive numbers +typedef uint32_t DriversBitmap; // Type of a bitmap representing a set of local driver numbers typedef uint32_t FansBitmap; // Type of a bitmap representing a set of fan numbers typedef uint32_t HeatersBitmap; // Type of a bitmap representing a set of heater numbers typedef uint16_t Pwm_t; // Type of a PWM value when we don't want to use floats +#if SUPPORT_CAN_EXPANSION +typedef uint64_t SensorsBitmap; +#else +typedef uint32_t SensorsBitmap; +#endif + +static_assert(MaxAxes <= sizeof(AxesBitmap) * CHAR_BIT); +static_assert(MaxExtruders <= sizeof(ExtrudersBitmap) * CHAR_BIT); +static_assert(MaxFans <= sizeof(FansBitmap) * CHAR_BIT); +static_assert(MaxHeaters <= sizeof(HeatersBitmap) * CHAR_BIT); +static_assert(NumDirectDrivers <= sizeof(DriversBitmap) * CHAR_BIT); +static_assert(MaxSensors <= sizeof(SensorsBitmap) * CHAR_BIT); + #if SUPPORT_IOBITS typedef uint16_t IoBits_t; // Type of the port control bitmap (G1 P parameter) #endif @@ -363,6 +377,7 @@ constexpr size_t ShortScratchStringLength = 50; constexpr size_t XYZ_AXES = 3; // The number of Cartesian axes constexpr size_t X_AXIS = 0, Y_AXIS = 1, Z_AXIS = 2; // The indices of the Cartesian axes in drive arrays constexpr size_t U_AXIS = 3; // The assumed index of the U axis when executing M673 +constexpr size_t NO_AXIS = 0x0F; // A value to represent no axis, must fit in 4 bits (see Endstops) and not be a valid axis number static_assert(MaxAxesPlusExtruders <= MaxAxes + MaxExtruders); static_assert(MaxAxesPlusExtruders >= MinAxes + NumDefaultExtruders); diff --git a/src/Version.h b/src/Version.h index 39612462..9f6450ee 100644 --- a/src/Version.h +++ b/src/Version.h @@ -10,7 +10,7 @@ #ifndef VERSION -# define MAIN_VERSION "3.0beta12+1" +# define MAIN_VERSION "3.0RC1" # ifdef USE_CAN0 # define VERSION_SUFFIX " (CAN0)" # else @@ -20,7 +20,7 @@ #endif #ifndef DATE -# define DATE "2019-12-10b2" +# define DATE "2019-12-12b2" #endif #define AUTHORS "reprappro, dc42, chrishamm, t3p3, dnewman, printm3d" |