So, this is starting to seriously call for a class to manage all the dosing pumps and a class for each dosing pump with its characteristics (calibration volume, rate factor, timers, messages, etc.)
Anyway, here's my first run at a calibraton routine. The way it works is that I have a virtual outlet that I turn on to calibrate. This could just as easily be a menu mode... When that outlet is on, the calibration starts. For each pump defined it waits for the maskon to happen. when you turn it on it assumes you are filling a measuring cup to whatever amount you want. At that point it records the time. When the mask off happens it compares the times and gets the total running time. It then pages you with the result. If you need to turn the pump back on for a little more, it will track the running time. When your happy with the result, the last page you get will be the total time.
You can then put that time into a memory variable and that is used by my previous dosing pump routine to calculate the dosage. Since you've also stored the amount of liquid you are measuring we can properly calculate this. Also, the units can be whatever.. it could just as easily be 5 gallons in 200 seconds or 100ml in an hour.
What is now important is that you can now enter the number of ml or gallons or whatever you want and over how ever many doses you want per day and it's all calculated...
Let's see how it tests out.
I'm also going to add logging that we started working on for kirkwood. What I would like a separate function that is logging the relay and storing the total time it is on and send me the total each hour.
Anyway, without further-ado. This code is compiled but not yet tested. It will be uploaded after this post
Code: Select all
// Run calibration routine,
void CalibrateDPumps() {
const byte numPumps=2;
byte pump[numPumps] = { DPump1, DPump2 };
static time_t pumpTimer[numPumps];
static WiFiAlert calibrateMsg;
char msg[16];
if (ReefAngel.Relay.Status(VO_Calibrate)) {
for (int i=0;i < numPumps;i++) {
if (ReefAngel.Relay.isMaskOn(pump[i])) {
pumpTimer[i]=now()-pumpTimer[i];
ReefAngel.Relay.Override(pump[i],2);
ReefAngel.Relay.On(pump[i]);
}
if (ReefAngel.Relay.isMaskOff(pump[i]) && pumpTimer[i]>0) {
ReefAngel.Relay.Override(pump[i],2);
ReefAngel.Relay.Off(pump[i]);
pumpTimer[i]=now()-pumpTimer[i];
sprintf(msg,"Pump%d+:+%d",i+1,pumpTimer[i]);
calibrateMsg.Send(msg,true);
}
}
} else {
for (int i=0;i< numPumps;i++) {
pumpTimer[i]=0;
}
}
}