Please help with PAC programing

Discussion in 'General Discussion' started by KK06, Dec 1, 2012.

  1. KK06

    KK06

    Joined:
    Sep 19, 2006
    Messages:
    22
    Likes Received:
    0
    Hi,

    I am trying to upload this logic into the PAC but it doesn't seem to do anything. I have tested the logic in the PICED and it works fine.
    Sometimes I was wondering is the logic loaded into the PAC or not. I even recovered the PAC. I thought these are very simple instructions or have I done something wrong. please help..

    "SouthGate Status Close" is from a limit switch that fed into Aux input unit (BCI4A)


    {When south gate opens and its dark/sunset then turn on porch light for 7 mins and front deck for 6mins}

    if (GetLightingState("SouthGate Status Close") = OFF) and
    (Time = sunset) then
    begin
    PulseCBusLevel("The Perfect", "Lighting", "PORCH Wall light (POLI2)", 100%, 0, "0:07:00", 0%);
    PulseCBusLevel("The Perfect", "Lighting", "Front Deck", 100%, 0, "0:06:00", 0%);
    end;
     
    KK06, Dec 1, 2012
    #1
  2. KK06

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    This code would work, but only if the gate was open at the precise moment that Sunset occurred. What it sounds like you're looking for is for the two lights to be pulsed on whenever the gate is detected as being opened, any time between sunset and sunrise.

    If that is the case, try this:
    Code:
    Once (GetLightingState("SouthGate Status Close") = OFF) then
    begin
      if ((time >= sunset) or (time <= sunrise)) then
      begin
        PulseCBusLevel("The Perfect", "Lighting", "PORCH Wall light (POLI2)", 100%, 0, "0:07:00", 0%);
        PulseCBusLevel("The Perfect", "Lighting", "Front Deck", 100%, 0, "0:06:00", 0%);
      end;
    end;
     
    Newman, Dec 1, 2012
    #2
  3. KK06

    KK06

    Joined:
    Sep 19, 2006
    Messages:
    22
    Likes Received:
    0
    Thanks

    Thanks Newman, it works wonder.. Once again you saved the day :) cheers!
     
    KK06, Dec 1, 2012
    #3
  4. KK06

    Robbo_VIC

    Joined:
    Jan 24, 2011
    Messages:
    143
    Likes Received:
    0
    Location:
    Melbourne, VIC
    Newman, is there any reason not to include the time check in the first "once" test? Like so:
    Code:
    Once ((GetLightingState("SouthGate Status Close") = OFF) and
    (time >= sunset) or (time <= sunrise)) then
    begin
        PulseCBusLevel("The Perfect", "Lighting", "PORCH Wall light (POLI2)", 100%, 0, "0:07:00", 0%);
        PulseCBusLevel("The Perfect", "Lighting", "Front Deck", 100%, 0, "0:06:00", 0%);
    end;
     
    Robbo_VIC, Dec 2, 2012
    #4
  5. KK06

    Newman

    Joined:
    Aug 3, 2004
    Messages:
    2,203
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    The pulse commands needs to occur only when the gate opens, whereas sunset-to-sunrise will be true for approximately half the day. By evaluating the gate opening independently first, this speeds up the execution of the code by a teensy amount during the normal (gate closed) case as the logic engine does not waste time evaluating the sunset-to-sunrise condition unless it really needs to.

    If you do this sort of thing as a general practice it will allow you to execute a little more code in each logic engine cycle.
     
    Newman, Dec 3, 2012
    #5
  6. KK06

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,548
    Likes Received:
    178
    Location:
    Adelaide, Australia
    Also, with both conditions in the ONCE statemnet it will be triggered only after both conditions become true, but in any order. So if the gate is shut during the day, as soon as it gets to sunset the lights will be triggered, which is probably not what you want.
     
    Ashley, Dec 3, 2012
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.