OMRON PLC,use serial port to read data from scanner to write in and read,but i can't read it?How can i modify it?

[
    {
        "id": "f8555ecde23c4720",
        "type": "tab",
        "label": "流程 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "5bc474d41b9650ad",
        "type": "FINS Read",
        "z": "f8555ecde23c4720",
        "name": "",
        "connection": "23c3feb1965d4f37",
        "addressType": "str",
        "address": "D100",
        "countType": "num",
        "count": "24",
        "msgPropertyType": "msg",
        "msgProperty": "payload",
        "outputFormatType": "signed",
        "outputFormat": "",
        "x": 260,
        "y": 200,
        "wires": [
            [
                "a4da6569feb40eed"
            ]
        ]
    },
    {
        "id": "d1739de3e6619b8b",
        "type": "inject",
        "z": "f8555ecde23c4720",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 70,
        "y": 280,
        "wires": [
            [
                "5bc474d41b9650ad",
                "c755f7d780bf68b4"
            ]
        ]
    },
    {
        "id": "a4da6569feb40eed",
        "type": "buffer-parser",
        "z": "f8555ecde23c4720",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "int16be",
                "name": "计数器",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "result",
                "offset": 8,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "服务器错误代码",
                "offset": 20,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "面差检测",
                "offset": 36,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "孔位",
                "offset": 32,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "mask": ""
            },
            {
                "type": "int16be",
                "name": "急停",
                "offset": 28,
                "length": 1,
                "offsetbit": 0,
                "scale": "0",
                "mask": ""
            },
            {
                "type": "ascii",
                "name": "productBarcode",
                "offset": 40,
                "length": 38,
                "offsetbit": 0,
                "scale": "0",
                "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": 490,
        "y": 200,
        "wires": [
            [
                "98c259a1afeaf4af"
            ]
        ]
    },
    {
        "id": "c755f7d780bf68b4",
        "type": "FINS Read",
        "z": "f8555ecde23c4720",
        "name": "",
        "connection": "23c3feb1965d4f37",
        "addressType": "str",
        "address": "D950",
        "countType": "num",
        "count": "20",
        "msgPropertyType": "msg",
        "msgProperty": "payload",
        "outputFormatType": "buffer",
        "outputFormat": "buffer",
        "x": 260,
        "y": 360,
        "wires": [
            [
                "638d91d2dfeb3337"
            ]
        ]
    },
    {
        "id": "638d91d2dfeb3337",
        "type": "buffer-parser",
        "z": "f8555ecde23c4720",
        "name": "",
        "data": "payload",
        "dataType": "msg",
        "specification": "spec",
        "specificationType": "ui",
        "items": [
            {
                "type": "floatle",
                "name": "产品底部百分表 1",
                "offset": 0,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "产品底部百分表 2",
                "offset": 8,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "产品底部百分表 3",
                "offset": 16,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "产品底部百分表 4",
                "offset": 24,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            },
            {
                "type": "floatle",
                "name": "产品底部百分表 5",
                "offset": 32,
                "length": 1,
                "offsetbit": 0,
                "scale": "1",
                "mask": ""
            }
        ],
        "swap1": "swap16",
        "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": 470,
        "y": 360,
        "wires": [
            [
                "783582755a37df09"
            ]
        ]
    },
    {
        "id": "783582755a37df09",
        "type": "debug",
        "z": "f8555ecde23c4720",
        "name": "百分表",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 670,
        "y": 360,
        "wires": []
    },
    {
        "id": "f2f4d819d6d3091a",
        "type": "http request",
        "z": "f8555ecde23c4720",
        "name": "",
        "method": "POST",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://localhost:8080/checkData",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 940,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "98c259a1afeaf4af",
        "type": "function",
        "z": "f8555ecde23c4720",
        "name": "function 1",
        "func": "var temp = msg.payload;\nif(temp.result ==1)\n{\n    temp.result = 'NG'\n}else if(temp.result ==2)\n{\n    temp.result ='OK'\n}\n\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 680,
        "y": 200,
        "wires": [
            [
                "3ece98fd8b8c9d6a"
            ]
        ]
    },
    {
        "id": "3ece98fd8b8c9d6a",
        "type": "debug",
        "z": "f8555ecde23c4720",
        "name": "读取内存",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 800,
        "y": 100,
        "wires": []
    },
    {
        "id": "1cba9c97bcf7ac69",
        "type": "FINS Write",
        "z": "f8555ecde23c4720",
        "name": "",
        "connection": "23c3feb1965d4f37",
        "addressType": "str",
        "address": "D120",
        "dataType": "msg",
        "data": "payload",
        "msgPropertyType": "str",
        "msgProperty": "string",
        "x": 530,
        "y": 580,
        "wires": [
            [
                "709a05a2333fb13a"
            ]
        ]
    },
    {
        "id": "c95a1ea9049cf17e",
        "type": "serial in",
        "z": "f8555ecde23c4720",
        "name": "",
        "serial": "26f196590d49bd98",
        "x": 120,
        "y": 580,
        "wires": [
            [
                "95dc0ccd6e68f0e4"
            ]
        ]
    },
    {
        "id": "9ef511da140fe1b2",
        "type": "debug",
        "z": "f8555ecde23c4720",
        "name": "扫码",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 530,
        "y": 500,
        "wires": []
    },
    {
        "id": "709a05a2333fb13a",
        "type": "debug",
        "z": "f8555ecde23c4720",
        "name": "写入条码",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 700,
        "y": 500,
        "wires": []
    },
    {
        "id": "95dc0ccd6e68f0e4",
        "type": "function",
        "z": "f8555ecde23c4720",
        "name": "function 2",
        "func": "\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 320,
        "y": 580,
        "wires": [
            [
                "1cba9c97bcf7ac69",
                "9ef511da140fe1b2"
            ]
        ]
    },
    {
        "id": "aa344c576a88db13",
        "type": "FINS Write",
        "z": "f8555ecde23c4720",
        "name": "",
        "connection": "23c3feb1965d4f37",
        "addressType": "str",
        "address": "W19.00",
        "dataType": "num",
        "data": "1",
        "msgPropertyType": "str",
        "msgProperty": "int",
        "x": 520,
        "y": 660,
        "wires": [
            [
                "52e82a5bfac8a6d3"
            ]
        ]
    },
    {
        "id": "52e82a5bfac8a6d3",
        "type": "debug",
        "z": "f8555ecde23c4720",
        "name": "启动设备",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 700,
        "y": 660,
        "wires": []
    },
    {
        "id": "22f3685ed89fadba",
        "type": "inject",
        "z": "f8555ecde23c4720",
        "name": "",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "0050040600106B61327745240001",
        "payloadType": "str",
        "x": 110,
        "y": 500,
        "wires": [
            [
                "95dc0ccd6e68f0e4"
            ]
        ]
    },
    {
        "id": "23c3feb1965d4f37",
        "type": "FINS Connection",
        "name": "",
        "host": "192.168.154.103",
        "port": "9600",
        "MODE": "",
        "MODEType": "CJ",
        "protocol": "",
        "protocolType": "tcp",
        "ICF": "128",
        "DNA": "",
        "DA1": "103",
        "DA2": "",
        "SNA": "",
        "SA1": "",
        "SA2": "",
        "autoConnect": true
    },
    {
        "id": "26f196590d49bd98",
        "type": "serial-port",
        "name": "扫码枪扫描",
        "serialport": "COM7",
        "serialbaud": "57600",
        "databits": "8",
        "parity": "none",
        "stopbits": "1",
        "waitfor": "",
        "dtr": "none",
        "rts": "none",
        "cts": "none",
        "dsr": "none",
        "newline": "\\n",
        "bin": "false",
        "out": "char",
        "addchar": "",
        "responsetimeout": "10000"
    }
]

