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
path: root/src
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-03-08 16:44:27 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-03-08 16:44:27 +0300
commit75c69294278f838666680e413f73a3a57278b1ac (patch)
tree82c74e850955920c184e2058d145b46330e42753 /src
parent42b3d4e999e31a82ac67a0c4feaa5495a440abcf (diff)
Fixed bug with incorrect heater feedforward when fan speed changes
Diffstat (limited to 'src')
-rw-r--r--src/Heating/FOPDT.cpp10
-rw-r--r--src/Heating/Heater.cpp2
-rw-r--r--src/Heating/Heater.h2
-rw-r--r--src/Heating/LocalHeater.cpp2
4 files changed, 8 insertions, 8 deletions
diff --git a/src/Heating/FOPDT.cpp b/src/Heating/FOPDT.cpp
index 804eab14..2d83c4e8 100644
--- a/src/Heating/FOPDT.cpp
+++ b/src/Heating/FOPDT.cpp
@@ -298,15 +298,15 @@ void FopDt::CalcPidConstants(float targetTemperature) noexcept
{
if (!pidParametersOverridden)
{
- // Calculate the cooling rate per degC at this temperature. We assume the fan is off because that is the worst case i.e. longest time constant and less stable.
- const float temperatureRise = targetTemperature - NormalAmbientTemperature;
+ // Calculate the cooling rate per degC at this temperature. We assume the fan is at 20% speed.
+ const float temperatureRise = max<float>(targetTemperature - NormalAmbientTemperature, 1.0); // avoid division by zero!
const float averageCoolingRatePerDegC = GetCoolingRate(temperatureRise, 0.2)/temperatureRise;
loadChangeParams.kP = 0.7/(heatingRate * deadTime);
- loadChangeParams.recipTi = powf(averageCoolingRatePerDegC, 0.25)/(1.14 * powf(deadTime, 0.75)); // Ti = 1.14 * timeConstant^0.25 * deadTime^0.75 (Ho et al)
+ loadChangeParams.recipTi = powf(averageCoolingRatePerDegC, 0.25)/(1.14 * powf(deadTime, 0.75)); // Ti = 1.14 * timeConstant^0.25 * deadTime^0.75 (Ho et al)
loadChangeParams.tD = deadTime * 0.7;
setpointChangeParams.kP = 0.7/(heatingRate * deadTime);
- setpointChangeParams.recipTi = powf(averageCoolingRatePerDegC, 0.5)/powf(deadTime, 0.5); // Ti = timeConstant^0.5 * deadTime^0.5
+ setpointChangeParams.recipTi = powf(averageCoolingRatePerDegC, 0.5)/powf(deadTime, 0.5); // Ti = timeConstant^0.5 * deadTime^0.5
setpointChangeParams.tD = deadTime * 0.7;
}
}
@@ -323,7 +323,7 @@ float FopDt::CorrectPwmForVoltage(float requiredPwm, float actualVoltage) const
float FopDt::GetPwmCorrectionForFan(float temperatureRise, float fanPwmChange) const noexcept
{
- return temperatureRise * 0.01 * fanCoolingRate / heatingRate;
+ return temperatureRise * 0.01 * fanCoolingRate * fanPwmChange / heatingRate;
}
// Calculate the expected cooling rate for a given temperature rise above ambient
diff --git a/src/Heating/Heater.cpp b/src/Heating/Heater.cpp
index 5f02fa5e..ed868737 100644
--- a/src/Heating/Heater.cpp
+++ b/src/Heating/Heater.cpp
@@ -290,7 +290,7 @@ GCodeResult Heater::StartAutoTune(GCodeBuffer& gb, const StringRef& reply, FansB
tuningFans = fans;
tuningPwm = (gb.Seen('P')) ? gb.GetLimitedFValue('P', 0.1, 1.0) : GetModel().GetMaxPwm();
tuningHysteresis = (gb.Seen('Y')) ? gb.GetLimitedFValue('Y', 1.0, 20.0) : DefaultTuningHysteresis;
- tuningFanPwm = (gb.Seen('F')) ? gb.GetLimitedFValue('F', 0.1, 1.0) : 1.0;
+ tuningFanPwm = (gb.Seen('F')) ? gb.GetLimitedFValue('F', 0.1, 1.0) : DefaultTuningFanPwm;
const GCodeResult rslt = StartAutoTune(reply, seenA, ambientTemp);
if (rslt == GCodeResult::ok)
diff --git a/src/Heating/Heater.h b/src/Heating/Heater.h
index 220164a4..28c27933 100644
--- a/src/Heating/Heater.h
+++ b/src/Heating/Heater.h
@@ -157,8 +157,8 @@ protected:
static constexpr unsigned int MinTuningHeaterCycles = 5;
static constexpr unsigned int MaxTuningHeaterCycles = 25;
static constexpr float DefaultTuningHysteresis = 5.0;
+ static constexpr float DefaultTuningFanPwm = 0.7;
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;
// Variables used during heater tuning
diff --git a/src/Heating/LocalHeater.cpp b/src/Heating/LocalHeater.cpp
index 8930c066..45c73d1a 100644
--- a/src/Heating/LocalHeater.cpp
+++ b/src/Heating/LocalHeater.cpp
@@ -557,7 +557,7 @@ void LocalHeater::FeedForwardAdjustment(float fanPwmChange, float extrusionChang
{
if (mode == HeaterMode::stable)
{
- const float boost = GetModel().GetPwmCorrectionForFan(GetTargetTemperature() - NormalAmbientTemperature, fanPwmChange) * FeedForwardMultiplier;
+ const float boost = GetModel().GetPwmCorrectionForFan(GetTargetTemperature() - NormalAmbientTemperature, fanPwmChange) * FanFeedForwardMultiplier;
#if 0
if (reprap.Debug(moduleHeat))
{