ATO Code verification

Basic / Standard Reef Angel hardware
Post Reply
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

ATO Code verification

Post by Smotz »

'Lo all,

Had a bit of an issue today. For some reason, the 2nd channel of my water level sensor became un-calibrated and was reading 200 (as if it was never setup). I came home from work and noticed that my entire reservoir dumped in to my tank (about 3 gallons). IT wasn't a catastrophe, but definitely concerning.

Channel (1) is my sump and (2) is my reservoir.

Can someone review this code and advise if they see any flaws?

(I just added the && ReefAngel.WaterLevel.GetLevel(2) < 150 as a safeguard to ensure that it recognized that it was calibrated properly.

Code: Select all

// Main Top Off
    if ( ReefAngel.WaterLevel.GetLevel(2) >= 15 && ReefAngel.WaterLevel.GetLevel(2) < 150 && ReefAngel.Params.PH < 850 && millis() > 1000) // Ensure there is 15% of water in the Top Off reservoir and PH is less than 8.5 and the RA didn't just reboot
    {
    if ( ReefAngel.WaterLevel.GetLevel(1) <= 80 ) ReefAngel.Relay.On(Topoff);
    if ( ReefAngel.WaterLevel.GetLevel(1) >= 100 ) ReefAngel.Relay.Off(Topoff);
    }
// End Main Top Off 
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO Code verification

Post by lnevo »

I guess the WaterLevelATO function can't take a channel number yet? That would give you the ato timeout functionality that would protect against that situation..


What I would do is add a time condition to the if so that it reads if the waterlevel is < 80 && now()%3600<60

That way if the water level is low it will only be on for the first 60 seconds of every hour.. You could change the values to whatever works right for you.

I would then add a portal alarm if any of the water level channels go out of whack
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

I will give that a try. Thanks again.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

lnevo wrote:I guess the WaterLevelATO function can't take a channel number yet? That would give you the ato timeout functionality that would protect against that situation..


What I would do is add a time condition to the if so that it reads if the waterlevel is < 80 && now()%3600<60

That way if the water level is low it will only be on for the first 60 seconds of every hour.. You could change the values to whatever works right for you.

I would then add a portal alarm if any of the water level channels go out of whack
wondering if there would be a more elegant way of doing this?

I don't know how to do it but is there a way for me to set a timer for how long the ATO is on and stop it at 30 seconds?
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO Code verification

Post by lnevo »

Thats the now()%3600<60

The 60 is the runtime and the 3600 is the repeat interval. You can change those to values to fit your needs.

The more elegant way is probably in the dev libraries where you can just say WaterLevelATO(channel, %start, %end, timeout);

Roberto can confirm that part
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO Code verification

Post by rimai »

brunnels has patched our libraries to gives us that option:
https://github.com/reefangel/Libraries/issues/138
If you grab the latest dev branch, you will be able to use it.
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

lnevo wrote:Thats the now()%3600<60

The 60 is the runtime and the 3600 is the repeat interval. You can change those to values to fit your needs.

The more elegant way is probably in the dev libraries where you can just say WaterLevelATO(channel, %start, %end, timeout);

Roberto can confirm that part
Gotcha. Thank you all.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

lnevo wrote:Thats the now()%3600<60

The 60 is the runtime and the 3600 is the repeat interval. You can change those to values to fit your needs.

The more elegant way is probably in the dev libraries where you can just say WaterLevelATO(channel, %start, %end, timeout);

Roberto can confirm that part
I installed the Devs - to confirm:
Instead of:

Code: Select all


if ( ReefAngel.WaterLevel.GetLevel(1) <= 80 && ReefAngel.DisplayedMenu!=WATERCHANGE_MODE && millis() > 2000 && now()%3600<15) ReefAngel.Relay.On(Topoff);
if ( ReefAngel.WaterLevel.GetLevel(1) >= 100 ) ReefAngel.Relay.Off(Topoff);
I would simply use this? I don't see how it knows to use the pump...?

Code: Select all

ReefAngel.WaterLevelATO(1,80,100,15);
1 being the channel of the multi water level, 80 = start, 100 = stop, run for 15 seconds - max)

do I have to do something like this?

Code: Select all

if (ReefAngel.WaterLevel.GetLevel(1) < 80) ReefAngel.WaterLevelATO(Topoff,80,100,15);
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

No thoughts?

Sent from my SCH-I605 using Tapatalk
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO Code verification

Post by lnevo »

Yes but i didn't get to look at the code to verify. Roberto can hopefully confirm. There needs to be an arg for the port.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

Thanks..sorry. Didn't mean to be impatient.
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO Code verification

Post by rimai »

Never used nor tested yet either, yet.
brunnels is the one that created that.
Your function is slightly wrong though.
The function is declared as this:
void ReefAngelClass::WaterLevelATO(byte Channel, byte ATORelay, int ATOTimeout, byte LowLevel, byte HighLevel)
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

yea, not sure it's ready for prime time :)

I used this (as you specified)

Code: Select all

ReefAngel.WaterLevelATO(1,Topoff,15,80,100);
and got this on the compile -

Display_Tank_test.cpp: In function 'void loop()':
Display_Tank_test:129: error: no matching function for call to 'ReefAngelClass::WaterLevelATO(int, int, int, int, int)'
C:\Users\Joe\Documents\Arduino\libraries\ReefAngel/ReefAngel.h:331: note: candidates are: void ReefAngelClass::WaterLevelATO(byte, int, byte, byte)
C:\Users\Joe\Documents\Arduino\libraries\ReefAngel/ReefAngel.h:368: note: void ReefAngelClass::WaterLevelATO(byte)
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO Code verification

Post by rimai »

Ahh..
You also need this on setup():

Code: Select all

ReefAngel.AddMultiChannelWaterLevelExpansion();
And you also need the newest feature.txt file from our github:
https://github.com/reefangel/FeaturesAndUpdateFiles
Roberto.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

rimai wrote:Ahh..
You also need this on setup():

Code: Select all

ReefAngel.AddMultiChannelWaterLevelExpansion();
And you also need the newest feature.txt file from our github:
https://github.com/reefangel/FeaturesAndUpdateFiles
Thanks, Roberto - that compiled.

Where do you think I should place :

Code: Select all

ReefAngel.WaterLevelATO(1,Topoff,15,80,100);
rimai
Posts: 12857
Joined: Fri Mar 18, 2011 6:47 pm

Re: ATO Code verification

Post by rimai »

Place anywhere in the loop() section.
Roberto.
User avatar
lnevo
Posts: 5422
Joined: Fri Jul 20, 2012 9:42 am

Re: ATO Code verification

Post by lnevo »

Before any other checks that you may use to disable that port :)

I.e. if you have something like

if (ReefAngel.GetWaterLevel(1) < 10) ReefAngel.Relay.Off(Topoff);

then put it before. If you have no other checks that would disable/enable the Topoff port then it can go anywhere.
Smotz
Posts: 401
Joined: Sat Mar 30, 2013 5:02 pm
Location: CT, USA

Re: ATO Code verification

Post by Smotz »

looks good. thanks again, guys.

Tested and working so far!
Post Reply