Conditional Ports Based Upon PH Help please

Do you have a question on how to do something.
Ask in here.
Post Reply
sf340flier
Posts: 11
Joined: Sat Jan 12, 2013 7:17 pm

Conditional Ports Based Upon PH Help please

Post 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!
Image
sf340flier
Posts: 11
Joined: Sat Jan 12, 2013 7:17 pm

Re: Conditional Ports Based Upon PH Help please

Post 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 );
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Conditional Ports Based Upon PH Help please

Post 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..
User avatar
DrewPalmer04
Posts: 818
Joined: Tue May 29, 2012 2:12 pm
Location: Christopher, IL

Re: Conditional Ports Based Upon PH Help please

Post 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!
Out for now...but not over.

VISIT: Ethernet Module/Wifi Alternative
sf340flier
Posts: 11
Joined: Sat Jan 12, 2013 7:17 pm

Re: Conditional Ports Based Upon PH Help please

Post by sf340flier »

That's a good point!
Image
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: Conditional Ports Based Upon PH Help please

Post 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 :)
binder
Posts: 2865
Joined: Fri Mar 18, 2011 6:20 pm
Location: Illinois
Contact:

Re: Conditional Ports Based Upon PH Help please

Post 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. :)
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Conditional Ports Based Upon PH Help please

Post 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
180G FOWLR
20GH QT#1
29G QT#2

Image
sf340flier
Posts: 11
Joined: Sat Jan 12, 2013 7:17 pm

Re: Conditional Ports Based Upon PH Help please

Post 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!
Image
00Warpig00
Posts: 289
Joined: Wed May 16, 2012 9:52 pm

Re: Conditional Ports Based Upon PH Help please

Post 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
180G FOWLR
20GH QT#1
29G QT#2

Image
Post Reply