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.

Split Modbus register
#1
Hello all,

I need to split a Modbus register to different bits as you can see from the attached manual starting at page 5 for register 0x0107.
Below the script so far. For example register 0x0107 pH status now returns a number which makes sense as it need to be split to different bits i assume.

Modbus Manual

Code:
require('luamodbus')
mb = luamodbus.rtu()
mb:open('/dev/RS485', 19200, 'N', 8, 1, 'H')
mb:connect()
mb:setslave(1)

--Hydrolyse Percentage
value = mb:readregisters(0x0101)
if value then
    value = value * 0.1
    --log(value)
    grp.write('10/0/1', value)
end

--pH waarde
value = mb:readregisters(0x0102)
if value then
    value = value * 0.01
    --log(value)
    grp.write('10/0/2', value)
end

--Rx waarde
value = mb:readregisters(0x0103)
if value then
  --log(value)
    grp.write('10/0/3', value)
end

--pH status
value = mb:readregisters(0x0107)
if value then
  --log(value)
    grp.write('10/0/4', value)
end
 
--Rx status
value = mb:readregisters(0x0108)
if value then
  --log(value)
    grp.write('10/0/5', value)
end
 
--Water temperatuur
value = mb:readregisters(0x0106)
if value then
  value = value * 0.1
    --log(value)
    grp.write('10/0/6', value)
end
 
mb:close()
Reply


Messages In This Thread
Split Modbus register - by Joep - 26.04.2023, 13:07
RE: Split Modbus register - by Daniel - 26.04.2023, 13:40
RE: Split Modbus register - by Joep - 26.04.2023, 14:01
RE: Split Modbus register - by Daniel - 26.04.2023, 14:05

Forum Jump: