Can't send network variables to codesys

Hi, I am struggeling with sending network variables to codesys.
I am able to receive variables from PLC to Node-RED through node-red-contrib-nvl, but not the other way.

Node-RED V3.0.2 running on raspberry pi 4
Codesys 3.5 running on Deif AMC300

[
    {
        "id": "0b0cedbd47c94c35",
        "type": "tab",
        "label": "Codesys UECC",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "1a6f5a728e9537a6",
        "type": "udp out",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "addr": "192.168.1.97",
        "iface": "",
        "port": "1202",
        "ipv": "udp4",
        "outport": "",
        "base64": false,
        "multicast": "false",
        "x": 1210,
        "y": 260,
        "wires": []
    },
    {
        "id": "e1d02d7d119a83c4",
        "type": "udp in",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "iface": "",
        "port": "1202",
        "ipv": "udp4",
        "multicast": "false",
        "group": "",
        "datatype": "buffer",
        "x": 160,
        "y": 160,
        "wires": [
            [
                "f79a36fe563603f9",
                "6cc11dd97326b7fd"
            ]
        ]
    },
    {
        "id": "f79a36fe563603f9",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 490,
        "y": 100,
        "wires": []
    },
    {
        "id": "6cc11dd97326b7fd",
        "type": "nvl-receive",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "definition": "VAR_GLOBAL\n    xBool:  BOOL;\nEND_VAR",
        "listId": "1",
        "globaltypes": "e1676971a228cf35",
        "x": 490,
        "y": 160,
        "wires": [
            [
                "1585a99456d92050"
            ]
        ]
    },
    {
        "id": "1585a99456d92050",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 1170,
        "y": 160,
        "wires": []
    },
    {
        "id": "c38b0a5c0305d07e",
        "type": "nvl-send",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "definition": "VAR_GLOBAL\n    xBool2 : BOOL;\nEND_VAR\n\n",
        "listId": "3",
        "globaltypes": "e1676971a228cf35",
        "x": 480,
        "y": 260,
        "wires": [
            [
                "1a6f5a728e9537a6",
                "f80ae7976c014aba"
            ]
        ]
    },
    {
        "id": "da042db614c37923",
        "type": "inject",
        "z": "0b0cedbd47c94c35",
        "name": "False",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "0",
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 170,
        "y": 220,
        "wires": [
            [
                "b2bf3a6572586bf4"
            ]
        ]
    },
    {
        "id": "dfe07dd340b0d084",
        "type": "inject",
        "z": "0b0cedbd47c94c35",
        "name": "True",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": "1",
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 170,
        "y": 260,
        "wires": [
            [
                "b2bf3a6572586bf4"
            ]
        ]
    },
    {
        "id": "f80ae7976c014aba",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 690,
        "y": 320,
        "wires": []
    },
    {
        "id": "b2bf3a6572586bf4",
        "type": "function",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "func": "const bool = msg.payload;\n\nmsg.payload = {\n    \"xBool2\": bool\n}\n\nreturn msg;\n\n// {\n//     \"xBool\": true,\n// }",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 260,
        "wires": [
            [
                "c38b0a5c0305d07e",
                "6e0a73a3f78cb3ae"
            ]
        ]
    },
    {
        "id": "6e0a73a3f78cb3ae",
        "type": "debug",
        "z": "0b0cedbd47c94c35",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": true,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "payload",
        "statusType": "auto",
        "x": 490,
        "y": 320,
        "wires": []
    },
    {
        "id": "e1676971a228cf35",
        "type": "nvl-datatypes",
        "name": "",
        "datatypes": ""
    }
]

Send Node:
image

Network variables list (receiver):
image

Hello Mossi,

Did you try by temporally disabling your firewall on de CodeSys device? Is it also possible to share the full receiver configuration in CodeSys (or the imported file)?

Hi Hopperpop,

do you mean the network firewall or on the codesys device? Cant seem to find a firewall on the device..

<GVL>
  <Declarations><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL
    xBool2:  BOOL;
END_VAR]]></Declarations>
  <NetvarSettings Protocol="UDP">
    <ListIdentifier>3</ListIdentifier>
    <Pack>True</Pack>
    <Checksum>False</Checksum>
    <Acknowledge>False</Acknowledge>
    <CyclicTransmission>True</CyclicTransmission>
    <TransmissionOnChange>True</TransmissionOnChange>
    <TransmissionOnEvent>False</TransmissionOnEvent>
    <Interval>T#5000ms</Interval>
    <MinGap>T#20ms</MinGap>
    <EventVariable>
    </EventVariable>
    <ProtocolSettings>
      <ProtocolSetting Name="Broadcast Adr." Value="255.255.255.255" />
      <ProtocolSetting Name="Port" Value="1202" />
    </ProtocolSettings>
  </NetvarSettings>
</GVL>

I was indeed referring to the firewall on the codesys device. It's always possible that the firewall is blocking incoming traffic and allowing outgoing. Although if it works with another controller/plc it should be fine.

I have imported your flow and GVL into a codesys project. Changed the IP-adress of the udp sender node to the one of my controller, and everything works fine. Can you double check if your IP-adress is set correctly to the one of the controller in the udp node?

Not sure where I can find this setting on the PLC.
Waiting for answer from the supplier.
I'll update as soon as I get it.

The IP is correct. I have logged in to the web interface for the controller with the IP I use in Node-RED.

Thank you for the help @Hopperpop.

The firewall was the problem!

For anyone else facing this in the future:
temporarily disable firewall with these commands in cmd or login with PuTTy.

SSH admin@AMC300.local
 sudo su
 sudo nft flush ruleset

Great to hear that. But only fully disable the firewall to test and see if it's causing the issue. Keeping it enabled and adding a rule for all incoming traffic on port 1202, is the proper solution!

1 Like

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