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 whether you accept or reject these cookies being set.

Modbus register write command
#1
Hi,

I'm writing the modbus interface to Daikin VRF. I have finished and checked with the virtual modbus slave software with the input register with the modbus profile that i create as follow.

{
  "manufacturer": "Daikin",
  "description": "Daikin VRV 1-00",
  "mapping": [

{ "name": "1-00 A/C Control-Read", "bus_datatype": "bool", "type": "inputregister", "address": 2001, "writable": 0, "datatype": "uint16", "value_bitmask": 0x01, "value_custom": {"0": "Off", "1": "On" } },
{ "name": "1-00 A/C Control-Write", "bus_datatype": "bool", "type": "register", "address": 2001, "writable": true, "datatype": "uint16", "value_bitmask": 0x01, "value_custom": {"0": "Off", "1": "On" } },
{ "name": "1-00 Swing-Read", "bus_datatype": "uint16", "type": "inputregister", "address": 2001, "writable": 0, "datatype": "uint16", "value_bitmask": 0x700, "value_custom": {"0": "P0", "1": "P1", "2": "P2", "3": "P3", "4": "P4", "6": "Swing stop", "7": "Swing on" } },
{ "name": "1-00 Swing-Write", "bus_datatype": "uint16", "type": "register", "address": 2001, "writable": true, "datatype": "uint16", "value_bitmask": 0x700, "value_custom": {"0": "P0", "1": "P1", "2": "P2", "3": "P3", "4": "P4", "6": "Swing stop", "7": "Swing on" } },
{ "name": "1-00 Fan Speed-Read", "bus_datatype": "uint16", "type": "inputregister", "address": 2001, "writable": 0, "datatype": "uint16", "value_bitmask": 0x7000, "value_custom": {"1": "Low", "3": "Medium", "5": "High" } },
{ "name": "1-00 Fan Speed-Write", "bus_datatype": "uint16", "type": "register", "address": 2001, "writable": true, "datatype": "uint16", "value_bitmask": 0x7000, "value_custom": {"1": "Low", "3": "Medium", "5": "High" } },
{ "name": "1-00 Operation Mode-Read ", "bus_datatype": "uint16", "type": "inputregister", "address": 2002, "writable": 0, "datatype": "uint16", "value_bitmask": 0xF, "value_custom": {"0": "Fan", "1": "Heating", "2": "Cooling", "3": "Auto ", "7": "Dry" } },
{ "name": "1-00 Operation Mode-Write ", "bus_datatype": "uint16", "type": "register", "address": 2002, "writable": true, "datatype": "uint16", "value_bitmask": 0xF, "value_custom": {"0": "Fan", "1": "Heating", "2": "Cooling", "3": "Auto ", "7": "Dry" } },
{ "name": "1-00 Filter Alarm-Read ", "bus_datatype": "bool", "type": "inputregister", "address": 2002, "writable": 0, "datatype": "uint16", "value_bitmask": 0xF0, "value_custom": {"0": "Normal", "1": "Alarm", "2": "Alarm", "3": "Alarm", "4": "Alarm", "5": "Alarm", "6": "Alarm", "7": "Alarm", "8": "Alarm", "9": "Alarm", "10": "Alarm", "11": "Alarm", "12": "Alarm", "13": "Alarm", "14": "Alarm", "15": "Alarm" } },
{ "name": "1-00 Filter Alarm-Write ", "bus_datatype": "bool", "type": "register", "address": 2002, "writable": true, "datatype": "uint16", "value_bitmask": 0xF0, "value_custom": {"0": "Normal", "1": "Alarm", "2": "Alarm", "3": "Alarm", "4": "Alarm", "5": "Alarm", "6": "Alarm", "7": "Alarm", "8": "Alarm", "9": "Alarm", "10": "Alarm", "11": "Alarm", "12": "Alarm", "13": "Alarm", "14": "Alarm", "15": "Alarm" } },
{ "name": "1-00 Room Temperature Setpoint-Read", "bus_datatype": "float16", "type": "inputregister", "address": 2003, "writable": 0, "datatype": "int16", "value_multiplier": 0.1, "units": "°C" },
{ "name": "1-00 Room Temperature Setpoint-Write", "bus_datatype": "float16", "type": "register", "address": 2003, "writable": true, "datatype": "int16", "value_multiplier": 0.1, "units": "°C" },
{ "name": "1-00 Actual Room Temperature", "bus_datatype": "float16", "type": "inputregister", "address": 2005, "writable": 0, "datatype": "int16", "value_multiplier": 0.1, "units": "°C" }

  ]
}


All "inputregister" are working fine with bit mask, however all failed in command output.
I have check the previous post that the Bitmasks are supported for reading only. How can I write script for bitmasks writing?

I use 1/1/1 for on/off, 1/1/2 for fan direction and 1/1/3 for fan speed. The protocol table for those points is attached.

Thanks in advance.

Attached Files Image(s)
   
Reply
#2
Hi, Input registers are read only anyway. Check if they can be written at all. If yes fallow this
https://forum.logicmachine.net/showthrea...5#pid11915
Reply
#3
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)
Reply
#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


Forum Jump: