Logic Machine Forum
Modbus bit control over script - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Modbus bit control over script (/showthread.php?tid=1744)



Modbus bit control over script - Thinklight - 23.11.2018

Hi,
Same ideas how can I control Modbus bit over script. Reading works for mee so I need write commands over Event script.

Code:
local adr1001 = mb:readregistervalue(1001, 'uint16')
grp.write('32/5/52', bit.band(bit.rshift(adr1001,8),0x1), dt.bool)  -- Baseino filtravimo laikmatis jei abu isjungti
grp.write('32/5/53', bit.band(bit.rshift(adr1001,9),0x1), dt.bool)  -- Filtravimas vyksta istisai
grp.write('32/5/54', bit.band(bit.rshift(adr1001,10),0x1), dt.bool)     --Vonios filtravimo laikmatis jei abu isjungti
grp.write('32/5/55', bit.band(bit.rshift(adr1001,11),0x1), dt.bool)     --Filtravimas vyksta istisai
   


RE: Modbus bit control over script - Daniel - 23.11.2018

Hi
As long it is register you have to build back the 2 byte and send it as register. Usually bit control is done via coil.
BR


RE: Modbus bit control over script - admin - 23.11.2018

You should also use modbus mapper proxy functions if you want to access same RS485 port from several scripts. Otherwise you will get random access errors. https://forum.logicmachine.net/showthread.php?tid=387&pid=1953#pid1953