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
853
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?
 
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/
 
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.
 
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:
 
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.
 
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?
 
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.
 

IF YOU HAD TO TAKE A REEFING EXAM, WOULD YOU PASS?

  • Yes!

    Votes: 32 45.7%
  • Not yet, but I have one that I want to buy in mind!

    Votes: 9 12.9%
  • No.

    Votes: 26 37.1%
  • Other (please explain).

    Votes: 3 4.3%
Back
Top