buscouplers, relays and PAC programming

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by Neil C, Aug 27, 2007.

  1. Neil C

    Neil C

    Joined:
    Jun 27, 2007
    Messages:
    46
    Likes Received:
    0
    I have been set the task of controlling a heating system. The inputs will come from various channels of bus couplers, and the outputs will be the control of relays, which actuate various pumps. These pumps need to be switched on and off according to the status of the inputs. It appears that I will have to provide some custom code via a Pascal controller in order to do this.

    Switching the relays on is fairly straight-forward, as when any bus coupler raises a signal, then the various relays which that bus coupler channel require can be actuated on. (Question, - is it right to use the ?Once? statement within the Pascal controller to detect this change of state of the Bus Coupler channel?). Some of the relays may already be on, but sending another on signal won?t cause any problems.

    However, where the problem will lie, is when a bus coupler channel goes off, and the various relays associated with that channel need to be turned off. The difficulty is that there may be other bus coupler channels on, which share some of those relays, and so these relays need to remain activated. It is therefore not just a question of turning off all the relays associated with that bus coupler channel. What I think is required is some kind of Pascal code which examines the current levels of the inputs from various bus couplers, and then only switches off the relays required. Can anybody please tell me what Pascal code is needed to examine the current levels of the bus coupler channels?


    Once these levels have been determined, I would imagine that this is possible using various ?if? and ?and? statements. For example (using semi-formal english rather than Pascal code), -

    if bus cup channel 1 is off, and bus cup channel 2 if off, and bus cup channel 3 is off, then switch off relays 123, 123, and 125;

    else if bus cup channel 1 is off and bus cup channel 2 is off, then switch off relays 123 and 124,

    else ... (etc, etc).

    Does this look correct and feasible? If it is not, then does anybody have any suggestions on how it can be done?

    Another question which arises is that when creating the code with the Pascal controller, it appears to not support the continuous running of programs, which in conventional Pascal would be achieved by simply running a continuous loop. As the Pascal controller is running continuously, does the use of ?once? statements get around this problem?


    So, to summarise, if anybody could answer the following questions, it would be greatly appreciated:

    (1) Is the use of the ?once? statement in order to find detect changes in state of the bus coupler channels correct?

    (2) What code is needed to examine the current levels of the outputs of the bus couplers?

    (3) Does the combination of various ?if? and ?and? statements appear possible, in order to switch off only those relays required?

    (4) Will the use of ?once? statements provide a mechanism which avoids the continual looping of Pascal code, by activating the various ?if? and ?and? statements only when there is a change in state of the bus coupler inputs?


    Any comments and suggestions would be most gratefully received
     
    Neil C, Aug 27, 2007
    #1
  2. Neil C

    Ianr

    Joined:
    Aug 26, 2005
    Messages:
    36
    Likes Received:
    0
    Location:
    Wellington, NZ
    Once statements

    Hi Neil,

    Have a look in the help files pertaining to the use of ONCE statements. Sometimes a ONCE statement can be missed. I only use a ONCE statement when using code internal to the PACA. It is better to use an IF statement and compare a measured parameter to a stored value i.e.

    BUS_COUPLER := GetLightingState("BusCoupler");

    If (BUS_COUPLER <> BUS_COUPLER_STORED) then
    begin
    BUS_COUPLER_STORED := BUS_COUPLER;
    if (BUS_COUPLER = ON) then

    ....
    end;

    The code will only be executed when there is a change in state and prevent running of unnecessary IF statements.

    (You do not have to use GetLightingState you can use GetLightingLevel).

    Also if you are going to use a lot of else if's under a single if statement, read up on the use of the CASE statement.

    I see no problem with the use of If and AND statements, dependent on the size of the code you may get run time errors if you have a lot of AND statements that are run every cycle of code. The help files in PICED when in the Logic programming screen are very helpful.
     
    Ianr, Sep 3, 2007
    #2
  3. Neil C

    Neil C

    Joined:
    Jun 27, 2007
    Messages:
    46
    Likes Received:
    0
    Thanks for your answer to my query, it has clarified one or two things for me. However, I'm a little surprised to hear you say that sometimes the "once" statements can get missed. I thought that the change of state of an item made the Pascal Controller execute the once statement, - is this not the case? I also thought that use of the once statement avoided the continual transmission down the Cbus network several times a second, of an "if" statement. Have I got this wrong?

    Many thanks
    Neil C
     
    Neil C, Sep 9, 2007
    #3
  4. Neil C

    paulw11

    Joined:
    Dec 4, 2006
    Messages:
    93
    Likes Received:
    0
    Location:
    Blue Mountains, NSW, Australia
    Can you use output channel logic?

    Hi,

    You don't give the full details of your logic, but if all that is required is simple AND or OR logic then you may be able to use the logic capabilities in the relay modules.

    Paul
     
    paulw11, Sep 9, 2007
    #4
  5. Neil C

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    You will only miss a transition if the condition goes from true to false and back to true again in between two "scans". Since scans happen every 200ms, it would have to be a very sudden change to get missed.

    This is the case, subject to the above.

    The "once" statement is generally used to prevent the situation you can get with using an "if" statement where you send the same C-Bus commands on every scan, which is a Very Bad Thing.

    No.
     
    Darren, Sep 10, 2007
    #5
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.