Skip to content

Commit

Permalink
bug fixing
Browse files Browse the repository at this point in the history
  • Loading branch information
Loic74650 committed Feb 7, 2019
1 parent 96f8273 commit 0562224
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 25 deletions.
6 changes: 6 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
PoolMaster: change log
=======================

v2.1.1
-------

* fixed bug in AntiFreeze filtration function
* updated documentation

v2.1.0
-------

Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ Every 30 seconds (by default), the system will publish on the "PoolTopic" (hardc
{"Tmp":818,"pH":321,"pHEr":0,"Orp":583,"OrpEr":0,"FilUpT":8995,"PhUpT":0,"ChlUpT":0,"IO":11,"IO2":0}


Temp: measured Water temperature value in °C x100 (8.18°C in the above example payload)<br />
Tmp: measured Water temperature value in °C x100 (8.18°C in the above example payload)<br />
pH: measured pH value x100 (3.21 in the above example payload)<br />
PhError/100: Ph PID regulation loop instantaneous error (0 in the above example payload)<br />
PhEr/100: Ph PID regulation loop instantaneous error (0 in the above example payload)<br />
Orp: measured Orp (aka Redox) value in mV (583mV in the above example payload)<br />
OrpError/100: Orp PID regulation loop instantaneous error (0 in the above example payload)<br />
FiltUpTime: current running time of Filtration pump in seconds (reset every 24h. 8995secs in the above example payload)<br />
PhUpTime: current running time of Ph pump in seconds (reset every 24h. 0secs in the above example payload)<br />
ChlUpTime: current running time of Chl pump in seconds (reset every 24h. 0secs in the above example payload)<br />
OrpEr/100: Orp PID regulation loop instantaneous error (0 in the above example payload)<br />
FiltUpT: current running time of Filtration pump in seconds (reset every 24h. 8995secs in the above example payload)<br />
PhUpT: current running time of Ph pump in seconds (reset every 24h. 0secs in the above example payload)<br />
ChlUpT: current running time of Chl pump in seconds (reset every 24h. 0secs in the above example payload)<br />
IO: a variable of type BYTE where each individual bit is the state of a digital input on the Arduino. These are :<br />
<ul>
<li>FiltPump: current state of Filtration Pump (0=on, 1=off)</li>
Expand Down Expand Up @@ -53,7 +53,7 @@ IO2: a variable of type BYTE where each individual bit is the state of a digital
- MAC and IP address of the Ethernet shield<br />
- MQTT broker IP address and login credentials<br />
- possibly the topic names on the MQTT broker to subscribe and publish to<br />
- the Kp,Ki,Kd parameters for both PID loops in case your peristaltic pumps have a different throughput than 2Liters/hour. For instance, if twice more, divide the parameters by 2<br /></p>
- the Kp,Ki,Kd parameters for both PID loops in case your peristaltic pumps have a different throughput than 2Liters/hour. For instance, if twice more, divide the parameters by 2. In any case these parameters are likely to require adjustments for every pool<br /></p>

</p>

Expand Down Expand Up @@ -92,7 +92,7 @@ Below are the Payloads/commands to publish on the "PoolTopicAPI" topic (see hard
<li>{"PumpsMaxUp":1800} -> set the Max Uptime (in secs) for the Ph and Chl pumps over a 24h period. If over, PID regulation is stopped and a warning flag is raised</li>
<li>{"Clear":1} -> reset the pH and Orp pumps overtime error flags in order to let the regulation loops continue. "Mode" also needs to be switched back to Auto (1) after an error flag was raised</li>
<li>{"DelayPID":30} -> Delay (in mins) after FiltT0 before the PID regulation loops will start. This is to let the Orp and pH readings stabilize first. 30mins in this example. Should not be > 59mins</li>
<li>{"TempExt":4.2} -> Provide the external temperature. Should be updated regularly and will be used to start filtration for 10mins every hour when temperature is negative. 4.2deg in this example</li>
<li>{"TempExt":4.2} -> Provide the system with the external temperature. Should be updated regularly and will be used to start filtration for 10mins every hour when temperature is less than 2°C. 4.2deg in this example</li>

</ul>
</p><br />
Expand Down
31 changes: 14 additions & 17 deletions source/PoolMaster/PoolMaster.ino
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ https://github.com/arduino-libraries/LiquidCrystal
#include <ArduinoJson.h>

// Firmware revision
String Firmw = "2.1.0";
String Firmw = "2.1.1";

//LCD init.
//LCD connected on pin header 2 connector, not on screw terminal (/!\)
Expand Down Expand Up @@ -231,6 +231,9 @@ PID OrpPID(&OrpValue, &OrpPIDOutput, &Orp_SetPoint, Orp_Kp, Orp_Ki, Orp_Kd, DIRE
//Filtration/regulation mode: auto (1) or manual (0)
bool AutoMode = 0;

//Filtration anti freeze mode
bool AntiFreezeFiltering = false;

//BitMaps with GPIO states
unsigned char BitMap = 0;
unsigned char BitMap2 = 0;
Expand Down Expand Up @@ -598,19 +601,7 @@ void messageReceived(String &topic, String &payload)
{
//Serial<<F("starting Filtration")<<endl;
if((int)command[F("FiltPump")]==0)
{
FiltrationPump(false); //stop filtration pump

//If auto mode, switch to manual mode
if(AutoMode)
{
AutoMode = 0;

//Stop PIDs
SetPhPID(false);
SetOrpPID(false);
}
}
else
FiltrationPump(true); //start filtration pump
}
Expand Down Expand Up @@ -823,8 +814,8 @@ void GenericCallback(Task* me)
SetOrpPID(true);
}

//stop filtration pump and PIDs as scheduled
if(AutoMode && digitalRead(FILTRATION_PUMP) && ((hour < FiltrationStart) || (hour >= FiltrationStop)))
//stop filtration pump and PIDs as scheduled unless we are in AntiFreeze mode
if(AutoMode && digitalRead(FILTRATION_PUMP) && !AntiFreezeFiltering && ((hour < FiltrationStart) || (hour >= FiltrationStop)))
{
SetPhPID(false);
SetOrpPID(false);
Expand All @@ -833,12 +824,18 @@ void GenericCallback(Task* me)

//start filtration pump every hour for 10 mins in cold temperatures (<2.0deg)
if(AutoMode && (!digitalRead(FILTRATION_PUMP)) && ((hour < FiltrationStart) || (hour > FiltrationStop)) && (minute == 0) && (TempExternal<2.0))
{
FiltrationPump(true);
AntiFreezeFiltering = true;
}

//stop filtration pump every hour after 10 mins in cold temperatures (<2.0deg)
if(AutoMode && (digitalRead(FILTRATION_PUMP)) && ((hour < FiltrationStart) || (hour > FiltrationStop)) && (minute == 10) && (TempExternal<2.0))
if(AutoMode && (digitalRead(FILTRATION_PUMP)) && ((hour < FiltrationStart) || (hour > FiltrationStop)) && (minute == 10))
{
FiltrationPump(false);

AntiFreezeFiltering = false;
}

//UPdate LCD
if(LCDToggle)
LCDScreen1();
Expand Down

0 comments on commit 0562224

Please sign in to comment.