Hi,
i'ld want make a function that start the electric vlave for CO2 when the PH is >6.50 and >6.20 .
But i don't want continuos on & off for little variation. Like the temp function:
void ReefAngelClass::StandardHeater(byte HeaterRelay, int LowTemp, int HighTemp)
{
if (Params.Temp1 == 0) return; // Don't turn the heater on if the temp is reading 0
if (Params.Temp1 <= LowTemp && Params.Temp1 > 0) Relay.On(HeaterRelay); // If sensor 1 temperature <= LowTemp - turn on heater
if (Params.Temp1 >= HighTemp) Relay.Off(HeaterRelay); // If sensor 1 temperature >= HighTemp - turn off heater
}
I make so:
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (Params.PH == 0) return; // Don't turn the heater on if the temp is reading 0
if (Params.PH >= HighPH && Params.PH > 0 && Params.PH >= LowPH ) Relay.On(CO2Relay); // If sensor PH >= LowPH and <= HighPH - turn on the CO2
if (Params.PH <= LowPH) Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
}
What do you think ? IS CORRECT ?
Thanks
Intelligent PH function for Calcium Reactor
Re: Intelligent PH function for Calcium Reactor
With help of my firend Siro
static bool co2on = false;
int LowPH;
int HighPH;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (Params.PH == 0) return; // Don't turn the heater on if the temp is reading 0
if (Params.PH >= HighPH ) co2on=true;
if (co2on) {
Relay.On(CO2Relay);
if (Params.PH <= LowPH){
Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
static bool co2on = false;
int LowPH;
int HighPH;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (Params.PH == 0) return; // Don't turn the heater on if the temp is reading 0
if (Params.PH >= HighPH ) co2on=true;
if (co2on) {
Relay.On(CO2Relay);
if (Params.PH <= LowPH){
Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
Re: Intelligent PH function for Calcium Reactor
I haven't reviewed the code, so I'm not going to comment on accuracy. I will say that just looking at the code, if you keep this function inside your PDE file, you will have to make changes to it for it to work properly.
This way you can actually reference the proper parameters and everything will compile for you.
To keep things a little simpler, I would have done something like this:
From your scenario you gave, you want the valve turned on when your PH exceeds your HighPH. Then you want it to run until the PH goes below the LowPH and not turn back on until the PH gets above the HighPH. Your code looked like it was close initially but was just off a little.
Hopefully this will work for you, if not, I'm sure somebody will correct it.
curt
Code: Select all
static bool co2on = false;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (ReefAngel.Params.PH == 0) return;
if (ReefAngel.Params.PH >= HighPH ) co2on=true;
if (co2on) {
ReefAngel.Relay.On(CO2Relay);
if (ReefAngel.Params.PH <= LowPH){
ReefAngel.Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
To keep things a little simpler, I would have done something like this:
Code: Select all
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (ReefAngel.Params.PH == 0) return;
// If sensor PH >= LowPH and PH >= HighPH - turn on the CO2
if (ReefAngel.Params.PH >= LowPH && ReefAngel.Params.PH >= HighPH) Relay.On(CO2Relay);
// If sensor PH < LowPH - turn off the CO2
if (ReefAngel.Params.PH < LowPH) Relay.Off(CO2Relay);
}
Hopefully this will work for you, if not, I'm sure somebody will correct it.
curt
Re: Intelligent PH function for Calcium Reactor
ok...binder wrote:I haven't reviewed the code, so I'm not going to comment on accuracy. I will say that just looking at the code, if you keep this function inside your PDE file, you will have to make changes to it for it to work properly.
This way you can actually reference the proper parameters and everything will compile for you.Code: Select all
static bool co2on = false; void CO2(byte CO2Relay, int LowPH, int HighPH) { if (ReefAngel.Params.PH == 0) return; if (ReefAngel.Params.PH >= HighPH ) co2on=true; if (co2on) { ReefAngel.Relay.On(CO2Relay); if (ReefAngel.Params.PH <= LowPH){ ReefAngel.Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2 co2on = false; } }
imho this is wrong the second if is never true....To keep things a little simpler, I would have done something like this:From your scenario you gave, you want the valve turned on when your PH exceeds your HighPH. Then you want it to run until the PH goes below the LowPH and not turn back on until the PH gets above the HighPH. Your code looked like it was close initially but was just off a little.Code: Select all
void CO2(byte CO2Relay, int LowPH, int HighPH) { if (ReefAngel.Params.PH == 0) return; // If sensor PH >= LowPH and PH >= HighPH - turn on the CO2 if (ReefAngel.Params.PH >= LowPH && ReefAngel.Params.PH >= HighPH) Relay.On(CO2Relay); // If sensor PH < LowPH - turn off the CO2 if (ReefAngel.Params.PH < LowPH) Relay.Off(CO2Relay); }
Hopefully this will work for you, if not, I'm sure somebody will correct it.
curt
Re: Intelligent PH function for Calcium Reactor
i will have to look at this more when i get home tonight. i'm at work and checking this during my short breaks so i may be a little off.
curt
curt
Re: Intelligent PH function for Calcium Reactor
don't worry... i can use this :
static bool co2on = false;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (ReefAngel.Params.PH == 0) return;
if (ReefAngel.Params.PH >= HighPH ) co2on=true;
if (co2on) {
ReefAngel.Relay.On(CO2Relay);
if (ReefAngel.Params.PH <= LowPH){
ReefAngel.Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
logically it seems to work... :-d
static bool co2on = false;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (ReefAngel.Params.PH == 0) return;
if (ReefAngel.Params.PH >= HighPH ) co2on=true;
if (co2on) {
ReefAngel.Relay.On(CO2Relay);
if (ReefAngel.Params.PH <= LowPH){
ReefAngel.Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
logically it seems to work... :-d
Re: Intelligent PH function for Calcium Reactor
I was using this , and it work right.lukeluke wrote:don't worry... i can use this :
static bool co2on = false;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (ReefAngel.Params.PH == 0) return;
if (ReefAngel.Params.PH >= HighPH ) co2on=true;
if (co2on) {
ReefAngel.Relay.On(CO2Relay);
if (ReefAngel.Params.PH <= LowPH){
ReefAngel.Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
logically it seems to work... :-d
Re: Intelligent PH function for Calcium Reactor
For the community, below the #include i put this:
CO2(Port2,620,650);
Bye
and in the void loop() , this:static bool co2on = false;
void CO2(byte CO2Relay, int LowPH, int HighPH)
{
if (ReefAngel.Params.PH == 0) return;
if (ReefAngel.Params.PH >= HighPH ) co2on=true;
if (co2on) {
ReefAngel.Relay.On(CO2Relay);
if (ReefAngel.Params.PH <= LowPH){
ReefAngel.Relay.Off(CO2Relay); // If sensor PH <= HighPH - turn off the CO2
co2on = false;
}
}
}
CO2(Port2,620,650);
Bye