Sorry, there is not enough info to even begin looking at this.

Please provide a stepwise explanation of what your process and shall details.

Example:

  1. Poll Dm1000 and when it changes, send a start signal to the scanner
  2. When the scanner returns the value, set DM 1001 to the value of DM 1000 and the string data to DM1010~DM1099

Also include information for the serial scanner like what protocols it supports, what values it will return (string data? Raw bytes? 16 but unsigned integers? Etc?) and include links to manuals.

If you provide this level of information we may be able to advise.

When i scan a barcode(0050040600106B61327745240001,here is the code).I'll read the data and write it in D120 intactly(no format conversion).Meanwhile, write "1" in W19.00 to start the device.
After the end of the operation of the device, I will submit the barcode information read at the beginning and the device parameters through the interface

Not exactly the stepwise info i asked for (and no details on the device)


So where are you stuck?

  • Are you getting data into node-red from the scanner?
  • Are you struggling to write the data to the PLC?
  • " I will submit the barcode information read at the beginning and the device parameters through the interface"
    • are you stuck with this part?
    • what is "the interface"?


I am sorry that I did not make it clear. The data read from the scanner is normal, but there seems to be a problem with PLC writing, so the D120 I read is garbled(like 'b@').And here is the picture the device engineer show me what he read in D120

  1. What part of this data is required to be written to the PLC? All of it?

  2. What does it represent - tell me how 0050040600106B61327745240001 should look like once written to the PLC

  3. What data type is this? Is there any encoding? Is it UTF8?/ASCII?

