Write data into modbus server

[
    {
        "id": "d957bb780997c872",
        "type": "modbus-write",
        "z": "7568dacddffb4c49",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "MHoldingRegisters",
        "adr": "1",
        "quantity": "125",
        "server": "3831b0d8d7adf795",
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 300,
        "y": 740,
        "wires": [
            [
                "5e1212b9e016eec8"
            ],
            []
        ]
    },
    {
        "id": "d57eedf18e3284b4",
        "type": "inject",
        "z": "7568dacddffb4c49",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "[127,136,216,101,31,31,31,35,35,35,215,215,215,20,20,20,0,0,0,0,0,0,0,0,0,10,10,10,3,3,3,3,3,3,65,65,65,81,0,0,0,0,0,0,0,0,0,0,0,87,136,216,101,33,33,33,39,39,39,215,215,215,20,20,20,0,0,0,0,0,0,0,0,0,6,6,6,10,10,10,6,6,6,69,69,69,96,0,0,0,0,0,0,0,0,0,0,0,99,99,99,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]",
        "payloadType": "json",
        "x": 130,
        "y": 740,
        "wires": [
            [
                "d957bb780997c872",
                "1f4d3f3b3138b69c"
            ]
        ]
    },
    {
        "id": "5e1212b9e016eec8",
        "type": "modbus-flex-server",
        "z": "7568dacddffb4c49",
        "name": "",
        "logEnabled": false,
        "serverAddress": "192.168.0.114",
        "serverPort": "1025",
        "responseDelay": 100,
        "unitId": 1,
        "delayUnit": "ms",
        "coilsBufferSize": 20000,
        "registersBufferSize": 20000,
        "minAddress": 0,
        "splitAddress": 10000,
        "funcGetCoil": "function getFlexCoil(addr, unitID) {\n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t}  \n}",
        "funcGetDiscreteInput": "function getFlexDiscreteInput(addr, unitID) {\n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.coils.readUInt8(addr * node.bufferFactor) \n\t}  \n}",
        "funcGetInputRegister": "function getFlexInputRegister(addr, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor)  \n\t} \n}",
        "funcGetHoldingRegister": "function getFlexHoldingRegsiter(addr, unitID) { \n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\treturn node.registers.readUInt16BE(addr * node.bufferFactor)  \n\t} \n}",
        "funcSetCoil": "function setFlexCoil(addr, value, unitID) { \n\tif (unitID === node.unitId && \n\t\taddr >= node.minAddress && \n\t\taddr <= node.splitAddress) { \n\n\t\tnode.coils.writeUInt8(value, addr * node.bufferFactor)  \n\t} \n}",
        "funcSetRegister": "function setFlexRegister(addr, value, unitID) { \n\taddr += node.splitAddress\n\tif (unitID === node.unitId && \n\t\taddr >= node.splitAddress && \n\t\taddr <= node.splitAddress * 2) { \n\n\t\tnode.registers.writeUInt16BE(value, addr * node.bufferFactor)  \n\t} \n}",
        "showErrors": false,
        "x": 540,
        "y": 740,
        "wires": [
            [],
            [],
            [],
            [],
            []
        ]
    },
    {
        "id": "1f4d3f3b3138b69c",
        "type": "debug",
        "z": "7568dacddffb4c49",
        "name": "debug 8",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 660,
        "y": 820,
        "wires": []
    },
    {
        "id": "3831b0d8d7adf795",
        "type": "modbus-client",
        "name": "",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "queueLogEnabled": false,
        "failureLogEnabled": true,
        "tcpHost": "192.168.0.114",
        "tcpPort": "1025",
        "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,
        "showWarnings": true,
        "showLogs": true
    }
]

I write 125 tag data successfully into holding register, but if I increase array size data is not written on Modbus server. Is it possible to write 1000 length array data into Modbus server.

datatype-INT

No. the protocol structure can only fit a certain number of values into a transmission. If you inspect the protocol, you will see it uses a byte to specify the "byte count" in message. Since each WD is 2 bytes, the maximum number of WDs a transmission can have is 255/2 (rounded down that is 127) but then there is other data in a packet. Some say the max length is 123 some say 125. Different implementations of the protocol set limits, some don't.

In short, you will have to do multiple transmissions.

I suggest, for easy maintenance of flows, you group them into a size of 100 WDs.


All that said, the modbus-server node itself may permit an alterative means of initialising the internal memory areas of the server node (i.e. not using the modbus protocol) but i dont know.

Could you please give me example? this will help us.

An example of what?

this ↓

or this ↓

for this.if you have any example

whatever method is used, my aim is to write 1000 tag data into modbus server.

um, sure. but it is pretty much taking what you have already and doing it 10 times!

I dont have modbus nodes installed ATM and I dont have your data so here is a mock up...

I suggest, like I did in the picture ↑, you do these in series (not in parallel) to avoid congestion and timeouts.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.