Results 1 to 5 of 5

Thread: programming help: if switch 1 AND switch 2 = on then...

  1. #1
    Regular Vistor
    Join Date
    Feb 2016
    Location
    Upstate NY
    Posts
    30

    programming help: if switch 1 AND switch 2 = on then...

    I'm using a pair of momentary switches to trigger my water change program. The water change program is all set, no issues there. But I'm struggling getting my head around how to be program for the switches.

    Because my water change system is limited by buckets, I want to take care not to trigger the program if a button is pressed inadvertently. Thus the use of 2 buttons, and using a defer statement to make sure the buttons are pressed and held for 5 seconds. My problem is how to test that both buttons are pressed (closed). Will the following work, or is the a better/cleaner way to do it?

    Code:
    Fallback OFF
    Set OFF
    If Swx3_1 CLOSED Then ON
    If Swx3_2 CLOSED Then ON
    
    
    If Swx3_1 OPEN Then OFF
    If Swx3_2 OPEN Then OFF
    
    
    Defer 000:05 Then ON
    Min Time 015:00 Then ON

    My thinking is that the first pair of IFs will test the state of the buttons and trigger an ON if either are pressed. The second set will test the buttons and will revert the status to OFF of either are NOT pressed/held. The defer will make sure the buttons are held for 5 seconds, and the min time statement will keep the state of the outlet ON for a minimum of 15 minutes, as needed by my water change program.

    Will that work? Thanks all.

  2. #2
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    It will work if you do this.

    [CODE]
    Fallback OFF
    Set OFF
    If Swx3_1 CLOSED Then ON
    If Swx3_2 OPEN Then OFF
    Defer 000:05 Then ON
    Min Time 015:00 Then ON


    The basic formula for If this AND that is to turn on for one condition and turn off for the opposite of the other condition if that makes sense.

    You might be an engineer if...You have no life and can prove it mathematically.

  3. #3
    Regular Vistor
    Join Date
    Feb 2016
    Location
    Upstate NY
    Posts
    30
    OK, I think I've got it. For whatever reason, I couldn't connect the dots as I read the sticky post... but talking it through in the context of my system seems to be missing breadcrumb I needed.

    Just to be clear, because I like to understand, my code will work, it's just redundant, correct? The exclusive nature of the switch statuses makes your code cleaner.

  4. #4
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    Your code technically would have worked, but extra lines are never good. Hogs up processing power and makes things more confusing later.

    You might be an engineer if...You have no life and can prove it mathematically.

  5. #5
    Regular Vistor
    Join Date
    Feb 2016
    Location
    Upstate NY
    Posts
    30
    Gotcha. Thanks for the help.

Similar Threads

  1. Help! Float Switch programming - Help.
    By Iufan in forum Apex Programming for Dosing, ATO, and AWC
    Replies: 2
    Last Post: 01-04-2022, 12:29
  2. Help! Switch Programming
    By SRQReefer in forum Misc Apex Usage & Programming
    Replies: 2
    Last Post: 08-26-2020, 08:20
  3. Help! Float switch programming
    By Snulma1 in forum Apex Programming for Dosing, ATO, and AWC
    Replies: 6
    Last Post: 05-17-2020, 06:21
  4. my ATO "stuck switch" virtual switch doesn't seem to be working?
    By f3honda4me in forum Apex Programming for Dosing, ATO, and AWC
    Replies: 4
    Last Post: 05-17-2017, 05:56
  5. Float switch programming
    By balistikb in forum APEX Fusion
    Replies: 7
    Last Post: 11-09-2014, 15:32

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
  •