This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Help example on simple light controll, lux
#11
Hello Admin,

I have a project where I want to use the script below to do a simple light control in steps. Can you please help me to achieve the same functionality but for multiple lights groups.
This will be a resident script with sleep time 10sec. I was thinking if I can create a table to map all variables and then a function to execute every 10sec. Or any better idea

Code:
------Global Settings--------- min = 10 max = 100 hysteresis = 20 --------Light Group 1--------- local current = grp.getvalue('3/0/11')    --Area Lux Value local setpoint = grp.getvalue('3/1/11')    --Area Lux Setpoint Value local output = '3/3/11'            --Dim output local active = grp.getvalue('0/0/211')    --Light Control is active or not local disv = grp.getvalue('2/4/11')    --Status dim value local deltasc = setpoint - current             local deadband = math.abs(deltasc) < hysteresis local diva_up = disv + 5 local diva_down = disv - 5 local diva_up = math.min(diva_up, max) local diva_down = math.max(diva_down, min) if active and not deadband then   if disv ~= 0 then       if current < setpoint then     grp.checkwrite(output, diva_up)     elseif current > setpoint then     grp.checkwrite(output, diva_down)     end    end end --------Light Group 2---------- local current = grp.getvalue('3/0/12') local setpoint = grp.getvalue('3/1/12') local output = '3/3/12' local active = grp.getvalue('0/0/212') local disv = grp.getvalue('2/4/12') local deltasc = setpoint - current local deadband = math.abs(deltasc) < hysteresis local    diva_up = disv + 5 local    diva_down = disv - 5 local diva_up = math.min(diva_up, max) local diva_down = math.max(diva_down, min) if active and not deadband then   if disv ~= 0 then       if current < setpoint then     grp.checkwrite(output, diva_up)     elseif current > setpoint then     grp.checkwrite(output, diva_down)     end    end end

Thank you in advance.
Reply


Messages In This Thread
RE: Help example on simple light controll, lux - by manos@dynamitec - 28.03.2024, 09:42

Forum Jump: