Apex: Temporarily turn on outlet until optical sensor closes it?

Oberst Hajj

Well-Known Member
View Badges
Joined
Dec 23, 2012
Messages
978
Reaction score
852
Location
Colorado
Rating - 0%
0   0   0
I would like to turn on my MIXINGPUMP outlet manually, but have it turn off when my SW_HI optical sensor reads closed. This will be used to transfer water from my RODI res to my Salt mixing res. Since this pump is normally not in use (I currently manually turn it on to get RODI water into smaller containers as need), I just leave it set to off with this code:

Fallback OFF
Set OFF

I know I need to add some version of this:

If SW_Hi CLOSED Then OFF

But I'm pretty sure I need something in there to actually turn it on? Or will that last line I posted turn that outlet off once the res if full if I manually set the outlet to On?
 

Biglew11

Valuable Member
View Badges
Joined
May 10, 2020
Messages
1,577
Reaction score
1,882
Location
New York
Rating - 0%
0   0   0
If you manually switch the outlet on it will stay there until you put it back in auto. I think if you were to switch it to on and then back to auto it will stay on until the code turns it off.

I think the best way would be to use a momentary switch like a doorbell button and a virtual outlet or 2 with creative coding would be the best way.

@SuncrestReef has about 8 tutorials that are very good at explaining the coding process.

https://www.reef2reef.com/ams/neptune-apex-programming-tutorials-part-1.685/
 

Js.Aqua.Project

Reef Addict
View Badges
Joined
Apr 29, 2016
Messages
1,779
Reaction score
3,590
Location
Ocala, FL
Rating - 0%
0   0   0
Definitely check out @SuncrestReef tutorials I am thinking you might try leaving the outlet set to OFF when you don't want it to work but AUTO when you want it to move the water and follow the code.

I would think you would need something like:

Fallback OFF
Set ON
If SW_Hi CLOSED Then OFF
Defer 000:02 Then OFF

This will Set it to turn on until the sensor reads as closed. The Defer command used in this context makes sure the sensor is "closed" for a full two seconds before turning off so that it doesn't just turn off if it gets splashed.
 

SuncrestReef

That Apex guy
View Badges
Joined
Jan 18, 2018
Messages
4,214
Reaction score
9,217
Location
Oregon
Rating - 0%
0   0   0
There are two key issues here:

1. The programming can only be processed if the slider is set to AUTO.
2. The only command capable of moving the slider to the manual OFF position is the When timer.

As @Js.Aqua.Project mentioned above, leave the output slider set to OFF at all times until you are ready to activate it. Then move the slider to AUTO. This will turn the output on due to the Set ON command. As soon as the optical sensor detects the water, it will turn the output off. Then the When timer takes over and moves the slider back to the OFF position and all programming is halted.

Fallback OFF
Set ON
If SW_Hi CLOSED Then OFF
When OFF > 000:01 Then OFF

See my tutorial on Apex Timers for more details of how When works:
 
OP
OP
Oberst Hajj

Oberst Hajj

Well-Known Member
View Badges
Joined
Dec 23, 2012
Messages
978
Reaction score
852
Location
Colorado
Rating - 0%
0   0   0
Thanks guys. I was actually wondering if and how to use the When command because I remembered it was the only one that could set an outlet to the off position.
 
OP
OP
Oberst Hajj

Oberst Hajj

Well-Known Member
View Badges
Joined
Dec 23, 2012
Messages
978
Reaction score
852
Location
Colorado
Rating - 0%
0   0   0
Actually, the below code does not seem to be working. When ever I set MIXINGPUMP to Auto, Apex immediately switches it back to the off position.

Fallback OFF
Set ON
If SW_Hi CLOSED Then OFF
When Off > 010:00 Then OFF

From my understanding the Fallback is not evaluated unless it loses connection with the head unit. The Set ON should turn on that outlet until the third line evaluates as true and turns it off. The last line should tell it to turn off after 10 minutes regardless of the SW_HI condition. Is that correct?
 
OP
OP
Oberst Hajj

Oberst Hajj

Well-Known Member
View Badges
Joined
Dec 23, 2012
Messages
978
Reaction score
852
Location
Colorado
Rating - 0%
0   0   0
Alright, this code did work. I was just being a dumb-dumb and trying to put it into Auto without first putting it to the On position. Thanks again everyone for the help.
 

Creating a strong bulwark: Did you consider floor support for your reef tank?

  • I put a major focus on floor support.

    Votes: 54 40.3%
  • I put minimal focus on floor support.

    Votes: 28 20.9%
  • I put no focus on floor support.

    Votes: 48 35.8%
  • Other.

    Votes: 4 3.0%
Back
Top