you know, if you answer all the questions I can probably give you a very nice solution.

  • What is the barcode scanner make and model?
  • Provide an actual example of what is scanned AND the corresponding data you get into the debug node labeled 扫码
  • Plus, please answer all of the questions from my previous reply :point_up_2:

Now I have changed the method, the serial port is not very good to achieve my purpose, I now through a program written by myself (can be regarded as a local host computer, that is, the interface I mentioned before) scan the code to temporarily store the barcode information, and then read the parameters to submit to the server.

Just like with a PLC you can do an online edit and fix any issue during production, doing this all in Node-RED will give you the same benefits.

Now you have added a seperate program, you have LOST that capability and you have added another failure point and have make it harder to debug!

What a shame.


If you had simply provided the information I requested, I could have shown you how to avoid a separate application.

I know what your issue was - you were attempting to write a STRING to the OMRON PLC. OMRON expects 16 BIT Unsigned Integers.

If you simply told me what the data was supposed to be, I could have provided a VERY simple means of converting it inside Node-RED!

I'm sorry to trouble you, this is my first contact with Omron, I feel that this problem is because I do not understand the required string of this model, like the Siemens s7 only a string data type, it is very simple

It is simple in OMRON too, if you tell me what the data is supposed to be.

[{"id":"2560f47e361626d7","type":"buffer-parser","z":"f8555ecde23c4720","name":"Bytes to UINT16","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"uint16be","name":"barcodeData","offset":0,"length":-1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","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":320,"y":580,"wires":[["289427a8b4f8d8c2","1cba9c97bcf7ac69"]]},{"id":"1cba9c97bcf7ac69","type":"FINS Write","z":"f8555ecde23c4720","name":"","connection":"23c3feb1965d4f37","addressType":"str","address":"D120","dataType":"msg","data":"payload.barcodeData","msgPropertyType":"msg","msgProperty":"payload","x":530,"y":580,"wires":[["709a05a2333fb13a","aa344c576a88db13"]]},{"id":"23c3feb1965d4f37","type":"FINS Connection","name":"","host":"192.168.154.103","port":"9600","MODE":"","MODEType":"CJ","protocol":"","protocolType":"tcp","ICF":"128","DNA":"","DA1":"103","DA2":"","SNA":"","SA1":"","SA2":"","autoConnect":true}]

As for OMRON, you can set the memory viewer to view ASCII or you can add a TAG to the data and set its type.

To put it more simply, in fact, my previous purpose was to write the content obtained by scanning the code into the plc, and then read it with the device parameters intact, but in this process, I did not know whether to write or read out the problem (but the debug scanner was successfully read), resulting in my failure to achieve

I don't know if I can mention something other than the topic, I now have multiple read modules, now output multiple objects, but I want to combine these data into one object output, what should I do?

You can use a join node but I must warn you, the approach you have taken is not only the least optimal it will get you inconsistent data. Read this article if you want to understand why.

