02.11.2018, 20:22
Thanks for your help, I got the script to work today. When I contacted AHU, I realized that it was the wrong values I received. There were inputs 95 and 96 that I needed to compare.
Here is the final working code:
it was as simple as that.
Here is the final working code:
Code:
require('luamodbus')
if not mb then
mb = luamodbus.tcp()
mb:open('192.168.201.53', 502)
mb:connect()
end
openvalue = grp.getvalue('6/3/1', dt.uint8)
tfvalue = mb:readinputregisters(94, dt.uint16) -- 3x0095 Supply air flow
ffvalue = mb:readinputregisters(95, dt.uint16) -- 3x0096 Exhaust air flow
if tfvalue and ffvalue == 0 then
openvalue = 0
end
if tfvalue < ffvalue then
if openvalue < 220 then
openvalue = openvalue + 25
end
end
if tfvalue > ffvalue then
if openvalue > 25 then
openvalue = openvalue - 25
end
end
grp.write('6/3/1', openvalue, dt.int8)
it was as simple as that.