Read Omron PLC using node-red-omronplc (serial ; NOT FINS)

Hi.
I am using RS485 to USB converter to connect my Omron CP2E-N20DR-A PLC and my computer. I have successfully read the data from data memory of PLC and can see it on my debug window at node-red.

Here's the visual representation of my progress..


Data memory of my PLC

image
Data read at the node red debug window

Now, I just want the data '1234' to be displayed onto the node-red dashboard. What should I do?

The v1 beta of node-red-contrib-omronfins has c mode nodes to assist with reading and writing serial commands. It would be great if you could test these out?

Hi, I thought that Omron Fins is only applicable for those connected using ethernet. But I have connected through RS485. Will the Fins protocol work for me also? I'm asking also because Fins connection node requires IP address, which can be found only using ethernet, as far as I know...

The beta version I have pointed you to contains C Mode nodes that generate the hostlink protocol strings that you pass to a serial request then you pass the response through another C Mode node to parse the data.

In essence, they are doing what you did except they simplify the creation of the protocol strings and extracting the response from the PLC into meaningful values (including any error replies)


Okay, but for all the nodes present under node-red-contrib-omron-fins, IP address is required; in this case, how am I able to get the IP address using RS485?

Did you install the beta as explained in the post I linked to in my first response?

Did you restart node-red after installing?

Did you refresh the browser?

If you install correctly, you should see new nodes in the palette.

Example...

1 Like

Thanks, found the nodes after installing them through Windows Powershell. Now I would like to know the way to use the function node, to write out the response from the PLC

You don't. That was a placeholder to indicate where the serial port node goes.


I have replaced with my COM 11, but the data being read is not correct.

Here's my C-mode command setting:


Please let me know where I'm making a mistake


This is the data memory from the PLC. By right, I should be expecting the data "1122" from address number 25


Hi, just found out that the data is being displayed at the debug window, but I'm curious on why the data is being split into 2 hexadecimal string. In my case, I need the data to be displayed as a whole, (1122). In addition, I need help on how to compile the data as one whole string (1122) and remove the data:object when displayed onto node-red dashboard.


This is how my test dashboard looks at the moment. I see here that the data being split as 0x11 and 0x22 is being converted into decimal separately, which causes a display of 17,34. Instead, the decimal value for 1122 hex is 4386. Please help me on how to correct this.

where are you seeing 2 hexadecimal strings? I see a Data object with 2 16 bit values and an equivalent buffer containing the byte values.

So you want to "display" ( i assume on a dashboard) the hexadecimal value of the 16 bit integer returned from the PLC? So, if you read the readme you will see there is a companion node node-red-contrib-buffer-parser that can do pretty much everything you need to do with data.

As a tip, if you click the value msg.data[0] in the debug window, it will show you the hexadecimal equivalent of the decimal value 8721.

The readme has some info with regards PLC data formats...

Data formats and conversion

As I use multiple PLCs and didn't want to write boolean / 32bit / float / double functionality into each node (it's best to keep things atomic and good at what they do) so I wrote a separate second node for handling data conversions.

This node "node-red-contrib-buffer-parser" node-red-contrib-buffer-parser (node) - Node-RED is capable of pretty much anything you will need for this or any PLC that returns 16bit data or a NodeJS Buffer.

In essence, you pull a bunch of data from the plc in one go & convert it all in the buffer-parser node to almost any format you could wish for (bits, floats, 32bit signed / unsigned, byteswapping etc etc). It can do 1 or many conversions all at once. It can send a grouped item (object) or individual items with a topic ready for pushing your data directly from the PLC to MQTT.

Here is a demo...
chrome_3quTzEpd8Z

