Advertisement
Guest User

Untitled

a guest
Jan 2nd, 2019
429
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.33 KB | None | 0 0
  1. // delta max = 0.6544 wrt dewPoint()
  2. // 6.9 x faster than dewPoint()
  3. // reference: http://en.wikipedia.org/wiki/Dew_point
  4. double dewPointFast(double celsius, double humidity)
  5. {
  6.   double a = 17.271;
  7.   double b = 237.7;
  8.   double temp = (a * celsius) / (b + celsius) + log(humidity * 0.01);
  9.   double Td = (b * temp) / (a - temp);
  10.   return Td;
  11. }
  12.  
  13. int desiredCoolingIthoSpeed(float t, float h, float dp, float buitent, float buitenh, float buitendp) {
  14.   // called if (t > 20.0 || (t > 19.0 && buitent > 24.0))
  15.  
  16.   // only on extreme humidity we run when the outside temp is higher
  17.   if ((h > 65.0 && dp > (buitendp+2.0))
  18.     || (h > 75.0 && dp > (buitendp+1.0)))  {
  19.     Serial.println("it's hot, but it so humid that we still want to dry..");
  20.     return 1;
  21.   }
  22.  
  23.   if (buitent < (t-3.0)) {
  24.     // buiten 3 graden koeler
  25.     if (t > 22.0 && (buitent < 18.0) && buitendp <= dp) {
  26.       Serial.println("Extreme cooling (4 degrees) and also drying, use 2!");
  27.       return 2;
  28.     }
  29.     Serial.println("Normal cooling");
  30.     return 1;
  31.   }
  32.   Serial.println("Nothing to cool, default return 0");
  33.   return 0;
  34. }
  35.  
  36.  
  37.  
  38. int desiredDryingIthoSpeed(float t, float h, float dp, float buitent, float buitenh, float buitendp) {
  39.   // by default we send medium
  40.   if (dp - buitendp > 5.0) {
  41.     // buiten veeel droger, maar droger trekken dan 45 heeft echt geen zin
  42.     if (h > 57.0) {
  43.       Serial.println("Much drier outside, h>57 inside, return 2");
  44.       return 2;
  45.     } else if (h < 45.0) {
  46.       Serial.println("Much drier outside, but dry enough inside (h<45), return 0");
  47.       return 0;
  48.     } else {
  49.       Serial.println("Much drier outside, return 1");
  50.       return 1;
  51.     }
  52.   } else if (dp - buitendp > 2.0) {
  53.     // buiten iets droger dan binnen
  54.     if (h > 65.0) {
  55.       Serial.println("Drier outside, h>65 return 2");
  56.       return 2;
  57.     } else if (h < 55.0) {
  58.       Serial.println("Drier outside, h<52 return 0");
  59.       return 0;
  60.     } else {
  61.       Serial.println("Drier outside, return 1");
  62.       return 1;
  63.     }
  64.   } else if (dp - buitendp > 1.0) {
  65.     // buiten marginaal droger dan binnen
  66.     if (h > 75.0) {
  67.       Serial.println("Slightly drier outside, h>75 return 2");
  68.       return 2;
  69.     } else if (h < 62.0) {
  70.       Serial.println("Slightly drier outside, h<62 return 0");
  71.       return 0;
  72.     } else {
  73.       Serial.println("Slightly drier outside, return 1");
  74.       return 1;
  75.     }
  76.   } else if (dp - buitendp > 0.1) {
  77.     if (h > 80.0) {
  78.       Serial.println("Hardly drier outside, h>80 return 2");
  79.       return 2;
  80.     } else if (h < 70.0) {
  81.       Serial.println("Hardly drier outside, h<70 return 0");
  82.       return 0;
  83.     } else {
  84.       Serial.println("Hardly drier outside, return 1");
  85.       return 1;
  86.     }
  87.   } else {
  88.     Serial.println("Wetter or equal outside, return 0");
  89.     // buiten gelijk of natter, dan doen we time based ventilatie
  90.     // en dus niks op basis van de vochtigheid
  91.     return 0;
  92.   }
  93.   Serial.println("default, return 1");
  94.   return 1;
  95. }
  96.  
  97. int desiredIthoSpeed(float t, float h, float dp, float buitent, float buitenh, float buitendp) {
  98.   // it seems that this particular sesnor thinks it is pretty cool
  99.   if (t > 20.5 || (t > 19.0 && buitent > 24.0)) {
  100.     desiredCoolingIthoSpeed(t,h,dp,buitent,buitenh,buitendp);
  101.   } else {
  102.     desiredDryingIthoSpeed(t,h,dp,buitent,buitenh,buitendp);
  103.   }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement