diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-12-27 12:41:11 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-12-27 12:41:11 +0300 |
commit | f3390f52234c967c624ca1f725cb98af1c314e93 (patch) | |
tree | bdb891a9ee2782d45cc7e2443abaf840e88b2e4f | |
parent | 4300c3d6d8f5e4f2634b9a738ac7bd326606d2bb (diff) |
Allow greater tolerance for bed and chamber heaters when heating up
-rw-r--r-- | src/Heating/Heater.cpp | 5 | ||||
-rw-r--r-- | src/Heating/Heater.h | 13 | ||||
-rw-r--r-- | src/Heating/LocalHeater.cpp | 5 | ||||
-rw-r--r-- | src/Heating/RemoteHeater.cpp | 4 |
4 files changed, 20 insertions, 7 deletions
diff --git a/src/Heating/Heater.cpp b/src/Heating/Heater.cpp index 6c330504..0760deff 100644 --- a/src/Heating/Heater.cpp +++ b/src/Heating/Heater.cpp @@ -106,6 +106,7 @@ Heater::HeaterParameters Heater::fanOffParams, Heater::fanOnParams; Heater::Heater(unsigned int num) noexcept : tuned(false), heaterNumber(num), sensorNumber(-1), activeTemperature(0.0), standbyTemperature(0.0), maxTempExcursion(DefaultMaxTempExcursion), maxHeatingFaultTime(DefaultMaxHeatingFaultTime), + isBedOrChamber(false), active(false), modelSetByUser(false), monitorsSetByUser(false) { } @@ -573,6 +574,7 @@ GCodeResult Heater::Activate(const StringRef& reply) noexcept if (GetMode() != HeaterMode::fault) { active = true; + isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(heaterNumber); return SwitchOn(reply); } reply.printf("Can't activate heater %u while in fault state", heaterNumber); @@ -585,6 +587,7 @@ void Heater::Standby() noexcept { active = false; String<1> dummy; + isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(heaterNumber); (void)SwitchOn(dummy.GetRef()); } } @@ -605,6 +608,7 @@ void Heater::SetTemperature(float t, bool activeNotStandby) THROWS(GCodeExceptio if (GetMode() > HeaterMode::suspended && active == activeNotStandby) { String<StringLength100> reply; + isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(heaterNumber); if (SwitchOn(reply.GetRef()) > GCodeResult::warning) { throw GCodeException(-1, 1, reply.c_str()); @@ -703,6 +707,7 @@ GCodeResult Heater::SetTemperature(const CanMessageSetHeaterTemperature& msg, co return GCodeResult::ok; case CanMessageSetHeaterTemperature::commandOn: + isBedOrChamber = msg.isBedOrChamber; activeTemperature = standbyTemperature = msg.setPoint; model.CalcPidConstants(activeTemperature); return SwitchOn(reply); diff --git a/src/Heating/Heater.h b/src/Heating/Heater.h index f768e4a7..284e6783 100644 --- a/src/Heating/Heater.h +++ b/src/Heating/Heater.h @@ -138,6 +138,8 @@ protected: float GetMaxTemperatureExcursion() const noexcept { return maxTempExcursion; } float GetMaxHeatingFaultTime() const noexcept { return maxHeatingFaultTime; } float GetTargetTemperature() const noexcept { return (active) ? activeTemperature : standbyTemperature; } + bool IsBedOrChamber() const noexcept { return isBedOrChamber; } + GCodeResult SetModel(float hr, float bcr, float fcr, float coolingRateExponent, float td, float maxPwm, float voltage, bool usePid, bool inverted, const StringRef& reply) noexcept; // set the process model void ReportTuningUpdate() noexcept; // tell the user what's happening @@ -195,12 +197,13 @@ private: FopDt model; unsigned int heaterNumber; int sensorNumber; // the sensor number used by this heater - float activeTemperature; // The required active temperature - float standbyTemperature; // The required standby temperature - float maxTempExcursion; // The maximum temperature excursion permitted while maintaining the setpoint - float maxHeatingFaultTime; // How long a heater fault is permitted to persist before a heater fault is raised + float activeTemperature; // the required active temperature + float standbyTemperature; // the required standby temperature + float maxTempExcursion; // the maximum temperature excursion permitted while maintaining the setpoint + float maxHeatingFaultTime; // how long a heater fault is permitted to persist before a heater fault is raised - bool active; // Are we active or standby? + bool isBedOrChamber; // true if this was a bed or chamber heater when we were switched on + bool active; // are we active or standby? bool modelSetByUser; bool monitorsSetByUser; }; diff --git a/src/Heating/LocalHeater.cpp b/src/Heating/LocalHeater.cpp index fbc3be32..6a4e688c 100644 --- a/src/Heating/LocalHeater.cpp +++ b/src/Heating/LocalHeater.cpp @@ -307,14 +307,15 @@ void LocalHeater::Spin() noexcept else if (gotDerivative) // this is a check in case we just had a temperature spike { const float expectedRate = GetExpectedHeatingRate(); - const float minSamplingInterval = 3.0/expectedRate; // check the temperature if we expect a 3C rise since last time + const float minSamplingInterval = 3.0/expectedRate; // only check the temperature when we expect at least 3C rise since last time const float actualInterval = (float)(now - lastTemperatureMillis) * MillisToSeconds; if (actualInterval >= minSamplingInterval) { // Check that we are heating fast enough, and if so, take another sample const float expectedTemperatureRise = expectedRate * actualInterval; const float actualTemperatureRise = temperature - lastTemperatureValue; - if (actualTemperatureRise < expectedTemperatureRise * 0.5) + // Bed heaters sometimes have much slower long term heating rates than their short term heating rates, so allow them a lower measured heating rate + if (actualTemperatureRise < expectedTemperatureRise * ((IsBedOrChamber()) ? 0.35 : 0.6)) { ++heatingFaultCount; if (heatingFaultCount * HeatSampleIntervalMillis > GetMaxHeatingFaultTime() * SecondsToMillis) diff --git a/src/Heating/RemoteHeater.cpp b/src/Heating/RemoteHeater.cpp index a9cd8aff..931fbcf2 100644 --- a/src/Heating/RemoteHeater.cpp +++ b/src/Heating/RemoteHeater.cpp @@ -238,6 +238,7 @@ void RemoteHeater::SwitchOff() noexcept const CanRequestId rid = CanInterface::AllocateRequestId(boardAddress, buf); auto msg = buf->SetupRequestMessage<CanMessageSetHeaterTemperature>(rid, CanInterface::GetCanAddress(), boardAddress); msg->heaterNumber = GetHeaterNumber(); + msg->isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(GetHeaterNumber()); msg->setPoint = GetTargetTemperature(); msg->command = CanMessageSetHeaterTemperature::commandOff; String<StringLength100> reply; @@ -260,6 +261,7 @@ GCodeResult RemoteHeater::ResetFault(const StringRef& reply) noexcept const CanRequestId rid = CanInterface::AllocateRequestId(boardAddress, buf); auto msg = buf->SetupRequestMessage<CanMessageSetHeaterTemperature>(rid, CanInterface::GetCanAddress(), boardAddress); msg->heaterNumber = GetHeaterNumber(); + msg->isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(GetHeaterNumber()); msg->setPoint = GetTargetTemperature(); msg->command = CanMessageSetHeaterTemperature::commandResetFault; return CanInterface::SendRequestAndGetStandardReply(buf, rid, reply); @@ -357,6 +359,7 @@ void RemoteHeater::Suspend(bool sus) noexcept const CanRequestId rid = CanInterface::AllocateRequestId(boardAddress, buf); auto msg = buf->SetupRequestMessage<CanMessageSetHeaterTemperature>(rid, CanInterface::GetCanAddress(), boardAddress); msg->heaterNumber = GetHeaterNumber(); + msg->isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(GetHeaterNumber()); msg->setPoint = GetTargetTemperature(); msg->command = (sus) ? CanMessageSetHeaterTemperature::commandSuspend : CanMessageSetHeaterTemperature::commandUnsuspend; String<1> dummy; @@ -384,6 +387,7 @@ GCodeResult RemoteHeater::SwitchOn(const StringRef& reply) noexcept const CanRequestId rid = CanInterface::AllocateRequestId(boardAddress, buf); auto msg = buf->SetupRequestMessage<CanMessageSetHeaterTemperature>(rid, CanInterface::GetCanAddress(), boardAddress); msg->heaterNumber = GetHeaterNumber(); + msg->isBedOrChamber = reprap.GetHeat().IsBedOrChamberHeater(GetHeaterNumber()); msg->setPoint = GetTargetTemperature(); msg->command = CanMessageSetHeaterTemperature::commandOn; const GCodeResult rslt = CanInterface::SendRequestAndGetStandardReply(buf, rid, reply); |