Programming Question

Users Who Are Viewing This Thread (Total: 1, Members: 0, Guests: 1)

infinite0180

Valuable Member
View Badges
Joined
Apr 25, 2018
Messages
1,821
Reaction score
1,097
Rating - 100%
1   0   0
So i found this gem on the interwebs and im looking to implement it into my Apex on an optical sensor in my sump for a high level. Ill tie it to my ATO and my Skimmer. Im not sure why the “Defer then off” statement is there though. Can anybody shed some light for me? From my understanding, the “when” statement will lock the VO on... help me figure this one out!

“Form3: turning device off may deactivate sensor. Latch the device OFF until I manually intervene by resetting the VO

VOname
Set OFF
If SwitchName CLOSED Then ON
Defer 000:10 Then ON
Defer 000:10 Then OFF
When On > 000:02 Then ON

Device
(Existing code)
If Output VOname = ON Then OFF

Email
(Existing code)
If Output VOname = ON Then ON”
 

Brett S

Valuable Member
View Badges
Joined
Nov 28, 2016
Messages
1,062
Reaction score
1,373
Location
Orlando
Rating - 0%
0   0   0
The DEFER command means that the conditions that would set the outlet to ON or OFF need to be true for X amount of time before the outlet is actually turned ON or OFF.

In this case your water level sensor would need be detecting water or not detecting water for a full 10 seconds before the state of the outlet changes. The reason that’s there is to prevent the outlet from switching back and forth if there were some waves that washed over the sensor. By waiting to make sure that the sensor reading stays the same for a full 10 seconds you can be more confident that the water level really is where it says it is.
 

Brett S

Valuable Member
View Badges
Joined
Nov 28, 2016
Messages
1,062
Reaction score
1,373
Location
Orlando
Rating - 0%
0   0   0
Although in reading this further, the DEFER THEN OFF statement would never actually be used and I think there might be an error in the logic.

Assuming the sensor is normally OPEN when the water level is low if the water level gets too high the sensor will change to CLOSED. At this point nothing will happen for 10 seconds. If the sensor stays CLOSED for 10 seconds, then the outlet will switch to ON, which will switch your other devices off.

At this point, once the outlet has been on for 2 seconds the WHEN ON > 000:002 Then ON command will latch the outlet to ON and you will need to manually set it back to AUTO after you fix the high water level issue.

Even If the water level happened to go back down during that two second period before the outlet was latched ON the DEFER THEN OFF statement would prevent the outlet from switching off and it would still latch on.
 
OP
OP
infinite0180

infinite0180

Valuable Member
View Badges
Joined
Apr 25, 2018
Messages
1,821
Reaction score
1,097
Rating - 100%
1   0   0
The DEFER command means that the conditions that would set the outlet to ON or OFF need to be true for X amount of time before the outlet is actually turned ON or OFF.

In this case your water level sensor would need be detecting water or not detecting water for a full 10 seconds before the state of the outlet changes. The reason that’s there is to prevent the outlet from switching back and forth if there were some waves that washed over the sensor. By waiting to make sure that the sensor reading stays the same for a full 10 seconds you can be more confident that the water level really is where it says it is.

Ya i get that part of it and understand the “defer 10 then on” but the last statement is a “when” statement, meaning when the output is on for 2 sec it locks it to on. So why would there be a “defer 10 then off” statement? The outlet is locked on at that point right?
 

Brett S

Valuable Member
View Badges
Joined
Nov 28, 2016
Messages
1,062
Reaction score
1,373
Location
Orlando
Rating - 0%
0   0   0
Actually, I think I do see their logic. I think the DEFER THEN OFF command is purposely longer than the WHEN ON command because if the water level rises and stays high for at least 10 seconds, which would be enough to trigger this outlet then you would want the outlet to latch ON no matter what, even if the water level lowers again. This insures that once the water level has been high for 10 seconds then the outlet will definitely latch ON
 
OP
OP
infinite0180

infinite0180

Valuable Member
View Badges
Joined
Apr 25, 2018
Messages
1,821
Reaction score
1,097
Rating - 100%
1   0   0
Actually, I think I do see their logic. I think the DEFER THEN OFF command is purposely longer than the WHEN ON command because if the water level rises and stays high for at least 10 seconds, which would be enough to trigger this outlet then you would want the outlet to latch ON no matter what, even if the water level lowers again. This insures that once the water level has been high for 10 seconds then the outlet will definitely latch ON

Ohhh that makes sense! Thanks
 
OP
OP
infinite0180

infinite0180

Valuable Member
View Badges
Joined
Apr 25, 2018
Messages
1,821
Reaction score
1,097
Rating - 100%
1   0   0
Actually, I think I do see their logic. I think the DEFER THEN OFF command is purposely longer than the WHEN ON command because if the water level rises and stays high for at least 10 seconds, which would be enough to trigger this outlet then you would want the outlet to latch ON no matter what, even if the water level lowers again. This insures that once the water level has been high for 10 seconds then the outlet will definitely latch ON

I went through that same thought process and was hung up on why its there. Now that you point it out though it seems solid!
 
OP
OP
infinite0180

infinite0180

Valuable Member
View Badges
Joined
Apr 25, 2018
Messages
1,821
Reaction score
1,097
Rating - 100%
1   0   0
Actually, I think I do see their logic. I think the DEFER THEN OFF command is purposely longer than the WHEN ON command because if the water level rises and stays high for at least 10 seconds, which would be enough to trigger this outlet then you would want the outlet to latch ON no matter what, even if the water level lowers again. This insures that once the water level has been high for 10 seconds then the outlet will definitely latch ON

Now that i think about it. He states it right in the first line. Its all there to prevent a situation where shutting off equipment will change the water level potentially changing the state of the sensor. Its genius haha
 

Set it and forget it: Do you change your aquascape as your corals grow?

  • I regularly change something in my aquascape.

    Votes: 14 9.1%
  • I occasionally change something in my aquascape.

    Votes: 43 27.9%
  • I rarely change something in my aquascape.

    Votes: 75 48.7%
  • I never change something in my aquascape.

    Votes: 19 12.3%
  • Other.

    Votes: 3 1.9%
Back
Top