Hello friends.
Its been a while. I once posted a problem, where i wanded to read from one adress, that contained multiple information. For example adress 100 was listed in the documenation and contained multiple values:
ADR: 100.1 (bool value X)
ADR: 100.2 (bool value Y)
ADR: 100.3 (bool value Z) (and so on)
If someone want to read it: First project. Is Node-red the way to go
Here is my solution, how to read from an adress 100 that is splited into 6 "sub" adresses (100.1 , 100,2 ...)
[
{
"id": "c883412ea76f64d2",
"type": "modbus-flex-getter",
"z": "0c822967e78b69a8",
"name": "",
"showStatusActivities": false,
"showErrors": false,
"logIOActivities": false,
"server": "0e3ec676f3e39293",
"useIOFile": false,
"ioFile": "",
"useIOForPayload": false,
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 1630,
"y": 800,
"wires": [
[
"c3da37c4c8cd7d50",
"c14c540e23bfcdbc"
],
[]
]
},
{
"id": "c3da37c4c8cd7d50",
"type": "modbus-response",
"z": "0c822967e78b69a8",
"name": "",
"registerShowMax": 20,
"x": 1630,
"y": 860,
"wires": []
},
{
"id": "51c6209a18301ef8",
"type": "function",
"z": "0c822967e78b69a8",
"name": "Read_101",
"func": "msg.payload =\n{ value: msg.payload, \n'fc': 3, \n'unitid': 0, \n'address': 100, \n'quantity':1 \n \n} ;\nreturn msg",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1380,
"y": 800,
"wires": [
[
"c883412ea76f64d2"
]
]
},
{
"id": "a8b39931d1595820",
"type": "inject",
"z": "0c822967e78b69a8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "2",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1410,
"y": 940,
"wires": [
[
"51c6209a18301ef8"
]
]
},
{
"id": "c14c540e23bfcdbc",
"type": "buffer-parser",
"z": "0c822967e78b69a8",
"name": "",
"data": "payload",
"dataType": "msg",
"specification": "spec",
"specificationType": "ui",
"items": [
{
"type": "bool",
"name": "Remote_On_Off",
"offset": 1,
"length": 1,
"offsetbit": 0,
"scale": "1",
"mask": ""
},
{
"type": "bool",
"name": "Deaerating",
"offset": 1,
"length": 1,
"offsetbit": 1,
"scale": "1",
"mask": ""
},
{
"type": "bool",
"name": "AnalogueMode",
"offset": 1,
"length": 1,
"offsetbit": 2,
"scale": "1",
"mask": ""
},
{
"type": "bool",
"name": "TimerMode",
"offset": 1,
"length": 1,
"offsetbit": 3,
"scale": "1",
"mask": ""
},
{
"type": "bool",
"name": "SlowMode",
"offset": 1,
"length": 1,
"offsetbit": 4,
"scale": "1",
"mask": ""
},
{
"type": "bool",
"name": "Velocity",
"offset": 1,
"length": 1,
"offsetbit": 5,
"scale": "1",
"mask": ""
}
],
"swap1": "",
"swap2": "",
"swap3": "",
"swap1Type": "swap",
"swap2Type": "swap",
"swap3Type": "swap",
"msgProperty": "payload",
"msgPropertyType": "str",
"resultType": "keyvalue",
"resultTypeType": "return",
"multipleResult": false,
"fanOutMultipleResult": false,
"setTopic": true,
"outputs": 1,
"x": 1670,
"y": 960,
"wires": [
[
"58b5d9ecd58ba23f"
]
]
},
{
"id": "58b5d9ecd58ba23f",
"type": "debug",
"z": "0c822967e78b69a8",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 1890,
"y": 860,
"wires": []
},
{
"id": "0e3ec676f3e39293",
"type": "modbus-client",
"name": "CIM500",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "10.240.6.39",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": 1,
"commandDelay": 1,
"clientTimeout": 1000,
"reconnectOnTimeout": true,
"reconnectTimeout": 2000,
"parallelUnitIdsAllowed": true
}
]
My problem rn is, now kinda the same, but now i want to write to an adress that has "subadresses". For example, i want to write to the adress 101.1, I tried to find an answer and tested around to make it work, but i cant find a way to manage it. I am a bit confused ho to implement the buffer parser in the writing process. Thats what i have so far:
[
{
"id": "a49c5714d15ff31a",
"type": "modbus-flex-write",
"z": "0c822967e78b69a8",
"name": "",
"showStatusActivities": false,
"showErrors": false,
"server": "0e3ec676f3e39293",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 1510,
"y": 340,
"wires": [
[],
[
"363f74101ce7d6ce"
]
]
},
{
"id": "363f74101ce7d6ce",
"type": "modbus-response",
"z": "0c822967e78b69a8",
"name": "",
"registerShowMax": 20,
"x": 1530,
"y": 420,
"wires": []
},
{
"id": "a421342e3c0ce1b7",
"type": "inject",
"z": "0c822967e78b69a8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1020,
"y": 280,
"wires": [
[
"2c2bc60ddb01114a"
]
]
},
{
"id": "74f8ba5aded6e8ac",
"type": "inject",
"z": "0c822967e78b69a8",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 1060,
"y": 360,
"wires": [
[
"e9de7a7d92187b5b"
]
]
},
{
"id": "e9de7a7d92187b5b",
"type": "function",
"z": "0c822967e78b69a8",
"name": "0",
"func": "var fc=6;\nvar sa=100;\nvar addresses=1;\nvar value=0;\nmsg.slave_ip=\"10.240.6.39\";\nmsg.payload={\"value\":value , 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1310,
"y": 400,
"wires": [
[
"a49c5714d15ff31a"
]
]
},
{
"id": "2c2bc60ddb01114a",
"type": "function",
"z": "0c822967e78b69a8",
"name": "0",
"func": "var fc=6;\nvar sa=100;\nvar addresses=1;\nvar value=1;\nmsg.slave_ip=\"10.240.6.39\";\nmsg.payload={\"value\":value , 'fc': fc, 'unitid': 1, 'address': sa , 'quantity': addresses };\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1310,
"y": 300,
"wires": [
[
"a49c5714d15ff31a"
]
]
},
{
"id": "0e3ec676f3e39293",
"type": "modbus-client",
"name": "CIM500",
"clienttype": "tcp",
"bufferCommands": true,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "10.240.6.39",
"tcpPort": "502",
"tcpType": "DEFAULT",
"serialPort": "/dev/ttyUSB",
"serialType": "RTU-BUFFERD",
"serialBaudrate": "9600",
"serialDatabits": "8",
"serialStopbits": "1",
"serialParity": "none",
"serialConnectionDelay": "100",
"serialAsciiResponseStartDelimiter": "0x3A",
"unit_id": "1",
"commandDelay": "1",
"clientTimeout": "1000",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": true
}
]