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.

modbus variable with 4 memory locations
#1
hi.

I currently have a meter that has a modbus variable with 4 memory locations, someone knows how I can convert that variable to 32 bit format or higher
Code:
-- init modbus on first script execution
if not mb then
    require('luamodbus')
    mb = luamodbus.rtu()
    mb:open('/dev/ttyS2', 9600, 'E', 8, 1, 'H')
    mb:connect()
end

-- sets slave ID to read/write data from/to
mb:setslave(20)

-- read 3-phase system voltage from 32-bit register
r1, r2 = mb:readregisters(0x1000, 2)
result = bit.lshift(r1, 16) + r2
grp.write('5/5/1',result)

-- read 3-phase system current from 32-bit register
r1, r2 = mb:readregisters(0x100E, 2)
result = bit.lshift(r1, 16) + r2
grp.write('5/5/2',result)

I was looking at this example, but I can not find out how I can do it 

thank you
Reply
#2
For ModBus the recommended approach is to use mapper with profiles. It supports all kind of numeric values up to 64 bits.
Reply
#3
Well, I'm new to this, you can explain to me how I could do that or if there is an example that I can take as a reference.
Reply
#4
Check this thread: https://forum.logicmachine.net/showthread.php?tid=839
Reply


Forum Jump: