Added safetyNet()

Still untested
This commit is contained in:
mrcory
2020-03-07 11:18:31 -05:00
parent de70ab7ade
commit b46567738a
3 changed files with 19 additions and 2 deletions
+2
View File
@@ -162,6 +162,8 @@ void loop() {
//Serial.println(temp.cur);
}
safetyNet(); //Overload protection
if (isFirstRun == true) {
Blynk.virtualWrite(V53,temp.target);
Blynk.virtualWrite(V55,temp.offset);
+15 -1
View File
@@ -241,7 +241,7 @@ void ReadCse7766()
//Basic functions that must run
void process() {
if (timer(1000,0)) {
if (timer(2000,0)) {
ReadCse7766();
}
@@ -318,8 +318,22 @@ bool overloadCheck() {
}
void safetyNet() {
overloadCheck();
if (!safeLoad && timerCheck(4) >= loadCooldown*1000 && loadAttempt < loadConnectAttempts) {
safeLoad = true;
loadAttempt++;
timerReset(4);
timerReset(5);
}
if (loadAttempt > 0) {
if (timerCheck(5) > 30*1000) { //If relay hasn't overloaded for 30 seconds, reset the loadAttempt count
loadAttempt = 0;
}
if (loadAttempt > loadConnectAttempts) {
resetRequired = true;
}
}
}
+2 -1
View File
@@ -4,10 +4,11 @@
* 2 - Update Blynk app data
* 3 - Heater trigger cooldown
* 4 - Overload cooldown
* 5 - Overload reset
*/
#define countDataAmount 5 //Number of timers
#define countDataAmount 6 //Number of timers
unsigned long countData[countDataAmount] = {0}; //Holds count information. (Adjust for numeber of timers needed.)