Logic Machine Forum
Modbus register write command - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Gateway (https://forum.logicmachine.net/forumdisplay.php?fid=10)
+--- Thread: Modbus register write command (/showthread.php?tid=2464)



Modbus register write command - kcw - 12.02.2020

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.


RE: Modbus register write command - Daniel - 12.02.2020

Hi, Input registers are read only anyway. Check if they can be written at all. If yes fallow this
https://forum.logicmachine.net/showthread.php?tid=1922&pid=11915#pid11915


RE: Modbus register write command - admin - 12.02.2020

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)



RE: Modbus register write command - kcw - 12.02.2020

(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


RE: Modbus register write command - Rajesh - 13.04.2022

How to do AC on/off , fan speed and fan direction by using event script


RE: Modbus register write command - Daniel - 13.04.2022

Add TAG to the 3 input groups and create event script triggered by this tag.


RE: Modbus register write command - TranVanHieu - 06.09.2023

(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?


RE: Modbus register write command - Daniel - 06.09.2023

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.


RE: Modbus register write command - Votrungtin - 17.05.2024

(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" } }
]
}


RE: Modbus register write command - admin - 20.05.2024

You need to add "write_bitmask": true to relevant mapping entries.