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
#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 Thumbnail(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
------------------------------
Ctrl+F5
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
#5
How to do AC on/off , fan speed and fan direction by using event script
Reply
#6
Add TAG to the 3 input groups and create event script triggered by this tag.
------------------------------
Ctrl+F5
Reply
#7
(13.04.2022, 07:48)Daniel Wrote: Add TAG to the 3 input groups and create event script triggered by this tag.
Can you clarify this place for me?
I don't know how to do this?
Reply
#8
All grp.getvalue objects in this scripts are inputs and they must have the TAG added. Later under Scripting, create event script which will be trigerred by this TAG you just created on input objects.
PS. bit mask write is supported on modbus profile now.
------------------------------
Ctrl+F5
Reply
#9
(06.09.2023, 07:49)Daniel Wrote: All grp.getvalue objects in this scripts are inputs and they must have the TAG added.  Later under Scripting, create event script which will be trigerred by this TAG you just created on input objects.
PS. bit mask write is supported on modbus profile now.
Hi Daniel,
With profile daiking DTA116, i just write On/off AC 1-00, set temp & Feedback Set temp, Room Temp and Mode operator, But i can't write fan speed & fan director because it is the same address with ON/OFF function, When i write value "1" Low level  ( fan speed) then AC 1-00 On, auto value "0" (fan
speed) then AC1-00 Off, so how i fix this problem. 

{
"manufacturer":"daikin",
"description":"Integration of Daikin Air Conditioners",
"mapping":[
{"name":"IDU1-00_On/Off","bus_datatype":"bool","datatype":"uint16","type":"register","address":2000,"writable": true,"value_bitmask": 0x1,"value_custom": {"0": "OFF", "1": "ON"}},
{"name":"IDU1-00_On/Off_FB","bus_datatype":"bool","datatype":"uint16","type":"inputregister","address":2000,"value_bitmask": 0x1,"value_custom": {"0": "OFF", "1": "ON"}},
{"name":"IDU1-00_Mode","bus_datatype":"5","datatype":"uint8","type":"register","address":2001,"writable": true,"value_bitmask": 0xF,"value_custom": {"0": "Fan", "2": "Cooling", "7": "Dry"}},
{"name":"IDU1-00_Mode_FB","bus_datatype":"5","datatype":"uint8","type":"inputregister","address":2001,"value_bitmask": 0xF,"value_custom": {"0": "Fan", "2": "Cooling", "7": "Dry"}},
{"name":"IDU1-00_Fan","bus_datatype":"5","datatype":"uint8","type":"register","address":2000,"writable": true,"value_bitmask": 0x7000,"value_custom": {"0": "Auto", "1": "Low", "3": "Mid", "5": "High"} },
{"name":"IDU1-00_Fan_FB","bus_datatype":"5","datatype":"uint8","type":"inputregister","address":2000,"value_bitmask": 0x7000,"value_custom": {"0": "Auto", "1": "Low", "3": "Mid", "5": "High"} },
{"name":"IDU1-00_SetTemp","bus_datatype":"9","datatype":"uint16","type":"register","address":2002,"writable": true, "value_multiplier": 0.1,"units": "°C" },
{"name":"IDU1-00_SetTemp_FB","bus_datatype":"9","datatype":"uint16","type":"inputregister","address":2002, "value_multiplier": 0.1, "units": "°C" },
{"name":"IDU1-00_RoomTemp_FB","bus_datatype":"9","datatype":"float16","type":"inputregister","address":2004, "value_multiplier": 10, "units": "°C" },
{"name":"IDU1-00_Fan director","bus_datatype":"5","datatype":"uint8","type":"register","address":2000,"writable": true,"value_bitmask": 0x700,"value_custom": {"0": "P0", "4": "P4", "7": "Swing on" } },
{"name":"IDU1-00_Fan director_FB","bus_datatype":"5","datatype":"uint8","type":"inputregister","address":2000,"value_bitmask": 0x700,"value_custom": {"0": "P0", "4": "P4", "7": "Swing on" } }
]
}
Reply
#10
You need to add "write_bitmask": true to relevant mapping entries.
Reply


Forum Jump: