Results 1 to 12 of 12

Thread: Help, built Custom feeder with relays, cant' code it

  1. #1
    New User
    Join Date
    Sep 2018
    Location
    WI
    Posts
    12

    Help, built Custom feeder with relays, cant' code it

    I have 3 non apex feeders and 2 returns connected to EB832 but on a battery backup UPS on said outlet. If the outlet cuts power to the returns, they just turn right back on... SO, I need to press the feed button on the pumps. I have 1 outlet rigged to a relay, that when power is applied, closes the feeder button on the pumps. It needs about a 1-2 second pulse to enter feed mode.

    Then, I need to do the same thing to another outlet to trigger a pulse on a different outlet that presses the button on the other feeder, preferably a short while after the return turns off.

    I would like the feed timer to be about 5 minutes, but really doesn't matter, as I can turn the gyre/powerheads back on in code, but the returns have hardcoded 10 minute timer from the feeder.

    I can't figure out how to say if FEEDA or FEEDB is activated, then pulse relay for return, and pulse relay for feeder... I want to drive with a timer a few times a day, as well as push feedA/B button to perform a manual frozen food feeding.

    I got close with OSC function and WHEN ON > 3 seconds, then off, but it doesn't work as expected.

    *I write C code for a living, this is not obvious to me, very odd syntax. I just want some WHILE, IF, THEN loops, and timer checks...

  2. #2
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    This is the basic premise. It helps if you think of the coding more in terms of state machines triggered by scripts. Took me a bit to figure out how to translate C++, labview, matlab, etc knowledge over into it too.

    vFeed
    (Scheduled plus feed timers)

    StopRetPress
    Set OFF
    If Output vFeed = ON Then ON
    Defer 000:05 Then ON

    Return pushbutton
    Set OFF
    If Output vFeed = ON Then ON
    If Output StopRetPress = ON Then OFF

    StartFeedPress
    Set OFF
    If Output vFeed = ON Then ON
    Defer 001:00 Then ON

    StopFeedPress
    Set OFF
    If Output vFeed = ON Then ON
    Defer 001:05 Then ON

    Feed Pushbutton
    Set OFF
    If Output StartFeedPress = ON Then ON
    If Output StopFeedPress = ON Then OFF


    Sent from my SM-G965U using Tapatalk

  3. #3
    New User
    Join Date
    Sep 2018
    Location
    WI
    Posts
    12
    Mostly got it working now, but still a problem with logic flow. I can't figure out how many statements are allowed? must they all be true? or can I use AND/OR ?

    I want the skimmer to turn off during feedings, and turn on 2 minutes after the feed timer is complete so the sump can stabilize. I have three vfeeds for flake, pellet and frozen/manual feeding. This doesn't work:

    //skimmer pump outlet
    Fallback ON
    Set ON
    If Output VFEED = ON Then OFF
    If SKMFUL OPEN Then ON //switch for skimmer bucket
    If SKMFUL CLOSED Then OFF
    Defer 000:10 Then ON //debounce the skimmer bucket switch
    If Output VFEED = ON Then OFF
    Defer 002:00 Then ON
    If Output vpfeed = ON Then OFF
    Defer 002:00 Then ON
    If Output vmfeed = ON Then OFF
    Defer 002:00 Then ON

  4. #4
    Master Control Freak RussM's Avatar
    Join Date
    Dec 2012
    Location
    California - US Pacific
    Posts
    22,466
    Defer (and Min Time) statements apply to the entire program... you cannot have more than one Defer xxx Then ON.
    Please do not send me PMs with technical questions or requesting assistance - use the forums for Apex help. PM me ONLY if the matter is of a private or personal nature. Thanks.

  5. #5
    Frequent Visitor
    Join Date
    Mar 2017
    Location
    Wellington, NZ
    Posts
    114
    You can only have 1 defer on and 1 defer off statement, not multiple defer on etc so that will mess things up. You also don't need the If SKMFULL OPEN Then ON as the outlet will be on unless that switch is Closed (due to the set on)

    Try this and see how it works: (I am still getting used to programming myself)

    Fallback ON
    Set ON
    If SKMFUL CLOSED Then OFF
    If Output VFEED = ON Then OFF
    If Output vpfeed = ON Then OFF
    If Output vmfeed = ON Then OFF
    Defer 002:00 Then ON

    Also, it helps to explain what it does when it doesn't work

    A lot of people also put in there to turn the skimmer off if the return pump is off to avoid over flowing etc

  6. #6
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    Quote Originally Posted by zachtos View Post
    Mostly got it working now, but still a problem with logic flow. I can't figure out how many statements are allowed? must they all be true? or can I use AND/OR ?

    I want the skimmer to turn off during feedings, and turn on 2 minutes after the feed timer is complete so the sump can stabilize. I have three vfeeds for flake, pellet and frozen/manual feeding. This doesn't work:

    //skimmer pump outlet
    Fallback ON
    Set ON
    If Output VFEED = ON Then OFF
    If SKMFUL OPEN Then ON //switch for skimmer bucket
    If SKMFUL CLOSED Then OFF
    Defer 000:10 Then ON //debounce the skimmer bucket switch
    If Output VFEED = ON Then OFF
    Defer 002:00 Then ON
    If Output vpfeed = ON Then OFF
    Defer 002:00 Then ON
    If Output vmfeed = ON Then OFF
    Defer 002:00 Then ON
    Statements are like sequential OR and NOR gates where the last true statement wins. Only one defer of each type (one for ON one for OFF) are allowed in an outlet and they apply globally regardless of where they are located. If you need different delays for different conditions, you need to separate them into individual virtual outlets that act like intermediate registers.

    Only one equivalent AND gate can be done per outlet and the way to achieve AND is like this. This isn't written with correct syntax but show the process for a 3 input AND gate.

    Set OFF
    If condition 1 true then ON
    If condition 2 false then OFF
    If condition 3 false then OFF

    Sent from my SM-G965U using Tapatalk

  7. #7
    New User
    Join Date
    Sep 2018
    Location
    WI
    Posts
    12
    That is confusing. So with three if statement, what is the result if true if all 3 have different result if true?

    Sent from my moto g(6) using Tapatalk

  8. #8
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    Quote Originally Posted by zachtos View Post
    That is confusing. So with three if statement, what is the result if true if all 3 have different result if true?

    Sent from my moto g(6) using Tapatalk
    This is a more thorough example that might help you understand. AND statements in apex programming are performed by turning ON for the first condition and then turning OFF for the opposite of the other conditions.

    Turn ON if time is between 7am and 8pm AND temp is below 82 AND virtual outlet VO1 is ON.

    Set OFF
    If Time 07:00 to 19:59 Then ON
    If Temp > 81.9 Then OFF
    If Output VO1 = OFF Then OFF

    or

    Set OFF
    If Temp < 82.0 Then ON
    If Time 20:00 to 19:59 Then OFF
    If Output VO1 = OFF Then OFF

    or

    Set OFF
    If Output VO1 = ON Then ON
    If Time 20:00 to 19:59 Then OFF
    If Temp > 81.9 Then OFF

    OR statements run in sequence. Say you instead want to turn on if Time is between 7am and 8pm OR switch1 is CLOSED OR virtual outlet VO1 is ON

    Set OFF
    If Time 07:00 to 19:59 Then ON
    If Output VO1 = ON Then ON
    If Switch1 CLOSED Then ON




    Sent from my SM-G965U using Tapatalk

  9. #9
    New User
    Join Date
    Sep 2018
    Location
    WI
    Posts
    12
    //vfeed //enable a virtual feed
    Fallback OFF
    Set OFF
    If Output vffeed = ON Then ON //flakes are B
    If Output vpfeed = ON Then ON //pellets are C
    If Output vmfeed = ON Then ON //manual frozen feeding A

    //powerheads //turn these off in any feed mode
    Fallback ON
    Set ON
    If Output VFEED = ON Then OFF
    Defer 000:05 Then OFF



    //RETURN_FEED //pulse the relay to tap the feed button on the return pump
    Fallback OFF
    Set OFF
    If Output VFEED = ON Then ON
    If Output StopRetPress = ON Then OFF



    //StopRetPress
    Fallback OFF
    Set OFF
    If Output VFEED = ON Then ON
    Defer 000:05 Then ON

    //StartFeedPre
    Fallback OFF
    Set OFF
    If Output VFEED = ON Then ON
    Defer 000:15 Then ON

    //StopFeedPres
    Set OFF
    If Output VFEED = ON Then ON
    Defer 000:20 Then ON

    //vpfeed
    If Time 00:00 to 19:00 Then OFF
    If Time 19:10 to 00:00 Then OFF
    If FeedC 000 Then ON

    //vffeed
    If Time 00:00 to 16:00 Then OFF
    If Time 16:10 to 00:00 Then OFF
    If FeedB 000 Then ON

    //vmfeed
    Set OFF
    If FeedA 000 Then ON

    - - - Updated - - -

    Questions:
    Is there a way to know that someone tapped CANCEL on a feeding? I want to turn the return pump back on (pulse the relay to turn back on if all feeds disabled)
    Also, is this correct? I set a 10 minute timer for timed feedings?
    //vffeed
    If Time 00:00 to 16:00 Then OFF
    If Time 16:10 to 00:00 Then OFF
    If FeedB 000 Then ON

  10. #10
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    There isn't a way to detect when a feed is cancelled.

    You did the timed feedings incorrectly. They need an initial state and then turn on for the desired time

    Ex
    //vffeed
    Set OFF
    If Time 16:00 to 16:09 Then ON
    If FeedB 000 Then ON

    Sent from my SM-G965U using Tapatalk

  11. #11
    New User
    Join Date
    Sep 2018
    Location
    WI
    Posts
    12
    Ok, I just modified the feed code from default. What does the feed 000 mean? What are those variables?

    I got everything works ok

    Sent from my moto g(6) using Tapatalk

  12. #12
    Frequent Contributor zombie's Avatar
    Join Date
    Dec 2013
    Location
    Denver, CO
    Posts
    13,176
    Quote Originally Posted by zachtos View Post
    Ok, I just modified the feed code from default. What does the feed 000 mean? What are those variables?

    I got everything works ok

    Sent from my moto g(6) using Tapatalk
    The variable means how many minutes to stay off after the feed timer expires.

    Sent from my SM-G965U using Tapatalk

Similar Threads

  1. Review My Program Feeder code question
    By JimerC in forum Misc Apex Usage & Programming
    Replies: 4
    Last Post: 05-09-2019, 21:40
  2. Help! Help with code for eheim automatic fish feeder
    By Daltrey in forum Misc Apex Usage & Programming
    Replies: 3
    Last Post: 10-20-2017, 21:01
  3. AFS feeder and pump shutoff code
    By Singlefin in forum Apex Classic/Apex Lite/Apex Jr
    Replies: 3
    Last Post: 10-02-2015, 20:06
  4. Automatic refrigerated feeder system code help
    By Trichome in forum Misc Apex Usage & Programming
    Replies: 16
    Last Post: 11-15-2013, 09:24
  5. code for auto feeder
    By tasso in forum Apex Classic/Apex Lite/Apex Jr
    Replies: 8
    Last Post: 04-19-2013, 07:44

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
  •