Export your flow & I will help you improve it.

[{"id":"f8555ecde23c4720","type":"tab","label":"流程 1","disabled":false,"info":"","env":[]},{"id":"b8e35e147d8200a6","type":"junction","z":"f8555ecde23c4720","x":660,"y":240,"wires":[["3cd7186a82f9385e"]]},{"id":"5bc474d41b9650ad","type":"FINS Read","z":"f8555ecde23c4720","name":"","connection":"23c3feb1965d4f37","addressType":"str","address":"D100","countType":"num","count":"24","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"buffer","outputFormat":"","x":280,"y":220,"wires":[["a4da6569feb40eed"]]},{"id":"a4da6569feb40eed","type":"buffer-parser","z":"f8555ecde23c4720","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"计数器","offset":0,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"int16be","name":"result","offset":8,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"int16be","name":"服务器错误代码","offset":20,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"int16be","name":"面差检测","offset":36,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"int16be","name":"孔位","offset":32,"length":1,"offsetbit":0,"scale":"0","mask":""},{"type":"int16be","name":"急停","offset":28,"length":1,"offsetbit":0,"scale":"0","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":510,"y":220,"wires":[["b8e35e147d8200a6"]]},{"id":"c755f7d780bf68b4","type":"FINS Read","z":"f8555ecde23c4720","name":"百分表显示","connection":"23c3feb1965d4f37","addressType":"str","address":"D950","countType":"num","count":"20","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"buffer","outputFormat":"buffer","x":250,"y":280,"wires":[["638d91d2dfeb3337"]]},{"id":"638d91d2dfeb3337","type":"buffer-parser","z":"f8555ecde23c4720","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"floatle","name":"产品底部百分表 1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"产品底部百分表 2","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"产品底部百分表 3","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"产品底部百分表 4","offset":24,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"floatle","name":"产品底部百分表 5","offset":32,"length":1,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"value","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":510,"y":280,"wires":[["b8e35e147d8200a6"]]},{"id":"c95a1ea9049cf17e","type":"serial in","z":"f8555ecde23c4720","name":"","serial":"26f196590d49bd98","x":120,"y":100,"wires":[["95dc0ccd6e68f0e4"]]},{"id":"95dc0ccd6e68f0e4","type":"function","z":"f8555ecde23c4720","name":"function 2","func":"msg.payload =1\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":320,"y":100,"wires":[["aa344c576a88db13"]]},{"id":"aa344c576a88db13","type":"FINS Write","z":"f8555ecde23c4720","name":"","connection":"23c3feb1965d4f37","addressType":"str","address":"W29.00","dataType":"msg","data":"payload","msgPropertyType":"str","msgProperty":"number","x":540,"y":100,"wires":[[]]},{"id":"087e5805d54456d9","type":"FINS Read","z":"f8555ecde23c4720","name":"百分表1超出报警","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.00","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":270,"y":360,"wires":[["b0313a353fa649ae"]]},{"id":"fb60aa0f78ef474a","type":"inject","z":"f8555ecde23c4720","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":50,"y":460,"wires":[["087e5805d54456d9","0da46281b715f1b5","7d02799e1102a99a","54e59aeda2a1c14d","e045bdda6f9c458e","74ddbad12e32e682","6e5bea9888146dd9","4906d31adc7c6b37","c755f7d780bf68b4","5bc474d41b9650ad","1a49e4d795cef1ad"]]},{"id":"0da46281b715f1b5","type":"FINS Read","z":"f8555ecde23c4720","name":"百分表2超出报警","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.01","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":270,"y":400,"wires":[["b0313a353fa649ae"]]},{"id":"7d02799e1102a99a","type":"FINS Read","z":"f8555ecde23c4720","name":"百分表3超出报警","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.02","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":270,"y":440,"wires":[["b0313a353fa649ae"]]},{"id":"54e59aeda2a1c14d","type":"FINS Read","z":"f8555ecde23c4720","name":"百分表4超出报警","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.03","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":270,"y":480,"wires":[["b0313a353fa649ae"]]},{"id":"e045bdda6f9c458e","type":"FINS Read","z":"f8555ecde23c4720","name":"百分表5超出报警","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.04","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":270,"y":520,"wires":[["b0313a353fa649ae"]]},{"id":"74ddbad12e32e682","type":"FINS Read","z":"f8555ecde23c4720","name":"绿灯状态","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.05","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":240,"y":560,"wires":[["b0313a353fa649ae"]]},{"id":"6e5bea9888146dd9","type":"FINS Read","z":"f8555ecde23c4720","name":"黄灯状态","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.06","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":240,"y":600,"wires":[["b0313a353fa649ae"]]},{"id":"4906d31adc7c6b37","type":"FINS Read","z":"f8555ecde23c4720","name":"红灯状态","connection":"23c3feb1965d4f37","addressType":"str","address":"W36.07","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":240,"y":640,"wires":[["b0313a353fa649ae"]]},{"id":"1a49e4d795cef1ad","type":"FINS Read","z":"f8555ecde23c4720","name":"孔位","connection":"23c3feb1965d4f37","addressType":"str","address":"D1200","countType":"num","count":"86","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"buffer","outputFormat":"buffer","x":230,"y":180,"wires":[["5fc4dba122221af5"]]},{"id":"5fc4dba122221af5","type":"buffer-parser","z":"f8555ecde23c4720","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16be","name":"孔1","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔2","offset":2,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔3","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔4","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔5","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔6","offset":10,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔7","offset":12,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔8","offset":14,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔9","offset":16,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔10","offset":18,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔11","offset":20,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔12","offset":22,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔13","offset":24,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔14","offset":26,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔15","offset":28,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔16","offset":30,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔17","offset":32,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔18","offset":34,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔19","offset":36,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔20","offset":38,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔21","offset":40,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔22","offset":42,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔23","offset":44,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔24","offset":46,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔25","offset":48,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔26","offset":50,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔27","offset":52,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔28","offset":54,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔29","offset":56,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔30","offset":58,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔31","offset":60,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔32","offset":62,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔33","offset":64,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔34","offset":66,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔35","offset":68,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔36","offset":70,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔37","offset":72,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔38","offset":74,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔39","offset":76,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔40","offset":78,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔41","offset":80,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔42","offset":82,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔43","offset":84,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔44","offset":86,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔45","offset":88,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔46","offset":90,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔47","offset":92,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔48","offset":94,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔49","offset":96,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔50","offset":98,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔51","offset":100,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔52","offset":102,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔53","offset":104,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔54","offset":106,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔55","offset":108,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔56","offset":110,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔57","offset":112,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔58","offset":114,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔59","offset":116,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔60","offset":118,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔61","offset":120,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔62","offset":122,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔63","offset":124,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔64","offset":126,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔65","offset":128,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔66","offset":130,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔67","offset":132,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔68","offset":134,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔69","offset":136,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔70","offset":138,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔71","offset":140,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔72","offset":142,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔73","offset":144,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔74","offset":146,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔75","offset":148,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔76","offset":150,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔77","offset":152,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔78","offset":154,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔79","offset":156,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔80","offset":158,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔81","offset":160,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔82","offset":162,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔83","offset":164,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔84","offset":166,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔85","offset":168,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16be","name":"孔86","offset":170,"length":1,"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":510,"y":180,"wires":[["b8e35e147d8200a6"]]},{"id":"b0313a353fa649ae","type":"function","z":"f8555ecde23c4720","name":"function 3","func":"var temp = msg.payload\n\nreturn msg;","outputs":1,"timeout":0,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":500,"wires":[["9d40cd93db77bf4c"]]},{"id":"9d40cd93db77bf4c","type":"debug","z":"f8555ecde23c4720","name":"debug 1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":640,"y":360,"wires":[]},{"id":"3cd7186a82f9385e","type":"debug","z":"f8555ecde23c4720","name":"debug 2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":760,"y":240,"wires":[]},{"id":"23c3feb1965d4f37","type":"FINS Connection","name":"","host":"192.168.154.103","port":"9600","MODE":"","MODEType":"CJ","protocol":"","protocolType":"tcp","ICF":"128","DNA":"","DA1":"103","DA2":"","SNA":"","SA1":"","SA2":"","autoConnect":true},{"id":"26f196590d49bd98","type":"serial-port","name":"扫码枪扫描","serialport":"COM7","serialbaud":"57600","databits":"8","parity":"none","stopbits":"1","waitfor":"","dtr":"none","rts":"none","cts":"none","dsr":"none","newline":"\\n","bin":"false","out":"char","addchar":"","responsetimeout":"10000"}]

Here it is.I am now scanning the barcode to start device, and then reading the memory and relay addresses respectively, these steps are synchronized, and then packaging the read data into an object output

So as I discuss in this article, reading single values is highly inefficient and WILL cause inconsistent data. Please read again and try to follow the design pattern.

The better solution is to read AS MANY THINGS AS POSSIBLE in one go.

Here is how you would get all of the status bits into one object all in a single network read:

[{"id":"ce02363c3b863bd4","type":"inject","z":"6eabb45f5cfc6486","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":860,"wires":[["34deab9df6792ef5"]]},{"id":"34deab9df6792ef5","type":"FINS Read","z":"6eabb45f5cfc6486","name":"W36 (CHANNEL)","connection":"23c3feb1965d4f37","addressType":"str","address":"W36","countType":"num","count":"1","msgPropertyType":"msg","msgProperty":"payload","outputFormatType":"signed","outputFormat":"","x":330,"y":860,"wires":[["0acbf0557c9438de"]]},{"id":"0acbf0557c9438de","type":"buffer-parser","z":"6eabb45f5cfc6486","name":"Parse alarm bits from W36","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"bool","name":"dial_1_alarm","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"bool","name":"dial_2_alarm","offset":0,"length":1,"offsetbit":1,"scale":"1","mask":""},{"type":"bool","name":"dial_3_alarm","offset":0,"length":1,"offsetbit":2,"scale":"1","mask":""},{"type":"bool","name":"dial_4_alarm","offset":0,"length":1,"offsetbit":3,"scale":"1","mask":""},{"type":"bool","name":"dial_5_alarm","offset":0,"length":1,"offsetbit":4,"scale":"1","mask":""},{"type":"bool","name":"status_green","offset":0,"length":1,"offsetbit":5,"scale":"1","mask":""},{"type":"bool","name":"status_yellow","offset":0,"length":1,"offsetbit":6,"scale":"1","mask":""},{"type":"bool","name":"status_red","offset":0,"length":1,"offsetbit":7,"scale":"1","mask":""}],"swap1":"swap16","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":610,"y":860,"wires":[["34b8cc2315240800"]]},{"id":"34b8cc2315240800","type":"debug","z":"6eabb45f5cfc6486","name":"All In One","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":700,"y":760,"wires":[]},{"id":"ef7f2b659653eff8","type":"inject","z":"6eabb45f5cfc6486","name":"test data 0000001111111111","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1023]","payloadType":"json","x":340,"y":780,"wires":[["0acbf0557c9438de"]]},{"id":"70119a3857a7ac2e","type":"inject","z":"6eabb45f5cfc6486","name":"test data 000000010000001","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[129]","payloadType":"json","x":340,"y":820,"wires":[["0acbf0557c9438de"]]},{"id":"8b8544b1773c63d7","type":"inject","z":"6eabb45f5cfc6486","name":"test data 0000000000000000","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[0]","payloadType":"json","x":340,"y":740,"wires":[["0acbf0557c9438de"]]},{"id":"23c3feb1965d4f37","type":"FINS Connection","d":true,"name":"","host":"192.168.154.103","port":"9600","MODE":"","MODEType":"CJ","protocol":"","protocolType":"tcp","ICF":"128","DNA":"","DA1":"103","DA2":"","SNA":"","SA1":"","SA2":"","autoConnect":true}]
1 Like

OK,thank you very much for your patience.I'll mark this solution,and It seems that it would be more convenient for the electrical engineer to put all the data directly into the memory and then read the storage addresses consecutively, so that I only need one read node :thinking:

1 Like

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