Results 1 to 12 of 12

Thread: Help me understand the When command

  1. #1
    New User
    Join Date
    Jun 2018
    Location
    USA
    Posts
    8

    Help me understand the When command

    This is my code for a virtual outlet

    Code:
    Fallback OFF
    Set OFF
    If Sw3 CLOSED Then ON
    When Off > 001:00 Then OFF
    Switch 3 opens when my ATO reservoir is low and needs to be refilled. The outlet moved from Auto to Off as expected. I add water and switch 3 closes. Now if I change the outlet to Auto is will automatically move back to Off. I can get the Outlet back on again by manually moving it to On and then to Auto. Is this expected to have to move the outlet to On before going back to Auto?

    P.S. I added the 1 minute timeout to the When command thinking it would help but it did not.



  2. #2
    Frequent Contributor SuncrestReef's Avatar
    Join Date
    Feb 2018
    Location
    Beaverton, OR
    Posts
    3,105
    Quote Originally Posted by EricB View Post
    This is my code for a virtual outlet

    Code:
    Fallback OFF
    Set OFF
    If Sw3 CLOSED Then ON
    When Off > 001:00 Then OFF
    Switch 3 opens when my ATO reservoir is low and needs to be refilled. The outlet moved from Auto to Off as expected. I add water and switch 3 closes. Now if I change the outlet to Auto is will automatically move back to Off. I can get the Outlet back on again by manually moving it to On and then to Auto. Is this expected to have to move the outlet to On before going back to Auto?

    P.S. I added the 1 minute timeout to the When command thinking it would help but it did not.


    The WHEN command is a failsafe to permanently turn off an outlet due to an error or abnormal situation. Normally you would leave the outlet set to AUTO and then let your programming code turn on or off the outlet based on the conditions you programmed for. But the WHEN command should only be used for situations that could cause serious trouble if the programming continued without manual intervention. The best example is if your ATO pump runs longer than it normally takes to refill your sump. This could be because the optical or float switch failed to turn off the pump, and it then continues to flood your house. The WHEN command basically means if it runs longer than X:XX, then change the outlet from Auto to OFF and leave it that way until you have a chance to investigate what went wrong.

    RussM did a nice write up of the WHEN command in this post: https://forum.neptunesystems.com/sho...-Firmware-4-52

  3. #3
    New User
    Join Date
    Jun 2018
    Location
    USA
    Posts
    8
    Quote Originally Posted by SuncrestReef View Post
    The WHEN command is a failsafe to permanently turn off an outlet due to an error or abnormal situation. Normally you would leave the outlet set to AUTO and then let your programming code turn on or off the outlet based on the conditions you programmed for. But the WHEN command should only be used for situations that could cause serious trouble if the programming continued without manual intervention. The best example is if your ATO pump runs longer than it normally takes to refill your sump. This could be because the optical or float switch failed to turn off the pump, and it then continues to flood your house. The WHEN command basically means if it runs longer than X:XX, then change the outlet from Auto to OFF and leave it that way until you have a chance to investigate what went wrong.

    RussM did a nice write up of the WHEN command in this post: https://forum.neptunesystems.com/sho...-Firmware-4-52
    The failsafe part is working as I would expect. I want the outlet to go to OFF when to be sure my pump does not run dry. The problem happens when I try to reset the outlet, I have to move it from Off to On then to Auto. If I move it from Off to Auto it will go back to Off. Also this is not Auto-Off it is manual Off. Is this a bug? Shouldn't it run the auto program and bet set to Auto-On at this point?

  4. #4
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    You're throwing it into an infinite loop. You are telling it to turn off when the switch opens and then 1 minute after it turns off to latch into manual off.

    Sent from my SM-G965U using Tapatalk

  5. #5
    Frequent Contributor SuncrestReef's Avatar
    Join Date
    Feb 2018
    Location
    Beaverton, OR
    Posts
    3,105
    I'm guessing the problem is that your code says:

    When OFF > 001:00 Then OFF

    It should be:

    When ON > 001:00 Then OFF

    In other words, if the pump is running (On) for more than 1 minute, then turn the slider to Manual Off.

  6. #6
    New User
    Join Date
    Jun 2018
    Location
    USA
    Posts
    8
    Quote Originally Posted by zombie View Post
    You're throwing it into an infinite loop. You are telling it to turn off when the switch opens and then 1 minute after it turns off to latch into manual off.

    Sent from my SM-G965U using Tapatalk
    I think I am explaining this wrong. I want it to turn off when the switch is opened for 1 minute. The problem is when I close the switch and then change it to Auto. The outlet turns back off again. I believe it should turn on as the switch is now closed. How am I in a loop when the switch is closed?

  7. #7
    New User
    Join Date
    Jun 2018
    Location
    USA
    Posts
    8
    Quote Originally Posted by SuncrestReef View Post
    I'm guessing the problem is that your code says:

    When OFF > 001:00 Then OFF

    It should be:

    When ON > 001:00 Then OFF

    In other words, if the pump is running (On) for more than 1 minute, then turn the slider to Manual Off.
    That is not the behavior I want. I want this outlet to be off until I turn it back on whenever it turns off.

  8. #8
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    Quote Originally Posted by EricB View Post
    That is not the behavior I want. I want this outlet to be off until I turn it back on whenever it turns off.
    He's actually 99% right. The only difference is what he provided runs the pump for exactly 1 minute, not 1 minute after the switch opens.

    Your original code turns it off immediately when the switch opens and then latches OFF in an infinite loop.

    Sent from my SM-G965U using Tapatalk

  9. #9
    New User
    Join Date
    Jun 2018
    Location
    USA
    Posts
    8
    Quote Originally Posted by zombie View Post
    He's actually 99% right. The only difference is what he provided runs the pump for exactly 1 minute, not 1 minute after the switch opens.

    Your original code turns it off immediately when the switch opens and then latches OFF in an infinite loop.

    Sent from my SM-G965U using Tapatalk
    I am missing something with this infinite loop

    This is how I see the code working

    Fallback OFF False
    Set OFF True
    If Sw3 CLOSED Then ON True
    When Off > 001:00 Then OFF False


    I believe the code is executed every second so that would be 60 executions before the When line is true.

    I also do not understand why I do not enter the infinite loop when the outlet is manually on and moved to Auto.

    BTW: I do not want my pump to run dry at all. I have placed this switch so it opens before the water level is low enough for the pump to run dry.

  10. #10
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    When the outlet has been in manual OFF or OFF for more than 1 minute, the when line is true which puts it right back in manual off.

    This is what is actually happening

    Turn to manual ON resets when timer so it is no longer true

    Set to AUTO allows it to turn on when the switch is closed

    The moment the switch opens, the outlet turns off.

    Exactly 1 minute later the when statement is true again, which sets the outlet to manual OFF. This statement remains true until the outlet goes into the ON state.

    Sent from my SM-G965U using Tapatalk

  11. #11
    New User
    Join Date
    Jun 2018
    Location
    USA
    Posts
    8
    Quote Originally Posted by zombie View Post
    When the outlet has been in manual OFF or OFF for more than 1 minute
    Ok now I see. Because manual on/off overrides the auto I did not think manual conditions were included in the duration calculation. This explains the behavior exactly and I was able to test with another virtual outlet to confirm. Thank you for putting up with all of my questions.

  12. #12
    Frequent Visitor Todd's Avatar
    Join Date
    Jan 2013
    Location
    Huntsville, AL
    Posts
    583
    Quote Originally Posted by EricB View Post
    Ok now I see. Because manual on/off overrides the auto I did not think manual conditions were included in the duration calculation. This explains the behavior exactly and I was able to test with another virtual outlet to confirm. Thank you for putting up with all of my questions.
    Actually, the When command is executed first. Like Defer and Min Time, the When command does not rely on placement order. So a manual ON is needed to reset the register.

Similar Threads

  1. really cant understand this, please help
    By slayerhellfire in forum Networking & Internet Connectivity
    Replies: 9
    Last Post: 05-14-2016, 05:39
  2. really cant understand this, please help
    By slayerhellfire in forum Updating Apex Classic Firmware & Web Pages
    Replies: 1
    Last Post: 05-02-2016, 16:00
  3. Help me understand transitions
    By Smotz in forum WAV Powerheads
    Replies: 3
    Last Post: 12-10-2015, 07:08
  4. Help! Please help me understand
    By Bob71 in forum APEX Fusion
    Replies: 2
    Last Post: 11-20-2014, 11:26
  5. Question: Not sure I understand
    By Admonition in forum APEX Fusion
    Replies: 3
    Last Post: 07-01-2014, 22:11

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •