Good afternoon
I have a Modbus calorie meter connected to the RS485-2 port of my LM5pL and I would like to know how I have to do it to read 32bit values in Modbus RTU using scripts, thank you very much.
THX.
Hello again, I try to communicate using this code, I can read something but I don't know if it's correct, thank you
I have a Modbus calorie meter connected to the RS485-2 port of my LM5pL and I would like to know how I have to do it to read 32bit values in Modbus RTU using scripts, thank you very much.
THX.
Hello again, I try to communicate using this code, I can read something but I don't know if it's correct, thank you
Code:
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485-2', 2400, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(44)
res101 = mb:readregisters(1)
if res101 == nil then
grp.update('32/2/1', 0)
else
grp.update('32/2/1', res101*0,01)
end
os.sleep(1)
res102 = mb:readregisters(2)
if res102 == nil then
grp.update('32/2/2', 0)
else
grp.update('32/2/2', res102*0,01)
end
os.sleep(1)
res103 = mb:readregistervalue(3, "uint32")
grp.update('32/2/3', res103)
os.sleep(1)
res105 = mb:readregistervalue(5, "uint32")
grp.update('32/2/5', res105)
os.sleep(1)
res107 = mb:readregistervalue(7, "uint32")
grp.update('32/2/7', res107)
os.sleep(1)
res109 = mb:readregistervalue(9, "uint32")
grp.update('32/2/9', res109)
os.sleep(1)
res113 = mb:readregisters(13)
grp.update('32/2/13', res113)
os.sleep(1)
res114 = mb:readregistervalue(14, "uint32")
grp.update('32/2/14', res114)
os.sleep(1)
res116 = mb:readregistervalue(16, "uint32")
grp.update('32/2/16', res116)
os.sleep(1)
res118 = mb:readregistervalue(18, "uint32")
grp.update('32/2/18', res118)
os.sleep(1)
res120 = mb:readregisters(20)
grp.update('32/2/20', res120)
os.sleep(1)
mb:close()
mb:open('/dev/RS485-2', 2400, 'E', 8, 1, 'H')
mb:connect()
mb:setslave(45)
res201 = mb:readregisters(1)
if res201 == nil then
grp.update('32/3/1', 0)
else
grp.update('32/3/1', res201*0,01)
end
os.sleep(1)
res202 = mb:readregisters(2)
if res202 == nil then
grp.update('32/3/2', 0)
else
grp.update('32/3/2', res202*0,01)
end
os.sleep(1)
res203 = mb:readregistervalue(3, "uint32")
grp.update('32/3/3', res203)
os.sleep(1)
res205 = mb:readregistervalue(5, "uint32")
grp.update('32/3/5', res205)
os.sleep(1)
res207 = mb:readregistervalue(7, "uint32")
grp.update('32/3/7', res207)
os.sleep(1)
res209 = mb:readregistervalue(9, "uint32")
grp.update('32/3/9', res209)
os.sleep(1)
res213 = mb:readregisters(13)
grp.update('32/3/13', res213)
os.sleep(1)
res214 = mb:readregistervalue(14, "uint32")
grp.update('32/3/14', res214)
os.sleep(1)
res216 = mb:readregistervalue(16, "uint32")
grp.update('32/3/16', res216)
os.sleep(1)
res218 = mb:readregistervalue(18, "uint32")
grp.update('32/3/18', res218)
os.sleep(1)
res220 = mb:readregisters(20)
grp.update('32/3/20', res220)
os.sleep(1)
mb:close()