[{"id":"e655a6aea0634b73","type":"buffer-parser","z":"6061813d087d6df4","name":"","data":"payload.buffer","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"asInteger1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"asInteger12","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"hex","name":"asHex1","offset":0,"length":2,"offsetbit":0,"scale":"1","mask":""},{"type":"hex","name":"asHex2","offset":2,"length":2,"offsetbit":0,"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":1830,"y":160,"wires":[["4ea4b17021893a18"]]},{"id":"fdee6645fb2c9d53","type":"inject","z":"6061813d087d6df4","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1510,"y":100,"wires":[["be79f96065e17c75"]]},{"id":"be79f96065e17c75","type":"function","z":"6061813d087d6df4","name":"Faking your PLC data","func":"msg.payload = {\n    Data: [8721, 8721],\n    buffer: Buffer.from([0x11,0x22,0x11,0x22])\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1590,"y":160,"wires":[["e655a6aea0634b73","4dfdc0a13fb6675b"]]},{"id":"4ea4b17021893a18","type":"debug","z":"6061813d087d6df4","name":"Parsed Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1910,"y":220,"wires":[]},{"id":"4dfdc0a13fb6675b","type":"debug","z":"6061813d087d6df4","name":"PLC Data","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1680,"y":220,"wires":[]}]
1 Like

There’s a great page in the docs (Working with messages : Node-RED) that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

So for a text item, use `{{ msg.payload.xxx }}``` instead of the whole payload (which is an object containing multiple items.

1 Like
[
    {
        "id": "ba40178493839cb7",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "033c373046a2da30",
        "type": "C-Mode Command",
        "z": "ba40178493839cb7",
        "name": "CP2E",
        "plcSeries": "CSJP",
        "hostNumber": 0,
        "headerCode": "RD",
        "p1": "0",
        "p2": "12",
        "p3": "",
        "x": 270,
        "y": 100,
        "wires": [
            [
                "92dcb68ff10007a0"
            ]
        ]
    },
    {
        "id": "64c03284f8f31ee0",
        "type": "C-Mode Response",
        "z": "ba40178493839cb7",
        "name": "",
        "x": 570,
        "y": 100,
        "wires": [
            [
                "dc2cec39514b5748"
            ]
        ]
    },
    {
        "id": "91eb937ee4e89c68",
        "type": "inject",
        "z": "ba40178493839cb7",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "1",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 110,
        "y": 100,
        "wires": [
            [
                "033c373046a2da30"
            ]
        ]
    },
    {
        "id": "4ba084247ffa13ea",
        "type": "debug",
        "z": "ba40178493839cb7",
        "name": "debug 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 540,
        "y": 280,
        "wires": []
    },
    {
        "id": "92dcb68ff10007a0",
        "type": "serial request",
        "z": "ba40178493839cb7",
        "name": "",
        "serial": "893956afe4c6c260",
        "x": 400,
        "y": 100,
        "wires": [
            [
                "64c03284f8f31ee0"
            ]
        ]
    },
    {
        "id": "4a9d8cb4d0c90c8c",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 2,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 1",
        "format": "{{msg.payload.asInteger1[0]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 320,
        "wires": []
    },
    {
        "id": "dc2cec39514b5748",
        "type": "buffer-parser",
        "z": "ba40178493839cb7",
        "name": "",
        "data": "payload.buffer",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16be",
                "name": "asInteger1",
                "offset": 0,
                "length": 12,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "asHex1",
                "offset": 0,
                "length": 2,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "asHex2",
                "offset": 0,
                "length": 3,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "hex3",
                "offset": 0,
                "length": 4,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "hex4",
                "offset": 0,
                "length": 5,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "hex",
                "name": "hex5",
                "offset": 0,
                "length": 6,
                "offsetbit": 0,
                "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": 170,
        "y": 360,
        "wires": [
            [
                "4ba084247ffa13ea",
                "4a9d8cb4d0c90c8c",
                "f14369720473e9f7",
                "34f847f2bbe15d3b",
                "f022d5898a696ebf",
                "0b2ad89132104852",
                "042c5d8445576637",
                "f77a6d4e6acb8a58",
                "3e5216204600adf7",
                "494dbbc109ff3992",
                "3bcdec2a17238e0c",
                "4be0a557693b5c35",
                "5832bd24f1a404ad"
            ]
        ]
    },
    {
        "id": "f14369720473e9f7",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 3,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 2",
        "format": "{{msg.payload.asInteger1[1]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 380,
        "wires": []
    },
    {
        "id": "03439064148ae32c",
        "type": "ui_button",
        "z": "ba40178493839cb7",
        "name": "",
        "group": "efcc13e5a5b82fc5",
        "order": 14,
        "width": "9",
        "height": "1",
        "passthru": false,
        "label": "Reset",
        "tooltip": "",
        "color": "",
        "bgcolor": "red",
        "className": "",
        "icon": "",
        "payload": "",
        "payloadType": "str",
        "topic": "topic",
        "topicType": "msg",
        "x": 170,
        "y": 400,
        "wires": [
            [
                "f14369720473e9f7",
                "4a9d8cb4d0c90c8c",
                "34f847f2bbe15d3b",
                "f022d5898a696ebf",
                "0b2ad89132104852",
                "042c5d8445576637",
                "f77a6d4e6acb8a58",
                "3e5216204600adf7",
                "494dbbc109ff3992",
                "3bcdec2a17238e0c",
                "4be0a557693b5c35",
                "5832bd24f1a404ad"
            ]
        ]
    },
    {
        "id": "34f847f2bbe15d3b",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 4,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 3",
        "format": "{{msg.payload.asInteger1[2]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 440,
        "wires": []
    },
    {
        "id": "f022d5898a696ebf",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 5,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 4",
        "format": "{{msg.payload.asInteger1[3]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 500,
        "wires": []
    },
    {
        "id": "0b2ad89132104852",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 6,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 5",
        "format": "{{msg.payload.asInteger1[4]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 540,
        "wires": []
    },
    {
        "id": "042c5d8445576637",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 7,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 6",
        "format": "{{msg.payload.asInteger1[5]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 580,
        "wires": []
    },
    {
        "id": "f77a6d4e6acb8a58",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 8,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 7",
        "format": "{{msg.payload.asInteger1[6]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 620,
        "wires": []
    },
    {
        "id": "3e5216204600adf7",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 9,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 8",
        "format": "{{msg.payload.asInteger1[7]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 660,
        "wires": []
    },
    {
        "id": "494dbbc109ff3992",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 10,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 9",
        "format": "{{msg.payload.asInteger1[8]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 700,
        "wires": []
    },
    {
        "id": "3bcdec2a17238e0c",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 11,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 10",
        "format": "{{msg.payload.asInteger1[9]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 740,
        "wires": []
    },
    {
        "id": "4be0a557693b5c35",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 12,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 11",
        "format": "{{msg.payload.asInteger1[10]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 780,
        "wires": []
    },
    {
        "id": "5832bd24f1a404ad",
        "type": "ui_text",
        "z": "ba40178493839cb7",
        "group": "efcc13e5a5b82fc5",
        "order": 13,
        "width": "2",
        "height": "2",
        "name": "",
        "label": "Oven 12",
        "format": "{{msg.payload.asInteger1[11]}}",
        "layout": "col-center",
        "className": "",
        "x": 540,
        "y": 820,
        "wires": []
    },
    {
        "id": "893956afe4c6c260",
        "type": "serial-port",
        "z": "ba40178493839cb7",
        "serialport": "COM11",
        "serialbaud": "9600",
        "databits": "7",
        "parity": "even",
        "stopbits": "2",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\n",
        "bin": "false",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    },
    {
        "id": "efcc13e5a5b82fc5",
        "type": "ui_group",
        "name": "",
        "tab": "d6f687902eee7759",
        "order": 2,
        "disp": true,
        "width": "9",
        "collapse": false,
        "className": ""
    },
    {
        "id": "d6f687902eee7759",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

Recording  1
Hi, I think I am able to read the data from Plc to be displayed to the node-red dashboard.

Agreed, found the specific msg.payload to display the data I needed...

Now, I would like to add some logic to the dashboard. For example, I want the oven text boxes to blink in either red or green colour.

Additionally, I want to plot the temperature vs time graph for all Ovens. Please suggest ways for this functions..

This is the sample which shows the oven number and the present temperature value at the ###. So when the oven is running, I want the oven button to flash in green. When the oven has completed its operation, I want the oven button to flash in red.

This is a separate conversation. You should really start a new thread (in the dashboard category), with a suitably relevant title - to permit right forum members to discover your dashboard question.

For the topic at hand, I believe that is now resolved & you should pick a post that you consider to be the solution and mark it as the solution
image

Clearly understood, thanks for your assistance :smile:

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