Ph Exp issue

Do you have a question on how to do something.
Ask in here.

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Sun Apr 23, 2017 12:14 pm
Hello,

I have an issue with Ph expansion slot and co2 solenoid valve. CO2 solenoid valve keeps turning on/off a lot of times a day without reason. Actually there is a reason (there are two of them):

1st: as calcium reactor has feed pump ph changes during the seconds/minutes and this lead to that when ph reaches the border between limits - it switches co2 solenoid for a second and turns off, example: if solenoid should turn on when ph 6.50 and turn off when ph is 6.40 then when it reaches 6.49 and goes till 6.50 - it turns on solenoid just before it actually goes to 6.50

2nd: sometimes it just happens that you have ph in expansion 6.44 and suddenly it goes to 8.01 for a millisecond. Why - I don't know, but this triggers solenoid to turn on and off.

Here is the code that I'm using:

Code: Select all
if ( hour()>=7 && hour()<22 )           
    {if ( ReefAngel.Params.PHExp < 640 && ReefAngel.Params.PHExp >= 600) ReefAngel.Relay.Off(Box1_Port4); //CO2 Switch Off 635
     if ( ReefAngel.Params.PHExp >= 660 && ReefAngel.Params.PHExp < 800) ReefAngel.Relay.On(Box1_Port4); //CO2 Switch On 665
    }
    else
    {ReefAngel.Relay.Off(Box1_Port4); //CO2 Switch Off
    }


Any ideas how to add some kind of criteria to measure ph exp for example few seconds and then decide - would be appreciated.
Image

Posts: 12288
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Sun Apr 23, 2017 4:58 pm
You can average out the value over X amount of samples.
Code: Select all
static unsigned long lastmillis=millis();
static unsigned long avgphexp=0;
static unsigned int phexpvalues[] = {640,640,640,640,640};
static byte avgindex=0;
if ((millis() - lastmillis)>1000)
{
  lastmillis=millis();
  avgindex++;
  if (avgindex==5) avgindex=0;
  phexpvalues[avgindex)=ReefAngel.Params.PHExp;
  avgphexp=0;
  for (int a=0;a<5;a++)
  {
    avgphexp+=phexpvalues[a];
  }
  avgphexp=avgphexp/5;
}
// You can use avgphexp as the average value
Roberto.

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Sun Apr 23, 2017 9:53 pm
Where should I put this code and what does it mean following:

if ((millis() - lastmillis)>1000)

Afterwards I should use just avgphexp instead of ReefAngel.Params.PHExp, yes?

if ( avgphexp >= 660 && avgphexp < 800) ReefAngel.Relay.On(Box1_Port4);
Image

Posts: 12288
Joined: Fri Mar 18, 2011 6:47 pm
PostPosted: Mon Apr 24, 2017 9:25 pm
custom section of your loop()
Correct use avgexp. The line is to grab reading every second.
Roberto.

Posts: 78
Joined: Sat Mar 29, 2014 1:55 pm
PostPosted: Mon Apr 24, 2017 10:19 pm
Thank you, I will try that :)
Image

Return to How do I code ...

Who is online

Users browsing this forum: No registered users and 4 guests

cron