Перегрев реле временно отключает нагрев, а не сбрасывает состояние управления
This commit is contained in:
+18
-9
@@ -32,6 +32,8 @@ DHT dht(DHTPIN, DHTTYPE);
|
|||||||
|
|
||||||
// deviation from target t allowed (in degrees multiplied by 100)
|
// deviation from target t allowed (in degrees multiplied by 100)
|
||||||
#define T_HYSTERESIS 150
|
#define T_HYSTERESIS 150
|
||||||
|
// relay cooldown temperature (after what t we allow to turn on relay again) (in degrees multiplied by 100)
|
||||||
|
#define RELAY_COOLDOWN_T 500
|
||||||
// timeout to switch from external to internal temperature data (in milliseconds)
|
// timeout to switch from external to internal temperature data (in milliseconds)
|
||||||
#define SWITCH_TO_INTERNAL_TIMEOUT 50000
|
#define SWITCH_TO_INTERNAL_TIMEOUT 50000
|
||||||
|
|
||||||
@@ -287,7 +289,6 @@ void loop()
|
|||||||
{
|
{
|
||||||
cur_state = 1;
|
cur_state = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (current_t > target_t + T_HYSTERESIS)
|
else if (current_t > target_t + T_HYSTERESIS)
|
||||||
{
|
{
|
||||||
cur_state = 0;
|
cur_state = 0;
|
||||||
@@ -297,14 +298,22 @@ void loop()
|
|||||||
{
|
{
|
||||||
cur_state = override_state;
|
cur_state = override_state;
|
||||||
}
|
}
|
||||||
if (relay_t > CRITICAL_T)
|
if (!overheat)
|
||||||
{
|
{
|
||||||
//Serial.printf("Critical overheat, t = %d\n", relay_t);
|
if (relay_t > CRITICAL_T)
|
||||||
cur_state = 0;
|
{
|
||||||
overheat = 1;
|
overheat = 1;
|
||||||
}
|
}
|
||||||
else overheat = 0;
|
}
|
||||||
digitalWrite(RELAY_PIN, cur_state);
|
else
|
||||||
|
{
|
||||||
|
if (relay_t < CRITICAL_T - RELAY_COOLDOWN_T)
|
||||||
|
{
|
||||||
|
overheat = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (cur_state && !overheat) digitalWrite(RELAY_PIN, 1);
|
||||||
|
else digitalWrite(RELAY_PIN, 0);
|
||||||
if (u)
|
if (u)
|
||||||
{
|
{
|
||||||
Serial.printf("State %d Relay t %d Internal t %d External t %d Current t %d Target t %d\n", cur_state, relay_t, internal_t, external_t, current_t, target_t);
|
Serial.printf("State %d Relay t %d Internal t %d External t %d Current t %d Target t %d\n", cur_state, relay_t, internal_t, external_t, current_t, target_t);
|
||||||
|
|||||||
Reference in New Issue
Block a user