diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-01-23 19:50:25 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-01-23 19:50:25 +0300 |
commit | fec7a47b928ab9bcd0c11ec4f9b6926f2e732401 (patch) | |
tree | c389c54be0945af80c18b9e85633940b0902ed3f /src/Heating/LocalHeater.h | |
parent | 679be2794bddb1a8e044dbc3eab882ef159bf8e1 (diff) |
Partially implemented remote heater tuning
Diffstat (limited to 'src/Heating/LocalHeater.h')
-rw-r--r-- | src/Heating/LocalHeater.h | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/src/Heating/LocalHeater.h b/src/Heating/LocalHeater.h index 0486bccf..80afa0ad 100644 --- a/src/Heating/LocalHeater.h +++ b/src/Heating/LocalHeater.h @@ -17,7 +17,6 @@ #include "TemperatureError.h" #include <Hardware/IoPorts.h> #include <GCodes/GCodeResult.h> -#include <Math/DeviationAccumulator.h> class HeaterMonitor; @@ -41,15 +40,14 @@ public: GCodeResult SetPwmFrequency(PwmFrequency freq, const StringRef& reply) noexcept override; GCodeResult ReportDetails(const StringRef& reply) const noexcept override; - void Spin() noexcept override; // Called in a tight loop to keep things running - void SwitchOff() noexcept override; // Not even standby - all heater power off - GCodeResult ResetFault(const StringRef& reply) noexcept override; // Reset a fault condition - only call this if you know what you are doing - float GetTemperature() const noexcept override; // Get the current temperature - float GetAveragePWM() const noexcept override; // Return the running average PWM to the heater. Answer is a fraction in [0, 1]. - float GetAccumulator() const noexcept override; // Return the integral accumulator - GCodeResult StartAutoTune(GCodeBuffer& gb, const StringRef& reply, FansBitmap fans) THROWS(GCodeException) override; // Start an auto tune cycle for this heater + void Spin() noexcept override; // Called in a tight loop to keep things running + void SwitchOff() noexcept override; // Not even standby - all heater power off + GCodeResult ResetFault(const StringRef& reply) noexcept override; // Reset a fault condition - only call this if you know what you are doing + float GetTemperature() const noexcept override; // Get the latest temperature + float GetAveragePWM() const noexcept override; // Return the running average PWM to the heater. Answer is a fraction in [0, 1]. + float GetAccumulator() const noexcept override; // Return the integral accumulator void GetAutoTuneStatus(const StringRef& reply) const noexcept override; // Get the auto tune status or last result - void Suspend(bool sus) noexcept override; // Suspend the heater to conserve power or while doing Z probing + void Suspend(bool sus) noexcept override; // Suspend the heater to conserve power or while doing Z probing void PrintCoolingFanPwmChanged(float pwmChange) noexcept override; #if SUPPORT_CAN_EXPANSION @@ -59,10 +57,11 @@ public: protected: void ResetHeater() noexcept override; HeaterMode GetMode() const noexcept override { return mode; } - GCodeResult SwitchOn(const StringRef& reply) noexcept override; // Turn the heater on and set the mode - GCodeResult UpdateModel(const StringRef& reply) noexcept override; // Called when the heater model has been changed + GCodeResult SwitchOn(const StringRef& reply) noexcept override; // Turn the heater on and set the mode + GCodeResult UpdateModel(const StringRef& reply) noexcept override; // Called when the heater model has been changed GCodeResult UpdateFaultDetectionParameters(const StringRef& reply) noexcept override { return GCodeResult::ok; } GCodeResult UpdateHeaterMonitors(const StringRef& reply) noexcept override { return GCodeResult::ok; } + GCodeResult StartAutoTune(const StringRef& reply, FansBitmap fans, float targetTemp, float pwm, bool seenA, float ambientTemp) noexcept override; // Start an auto tune cycle for this heater private: void SetHeater(float power) const noexcept; // Power is a fraction in [0,1] @@ -87,19 +86,9 @@ private: uint8_t previousTemperaturesGood; // Bitmap indicating which previous temperature were good readings HeaterMode mode; // Current state of the heater - bool tuned; // True if tuning was successful uint8_t badTemperatureCount; // Count of sequential dud readings static_assert(sizeof(previousTemperaturesGood) * 8 >= NumPreviousTemperatures, "too few bits in previousTemperaturesGood"); - - static constexpr unsigned int TuningHeaterMinIdleCycles = 3; // minimum number of idle cycles after heating up, including the initial overshoot and cool down - static constexpr unsigned int TuningHeaterMaxIdleCycles = 10; - static constexpr unsigned int MinTuningHeaterCycles = 5; - static constexpr unsigned int MaxTuningHeaterCycles = 25; - static constexpr float TuningHysteresis = 5.0; - static constexpr float TuningPeakTempDrop = 2.0; // must be well below TuningHysteresis - static constexpr float FeedForwardMultiplier = 1.3; // how much we over-compensate feedforward to allow for heat reservoirs during tuning - static constexpr float HeaterSettledCoolingTimeRatio = 0.93; }; #endif /* SRC_LOCALHEATER_H_ */ |