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.