PDA

View Full Version : Lost in Programming


Swicki
02/07/2012, 07:55 PM
Is there a school I can go to for Apex Programming? Yikes! My wife hooked me up with an Apex for Christmas and I'm still manually adding water to my tank-Its time to learn a new language. First task...the ATO

A little background....300 gallon in wall (divider wall between my office and a playroom) marine land DD drains into the basement. Water first hits a 55 gallon fuge, then overflows into a 180 gallon frag tank. GEO built skimmer is hooked up but I have yet to connect the calcium reactor he built me (because I want the apex to control the solenoid on the bottle). This all adds up to a lot of water volume and evaporation--I need this programming!

So I built my breakout box following a few of the threads here, and have 3 float sensors ready to use. My goal is to replicate an idea taken from a video clip I saw (terrence Utah Marine Society reef addicts clip) that used a center float to detect water level low triggering a pump in my fresh water reservoir that fills the sump back up, a top switch to shut off the ATO if there was a failure, and a bottom switch is there is an issue with the pump not coming on or no fresh water. This seems to include enough redundancies and opportunities for alerts.....BUT I HAVE NO CLUE HOW TO DO IT!

A know there will be some virtual outlets--not sure how to do that. The pump will be plugged into the EB8. I pinned out the mini din and know that my floats are 1,2,3 but need some direction on how to finish this with programming. I also need to know how to add the breakout box as a module.

Any feedback would be greatly appreciated!

Swicki
02/07/2012, 07:59 PM
Probably should have mentioned that I have read the official and unofficial Apex guide....its just not sinking in

Mark Bianco
02/07/2012, 08:29 PM
This might help a little, it works but a little sloppy

Virtual outlet ATO
Set OFF
If Switch1 CLOSED Then ON
Defer 005:00 Then ON
If Switch1 OPEN Then OFF
If Switch2 OPEN Then OFF
If Switchx5_5 OPEN Then OFF
Defer 000:10 Then OFF

Line 1 sets it to off
Line 2 Turns the outlet state to on
Line 3 makes sure it is truly in the state for 5 minutes before turning the pump on.
Line 4 Probably not needed. Just being safe.
Line 5 A second float switch 1/4" above the first as a backup
Line 6 ATO container float switch.
Line 7 I am not sure why but, for some reason it would not work without this line.

Real Outlet
Fallback OFF
If Outlet ATO = ON Then ON
If Outlet ATO = OFF Then OFF

I am sure you have read the threads but always program float switches so if the state is open it shuts off.

Mark

swearint
02/08/2012, 08:39 AM
You don't really need to use virtual outlets for this operation. Everything in Mark's virtual outlet could replace the code for the real outlet. Having said that, I do like to use virtual outlets in order to name the switches and it allows you to use different Defer delays for each. This also allows you to track the behavior since each change in state is recored in the log. Virtual outlets are also useful for adding more complex behavior. So here is Mark's basic approach in a more readable format:

[Sump_Low]
Set OFF
If Switch1 OPEN Then ON

[Sump_OK]
Set OFF
If Switch2 CLOSED Then ON
Defer 1:00 Then OFF

[Sump_High]
Set OFF
If Switch3 OPEN Then ON

[ATO]
Fallback OFF
Set OFF
If Outlet Sump_OK = OFF Then ON
If Outlet Sump_Low = ON Then OFF
If Outlet Sump_High = ON Then OFF

Outlets Sump_Low and Sump_High are emergency conditions and you want to respond immediately, therefore no Defer. These conditions would also be used in your Alarm/Email outlets. As Mark mentioned, use the OPEN condition to result in the safest response. So if the switches were accidently disconnected, it would keep the ATO OFF and activate an alarm.

Sump_Low would be configured such that the float is OPEN when DOWN, Sump_High would be OPEN when UP, and Sump_OK is OPEN when UP.

So, Sump_OK performs the normal operation. If Sump_OK is ON, then no water is needed and the ATO remains OFF, and vice versa. The Defer will delay by 1 minute the indication of the sump level dropping from normal level. This will filter out any noise or false signals.

Todd

Swicki
02/08/2012, 07:15 PM
Thank you so much for responding to this...I really appreciate the help! Just so I am clear the virtual outlets Sump_OK and Sump_High are mounted the same way, and Sump_Low is installed upside down?

Also, How do I add these to the alarm/email piece? Do I add the same programming lines in those outlets?

swearint
02/08/2012, 08:06 PM
The floats are all mounted the same, although they are configured differently. The floats can be removed from the stem and inverted to achieve the desired behavior. You can then verify by observing the status of the virtual outlets.

To use in the Alarm/Email outlets add:

If Outlet Sump_Low = ON Then ON
If Outlet Sump_High = ON Then ON

Todd

Swicki
02/08/2012, 08:59 PM
Thanks Todd, I understand now. I was trying to get this in order before taking a week vacation to the cayman islands, but it's not cooperating yet. I'll have plenty of time to play with it when I get back. For the next week I'll swimming in the carribean reefs and making a list of all the critters I'll need to get in my own tank!
Cheers

Swicki
02/27/2012, 08:13 PM
Todd,

okay so I've finally gotten a few things figured out, and what I do know is that i cannot pull the tab off the float and flip it upside down to make it work in reverse. Does that make any sense? For example, when the float is up it opens....if I remove the tab and invert the float it will not register the magnet. If I physically invert the entire float switch it will effectively work the other way. How will this change the way your code is written? right now all of the floats are right angle facing down (float up magnet up switch on).....any suggestions?

Here is what I have for so far that seems to work:
(sump_ok)
Set OFF
If Switch2 Open Then ON
Defer 1:00 Then ON

(sump_low)
Set OFF
If Switch1 OPEN Then ON

(sump_high)
Set OFF
If Switch3 CLOSED Then ON

(ATO)
Fallback OFF
Set OFF
If Outlet Sump_OK = OFF Then ON
If Outlet Sump_High = ON Then OFF
If Outlet Sump_Low = ON Then OFF

thanks again, scott

Swicki
02/27/2012, 08:40 PM
actually that isn't working right! I just disconnected the float valve from the break out box, and the lamp (using a lamp for testing) turned on--which means that in the event something failed it is stuck in the on state. If I unplug either sump_high or sump_low the light stays off. what am I missing???

Swicki
02/27/2012, 09:18 PM
sorry for all the extra messages...i just inverted the sump_ok float and changed the code to:

Set OFF
If Switch2 OPEN Then ON

Now when I disconnect the float from the break out box the light turns off. I think I got it figured out! But Please, if you see any flaws in the code please share