Logic Machine Forum
Delay for DALI ! - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: Delay for DALI ! (/showthread.php?tid=2665)

Pages: 1 2


RE: Delay for DALI ! - admin - 04.01.2021

DALI bus is slow so you should minimize the number of requests. If you want to update two objects at once better do it like this:
Code:
function queryactual(short, addr1, addr2)
  local res, err = dalicmd('internal', 'queryactual', { addrtype = 'short', address = short })
  if res then
    local val = res:byte()
    if val > 0 then
      val = math.floor(val / 2.54 + 0.5)
      val = math.max(1, val)
    end
    grp.checkupdate(addr1, val)
    grp.checkupdate(addr2, val)
  end
end

queryactual(0, '1/1/0', '1/2/0')

You should also add at least one second delay between queries otherwise you will overload the DALI bus.


RE: Delay for DALI ! - davidchispas - 05.01.2021

(04.01.2021, 10:58)admin Wrote: DALI bus is slow so you should minimize the number of requests. If you want to update two objects at once better do it like this:
Code:
function queryactual(short, addr1, addr2)
  local res, err = dalicmd('internal', 'queryactual', { addrtype = 'short', address = short })
  if res then
    local val = res:byte()
    if val > 0 then
      val = math.floor(val / 2.54 + 0.5)
      val = math.max(1, val)
    end
    grp.checkupdate(addr1, val)
    grp.checkupdate(addr2, val)
  end
end

queryactual(0, '1/1/0', '1/2/0')

You should also add at least one second delay between queries otherwise you will overload the DALI bus.

Thanks Admin, what is more advisable not to saturate the dali bus? make a query script for each group of ballasts, or make a single script for all ballasts?

I understand that if 10 scripts are executed every 3-5 seconds at a time it is worse, right?


RE: Delay for DALI ! - admin - 05.01.2021

Single script is better because you can control the delay between each polling. The easiest way is just to add sleep after each queryactual call.


RE: Delay for DALI ! - davidchispas - 13.01.2021

Hello, in the Dali controls, having a minimum physical regulation value, the regulation bar is always at very high values, since I have a status object associated with it.
To fix this, I have created a script to fool my client.

In this case, I have a ballast with a minimum physical value of 161 which is 63%. This tells us that we have 37% regulation.

1- I made this script so that my control object, when I send 1%, actually send the value 63% and from there the final result would increase until it reaches 100%.

2- I have created another status script, which does the same calculation but in reverse.

My problem here is that the calculations are not exactly identical in one script and the other, with a minimal difference due to the decimals.

Surely there is another way to achieve this ... can you help me?


Control object% visu (1/3/9)
Status object% visu (1/4/9)
Ballast control object (1/5/9)
Ballast Status Object (1/6/9)





Control script (1/3/9)
Code:
--Minimum physical value of ballast
VFM = 63

--Regulation output object
VReg= '1/5/9'

------------------------------------
value = event.getvalue()

OP1 = (100-VFM)/100
OP2 = (value*OP1)+VFM

if value==0 then
  grp.write(VReg, 0)
elseif value>=1 then
  grp.write(VReg, OP2)
end


State script (1/6/9)
Code:
--Minimum physical value of ballast
VFM = 63

--Regulation output object
VReg= '1/4/9'

------------------------------------
value = event.getvalue()

OP1 = (100-VFM)/100
OP2 = (value-VFM)/OP1

if value == VFM then
  grp.write(VReg, 1)
elseif value ~= VFM then
  grp.write(VReg, OP2)
end



RE: Delay for DALI ! - Daniel - 13.01.2021

Try rounding it y = math.floor(x + 0.5)