APEX Programming for On-Demand Water Change

DanP-SD

Active Member
View Badges
Joined
Jan 4, 2014
Messages
309
Reaction score
349
Location
San Diego, CA
Rating - 0%
0   0   0
I've searched the forums and have seen a lot of great code samples that are close but not exactly what I'm looking to, and am hoping someone out there can help me with the last mile of getting the code to fit.

I have a 265g reef with a 20g saltwater reservoir for water changes. I have a dosing computer that is doing daily small water changes but want to set up the ability on the weekend to mix up a batch of saltwater, press a momentary button and use my two new PMUPs to automatically change out 15-16 gallons or so.

I have installed the PMUPs and have tested their flow rates. The NSW PMUP has more head pressure so it pumps at exactly half the rate of the OSW PMUP. The NSW does a gallon in 1 min. 30 sec. The OSW does a gallon in 45 seconds.

The sequence I'm looking for is:
- press button
- skimmer and ATO turn off (return pumps stay running because my NSW pumps into the display tank to avoid a siphon situation and my OSW pumps from the sump, but I may later add a command to turn off the return)
- NSW PMUP starts pumping (I want to give it a head start since it's the slower of the two. I'll play with the lead time but, for this thread, assume 8 minutes)
- 8 minutes later the OSW PMUP starts
- the NSW PMUP runs a total of 24 minutes (pumping in 16 gallons)
- the OSW PMUP runs a total of 12 minutes (for 16 gallons)
- 5 minute delay to let things settle down
- ATO and Skimmer turn back on.

So I've created a virtual outlet called Hold_AWC and have programmed it to switch ON when a button on my BOB (Swx14_4) is CLOSED with the following code:

Hold_AWC

Set OFF
If Swx14_4 CLOSED Then ON
Defer 024:00 Then OFF

My plan is to use the following code for the ATO and Skimmer:

ATO

Fallback ON
Set ON
If FeedA 030 Then OFF
If Outlet Return_Pump = OFF Then OFF
If Outlet Hold_ATO = ON Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 005 Then ON

Skimmer

Fallback ON
Set ON
If FeedA 010 Then OFF
If Outlet Hold_ATO = ON Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 005 Then ON

[Note: On the ATO and Skimmer, the Hold_ATO command line is unrelated to this thread. That just allows me to kill the skimmer and ATO for 2 hours with a separate button (like when I'm siphoning the bottom of the sump or doing anything that messes with the water level). The pertinent line for this thread is the Hold_AWC line. Sorry for the close names.]

To activate the two PMUPs, I plan to use the following:

NSW_PMUP

Fallback OFF
Set OFF
If Outlet Hold_AWC = ON Then On

OSW_PMUP

Fallback OFF
OSC 008:00/012:00/0 Then ON
If Outlet Hold_AWC = OFF Then OFF

I think the way these will work is that, when I press the button and switch Hold_AWC to ON, the NSW_PMUP will immediately kick on and will stay on for the full 24 minutes and then will turn off.

Meanwhile, I think (and hope) that OSW_PMUP will operate as follows: When I haven't pressed the button (ie, most of the time), it will read the OSC statement but then the final line will keep it from turning on so it will rest in OFF. But when I press the button, for the next 24 minutes, the conditional statement in the last line is not true so it has no effect. In its absence, the OSC statement keeps the pump off for 8 minutes and then turns it on for 12 minutes, then back to off for the remaining 4 minutes of the Hold_AWC cycle. Then it goes back to resting in OFF because of the last line of code being true.

I struggle with OSC statements and am far from an expert on Apex code generally so I welcome any and all input.

Thanks,
 

Brew12

Electrical Gru
View Badges
Joined
Aug 14, 2016
Messages
22,488
Reaction score
57,147
Location
Decatur, AL
Rating - 0%
0   0   0
I've searched the forums and have seen a lot of great code samples that are close but not exactly what I'm looking to, and am hoping someone out there can help me with the last mile of getting the code to fit.

I have a 265g reef with a 20g saltwater reservoir for water changes. I have a dosing computer that is doing daily small water changes but want to set up the ability on the weekend to mix up a batch of saltwater, press a momentary button and use my two new PMUPs to automatically change out 15-16 gallons or so.

I have installed the PMUPs and have tested their flow rates. The NSW PMUP has more head pressure so it pumps at exactly half the rate of the OSW PMUP. The NSW does a gallon in 1 min. 30 sec. The OSW does a gallon in 45 seconds.

The sequence I'm looking for is:
- press button
- skimmer and ATO turn off (return pumps stay running because my NSW pumps into the display tank to avoid a siphon situation and my OSW pumps from the sump, but I may later add a command to turn off the return)
- NSW PMUP starts pumping (I want to give it a head start since it's the slower of the two. I'll play with the lead time but, for this thread, assume 8 minutes)
- 8 minutes later the OSW PMUP starts
- the NSW PMUP runs a total of 24 minutes (pumping in 16 gallons)
- the OSW PMUP runs a total of 12 minutes (for 16 gallons)
- 5 minute delay to let things settle down
- ATO and Skimmer turn back on.

So I've created a virtual outlet called Hold_AWC and have programmed it to switch ON when a button on my BOB (Swx14_4) is CLOSED with the following code:

Hold_AWC

Set OFF
If Swx14_4 CLOSED Then ON
Defer 024:00 Then OFF

My plan is to use the following code for the ATO and Skimmer:

ATO

Fallback ON
Set ON
If FeedA 030 Then OFF
If Outlet Return_Pump = OFF Then OFF
If Outlet Hold_ATO = ON Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 005 Then ON

Skimmer

Fallback ON
Set ON
If FeedA 010 Then OFF
If Outlet Hold_ATO = ON Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 005 Then ON

[Note: On the ATO and Skimmer, the Hold_ATO command line is unrelated to this thread. That just allows me to kill the skimmer and ATO for 2 hours with a separate button (like when I'm siphoning the bottom of the sump or doing anything that messes with the water level). The pertinent line for this thread is the Hold_AWC line. Sorry for the close names.]

To activate the two PMUPs, I plan to use the following:

NSW_PMUP

Fallback OFF
Set OFF
If Outlet Hold_AWC = ON Then On

OSW_PMUP

Fallback OFF
OSC 008:00/012:00/0 Then ON
If Outlet Hold_AWC = OFF Then OFF

I think the way these will work is that, when I press the button and switch Hold_AWC to ON, the NSW_PMUP will immediately kick on and will stay on for the full 24 minutes and then will turn off.

Meanwhile, I think (and hope) that OSW_PMUP will operate as follows: When I haven't pressed the button (ie, most of the time), it will read the OSC statement but then the final line will keep it from turning on so it will rest in OFF. But when I press the button, for the next 24 minutes, the conditional statement in the last line is not true so it has no effect. In its absence, the OSC statement keeps the pump off for 8 minutes and then turns it on for 12 minutes, then back to off for the remaining 4 minutes of the Hold_AWC cycle. Then it goes back to resting in OFF because of the last line of code being true.

I struggle with OSC statements and am far from an expert on Apex code generally so I welcome any and all input.

Thanks,
Yup, looks like it should work exactly how you want.
 

Daniel@R2R

Living the Reef Life
View Badges
Joined
Nov 18, 2012
Messages
40,378
Reaction score
67,427
Location
Fontana, California
Rating - 100%
1   0   0
Cool! I may have to try to do something like this...
 
OP
OP
DanP-SD

DanP-SD

Active Member
View Badges
Joined
Jan 4, 2014
Messages
309
Reaction score
349
Location
San Diego, CA
Rating - 0%
0   0   0
It took longer than I anticipated but I finally got some free time to test and de-bug the code for this water change. The OSC statement in the above didn't work. The OSW PMUP was coming on too early and staying on, so I modified that. I also added lines to turn off the return pump and my Gyre during the process. I'm not sure if I'm going to keep those lines but here's the code as is. As a reminder, the Swx14_4 referenced in the Hold_AWC code is the momentary button I push to start the entire process. This works perfectly:


Hold_AWC

Fallback OFF
Set OFF
If Swx14_4 CLOSED Then ON
Defer 016:00 Then OFF


ATO

Fallback ON
Set ON
If FeedA 030 Then OFF
If Outlet Return_Pump = OFF Then OFF
If Outlet Hold_ATO = ON Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 015:00 Then ON


Skimmer

Fallback ON
Set ON
If FeedA 010 Then OFF
If Outlet Hold_ATO = ON Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 005:00 Then ON


Return Pump

Fallback ON
Set ON
If FeedA 000 Then OFF
If Outlet Hold_AWC = ON Then OFF
Defer 001:00 Then ON


Gyre

Fallback ON
Set ON
If Outlet Hold_AWC = ON Then OFF
Defer 002:00 Then ON


NSW_PMUP

Fallback OFF
Set OFF
If Outlet Hold_AWC = ON Then On


OSW_PMUP

Fallback OFF
Set OFF
If Outlet Hold_AWC = ON Then ON
Defer 008:00 Then ON


Other than the possibility of leaving the return pump and Gyre running through the change, the only other improvement I'm considering is adding a couple of float or pressure switches and some code that would kick in at the end and level the water. This code is working as is but I'm concerned that, if one of the PMUP's slows down or gets a little blockage in the plumbing, the amount of water removed and the amount added may not line up. I see a couple options to fix this:

1. I can intentionally make the OSW pump stay on longer. This will lower the water level and then my ATO will automatically fix it. The minor impact on salinity won't matter because the way I maintain salinity is to test it in the tank each time I'm making up a batch of saltwater and adjust the salt concentration accordingly.

Or 2. I can set up two pressure switches or floats -- one slightly above and one slightly below the normal water level -- and then add some code to add or remove water if one of them alerts. My biggest concern with this approach is having the pumps trigger during momentary changes in water level, so I'd want to program it so that these only activate right after running the water change program.

As always, please chime in with any input.
 

TOP 10 Trending Threads

WHAT AMOUNT OF LIVE ROCK AND SAND SHOULD BE PRIORITIZED FOR OPTIMAL BIODIVERSITY/FILTRATION?

  • 100% live rock + bagged sand

    Votes: 37 27.8%
  • 100% dry rock + 100% live sand

    Votes: 45 33.8%
  • 50/50 live/dry rock, 50/50 live/bagged sand

    Votes: 29 21.8%
  • 75% live rock, 25% live sand

    Votes: 12 9.0%
  • 25% live rock, 75% live sand

    Votes: 10 7.5%
Back
Top