How do I use Node-RED to control Analog Output Module ED-560 with Modbus TCP??

FAQs

Introduction

This FAQ explains how to use different nodes inside Node-RED, being used to show how to use a Brainboxes BB-400 (Neuron IoT Controller), with a Brainboxes ED-560 (Ethernet to 4xAnalogue Outputs). The end example is a flow which will be able to set the outputs of a Brainboxes ED-560.

Nodes used in this FAQ:

Image Description
debug node Debug, for debugging the returned data from the nodes it’s attached to.
Modbus Read node Modbus TCP/Serial read node. Connects to a Modbus TCP or serial to read registers/coils values with a given polling rate.
Modbus Flex Write node Modbus TCP flexible input triggered write node with connection input parameters.
function node Function, a JavaScript block to run against the messages being received and output as a msg object.
slider node Adds a slider widget to the user interface.
text input node Adds a text input field to the user interface.

Requirements:

Software/Equipment Details
Brainboxes BB-400 Brainboxes BB-400
BB-Node-RED installed On the BB-400, you must have the software package bb-node-red installed
You can check if it’s installed using bb status.version or install it with sudo apt-get install bb-node-red
Brainboxes ED-560 Brainboxes ED-560

ED-560 Setup

A Brainboxes ED-560 comes in a default configuration using the ASCII protocol. The unit needs to be configured to use the Modbus TCP protocol instead. To do that, simply go to the ED-560 Web UI configuration, and change the protocol settings from ASCII to Modbus TCP:

ED-560 Web UI configuration

Guide

The Modbus TCP/Serial nodes come from a 3rd party NPM package known as « node-red-contrib-modbus ». It comes with many useful tools that can be used with the BB-400 to talk with and between other Brainboxes ED devices. For this FAQ, we’ll be using the Modbus TCP read node and Modbus TCP flex write node:

Modbus Read node Modbus Read node configuration

For the new modbus-client, you need to configure your ED-560 as the new device. For example:

Analogue Output configuration

Now to add a function node. The Modbus TCP Read Node passes all the values for all the lines, and the function node will be used to split all of the values into 4 separate lanes, 1 for each output on the ED-560.

Why do this? This will keep all the values updated for all of the widgets on the user interface!

function node Split Outputs function
`js
return msg.payload.map(function(ioValue, ioNumber) {
return {payload: ioValue, topic: ioNumber};
});
`

The Modbus Read Node will connect to the left side of the function node. Each of the outputs from the ED-560 will go into the split outputs, and out of the corresponding output, which is where we can set each of the outputs separately:ED Read Outputs flow

You can immediately test that you are getting a connection to the ED-560 at this point, and that data is being displayed and returned correctly. Simply add a debug node to one of the function outputs (for AOut0, we will use the top most output) to see what value it returns:

debug test ED Read Outputs

After the flow has been deployed, Deploy node the user should immediately notice the active connection on the Modbus Read Node. When looking at the Debug tab Debug tab on the right, you will see the value which is set on AOut0 output:

Modbus TCP Read Node Value from Node-RED debug Value from ED-560 Web UI
ED Read Outputs node Debug value Value from ED-560

In an ED-560 factory default configuration, with this Node-RED setup, 5000 is equal to 5.000V on the AOut0 output.

Now add some UI nodes for each of the outputs, and configure them as you desire.
These UI nodes will appear on your Node-RED dashboard for each of the Analogue Outputs.

This example has the Full Scale Range on the outputs configured to 0-10V. This means that the UI nodes will also need to be configured to match this:

UI nodes configuration
Node Configuration
slider node slider node configuration
text input node text input node configuration

All of these configuration settings can be uniquely changed to however you see fit:

ED Read Outputs flow

The slider and text controls now need to send the data it’s changed to, to the Modbus TCP send node. First, however, we need to create the payload message, which will hold all of the Modbus data, including the function code, value, ID, etc:

function node Modbus payload
msg.payload = {
    value: msg.payload,
    'fc': 6,
    'unitid': 255,
    'address': msg.topic,
    'quantity': 1
}
return msg;

After finishing the function node above, we then send that message into the Modbus Flex Write node, using the Analogue Output device we created at the start:

Modbus Flex Write node Modbus Flex Write configuration

Everything is finished! Tie everything together and try out the new Node-RED flow.
This example is everything together with 1 Analogue Output setup:

1 Analogue Output Node-RED flow

And everything together with all 4 Analogue Outputs setup:

4 Analogue Outputs flow

After you have completed everything and tied everything together, Deploy node it and test it out:

Slider UI

When changing the values, either by the slider or text input, it will change the output of your ED-560:

Changing values for ED-560

Full Flow

[
    {
        "id": "14a1a272.213d1e",
        "type": "tab",
        "label": "[ED-Analogue] Modbus",
        "disabled": true,
        "info": "# Modbus ExamplenThis flow gives you an example on how you can use Modbus in Node-RED, talking to a Brainboxes ED device from a BB-400.nnFor this flow to work:n* Your Brainboxes ED device needs to be configured to use the Modbus TCP protocol.n* The IP address for your Brainboxes ED device, needs to be configured inside each of the Modbus nodes found on this flow.nn# **Brainboxes Node-RED FAQ**nNeed more help or tutorials on using Node-RED? Go to: nhttps://www.brainboxes.com/faqs/search/Node-RED"
    },
    {
        "id": "d679e58.f1a9618",
        "type": "function",
        "z": "14a1a272.213d1e",
        "name": "Split Inputs",
        "func": "// Split the payload from an array of 8n// analogue input values into 8 messages withn// a value and an IO numbernreturn msg.payload.map(function(ioValue, ioNumber) {n    ioValue=ioValue/1000n    return {payload: ioValue, topic: ioNumber};n});",
        "outputs": 8,
        "noerr": 0,
        "x": 350,
        "y": 320,
        "wires": [
            [
                "9b83d68f.cf96c8",
                "ebf90e0.f7cfdf"
            ],
            [
                "b66633bd.cdd2",
                "5b3c27bc.144ae8"
            ],
            [
                "f688dfb6.e3cfd",
                "7edebe57.3b68f"
            ],
            [
                "88343792.2dc368",
                "ecefc57.4a1fa38"
            ],
            [
                "db3217b7.2add48",
                "a33f73d.ca3169"
            ],
            [
                "2c38e77a.0c1e98",
                "46574b7f.95f124"
            ],
            [
                "22ba140a.3f746c",
                "81d84239.f8c86"
            ],
            [
                "220b0459.f1d5bc",
                "8c187e97.a20fe"
            ]
        ]
    },
    {
        "id": "2f11f8a2.756e28",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "2. Then make sure to DEPLOY this flow by clicking the button located in the top right",
        "info": "",
        "x": 310,
        "y": 60,
        "wires": []
    },
    {
        "id": "f327cd5d.30dc9",
        "type": "modbus-read",
        "z": "14a1a272.213d1e",
        "name": "ED Read Inputs",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "unitid": "",
        "dataType": "HoldingRegister",
        "adr": "0",
        "quantity": "8",
        "rate": "1000",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "447f3ae2.d53104",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "x": 120,
        "y": 280,
        "wires": [
            [
                "d679e58.f1a9618",
                "499aea89.6c06d4"
            ],
            []
        ]
    },
    {
        "id": "9b83d68f.cf96c8",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn0",
        "group": "6838a81b.c3bbc8",
        "order": 1,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn0",
        "label": "V",
        "format": "",
        "min": "-10",
        "max": "10",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "2",
        "seg2": "5",
        "x": 550,
        "y": 160,
        "wires": []
    },
    {
        "id": "b66633bd.cdd2",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn1",
        "group": "6838a81b.c3bbc8",
        "order": 2,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn1",
        "label": "mA",
        "format": "",
        "min": "4",
        "max": "20",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "10",
        "seg2": "16",
        "x": 550,
        "y": 360,
        "wires": []
    },
    {
        "id": "f688dfb6.e3cfd",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn2",
        "group": "6838a81b.c3bbc8",
        "order": 3,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn2",
        "label": "V",
        "format": "",
        "min": "-10",
        "max": "10",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "2",
        "seg2": "5",
        "x": 550,
        "y": 200,
        "wires": []
    },
    {
        "id": "88343792.2dc368",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn3",
        "group": "6838a81b.c3bbc8",
        "order": 4,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn3",
        "label": "mA",
        "format": "",
        "min": "4",
        "max": "20",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "10",
        "seg2": "16",
        "x": 550,
        "y": 400,
        "wires": []
    },
    {
        "id": "ebf90e0.f7cfdf",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "dc5d43e0.5931",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn0",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "-10",
        "ymax": "10",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 163,
        "wires": [
            []
        ]
    },
    {
        "id": "5b3c27bc.144ae8",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "dc5d43e0.5931",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn1",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "4",
        "ymax": "20",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 363,
        "wires": [
            []
        ]
    },
    {
        "id": "7edebe57.3b68f",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "dc5d43e0.5931",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn2",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "-10",
        "ymax": "10",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 203,
        "wires": [
            []
        ]
    },
    {
        "id": "ecefc57.4a1fa38",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "dc5d43e0.5931",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn3",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "4",
        "ymax": "20",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 403,
        "wires": [
            []
        ]
    },
    {
        "id": "9a9773d5.737c4",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "3. Visit your dashboard! http://bb400-xxxx:1880/ui (where bb400-xxxx is your BB-400 hostname or IP address)",
        "info": "",
        "x": 390,
        "y": 800,
        "wires": []
    },
    {
        "id": "2c38e77a.0c1e98",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn5",
        "group": "20aa9b2a.7dab04",
        "order": 2,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn5",
        "label": "mA",
        "format": "",
        "min": "4",
        "max": "20",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "10",
        "seg2": "16",
        "x": 550,
        "y": 440,
        "wires": []
    },
    {
        "id": "22ba140a.3f746c",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn6",
        "group": "20aa9b2a.7dab04",
        "order": 3,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn6",
        "label": "V",
        "format": "",
        "min": "-10",
        "max": "10",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "2",
        "seg2": "5",
        "x": 550,
        "y": 280,
        "wires": []
    },
    {
        "id": "220b0459.f1d5bc",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn7",
        "group": "20aa9b2a.7dab04",
        "order": 4,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn7",
        "label": "mA",
        "format": "",
        "min": "4",
        "max": "20",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "10",
        "seg2": "16",
        "x": 550,
        "y": 480,
        "wires": []
    },
    {
        "id": "db3217b7.2add48",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "a2c176bc.cade88",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn4",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "-10",
        "ymax": "10",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 240,
        "wires": [
            []
        ]
    },
    {
        "id": "46574b7f.95f124",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "a2c176bc.cade88",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn5",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "4",
        "ymax": "20",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 443,
        "wires": [
            []
        ]
    },
    {
        "id": "81d84239.f8c86",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "a2c176bc.cade88",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn6",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "-10",
        "ymax": "10",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 283,
        "wires": [
            []
        ]
    },
    {
        "id": "8c187e97.a20fe",
        "type": "ui_chart",
        "z": "14a1a272.213d1e",
        "name": "",
        "group": "a2c176bc.cade88",
        "order": 1,
        "width": 0,
        "height": 0,
        "label": "AIn7",
        "chartType": "line",
        "legend": "false",
        "xformat": "HH:mm:ss",
        "interpolate": "linear",
        "nodata": "",
        "dot": false,
        "ymin": "4",
        "ymax": "20",
        "removeOlder": 1,
        "removeOlderPoints": "",
        "removeOlderUnit": "60",
        "cutout": 0,
        "useOneColor": false,
        "colors": [
            "#1f77b4",
            "#aec7e8",
            "#ff7f0e",
            "#2ca02c",
            "#98df8a",
            "#d62728",
            "#ff9896",
            "#9467bd",
            "#c5b0d5"
        ],
        "useOldStyle": false,
        "outputs": 1,
        "x": 670,
        "y": 483,
        "wires": [
            []
        ]
    },
    {
        "id": "499aea89.6c06d4",
        "type": "modbus-response",
        "z": "14a1a272.213d1e",
        "name": "",
        "registerShowMax": "8",
        "x": 170,
        "y": 380,
        "wires": []
    },
    {
        "id": "f2d8dc6e.c17c6",
        "type": "function",
        "z": "14a1a272.213d1e",
        "name": "Modbus Payload",
        "func": "msg.payload = { n    value: msg.payload, n    'fc': 6, n    'unitid': 255, n    'address': msg.topic, n    'quantity': 1 n} nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 850,
        "y": 600,
        "wires": [
            [
                "93c3d451.6fba78"
            ]
        ]
    },
    {
        "id": "93c3d451.6fba78",
        "type": "modbus-flex-write",
        "z": "14a1a272.213d1e",
        "name": "Set Output",
        "showStatusActivities": true,
        "showErrors": true,
        "server": "e0dfcc8.bcc183",
        "x": 870,
        "y": 640,
        "wires": [
            [],
            []
        ]
    },
    {
        "id": "704df223.3d476c",
        "type": "modbus-read",
        "z": "14a1a272.213d1e",
        "name": "ED Read Outputs",
        "topic": "",
        "showStatusActivities": false,
        "logIOActivities": false,
        "showErrors": false,
        "unitid": "",
        "dataType": "HoldingRegister",
        "adr": "0",
        "quantity": "4",
        "rate": "1000",
        "rateUnit": "ms",
        "delayOnStart": false,
        "startDelayTime": "",
        "server": "2d38213a.e96ace",
        "useIOFile": false,
        "ioFile": "",
        "useIOForPayload": false,
        "x": 120,
        "y": 580,
        "wires": [
            [
                "86f63f9e.d5e25"
            ],
            []
        ]
    },
    {
        "id": "a16d6e33.57ff8",
        "type": "ui_slider",
        "z": "14a1a272.213d1e",
        "name": "",
        "label": "AOut0",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 5,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "end",
        "topic": "0",
        "min": 0,
        "max": "10000",
        "step": "50",
        "x": 550,
        "y": 540,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "93c9a3f6.5d54a",
        "type": "ui_slider",
        "z": "14a1a272.213d1e",
        "name": "",
        "label": "AOut1",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 6,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "end",
        "topic": "1",
        "min": 0,
        "max": "10000",
        "step": "100",
        "x": 550,
        "y": 580,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "c98ef5f6.8ab388",
        "type": "ui_slider",
        "z": "14a1a272.213d1e",
        "name": "",
        "label": "AOut2",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 7,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "end",
        "topic": "2",
        "min": 0,
        "max": "10000",
        "step": "100",
        "x": 550,
        "y": 620,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "f0a00f55.de487",
        "type": "ui_slider",
        "z": "14a1a272.213d1e",
        "name": "",
        "label": "AOut3",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": true,
        "outs": "end",
        "topic": "3",
        "min": 0,
        "max": "10000",
        "step": "100",
        "x": 550,
        "y": 660,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "86f63f9e.d5e25",
        "type": "function",
        "z": "14a1a272.213d1e",
        "name": "Split Outputs",
        "func": "return msg.payload.map(function(ioValue, ioNumber) {n    return {payload: ioValue, topic: ioNumber};n});",
        "outputs": 4,
        "noerr": 0,
        "x": 350,
        "y": 600,
        "wires": [
            [
                "a16d6e33.57ff8",
                "54554ea3.a62c4"
            ],
            [
                "93c9a3f6.5d54a",
                "818e6e99.e6d8c"
            ],
            [
                "c98ef5f6.8ab388",
                "3bf9da0c.610996"
            ],
            [
                "f0a00f55.de487",
                "27f0093b.e7d126"
            ]
        ]
    },
    {
        "id": "54554ea3.a62c4",
        "type": "ui_text_input",
        "z": "14a1a272.213d1e",
        "name": "AOut0",
        "label": "AOut0",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 16,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": "0",
        "topic": "0",
        "x": 670,
        "y": 540,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "818e6e99.e6d8c",
        "type": "ui_text_input",
        "z": "14a1a272.213d1e",
        "name": "AOut1",
        "label": "AOut1",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 16,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": "0",
        "topic": "1",
        "x": 670,
        "y": 580,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "3bf9da0c.610996",
        "type": "ui_text_input",
        "z": "14a1a272.213d1e",
        "name": "AOut2",
        "label": "AOut2",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 16,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": "0",
        "topic": "2",
        "x": 670,
        "y": 620,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "27f0093b.e7d126",
        "type": "ui_text_input",
        "z": "14a1a272.213d1e",
        "name": "AOut3",
        "label": "AOut3",
        "tooltip": "",
        "group": "d7e21aab.3b8a28",
        "order": 16,
        "width": 0,
        "height": 0,
        "passthru": true,
        "mode": "text",
        "delay": "0",
        "topic": "3",
        "x": 670,
        "y": 660,
        "wires": [
            [
                "f2d8dc6e.c17c6"
            ]
        ]
    },
    {
        "id": "a33f73d.ca3169",
        "type": "ui_gauge",
        "z": "14a1a272.213d1e",
        "name": "AIn4",
        "group": "20aa9b2a.7dab04",
        "order": 1,
        "width": 0,
        "height": 0,
        "gtype": "donut",
        "title": "AIn4",
        "label": "V",
        "format": "",
        "min": "-10",
        "max": "10",
        "colors": [
            "#00a800",
            "#e6e600",
            "#ca3838"
        ],
        "seg1": "2",
        "seg2": "5",
        "x": 550,
        "y": 237,
        "wires": []
    },
    {
        "id": "f561bd3c.32d82",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "milliAmps (4-20mA)",
        "info": "",
        "x": 590,
        "y": 320,
        "wires": []
    },
    {
        "id": "d5fd82d1.ed8bc",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "Voltage (±10V)",
        "info": "",
        "x": 580,
        "y": 120,
        "wires": []
    },
    {
        "id": "6472c7a0.8808d8",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "Brainboxes ED-549 8x Analogue Inputs",
        "info": "[Brainboxes ED-549 8 Analogue Inputs](http://www.brainboxes.com/product/ed-549/ethernet-to-8-analogue-inputs-rs485-gateway)nn[Brainboxes ED-560 4 Analogue Outputs](http://www.brainboxes.com/product/ed-560/ethernet-to-4-analogue-outputs-rs485-gateway)n![image.png](http://www.brainboxes.com/files/catalog/product/ED/ED-549/img/analogue-range.jpg)",
        "x": 170,
        "y": 240,
        "wires": [],
        "icon": "font-awesome/fa-lightbulb-o"
    },
    {
        "id": "97235015.23152",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "Brainboxes ED-560 4x Analogue Outputs",
        "info": "[Brainboxes ED-560 4x Analogue Outputs](http://www.brainboxes.com/product/ed-549/ethernet-to-8-analogue-inputs-rs485-gateway)n",
        "x": 180,
        "y": 540,
        "wires": [],
        "icon": "font-awesome/fa-lightbulb-o"
    },
    {
        "id": "3e31efe4.c4f5e",
        "type": "ui_template",
        "z": "14a1a272.213d1e",
        "group": "d7e21aab.3b8a28",
        "name": "",
        "order": 2,
        "width": 0,
        "height": 0,
        "format": "",
        "storeOutMessages": false,
        "fwdInMessages": false,
        "templateScope": "local",
        "x": 100,
        "y": 20,
        "wires": [
            []
        ]
    },
    {
        "id": "f76734f4.d9dd28",
        "type": "comment",
        "z": "14a1a272.213d1e",
        "name": "1. Enable this flow by double clicking "[ED-Analogue] Modbus" above",
        "info": "",
        "x": 260,
        "y": 20,
        "wires": []
    },
    {
        "id": "447f3ae2.d53104",
        "type": "modbus-client",
        "z": "",
        "name": "Analogue Inputs",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "tcpHost": "192.168.127.254",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "unit_id": 255,
        "commandDelay": 1,
        "clientTimeout": 2000,
        "reconnectTimeout": 2000
    },
    {
        "id": "6838a81b.c3bbc8",
        "type": "ui_group",
        "z": "",
        "name": "Gauge (0-3)",
        "tab": "f17a1f08.c1195",
        "order": 2,
        "disp": false,
        "width": "5",
        "collapse": false
    },
    {
        "id": "dc5d43e0.5931",
        "type": "ui_group",
        "z": "",
        "name": "Chart (0-3)",
        "tab": "f17a1f08.c1195",
        "order": 3,
        "disp": false,
        "width": "6",
        "collapse": false
    },
    {
        "id": "20aa9b2a.7dab04",
        "type": "ui_group",
        "z": "",
        "name": "Gauge (4-7)",
        "tab": "f17a1f08.c1195",
        "order": 4,
        "disp": false,
        "width": "5",
        "collapse": false
    },
    {
        "id": "a2c176bc.cade88",
        "type": "ui_group",
        "z": "",
        "name": "Chart (4-7)",
        "tab": "f17a1f08.c1195",
        "order": 5,
        "disp": false,
        "width": "6",
        "collapse": false
    },
    {
        "id": "e0dfcc8.bcc183",
        "type": "modbus-client",
        "z": "",
        "name": "Digital Outputs",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "tcpHost": "192.168.127.254",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "unit_id": 1,
        "commandDelay": 1,
        "clientTimeout": 2000,
        "reconnectTimeout": 2000
    },
    {
        "id": "2d38213a.e96ace",
        "type": "modbus-client",
        "z": "",
        "name": "Analogue Outputs",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "tcpHost": "192.168.127.254",
        "tcpPort": "502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "unit_id": 255,
        "commandDelay": 1,
        "clientTimeout": 2000,
        "reconnectTimeout": 2000
    },
    {
        "id": "d7e21aab.3b8a28",
        "type": "ui_group",
        "z": "",
        "name": "Sliders [&] Numbers",
        "tab": "f17a1f08.c1195",
        "order": 1,
        "disp": false,
        "width": "8",
        "collapse": false
    },
    {
        "id": "f17a1f08.c1195",
        "type": "ui_tab",
        "z": "",
        "name": "Modbus: Brainboxes ED-Analogue",
        "icon": "dashboard",
        "order": 5,
        "disabled": false,
        "hidden": false
    }
]

Modbus Registers & Value Encoding

ED-560 Registers:

Modbus access type Modbus function codes Logical address 984 style address IEC 61131 address
Analogue outputs (as integer Holding register 3, 6, 16 0x0000 – 3 40001 – 4 %MW0 – 3
Analogue outputs (as float) Holding register 3, 16 0x0020 – 7 40033 – 40 %MF32 – 39
Analogue type/range Holding register 3, 6, 16 0x0060 – 3 40097 – 100 %MW96 – 99
Integer format Holding register 3, 6, 16 0x0080 40129 %MW128
Integer format Coil 1, 5, 15 0x0080 129 %M128

Brainboxes Value Encoding

Integer values are encoded in one of two formats, depending on the integer format setting.

  • “Hexadecimal” (integer format register = 0, integer format coil OFF): the output range is scaled to an integer value ranging from 0 to 16383 (3FFF hexadecimal).
  • “Engineering units” (integer format register = 1, integer format coil ON): the output, in mA or V, is scaled up to as high a power of 10 as possible while allowing the full range of values to fit in a 16-bit integer.

Floating-point values are encoded according to the IEEE 754 standard for 32-bit floating-point numbers. Each value takes two sequential 16-bit Modbus registers, with the least-significant bits of the 32-bit value being held in the lower register address (“little-endian” format). Both Modbus registers must be written or read in the same Modbus request. The units of the float values are Volts or milliamps.

Writing values below the minimum results in the minimum output for the range being used, and writing values above the maximum results in the maximum output for the range being used.

The type/range codes which can be set using Modbus, and the data ranges they result in, are tabulated below. The codes are the same as for the ASCII protocol.

Type Code Input Type Data Format + Full Scale Minimum
30 0 to +20mA Float engineering unit 20 0
Integer hexadecimal 0x3FFF = 16383 0
Integer engineering unit 20000 0
31 +4 to +20mA Float engineering unit 20 4
Integer hexadecimal 0x3FFF = 16383 0
Integer engineering unit 20000 4000
32 0 to +10V Float engineering unit 10 0
Integer hexadecimal 0x3FFF = 16383 0
Integer engineering unit 10000 0
FAQs