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 register write command
#4
(12.02.2020, 08:15)admin Wrote: You will need a script to calculate final value by combining 3 objects together. Just make sure to use different group addresses for status and control otherwise you can produce an infinite loop.

Code:
onoff = grp.getvalue('1/1/1') -- fan on/off
direction = grp.getvalue('1/1/2') -- fan direction
speed = grp.getvalue('1/1/3') -- fan speed

value = bit.bor(
  onoff and 1 or 0,
  bit.lshift(bit.band(direction, 0x07), 8),
  bit.lshift(bit.band(speed, 0x07), 12)
)

grp.update('1/1/4', value)

Thanks so much. I will check it
Reply


Messages In This Thread
Modbus register write command - by kcw - 12.02.2020, 07:47
RE: Modbus register write command - by Daniel - 12.02.2020, 08:14
RE: Modbus register write command - by admin - 12.02.2020, 08:15
RE: Modbus register write command - by kcw - 12.02.2020, 10:07
RE: Modbus register write command - by Rajesh - 13.04.2022, 07:27
RE: Modbus register write command - by Daniel - 13.04.2022, 07:48
RE: Modbus register write command - by Daniel - 06.09.2023, 07:49
RE: Modbus register write command - by admin - 20.05.2024, 07:29

Forum Jump: