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 8bit low and high
#1
Hi,

how can I create a profile (or a Script ) to read and write this modbus word (Register 21) ?




BR,
Alberto
KNX Advanced Partner + Tutor
Reply
#2
Try this, you may need to subtract -1 from the register.
Code:
if not mb then
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 9600, 'E', 8, 1, 'H')
mb:connect()
end


mb:setslave(1)

value = mb:readregisters(21)
address = bit.rshift(value, 8)
baudrate = value-address*256

log(address,baudrate)

newaddress = 2
newbaudrate = 1
reg=newaddress*256 + newbaudrate

mb:writeregisters(21, reg)
------------------------------
Ctrl+F5
Reply


Forum Jump: