PLC -> Buffer -> TCP Connection w/ Laptop ->Buffer Parser -> CSV

We are working on creating a csv file from flow sensor data for a project. The flow sensor data will be coming from a s7 PLC (we have the node for that set up). I then plan to turn that data into a buffer and use a TCP connection (also working) to send the buffer to my laptop where I will parse the buffer into either an array or a series of floats/doubles. Those values will then be made into a csv file on my laptop that can be used for other processes we will be completing.

The problem here is that I am not the most comfortable with creating and parsing the buffer. Are there any straightforward resources that any of you used for working with buffers? I'm extremely new to Node-Red.

I would look at the excellent node-red-contrib-buffer-parser node... that probably does exactly what you want. It has lots of examples under the menu - import - examples list.

2 Likes

I found the example, and I see a few that mimic PLC data. I believe this will be very helpful, so thank you.

As long as you have the manual for your device that descibes how the data is packed then we should be able to help you unpack it into something useful.

2 Likes

So it has come to my attention that instead on a TCP connection, I could use a MQTT node. This should remove my need for buffers. I don't have the PLC node set-up yet (I'm currently playing with this from my computer away from our IoT module). However, the PLC data will be sent to a function where I will take on a topic to the msg. Then, I should be able to send the msg to a MQTT node to be sent to my computer (where I am running mosquitto). Is my understanding of how this works correct? My code is below:

[
    {
        "id": "3cd910722e16ce1f",
        "type": "mqtt out",
        "z": "797817a747fe6a25",
        "name": "",
        "topic": "PLCData",
        "qos": "",
        "retain": "",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "407a01e4.6b637",
        "x": 580,
        "y": 460,
        "wires": []
    },
    {
        "id": "afae811ab5ae6cdd",
        "type": "s7 in",
        "z": "797817a747fe6a25",
        "endpoint": "",
        "mode": "single",
        "variable": "",
        "diff": true,
        "name": "",
        "x": 230,
        "y": 420,
        "wires": [
            [
                "3528fb91eb956713"
            ]
        ]
    },
    {
        "id": "3528fb91eb956713",
        "type": "function",
        "z": "797817a747fe6a25",
        "name": "Add Topic",
        "func": "msg.payload;\nmsg.topic = \"PLCData\";\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 420,
        "wires": [
            [
                "3cd910722e16ce1f"
            ]
        ]
    },
    {
        "id": "407a01e4.6b637",
        "type": "mqtt-broker",
        "broker": "localhost",
        "port": "1883",
        "clientid": "",
        "usetls": false,
        "compatmode": true,
        "keepalive": "60",
        "cleansession": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "willTopic": "",
        "willQos": "0",
        "willPayload": ""
    }
]

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