Last active
March 16, 2019 16:02
-
-
Save niektemme/4bc2dd1c4d9e47bf7d52 to your computer and use it in GitHub Desktop.
Smart Thermostat Arduino - part thermostat functions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//function to determine if boiler controll loop should go to run level 1 | |
int frunScen (int actTemp, int setTemp) { | |
if ( (setTemp*10) - actTemp > 35) { | |
return 1; | |
} else { | |
return 0; | |
} | |
} | |
//function to determine how many seconds boiler should go on within 10 minute interval | |
unsigned long fscenLength(int actTemp, int setTemp) { | |
unsigned long scnel; | |
// int iscnel = 0; | |
if ( (setTemp*10) - actTemp > 260) { | |
scnel = (6UL*60UL*1000UL); | |
} else if ( (setTemp*10) - actTemp > 160) { | |
scnel = (5UL*60UL*1000UL); | |
} else if ( (setTemp*10) - actTemp > 70) { | |
scnel = (4UL*60UL*1000UL); | |
} else if ( (setTemp*10) - actTemp > 40) { | |
scnel = (3UL*60UL*1000UL); | |
} else { | |
scnel = (2UL*60UL*1000UL); | |
} | |
return scnel; | |
} | |
//function to check if boiler should stay on or go off | |
int fboilerStat(unsigned long starts,unsigned long scenl,unsigned long cur ,int actTemp, int setTemp) { | |
if (actTemp - (setTemp*10) < 35){ //criteria 1: only say on if act temperature is below set temperature + margin | |
if (cur - starts < scenl) { //criteria 2: only stay on of boiler has not been on for the number of seconds determined by fscenLength | |
return 1; //stay on | |
} else { | |
return 0; //go off (because boiler was on for number of minues determined by fscenLength | |
} | |
} else { | |
return 2; //go off (2 is used to monitor overflow) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment