PDA

View Full Version : Controlling a Timer via multiple inputs that may conflict with each other


Urchinhead
05/14/2009, 07:50 PM
I apologize as I am sure this has been asked and answered several times. For some reason though I can't find the answer and my Google-Fu is failing me.

Right now my code is monitoring two float switches...

A low water level switch for the sump that turns the return pump off if its tripped and a high water switch for the sump that turns off the ATO system (Tunze Ozmolator) and Dosing Controller (Profilux) if the water level is too high.

What I would like to be able to do is to turn these items off and on based on pH and ORP values or if the switch(s) are tripped. What I am finding is that if I code for a switch trip then then I can't get the device I want to control to go on/off based on a pH shift and vice versa. Is there a way to do that?

Here is the code I have so far:

SKM$-A01 // skimmer
RTN$-A02 // return pump
SMP$-A03 // small powerhead in sump to keep detritus stirred up
CLP$-A04 // closed loop pump
HTR$-A05 // heater
MP1$-A06 // Vortech MP40 #1
ATO$-A07 // ATO controller
REF$-A08 // Refugium light
CHL$-B01 // Chiller
DOS$-B02 // Dosing pump controller
T5A$-B03 // T5 Actinic lights
T5B$-B04 // T5 VHO lights
FAN$-B05 // Inside stand fan to move air for chiller
ALM#-P07 // big deal alarm
AL1#-P01 // low water alarm for return compartment of sump
AL2#-P02 // high water alarm for return compartment of sump
AL3#-P03 // pH too low alarm
AL4#-P04 // pH too high alarm
AL5#-P05 // ORP too low alarm
AL6#-P06 // ORP too high alarm
low%-N01 // turn of return pump if switch 1 is open because water is too low in sump
ovr%-n02 // turn off doser system and ATO if switch 2 is closed because water is too high in sump

// Set timers
If Time > 00:00 Then ALM OFF
If Time > 00:00 Then AL1 OFF
If Time > 00:00 Then AL2 OFF
If Time > 00:00 Then AL3 OFF
If Time > 00:00 Then AL4 OFF
If Time > 00:00 Then AL5 OFF
If Time > 00:00 Then AL6 OFF
If Time > 00:00 Then SKM ON
If Time > 00:00 Then SMP ON
If Time > 00:00 Then MP1 ON
If Time > 00:00 Then HTR ON
If Time > 00:00 Then CHL ON

// Lights come on
If Time > 18:00 Then T5A ON
If Time > 18:45 Then T5B ON

// Lights go off
If Time > 06:00 Then T5B OFF
If Time > 06:45 Then T5A OFF

// Refugium light on when main lights are off
If Timer T5A = OFF Then REF ON

// Temp Probe check. If faulty then shut all devices off and page me
If Temp < 73.0 Then CHL OFF
If Temp < 73.0 Then HTR OFF
If Temp < 73.0 Then FAN OFF
If Temp < 73.0 Then REF OFF
If Temp < 73.0 Then T5A OFF
If Temp < 73.0 Then T5B OFF
If Temp < 73.0 Then ALM ON
If Temp > 86.0 Then CHL OFF
If Temp > 86.0 Then HTR OFF
If Temp > 86.0 Then FAN OFF
If Temp > 86.0 Then REF OFF
If Temp > 86.0 Then T5A OFF
If Temp > 86.0 Then T5B OFF
If Temp > 86.0 Then ALM ON

// Regular temp controls
If Temp > 78.0 Then FAN ON
If Temp > 80.0 Then HTR OFF
If Temp > 80.0 Then REF OFF
If Temp > 82.0 Then T5B OFF
Max Change 015 M Then T5B OFF
If Temp > 83.0 Then T5A OFF
Max Change 015 M Then T5A OFF

// Monitor pH and ORP
If pH < 8.10 Then AL3 ON
If pH > 8.60 Then AL4 ON
If ORP < 300 Then AL5 ON
If ORP > 450 Then AL6 ON

// Monitor float switches
If Switch1 Closed Then low OFF
If Switch1 Closed Then AL1 OFF
If Switch1 Open Then low ON
if switch1 open then al1 on
If Switch2 Open Then OVR OFF
If Switch2 Open Then AL2 OFF
If Switch2 Closed Then OVR ON
If Switch2 Closed Then AL2 ON

// Actions if either float switch is tripped
If Timer low = OFF Then RTN ON
if timer low = on then RTN off
if timer ovr = off then dos on
if timer ovr = off then ato on
if timer ovr = on then dos off
if timer ovr = on then ato off

// Tell me if the power went out
If Power 000 Then ALM ON

// Feed the tank
if FeedA 000 then SKM OFF
If FeedA 000 Then RTN OFF
If FeedA 000 Then OVR OFF
If FeedA 000 Then CLP OFF
If FeedA 000 Then MP1 OFF

kenargo
05/14/2009, 08:25 PM
The best way to accomplish what you ask is to initialize the device to ON (or OFF) and then use the program to change the device state. That way different statements won't override one another.

Sometime, you will need to use a dummy timer (to evaluate the conditions) and then use an "if timer" to set device states.

From your description is sounds like you will need to use a dummy timer (to evaluate the conditions of PH and switches) then use "If Timer" to control the pumps.

Hope this give you an idea on how to accomplish what you want.

Urchinhead
05/14/2009, 08:39 PM
Thank you. You mean like this?

If Time > 00:00 Then Device1 ON

If pH < 8.11 then DummyTimer1 ON
if pH > 8.11 then DummyTimer1 OFF

if Switch1 OPEN then DummyTimer2 ON
If Switch2 CLOSED then DummyTimer2 OFF

if Timer DummyTimer1 = ON THEN Device1 OFF
if Timer DummyTimer1 = OFF THEN Device1 ON
If Timer DummyTimer2 = ON then Device1 OFF
If Timer DummyTimer2 = OFF then Device1 ON

Thus if Switch1 is closed but pH is below 8.11 the Device1 will be OFF and vice versa?

kenargo
05/14/2009, 08:47 PM
Something like that yes, but you can do it with fewer timers I think.

What might help is a quick lesson on how the AC evaluates and controls timers. In short:

If Time statements are ordered by time and evaluated individually. At the end of this evaluation cycle ALL devices indicated by ANY 'if time' should have a state (time rolls over).

Next comes everything else. Each statement is evaluated and if "true" the device (temp setting) is set. At the end the temp values are moved into the actual device.

Note; Max Change can affect the last part but for simplicity I've cut it out to make it easier to understand.

This should help yo ufigure out the more complex issues you want to program...

Urchinhead
05/15/2009, 11:17 AM
Thank you sir! I will gin that up on your outstanding simulator!

lakee911
05/15/2009, 07:28 PM
<a href=showthread.php?s=&postid=15013463#post15013463 target=_blank>Originally posted</a> by Urchinhead
...high water switch for the sump that turns off the ATO system (Tunze Ozmolator)...

What are your thoughts here? My Ozmolator shuts off the top off water automatically, plus it has the high water float. I do wish that I could interface that optical water sensor to my ACIII and then I can lose the whole Ozmolator...

Thx
Jason

Urchinhead
05/15/2009, 09:14 PM
Ah right. I should go into a bit more detail. It comes down to what amounts redundancy or as I like to think of it, defense in depth system design...

For example on the ozmolator...

From previous experience with ATO systems (not Tunze) I had two sensors fail simultaneously causing the ATO system to pump the entire 5 gallon reservoir into a 40 gallon tank. Having that much RO/DI water poured into the tank played havoc with things and fortunately I didn't loose any corals or fish from the major swing in pH and SG.

By having the ACIII monitor both water levels and pH I am guarding against a case where I have a major failure of the Osmolator similar to the one I list above. This the AC III acts as a backup and will shut the pump down.

This will also apply to the dosing system. If the AC III sees a big swing in pH up or down it could mean that I am dumping Ca or CaCO3 into the tank due to a pump controller failure. The AC III see's the spike and shuts down the dosing system.

In summation its a way for me to build redundant and independent controls to mitigate as much as possible a failure in the system.

Interfacing with the optical sensor would most likely be possible but not cost effective. As y