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.

On time delay
#1
Hi.

i don't figure out the soulution for a on delay script. 
so i would appreciate some guidance here Angel

task:
if value is higher than 10 for a constant 1800 sekonds then it send true signal.


if 10 > (spjeldvinkel_setpoint * spjeldvinkel_feedback / 100) then
  grp.write('14/2/1', true)
else 
  grp.write('14/2/1', false)


- Frank
Reply
#2
First, create an event script attached to your setpoint and feedback objects (replace 1/1/1 and 1/1/2 with your group addresses):
Code:
setpoint = grp.getvalue('1/1/1')
feedback = grp.getvalue('1/1/2')
value = setpoint * feedback / 100

if value <= 10 then
  storage.set('timer', os.time())
end

Then, create a resident script with 30 or 60 second sleep time (or you can use a scheduled script that runs every minute):
Code:
delta = os.time() - storage.get('timer', 0)
value = delta >= 1800
grp.checkwrite('14/2/1', value)
Reply
#3
Thanks!
After some hours i beginning to understand the programming in lua Smile

and now i have been trying to solve next case on this script that accured.

when i get e new value on feedback or setpoint input, the script sends out a "false" and start counting all over.
How do i get it to hold the value (True orfalse) and only send by change of the output?
And when in false state it sends out evry second since it dosen't send by change
Reply
#4
Can you explain the whole algorithm of your task then?
Reply
#5
1 reed feedback %
2 reed setpoint %
3 calculate to se if its over or under 10 % diffrence

4 if <= 10 % send false
5 If >= 10 % more than 30 minuts send true

and only send by change so it dont't jam the knx bus
Reply
#6
That's what the script is already doing, except that it expects at least one telegram from setpoint or feedback object in 30 minutes. You can set poll interval for one of these objects to ensure that timer is updated via event script. grp.checkwrite ensures that only new value is sent to the bus.

Or you can use a single resident script (set sleep interval to at least 5 seconds or more) without event scripts. This way some status feedback can be missed, but I don't think that it will make much difference.
Code:
setpoint = grp.getvalue('1/1/1')
feedback = grp.getvalue('1/1/2')
value = setpoint * feedback / 100

if value <= 10 then
  timer = nil

  if out then
    out = false
    grp.write('14/2/1', false)
  end
else
  if timer then
    delta = os.time() - timer

    if delta >= 1800 and not out then
      out = true
      grp.write('14/2/1', true)
    end
  else
    timer = os.time()
  end
end
Reply


Forum Jump: