ATO and Waterchange controlled by APEX

insomniac2k2

Active member
Soooo. I've had my APEX for 3 days now, and have fallen in love. Ask my wife. She aint getting any right now until my code is complete ;)

I believe that I have what looks to be proper code for my apex unit controlling ATO and also salt water changes. I will test it a bit more, but just doing a brain dump for others to look at and comment on. Please throw me some feedback on it.

Description:

Fresh water ATO triggers 3 times a day, based on a schedule. I plan on like matching my evaporation rate, and using a sensor/float. If the sensor/float fails, i wont likely overfill my tank due to close evaporation rate replenishment.

Auto saltwater changes are triggered to run daily at a certain time (when im usually around the house). It checks to make sure that the ATO isnt running, and then starts the water out pump for 5 minutes. After complete, saltwater IN sensor triggers an auto top off for 5+3 minutes (just in case the pump is a little slower). The sensor will shut it off as soon as its full.

I plan on measuring the pump flow to make X minutes reflect 1.5 gallons a day. I made the saltwater ATO trigger right after a freshwater ATO, so that I dont screw up saline levels. Thoughts on this? Anyway...

ATO pump port:
Fallback OFF
If Outlet ATO = ON Then ON
If Outlet ATO = OFF Then OFF

ATO Virtual port:
Fallback OFF
Set OFF
If Switch1 CLOSED Then ON
If Outlet ATO_ALLOW = ON Then ON
If Outlet ATO_ALLOW = OFF Then OFF


ATO_ALLOW virtual port:
Fallback OFF
If Time 00:01 to 00:06 Then ON
If Time 00:06 to 08:06 Then OFF
If Time 08:06 to 08:11 Then ON
If Time 08:11 to 16:30 Then OFF
If Time 16:30 to 16:35 Then ON
If Time 16:35 to 00:00 Then OFF
If Outlet Return = OFF Then OFF
If Outlet WCHANGE_OUT = ON Then OFF
If Outlet WCHANGE_ATO = ON Then OFF






WCHG_OUT PUMP port:
Fallback OFF
If Outlet WCHGOUT_ALLOW = ON Then ON
If Outlet WCHGOUT_ALLOW = OFF Then OFF


WCHG_IN PUMP port:

Fallback OFF
If Outlet WCHG_ATO = ON Then ON
If Outlet WCHG_ATO = OFF Then OFF
If Outlet WCHGOUT_ALLOW = ON Then OFF


WCHG_ATO:
Fallback OFF
Set OFF
If Switch2 CLOSED Then ON
If Outlet WCHGIN_ALLOW = ON Then ON
If Outlet WCHANGE_OUT = ON Then OFF



WCHGOUT_ALLOW:
Fallback Off
If Time 16:00 to 16:05 Then ON
If Time 16:05 to 16:00 Then OFF
If Outlet ATO_ALLOW = ON Then OFF
If Outlet Return = OFF Then OFF
If Outlet WCHGIN_ALLOW = ON Then OFF

WCHGIN_ALLOW:
Fallback OFF
If Time 16:06 to 16:14 Then ON
If Time 16:14 to 16:06 Then OFF
If Outlet WCHGOUT_ALLOW = ON Then OFF
If Outlet ATO_ALLOW = ON Then OFF
If Outlet Return = OFF Then OFF


Did I miss anything?
 
Tried to edit the original post to reflect my normal evaporation and water change rates, naming changes, but for some reason this forum wont allow it...

The Aqualifter is rated at 3.5GPH. I usually evaporate 1 - 1.5 gallons a day. This made my settings easy. I will have the ATO trigger 3 times a day for 10m ea. Totaling 30m (1.75g estimated). I can tweak from there. The auto saltwater change will just run for 30m straight and then replenish for 33m or until full. Also room for tweaking.

Between the time windows, only having about 10g salt and 10g fresh in a resevoir, and the floats, i cannot really over or under fill the tank too bad.Well in theory at least...

ATO pump port:
Fallback OFF
If Outlet ATO = ON Then ON
If Outlet ATO = OFF Then OFF

ATO Virtual port:
Fallback OFF
Set OFF
If Switch1 CLOSED Then ON
If Outlet ATO_ALLOW = ON Then ON
If Outlet ATO_ALLOW = OFF Then OFF


ATO_ALLOW virtual port:
Fallback OFF
If Time 00:01 to 00:11 Then ON
If Time 00:11 to 08:21 Then OFF
If Time 08:021 to 08:31 Then ON
If Time 08:41 to 16:30 Then OFF
If Time 16:30 to 16:40 Then ON
If Time 16:40 to 00:00 Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHANGE_OUT = ON Then OFF
If Outlet WCHANGE_ATO = ON Then OFF






WCHG_OUT PUMP port:
Fallback OFF
If Outlet WCHGOUTALLOW = ON Then ON
If Outlet WCHGOUTALLOW = OFF Then OFF


WCHG_IN PUMP port:

Fallback OFF
If Outlet WCHG_ATO = ON Then ON
If Outlet WCHG_ATO = OFF Then OFF
If Outlet WCHGOUTALLOW = ON Then OFF


WCHG_ATO:
Fallback OFF
Set OFF
If Switch2 CLOSED Then ON
If Outlet WCHGINALLOW = ON Then ON
If Outlet WCHANGE_OUT = ON Then OFF



WCHGOUT_ALLOW:
Fallback Off
If Time 16:41 to 17:10 Then ON
If Time 17:10 to 16:41 Then OFF
If Outlet ATO_ALLOW = ON Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHGINALLOW = ON Then OFF

WCHGIN_ALLOW:
Fallback OFF
If Time 17:11 to 17:44 Then ON
If Time 17:44 to 17:11 Then OFF
If Outlet WCHGOUTALLOW = ON Then OFF
If Outlet ATO_ALLOW = ON Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
 
Last edited:
Couple coding recommendations:

ATO Virtual port:
Fallback OFF {Unnecessary}
Set OFF
If Switch1 CLOSED Then ON
If Outlet ATO_ALLOW = ON Then ON
If Outlet ATO_ALLOW = OFF Then OFF {Unnecessary}

ATO_ALLOW virtual port:
Fallback OFF {Unnecessary}
Set OFF
If Time 00:01 to 00:11 Then ON
If Time 00:11 to 08:21 Then OFF {Unnecessary}
If Time 08:021 to 08:31 Then ON
If Time 08:41 to 16:30 Then OFF {Unnecessary}
If Time 16:30 to 16:40 Then ON
If Time 16:40 to 00:00 Then OFF {Unnecessary}
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHANGE_OUT = ON Then OFF
If Outlet WCHANGE_ATO = ON Then OFF

Keep in mind that the 'If Time...' command is only accurate to 1 minute. So your 10 minute intervals are actually 11 minutes. Most of that code can be replaced with the OSC command and it is accurate to 1 second.

You don't need to use Fallback on virtual outlets, it only applies to real EBx outlets.

Your ATO logic looks OK, but I'll have to think a bit about the water change code.

Also, you can edit your post up to a hour (I think) afterward.

Todd
 
Last edited:
Thanks for the feedback. I actually moved away from the OSC command, because i didnt feel that i could control the topoff time well enough, and wasnt sure on how the apex would handle OSC if one of the ports went offline temporarily and another didnt (for any reason). I wouldnt want the osc time to reset to the present, because my WCHANGE_ATO is dependant on the ATO timer as well.

I originally wrote the script with 1m offsets, but i kept seeing a bunch out there with exact minute on's and off's. Ill change it back to the way it was. Also good to know that the virtual ports are assumed off and i can remove the off timers.

thanks a bunch. Cant wait to test it. As for now, im getting pretty consistent results with powering other items. More testing tonight!
 
Your Waterchange code seems overly complicated. Since you are initiating each function at a precise time, the virtual outlets are not necessary as are most of the outlet state checks. Try the following:


[WC_OUT_PUMP]
Fallback OFF
Set OFF
If Time 16:41 to 17:10 Then ON
If Outlet RTN-SKIMMER = OFF Then OFF

[WC_IN_PUMP]
Fallback OFF
Set OFF
If Time 17:11 to 17:44 Then ON
If Outlet RTN-SKIMMER = OFF Then OFF


[WC_ATO]
{Not sure what you are wanting to do here. You have disabled ATO during WC operation. You would need to swap out the appropriate outlet names in the ATO code.}

The Apex limits outlet names to 12 characters, and you must be careful about using the exact name with the 'If Outlet...' command.

Todd
 
I actually moved away from the OSC command, because i didnt feel that i could control the topoff time well enough, and wasnt sure on how the apex would handle OSC if one of the ports went offline temporarily and another didnt (for any reason). I wouldnt want the osc time to reset to the present, because my WCHANGE_ATO is dependant on the ATO timer as well.
The OSC creates a repeating cycle of OFF/ON state changes. The way the Apex executes commands, the last TRUE statement prevails. If OSC happens to be in the ON phase, and a later condition evaluates to OFF, the outlet will be set to OFF, but the OSC cycle continues in the background and does not reset.

I originally wrote the script with 1m offsets, but i kept seeing a bunch out there with exact minute on's and off's. Ill change it back to the way it was.
The 'If Time...' is used when you need a single interval or you have unequal intervals. For example, if you need the outlet to come ON for 5 minutes in the morning and then 20 minutes in the evening.

Also good to know that the virtual ports are assumed off and i can remove the off timers.
No, not assumed. Notice I inserted a Set OFF at the beginning. If nothing changes it, then that state will remain.

Todd
 
Ill make some changes when I'm not on my phone. I'm using a sensor on the wc topoff. The pump checks the sensor and runs either 30m or until the sensor trips. Well at least Id like it to. Do you recommend a different direction on the sensor? I believe that if I do it your recommended way I can't build in redundancy can I?
 
OK. I took some of your advice and corrections, and here's what i've come up with. Im going to start testing it manually tonight. Thanks for all your help Todd!

[ATO_PUMP]
Fallback OFF
If Outlet ATO = ON Then ON
If Outlet ATO = OFF Then OFF

[ATO] Virtual port:
Set OFF
If Switch1 CLOSED Then ON {main switch}
If Switch2 CLOSED Then ON {backup switch}
If Outlet ATO_ALLOW = ON Then ON


[ATO_ALLOW] virtual port:
SET OFF
If Time 00:01 to 00:11 Then ON
If Time 08:01 to 08:31 Then ON
If Time 16:30 to 16:40 Then ON
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHG_OUT = ON Then OFF
If Outlet WCHG_IN = ON Then OFF




WCHG_OUT PUMP port:
Fallback OFF
Set OFF
If Time 15:26 to 15:56 Then ON
If Outlet RTN-SKIMMER = OFF Then OFF
If Switch3 CLOSED THEN OFF {low water sensor on the new SW resevoir. dont want to drain water i cant replace}


WCHG_IN PUMP port:

Fallback OFF
Set OFF
If Time 15:58 to 16:28 Then ON
If Outlet WCHG_OUT = ON Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
If Switch1 OPEN Then OFF {main switch}
If Switch2 OPEN Then OFF {backup switch}
If Switch4 CLOSED THEN OFF {low water sensor on the new SW resevoir}
 
So i tested it and a big fail. Here's what ended up working in the end:

[ATO_PUMP]
Fallback OFF
Set OFF
If Outlet ATO_ALLOW = ON Then ON

[ATO_ALLOW]
Set OFF
If Switch1 CLOSED Then ON
If Switch2 CLOSED Then ON
If Time 00:01 to 00:11 Then ON
If Time 00:11 to 08:11 Then OFF
If Time 08:11 to 08:21 Then ON
If Time 08:21 to 16:21 Then OFF
If Time 16:21 to 16:31 Then ON
If Time 16:31 to 00:00 Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHG_OUT = ON Then OFF
If Outlet WCHG_IN = ON Then OFF


[WCHG_IN]
Fallback OFF
Set OFF
If Time 15:45 to 16:18 Then ON
If Outlet WCHG_OUT = ON Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
If Switch1 OPEN Then OFF
If Switch2 OPEN Then OFF
If Switch4 CLOSED Then OFF

[WCHG_OUT]
Fallback OFF
Set OFF
If Time 15:15 to 15:45 Then ON
If Outlet RTN-SKIMMER = OFF Then OFF
If Switch3 CLOSED Then OFF

Oddly, i absolutely had to have the OFF statements in the ATO_ALLOW section in order to make it work. Otherwise it would stay on. Definitely because its a virtual. The WCHG_IN and WCHG_OUT worked fine as they are listed. I hope all this gibberish helped someone ;)
 
[ATO_ALLOW]
Set OFF
If Switch1 CLOSED Then ON
If Switch2 CLOSED Then ON

If Time 00:01 to 00:11 Then ON
If Time 00:11 to 08:11 Then OFF
If Time 08:11 to 08:21 Then ON
If Time 08:21 to 16:21 Then OFF
If Time 16:21 to 16:31 Then ON
If Time 16:31 to 00:00 Then OFF
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHG_OUT = ON Then OFF
If Outlet WCHG_IN = ON Then OFF
By adding the highlighted conditions, you changed the operation. So if either of those are true, then the Set OFF will be effectively ignored. Why do you have two switches to turn it ON? Even now, those highlighted conditions are nullified by the Time commands. Again, the Apex executes top to bottom and the last true statement determines the outcome.


Here try this:

[ATO_ALLOW]
Set OFF
If Time 00:01 to 00:11 Then ON
If Time 08:11 to 08:21 Then ON
If Time 16:21 to 16:31 Then ON
If Outlet RTN-SKIMMER = OFF Then OFF
If Outlet WCHG_OUT = ON Then OFF
If Outlet WCHG_IN = ON Then OFF

[ATO_Pump]
Fallback OFF
Set OFF
If Switch1 CLOSED Then ON
If Outlet ATO_ALLOW = OFF Then OFF
If Switch2 OPEN Then OFF


[ATO_ALLOW] is normally OFF, except for the selected times. [ATO_PUMP] will only come ON when Switch1 is CLOSED (low sump) and [ATO_ALLOW] is ON (ie If Outlet ATO_ALLOW = OFF is FALSE). Switch2 is mounted higher and acts as a backup to shut it OFF.

Todd
 
Back
Top