Hello,
I need to send a string of information to a Modbus device; They can be numbers from 1000 (decimal) to 120000, so the device receives 32 bits of information for each DWORD.
I have tried with Modbus TCP Node and with the one I am most interested in using the Modbus Flex-Write Node.
In neither of the two, I get it to send the value to the device correctly, if this value is greater than 65535. If it is less than this value, there is no error.
These are the examples I try to use, but none of them have worked for me with values greater than 65535...
Can you help me, please?
{
"id": "35e959d48dc8655d",
"type": "tab",
"label": "Flow",
"disabled": false,
"info": "",
"env": []
},
{
"id": "38ac22caa29e1daf",
"type": "change",
"z": "35e959d48dc8655d",
"name": "dest / msj",
"rules": [
{
"t": "set",
"p": "info",
"pt": "msg",
"to": "[msg.values]",
"tot": "jsonata",
"dc": true
},
{
"t": "set",
"p": "unit",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "varfc",
"pt": "msg",
"to": "16",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 80,
"wires": [
[
"bde50e161ba0fe7f"
]
]
},
{
"id": "bde50e161ba0fe7f",
"type": "function",
"z": "35e959d48dc8655d",
"name": "",
"func": "msg.payload = {};\nlet fc = msg.varfc;\nlet unitid = msg.unit;\nlet address = (~~msg.address);\nlet quantity = (~~msg.quantity);\nlet value = msg.info;\nmsg.payload = { value, fc, unitid, address, quantity};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 80,
"wires": [
[
"eb99819e101cb7cb"
]
]
},
{
"id": "eb99819e101cb7cb",
"type": "modbus-flex-write",
"z": "35e959d48dc8655d",
"name": "EscribeWords",
"showStatusActivities": false,
"showErrors": true,
"server": "e0c17133825e418c",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 680,
"y": 80,
"wires": [
[
"e6540f68d7783118"
],
[
"e6540f68d7783118"
]
]
},
{
"id": "e258bd3fbf593bab",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "address",
"v": "90",
"vt": "num"
},
{
"p": "quantity",
"v": "3",
"vt": "num"
},
{
"p": "values",
"v": "[90000,4000,20000]",
"vt": "jsonata"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 80,
"wires": [
[
"38ac22caa29e1daf"
]
]
},
{
"id": "e6540f68d7783118",
"type": "debug",
"z": "35e959d48dc8655d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 80,
"wires": []
},
{
"id": "710721c2c539be7e",
"type": "change",
"z": "35e959d48dc8655d",
"name": "dest / msj",
"rules": [
{
"t": "set",
"p": "info",
"pt": "msg",
"to": "$split(msg.values, \",\")",
"tot": "jsonata",
"dc": true
},
{
"t": "set",
"p": "unit",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "varfc",
"pt": "msg",
"to": "16",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 160,
"wires": [
[
"1be7836081fb0345"
]
]
},
{
"id": "2daae39b1cfacc91",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "address",
"v": "90",
"vt": "num"
},
{
"p": "quantity",
"v": "3",
"vt": "num"
},
{
"p": "values",
"v": "90000,5000,25000",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 160,
"wires": [
[
"710721c2c539be7e"
]
]
},
{
"id": "1be7836081fb0345",
"type": "function",
"z": "35e959d48dc8655d",
"name": "",
"func": "msg.payload = {};\nlet fc = msg.varfc;\nlet unitid = msg.unit;\nlet address = (~~msg.address);\nlet quantity = (~~msg.quantity);\nlet value = msg.info;\nmsg.payload = { value, fc, unitid, address, quantity};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 160,
"wires": [
[
"8b7c51de746a97af"
]
]
},
{
"id": "8b7c51de746a97af",
"type": "modbus-flex-write",
"z": "35e959d48dc8655d",
"name": "EscribeWords",
"showStatusActivities": false,
"showErrors": true,
"server": "e0c17133825e418c",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 680,
"y": 160,
"wires": [
[
"d717edde2e808b9b"
],
[
"d717edde2e808b9b"
]
]
},
{
"id": "d717edde2e808b9b",
"type": "debug",
"z": "35e959d48dc8655d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 160,
"wires": []
},
{
"id": "6b0856502c1ec8f8",
"type": "change",
"z": "35e959d48dc8655d",
"name": "dest / msj",
"rules": [
{
"t": "set",
"p": "info",
"pt": "msg",
"to": "$split(msg.values, \",\")",
"tot": "jsonata",
"dc": true
},
{
"t": "set",
"p": "unit",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "varfc",
"pt": "msg",
"to": "16",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 240,
"wires": [
[
"2f051284ae44d057"
]
]
},
{
"id": "ff20afe189ebb811",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "address",
"v": "90",
"vt": "num"
},
{
"p": "quantity",
"v": "3",
"vt": "num"
},
{
"p": "values",
"v": "90000,5000,25000",
"vt": "bin"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 240,
"wires": [
[
"6b0856502c1ec8f8"
]
]
},
{
"id": "2f051284ae44d057",
"type": "function",
"z": "35e959d48dc8655d",
"name": "",
"func": "msg.payload = {};\nlet fc = msg.varfc;\nlet unitid = msg.unit;\nlet address = (~~msg.address);\nlet quantity = (~~msg.quantity);\nlet value = msg.info;\nmsg.payload = { value, fc, unitid, address, quantity};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 240,
"wires": [
[
"001ea5705b2fd70f"
]
]
},
{
"id": "001ea5705b2fd70f",
"type": "modbus-flex-write",
"z": "35e959d48dc8655d",
"name": "EscribeWords",
"showStatusActivities": false,
"showErrors": true,
"server": "e0c17133825e418c",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 680,
"y": 240,
"wires": [
[
"1a65dca72067e497"
],
[
"1a65dca72067e497"
]
]
},
{
"id": "1a65dca72067e497",
"type": "debug",
"z": "35e959d48dc8655d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 240,
"wires": []
},
{
"id": "3119b10ec1b2d13c",
"type": "change",
"z": "35e959d48dc8655d",
"name": "dest / msj",
"rules": [
{
"t": "set",
"p": "info",
"pt": "msg",
"to": "$split(msg.values, \",\")",
"tot": "jsonata",
"dc": true
},
{
"t": "set",
"p": "unit",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "varfc",
"pt": "msg",
"to": "16",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 320,
"wires": [
[
"f2e68a9fb755b1ee"
]
]
},
{
"id": "11c3fb359dace953",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "address",
"v": "90",
"vt": "num"
},
{
"p": "quantity",
"v": "3",
"vt": "num"
},
{
"p": "values",
"v": "[90000,5000,25000]",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 320,
"wires": [
[
"3119b10ec1b2d13c"
]
]
},
{
"id": "f2e68a9fb755b1ee",
"type": "function",
"z": "35e959d48dc8655d",
"name": "",
"func": "msg.payload = {};\nlet fc = msg.varfc;\nlet unitid = msg.unit;\nlet address = (~~msg.address);\nlet quantity = (~~msg.quantity);\nlet value = msg.info;\nmsg.payload = { value, fc, unitid, address, quantity};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 320,
"wires": [
[
"afc283d312e9dd5c"
]
]
},
{
"id": "afc283d312e9dd5c",
"type": "modbus-flex-write",
"z": "35e959d48dc8655d",
"name": "EscribeWords",
"showStatusActivities": false,
"showErrors": true,
"server": "e0c17133825e418c",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 680,
"y": 320,
"wires": [
[
"8146271e3314ad9d"
],
[
"8146271e3314ad9d"
]
]
},
{
"id": "8146271e3314ad9d",
"type": "debug",
"z": "35e959d48dc8655d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 320,
"wires": []
},
{
"id": "8527a7d8d453d9f0",
"type": "change",
"z": "35e959d48dc8655d",
"name": "dest / msj",
"rules": [
{
"t": "set",
"p": "info",
"pt": "msg",
"to": "$split(msg.values, \",\")",
"tot": "jsonata",
"dc": true
},
{
"t": "set",
"p": "unit",
"pt": "msg",
"to": "1",
"tot": "num"
},
{
"t": "set",
"p": "varfc",
"pt": "msg",
"to": "16",
"tot": "num"
}
],
"action": "",
"property": "",
"from": "",
"to": "",
"reg": false,
"x": 380,
"y": 400,
"wires": [
[
"63d94e9bf83ec1ca"
]
]
},
{
"id": "51f8eca5d3064c79",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "address",
"v": "90",
"vt": "num"
},
{
"p": "quantity",
"v": "3",
"vt": "num"
},
{
"p": "values",
"v": "[90000,5000,25000]",
"vt": "json"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 180,
"y": 400,
"wires": [
[
"8527a7d8d453d9f0"
]
]
},
{
"id": "63d94e9bf83ec1ca",
"type": "function",
"z": "35e959d48dc8655d",
"name": "",
"func": "msg.payload = {};\nlet fc = msg.varfc;\nlet unitid = msg.unit;\nlet address = (~~msg.address);\nlet quantity = (~~msg.quantity);\nlet value = Buffer.from(msg.info, \"utf-8\");;\nmsg.payload = { value, fc, unitid, address, quantity};\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 520,
"y": 400,
"wires": [
[
"410a6459144ecfab"
]
]
},
{
"id": "410a6459144ecfab",
"type": "modbus-flex-write",
"z": "35e959d48dc8655d",
"name": "EscribeWords",
"showStatusActivities": false,
"showErrors": true,
"server": "e0c17133825e418c",
"emptyMsgOnFail": false,
"keepMsgProperties": false,
"x": 680,
"y": 400,
"wires": [
[
"a4f00a893a7c6498"
],
[
"a4f00a893a7c6498"
]
]
},
{
"id": "a4f00a893a7c6498",
"type": "debug",
"z": "35e959d48dc8655d",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 890,
"y": 400,
"wires": []
},
{
"id": "98622685435f48e2",
"type": "modbustcp-write",
"z": "35e959d48dc8655d",
"name": "Test",
"topic": "",
"dataType": "HoldingRegisters",
"adr": "90",
"server": "33c1604122b77618",
"x": 410,
"y": 680,
"wires": []
},
{
"id": "88c7c7737ba2c4b7",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[90000,6500,20000]",
"payloadType": "json",
"x": 210,
"y": 680,
"wires": [
[
"98622685435f48e2"
]
]
},
{
"id": "c6956cc1826a3baf",
"type": "modbustcp-write",
"z": "35e959d48dc8655d",
"name": "Test",
"topic": "",
"dataType": "HoldingRegisters",
"adr": "90",
"server": "33c1604122b77618",
"x": 410,
"y": 740,
"wires": []
},
{
"id": "79a71cc411136bab",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "90000,6500,20000",
"payloadType": "str",
"x": 210,
"y": 740,
"wires": [
[
"c6956cc1826a3baf"
]
]
},
{
"id": "5a26073984e9d02a",
"type": "modbustcp-write",
"z": "35e959d48dc8655d",
"name": "Test",
"topic": "",
"dataType": "HoldingRegisters",
"adr": "90",
"server": "33c1604122b77618",
"x": 410,
"y": 800,
"wires": []
},
{
"id": "b094c64b4f2316aa",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[90000,6500,20000]",
"payloadType": "bin",
"x": 170,
"y": 800,
"wires": [
[
"5a26073984e9d02a"
]
]
},
{
"id": "5ee5e4278839e319",
"type": "modbustcp-write",
"z": "35e959d48dc8655d",
"name": "Test",
"topic": "",
"dataType": "HoldingRegisters",
"adr": "90",
"server": "33c1604122b77618",
"x": 410,
"y": 860,
"wires": []
},
{
"id": "d37c9683a550a89a",
"type": "inject",
"z": "35e959d48dc8655d",
"name": "",
"props": [
{
"p": "payload"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "[90000,6500,20000]",
"payloadType": "jsonata",
"x": 170,
"y": 860,
"wires": [
[
"5ee5e4278839e319"
]
]
},
{
"id": "e0c17133825e418c",
"type": "modbus-client",
"name": "MODBUS",
"clienttype": "tcp",
"bufferCommands": false,
"stateLogEnabled": false,
"queueLogEnabled": false,
"tcpHost": "192.168.143.250",
"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": "50",
"clientTimeout": "100",
"reconnectOnTimeout": true,
"reconnectTimeout": "2000",
"parallelUnitIdsAllowed": false
},
{
"id": "33c1604122b77618",
"type": "modbustcp-server",
"name": "Modbus",
"host": "192.168.143.250",
"port": "502",
"unit_id": "1",
"reconnecttimeout": ""
}
] ```