Logic control in 12 way relays

Discussion in 'C-Bus Wired Hardware' started by max w, Feb 20, 2019.

  1. max w

    max w

    Joined:
    Sep 14, 2017
    Messages:
    24
    Likes Received:
    2
    Location:
    GB
    Ashley, thanks for your help! when I run the script I get the following error code. User script 8: attempt to call a table value stack trace back: userscript 8 in main chunk. It fails to log "got here"

    Thanks Max W
     
    max w, Mar 24, 2019
    #21
  2. max w

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Oops. Sorry, can't even copy my own code. The for statement was wrong. It should be paisr(boliers), not just boilers.


    Code:
    value = event.getvalue()
    if value == 255 then
        SetCBusState(0, 56, 12, true)
    end
    
    if value == 0 then
        boilers = GetCBusByKW('Boiler') -- Get table once outside of loop
        for _, group in pairs(boilers) do --  ***** ***********CHANGE THIS HERE *********************
             value = group.data.target
             if value ~= 0 then -- Don't need to continue once we find one on
                 break -- this exits from the loop
             end
        end
        if value == 0 then
            SetCBusState(0, 56, 12, false)
            log("got here")
        end
    end
    This is what I hate about Lua. Almost anything compiles but gives you meaningless run time errors.
     
    Ashley, Mar 25, 2019
    #22
  3. max w

    max w

    Joined:
    Sep 14, 2017
    Messages:
    24
    Likes Received:
    2
    Location:
    GB
    Ashley, thanks for all of your time and patience ! I have just altered the code and it works.
    But only when all of the UFH valve relays are on. If I have on relay off (UFH valve closed area temp satisfied) the boiler relay will intermittently pulse off and then back on. It seems like when the script I have running every 5 seconds to check the temperature and set point temperature. Thanks Max W
     
    max w, Mar 25, 2019
    #23
  4. max w

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Can't really help here as I can't see your other code :)
     
    Ashley, Mar 27, 2019
    #24
  5. max w

    max w

    Joined:
    Sep 14, 2017
    Messages:
    24
    Likes Received:
    2
    Location:
    GB
    Hi Ashley thanks fro all of your help. I ran your code and it works fine when the relays are operated by the edlt so my code is to blame. I have attached it. IM using a EDLT with a set point and a GA to adjust the set point up and down. This checks the actual temp and turns the relay on as required. But Im no expert there may be a better way to achieve this?
     

    Attached Files:

    max w, Mar 28, 2019
    #25
  6. max w

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    You need to have a dead band around your temperature setting. The temperature sensor will fluctuate slightly between reading, so when it's right at the set point it will continually go above and below the set point by a tiny amount and your code will continually turn the load on and off each 5 seconds. Generally 0.5 degrees is common, but you could reduce that depending on the fluctuations of the temperature reading.

    e.g.

    Code:
    if set_temp > temp1 then
    SetCBusLevel(0, 56, 1, 255, 0)
    elseif set_temp <= (temp1 - 0.5) then  -- deadband of 0.5 degrees.
     SetCBusLevel(0, 56, 1, 0, 0)
    end
    Are you duplicating all this for each zone ??
     
    Ashley, Mar 28, 2019
    #26
  7. max w

    max w

    Joined:
    Sep 14, 2017
    Messages:
    24
    Likes Received:
    2
    Location:
    GB
    Ashley, I have duplicated it for each zone, and have inputed the headband for each zone .
    the Boiler relay still still drops out if any one zone is not calling. But if all zones are demanding the valve to open it stays on. I seems to happen when the resident script sleeps. This is set at 10s at the moment but I planned to set it to 60s.
     
    max w, Mar 29, 2019
    #27
  8. max w

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    I suggest you run the cbus diagnostic routine while you are changing zones. It will tell you which unit is turning off the boiler relay. If it is the SHAC, post all the current code again.

    You could also put some more logging messages in your code to track what it is doing.
     
    Ashley, Apr 1, 2019
    #28
    max w likes this.
  9. max w

    max w

    Joined:
    Sep 14, 2017
    Messages:
    24
    Likes Received:
    2
    Location:
    GB
    Thanks for all of your help I will try that and report back.
     
    max w, Apr 2, 2019
    #29
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.