I finally got this to comply and wondered if anybody might be kind enough to tell me if the ‘while’ function will likely do what I expect, which is run the entire sketch when pH is less than 8.3 and only run the part of the sketch not bracketed by the ‘while’ function when pH is greater than 8.3.
I don’t have a pH probe yet to run a bench test. Also, pointing out problems/deficiencies would be appreciated.
Thanks
Joe
int pH = A7;
unsigned long hoursInMs(int h){
return h*3600000UL; //values will be expressed in hours
}
long minutesInMs(int m){
return m*60000L; //values will be expressed in minutes
}
long secondsInMs(int s){
return s*1000L; //values will be expressed in seconds
}
void setup() {
pinMode(A7, INPUT); // pin A7 connected to pH probe
pinMode(7, OUTPUT); // pin 7 controls mixing pump
pinMode(8, OUTPUT); // pin 8 controls kalk slurry
pinMode(9, OUTPUT); // pin 9 controls washing soda
pinMode(10, OUTPUT); // pin 10 controls calcium chloride
}
void loop() {
while( pH < 8.3 ) // if pH is higher than 8.3, kalk slurry will not be added
{
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
digitalWrite(9, LOW); // turn washing soda dosing pump off
digitalWrite(10, LOW); // turn calcium chloride dosing pump off
digitalWrite(7, HIGH); // turn mixing pump on using a NO relay
delay(secondsInMs(20)); // let mixing pump run for 20 seconds, or long enough to create kalk slurry
digitalWrite(7, LOW); // turn mixing pump off
delay(secondsInMs(30)); // leave mixing pump off for 30 seconds to allow any solid chunks to fall to the bottom of container
digitalWrite(8, HIGH); // turn kalk slurry dosing pump on using a second NO relay
delay(secondsInMs(3)); // let kalk slurry dosing pump run only briefly to prevent a precipitation event
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
delay(secondsInMs(30)); // leave kalk slurry dosing pump off briefly to allow slurry to dissipate
digitalWrite(8, HIGH); // same as above, this just spreads out the kalk slurry.
delay(secondsInMs(3));
digitalWrite(8, LOW);
delay(secondsInMs(30));
digitalWrite(8, HIGH); // same as above.
delay(secondsInMs(3));
digitalWrite(8, LOW);
delay(secondsInMs(30));
digitalWrite(8, HIGH); // almost same as above.
delay(secondsInMs(3));
digitalWrite(8, LOW);
delay(minutesInMs(5)); // in 5 minutes, the dosing series continues
}
digitalWrite(7, LOW); // turn mixing pump off
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
digitalWrite(10, LOW); // turn calcium chloride dosing pump off
digitalWrite(9, HIGH); // turn washing soda dosing pump on using a third NO relay
delay(secondsInMs(5)); // dose washing soda for 5 seconds
digitalWrite(9, LOW); // turn washing soda dosing pump off
delay(minutesInMs(5)); // wait 5 minutes before next dose
digitalWrite(7, LOW); // turn mixing pump off
digitalWrite(8, LOW); // turn kalk slurry dosing pump off
digitalWrite(9, LOW); // turn washing soda dosing pump off
digitalWrite(10, HIGH); // turn calcium chloride dosing pump on using a fourth NO relay
delay(secondsInMs(5)); // dose calcium chloride for 5 seconds
digitalWrite(10, LOW); // turn calcium chloride dosing pump off
delay(hoursInMs(6)); // wait 6 hours before starting at the top with a new dosing series.
}