alternate control of 2 outputs.. blinds??

Discussion in 'Pascal Logic Code Examples' started by coppo, Apr 13, 2006.

  1. coppo

    coppo

    Joined:
    Sep 7, 2004
    Messages:
    221
    Likes Received:
    10
    Location:
    Adelaide
    Application:
    1 C-Bus button ( BlindSW , INPUT) controlling 2 output Group Addresses alternately.
    ( BlindUP... BlindDN, outputs)

    PAC looks at the BlindSW GA for an ON state, depending upon the current state of the flag ( Blind1flag = ON ...OFF), then sends an ON command to either BlindUP or BlindDN.

    When BlindSW GA = OFF, the flag is left in its current state ( ready to alternate the output next time) and both BlindUP ...BlindDN are reset.

    The "auto resetting" of the BlindSW GA is done by you configuring your actual C-Bus wall switch to a "toggle timer" for a relevant timer.. 30Secs, 1 min .. whatever .

    If you use a delay in the code it will in most cases cause odd operation,
    unless you fully understand programming and modify your code appropriately.


    If the output device has some odd configuration requirement, this code will
    not work for you. ie: the blind needs both outputs "on" to stop. You will need to modify the codee to suit your application.


    This code is suitable for PAC / ColourTouch / HomegateV3 / ScheduleplusV3.


    Code:
    
    {Global Variables section}
    blind1flag, blind2flag : boolean;
    
    
    {Initialisation section}
    blind1flag := off;
    blind2flag := off;
    
    {Blind control Module}
    { DO NOT USE DELAYS in this module,  it will have adverse affects and cause problems
     with the rest of the code below it.}
    
    {Blind1 UP and DOWN control}
    { Delays for auto reset of cbus "Blind1SW" button must be done via C-Bus timer in button itself }
    once (GetLightingState("Blind1Sw") = ON) then
    begin
      if (blind1flag = OFF) then
      begin
        SetLightingState("Blind1DN", OFF);
        SetLightingState("Blind1UP", ON);
        blind1flag := ON;
      end
      else
      begin
        SetLightingState("Blind1Up", OFF);
        SetLightingState("Blind1DN", ON);
        blind1flag := OFF;
      end;
    end;
    
    {Blind1 RESET}
    once (GetLightingState("Blind1Sw") = OFF) then
    begin
      SetLightingState("Blind1DN", OFF);
      SetLightingState("Blind1UP", OFF);
    end;
    {=======================================================}
    
    {Blind2 UP and DOWN control}
    { Delays for auto reset of "Blind2SW" c-bus button must be done via C-Bus timer in button itself }
    once (GetLightingState("Blind2Sw") = ON) then
    begin
      if (blind2flag = OFF) then
      begin
        SetLightingState("Blind2DN", OFF);
        SetLightingState("Blind2UP", ON);
        blind2flag := ON;
      end
      else
      begin
        SetLightingState("Blind2Up", OFF);
        SetLightingState("Blind2DN", ON);
        blind2flag := OFF;
      end;
    end;
    
    {Blind2 RESET}
    once (GetLightingState("Blind2Sw") = OFF) then
    begin
      SetLightingState("Blind2DN", OFF);
      SetLightingState("Blind2UP", OFF);
    end;
    
    
     
    Last edited by a moderator: Apr 13, 2006
    coppo, Apr 13, 2006
    #1
  2. coppo

    Phil.H

    Joined:
    Jul 29, 2004
    Messages:
    466
    Likes Received:
    0
    Location:
    Sydney
    Can you imagine how tricky things would be without "once" for C-Bus related code.

    Darren - take the rest of the day off ;)
     
    Phil.H, Apr 13, 2006
    #2
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.