From 7c2059d7c646eddd5c3bdce28f62a858854ccf71 Mon Sep 17 00:00:00 2001 From: P43YM Date: Fri, 28 Feb 2025 18:29:47 +0300 Subject: [PATCH] ouch! --- lib/Equitherm/Equitherm.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Equitherm/Equitherm.h b/lib/Equitherm/Equitherm.h index 84422f4..cdc8bfc 100644 --- a/lib/Equitherm/Equitherm.h +++ b/lib/Equitherm/Equitherm.h @@ -44,15 +44,16 @@ public: private: unsigned short _minOut = 20, _maxOut = 90; - datatype getResultN() { - float tempDiff = targetTemp - outdoorTemp, + datatype getResultN() + { + float tempDelta = targetTemp - outdoorTemp, maxPoint = targetTemp - (_maxOut - targetTemp) / Kn, - sf = (_maxOut - targetTemp) / pow(targetTemp - maxPoint, 1.0 / Ke), - T_rad = targetTemp + sf * pow(tempDiff, 1.0 / Ke); + sf = (_maxOut - targetTemp) / pow(targetTemp - maxPoint, 1.0 / Ke), + T_rad = targetTemp + sf * (tempDelta >= 0 ? pow(tempDelta, 1.0 / Ke) : -pow(-tempDelta, 1.0 / Ke)); return T_rad > _maxOut ? _maxOut : T_rad; -} + } - // Расчет поправки (ошибки) термостата + // Реакция на разницу с целевой температурой datatype getResultT() { return constrain((targetTemp - indoorTemp), -3, 3) * Kt; }