Page 1 of 1

Conditional Ports Based Upon PH Help please

Posted: Sun Feb 24, 2013 8:44 pm
by sf340flier
I have an ato with kalk and an ato without. I would like to run either system, depending on ph, every hour for 120 seconds.

So, whenever the ph is below 8.35, I want to run ato with kalk (port 5) otherwise, I want to run ato without kalk (port 6). Although I can hack around a little, I wanted to see if the following code should work inside the main loop:

Code: Select all

if (ph > 8.35)
      ReefAngel.DosingPumpRepeat( Port5,0,60,120 );
    else
      ReefAngel.DosingPumpRepeat( Port6,0,60,120 );
Thanks for the help in advance!

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 6:37 am
by sf340flier
Or maybe something like this might be better:

Code: Select all

if (ph > 8.35) 
      p=Port6;
     else
      p=Port5;

ReefAngel.DosingPumpRepeat( p,0,60,120 );

Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 7:08 am
by lnevo
I like the second one. It should work although i believe ph would be 835 and assuming you called the function to get the ph...

I believe 00warpig is doing similar based on salinity..

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 8:59 am
by DrewPalmer04
I'd be "iffy" controlling anything on hobby grade pH probes. Stay your probe fails you might want to code a fail-safe or a "range" to insure your tank doesn't crash if the probe goes loopy on you. Just my two pennies!

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 2:34 pm
by sf340flier
That's a good point!

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 2:50 pm
by lnevo
I don't think you'd have too much problem... you'll either be only dosing kalk, or only dosing freshwater as part of ATO. Most people just put kalk in their ATO anyway... also the way you're looking to do it sounds like once an hour, to add for the 2 minutes, so it's not like you'll get into a situation with the kalk running continuously. You could always switch to a lab grade probe if that's a concern, but as long as you keep your eye on the ph and do a check with an external tester / test kit every now and again, I think you should be fine.

Additional error check would never hurt though :)

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 7:22 pm
by binder
The reference for ph is different than just ph and the value for ph does not have a decimal. So your code would actually need to be this:

Code: Select all

// put this above the loop() function, just anywhere outside of loop or setup
byte p;

// inside loop()
if (ReefAngel.Params.PH > 835) 
    p=Port6;
else
    p=Port5;
ReefAngel.DosingPumpRepeat( p,0,60,120 );
This would work for you based on what you were doing. Of course the other suggestions are always a great idea too. :)

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 8:08 pm
by 00Warpig00
lnevo wrote:I like the second one. It should work although i believe ph would be 835 and assuming you called the function to get the ph...

I believe 00warpig is doing similar based on salinity..

Yes I do this exact thing with my Salinitiy probe to choose whether I am topping off from an ATO with Saltwater or Fresh water. I imagine the concept is identical for PH but you need to change a few little details.

My code regarding this is below

Add to the INCLUDES/Variable Declarations (Modify accordingly for PH and default relay port)

Code: Select all

//*****Begin ATO By Salinity Additions

byte ATOBrutePort = Port2;

//*****End ATO By Salinity Additions

Add to the loop (Modify accordingly for PH and required relay ports)

Code: Select all

    //*****Begin ATO By Salinity Additions
    
    if (ReefAngel.Params.Salinity<300)
      {
        ATOBrutePort=Port7;
      }
    else
      {
        ATOBrutePort=Port2;
      }
    ReefAngel.StandardATO(ATOBrutePort,40 );
    if (iochannel2flag == 1)
      {
        ReefAngel.Relay.RelayMaskOff=~(Port7Bit);
      }
    if (iochannel4flag == 1)
      {
        ReefAngel.Relay.RelayMaskOff=~(Port2Bit);
      }
      
    //*****End ATO By Salinity Additions

Obviously this is for salinity and choosing ATO container by salinity probe reading but the concept should be identical with minimal modification to the code above.

ohh and you may not need the "if (iochannel2flag == 1)" and " if (iochannel4flag == 1)" IF/THEN statements. I have a float switch in the bottom of each of my ATO containers to prevent them from pumping water in the event of that container being empty.

One more thing... I also added this to my loop so I can use the portal or the android app to check which ATO port would be the selected one at any point in time. My portal/android says "ATO RO(2) SW(7)" so if the number displayed is 2 my current ATO is RO if the number displayed is 7 my ATO would fill with SW based on the probe reading at that very moment.

Code: Select all

   ReefAngel.CustomVar[7]=ATOBrutePort;
Nick

Re: Conditional Ports Based Upon PH Help please

Posted: Mon Feb 25, 2013 11:14 pm
by sf340flier
Curt/Nick,

Wow!

Thank you for the code snippets, that is exactly what I needed to know.

Nick, great idea/execution of the salinity ato concept!

Re: Conditional Ports Based Upon PH Help please

Posted: Tue Feb 26, 2013 9:45 pm
by 00Warpig00
sf340flier wrote:Curt/Nick,

Wow!

Thank you for the code snippets, that is exactly what I needed to know.

Nick, great idea/execution of the salinity ato concept!
Thanks, but I think I owe most of that code to Roberto and Curt myself :)

It has been switching my ATO between the two top off sources flawlessly for at least two months.

Nick