delayed turn off of relay

Discussion in 'C-Bus Wired Hardware' started by kojobomb, Sep 21, 2021.

  1. kojobomb

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    73
    Likes Received:
    6
    Location:
    Possum Brush
    I'm using a relay channel and an analogue output unit in unison to control a 0-10v controlled Big Ass Fan.
    On the Edlt lighting application for the fan I've got the nudge up/down at 17%, which gives 6 distinct fan speeds and a relay channel set to turn off at 2% so that when fan speed is set to 0% the standby power supply to the fan is disconnected.
    How can i set a delay for the relay to switch state after percentage drops below 2%?
    The fan makes a awfully loud clunk when power is disconnected when blades are still spinning and I would like to delay the relay off state for about 3-5 minutes.
     
    kojobomb, Sep 21, 2021
    #1
  2. kojobomb

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    this could be done with some code, do you have any logic engine in your system? if so what sort etc
     
    Pie Boy, Sep 21, 2021
    #2
  3. kojobomb

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    73
    Likes Received:
    6
    Location:
    Possum Brush
    I have a shac in the system but have not progressed in to any logic code and need to find a guide/video/information so i can dive into logic code do you have any suggestions that would lead me down the right path?
     
    kojobomb, Sep 21, 2021
    #3
  4. kojobomb

    Pie Boy

    Joined:
    Nov 21, 2012
    Messages:
    248
    Likes Received:
    31
    Location:
    New Zealand
    I think this might be what you need although untested, i would run it up on a spare shac and play it like a video game to see if its what you need before testing on site etc

    1- create user parameter 'Fan Timeout off' with data type uint(32bit)

    2- create an event script (below) on the GA which is in the 0-10v output unit that stores the time at the time of event is 2%

    local level = CBusLevelToPct(event.getvalue())
    local fan_time = GetUserParam(0, 'Fan Timeout off')

    -- store the value os.time() into user parameter 'Fan Timeout off' at event when percentage of 0-10v output unit Ga is 2% or less
    if level <= 2 then
    SetUserParam(0, 'Fan Timeout off', os.time())
    log('timer started')
    else
    if fan_time ~= 1 then SetUserParam(0, 'Fan Timeout off', 1)
    log('timer stopped if was running')
    end

    end

    3- a resident script that checks when time is past/expired set resolution(aka sleep interval) to 30 sec.
    The lower the resolution the more shac cpu resource will be used, as you increase resolution cpu load will decrease but so will your timer accuracy if you set to 30 sec you will be accurate at worst 30 sec past the actual timeout time you specify, it just depends when in the cycle of a minute the timer starts.
    so if you say 3 min worst it would be 3.5 min etc, you can make it finer resolution but it will increase cpu load on shac. in this case i don't think it needs to be approximate.

    -- resident script with 30 sec resolution
    local now_time = os.time()
    local timeout = GetUserParam(0, 'Fan Timeout off')

    if now_time >= timeout + 60*3 then -- 60*3 = 3 min -- time in secounds

    if timeout ~= 1 then
    SetUserParam(0, 'Fan Timeout off', 1) -- this resets the value in the user parameter for next time

    -- switch off your fan relay here uncomment change tag name to suit etc
    --SetLightingState('fan relay', false)
    log('Timer expiry' switching off fan relay')
    end

    end
     
    Last edited: Sep 23, 2021
    Pie Boy, Sep 23, 2021
    #4
  5. kojobomb

    Ashley

    Joined:
    Dec 1, 2005
    Messages:
    1,524
    Likes Received:
    173
    Location:
    Adelaide, Australia
    Seems a little complex :)

    Put the fan on it's own ga so the switch doesn't control it.

    Then create an event script on the light ga with the following code: (the 99 is the fan ga)

    if event.getvalue() > 3 then
    SetCBusState(0, 56, 99, true) -- Make sure fan on
    elseif GetCBusState(0, 56, 99) then -- Fan on?
    SetCBusLevel(0, 56, 99, 0, 300) -- Ramp to off over 5 minutes
    end

    That's it.

    The script is called everytime the light level changes.
    If the light is on, it makes sure the fan is on.
    If the light goes below 3 and the fan is running, it ramps the relay off over 5 minutes.
    If the light is turned on again, the relay will be set back to ON and the ramp cancelled automatically.
     
    Ashley, Sep 23, 2021
    #5
  6. kojobomb

    kojobomb

    Joined:
    May 27, 2019
    Messages:
    73
    Likes Received:
    6
    Location:
    Possum Brush
    Thank you both for your support, i will try and implement and let you know how i go.
     
    kojobomb, Sep 25, 2021
    #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.