Respected Steve Sir,
I don't understand it.
Ok I got the point that when I convert it to array each element is of 16 bit rather then 8 bit but then how do i get correct response. ?
After converting it to buffer as you said for the same pressure reading I am getting different values.
What data type should I keep ?
I kept int16(le) as the data is coming in little endian from SMC.
I want to read byte 10 and byte 11 so int16.
Now I am getting more and more confused.
how do i remove Byte10.0, byte 10.1 and byte 10.2 which is not relevant to me ?
I use >>>3 in scaling. is it correct ?
[
{
"id": "d46daf54501e291d",
"type": "tab",
"label": "Bihl Wiedemann OPC Server",
"disabled": false,
"info": "",
"env": []
},
{
"id": "5a6ae3bbd703e75f",
"type": "mqtt in",
"z": "d46daf54501e291d",
"name": "",
"topic": "RaspberryPi",
"qos": "2",
"datatype": "auto-detect",
"broker": "6c8927a5ed0034ab",
"nl": false,
"rap": true,
"rh": 0,
"inputs": 0,
"x": 134.8666648864746,
"y": 76.00000858306885,
"wires": [
[
"216ea618f6df5f13"
]
]
},
{
"id": "89299e81421bcf02",
"type": "mqtt out",
"z": "d46daf54501e291d",
"name": "",
"topic": "SiemensLaptop",
"qos": "",
"retain": "",
"respTopic": "",
"contentType": "",
"userProps": "",
"correl": "",
"expiry": "",
"broker": "6c8927a5ed0034ab",
"x": 299.8666687011719,
"y": 155.13333892822266,
"wires": []
},
{
"id": "b442ac8370bb0764",
"type": "inject",
"z": "d46daf54501e291d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "HI Raspberry Pi, I am Siemens Laptop and communicating with you from IP 192.168.1.119",
"payloadType": "str",
"x": 112.8666763305664,
"y": 154.00003051757812,
"wires": [
[
"89299e81421bcf02"
]
]
},
{
"id": "216ea618f6df5f13",
"type": "debug",
"z": "d46daf54501e291d",
"name": "debug 8",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 317.9333267211914,
"y": 78.9333267211914,
"wires": []
},
{
"id": "b7e1066612ea64b5",
"type": "inject",
"z": "d46daf54501e291d",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 108.93331909179688,
"y": 444.93335819244385,
"wires": [
[
"062398eb8c4d4b6d",
"866d89542c3718d7"
]
]
},
{
"id": "20d51df8772ac674",
"type": "OpcUa-Client",
"z": "d46daf54501e291d",
"endpoint": "d5876577da118764",
"action": "read",
"deadbandtype": "a",
"deadbandvalue": 1,
"time": 10,
"timeUnit": "s",
"certificate": "n",
"localfile": "",
"localkeyfile": "",
"securitymode": "None",
"securitypolicy": "None",
"useTransport": false,
"maxChunkCount": 1,
"maxMessageSize": 8192,
"receiveBufferSize": 8192,
"sendBufferSize": 8192,
"setstatusandtime": false,
"keepsessionalive": false,
"name": "",
"x": 460.93326568603516,
"y": 339.93335914611816,
"wires": [
[
"05cad23cc3152ad8",
"7f1a8165644967b8"
],
[],
[]
]
},
{
"id": "062398eb8c4d4b6d",
"type": "OpcUa-Item",
"z": "d46daf54501e291d",
"item": "ns=2;s=type=0&circ=0&slavenr=1.ProcessData.InputData",
"datatype": "Byte",
"value": "",
"name": "",
"x": 280.7333755493164,
"y": 339.6667585372925,
"wires": [
[
"20d51df8772ac674"
]
]
},
{
"id": "05cad23cc3152ad8",
"type": "debug",
"z": "d46daf54501e291d",
"name": "Output of OPC client",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 689.9333877563477,
"y": 326.9333906173706,
"wires": []
},
{
"id": "166bcf76d196177e",
"type": "buffer-parser",
"z": "d46daf54501e291d",
"name": "",
"data": "payload",
"dataType": "msg",
"specification": "spec",
"specificationType": "ui",
"items": [
{
"type": "int16le",
"name": "pressureSensorValue",
"offset": 10,
"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": false,
"outputs": 1,
"x": 872.2222709655762,
"y": 264.00007152557373,
"wires": [
[
"a2e5ad7a2c35696c",
"7458146d6ba70545"
]
]
},
{
"id": "a2e5ad7a2c35696c",
"type": "function",
"z": "d46daf54501e291d",
"name": "Scaling with 0.00025",
"func": "var valueFromObject = Object.values(msg.payload);\nvar finalPressureValue = Number(valueFromObject);\nmsg.payload = Number(((finalPressureValue * 0.00025)- 0.25).toFixed(3));\nnode.status({ fill: \"red\", shape: \"ring\", text: msg.payload });\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 1085.333236694336,
"y": 246.22223663330078,
"wires": [
[
"96e5732431e7159a"
]
]
},
{
"id": "7458146d6ba70545",
"type": "debug",
"z": "d46daf54501e291d",
"name": "Output of Parser",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 1069.111125946045,
"y": 297.11112213134766,
"wires": []
},
{
"id": "96e5732431e7159a",
"type": "debug",
"z": "d46daf54501e291d",
"name": "Final pressure Value",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 1141.111068725586,
"y": 162.11110591888428,
"wires": []
},
{
"id": "866d89542c3718d7",
"type": "OpcUa-Item",
"z": "d46daf54501e291d",
"item": "ns=2;s=type=0&circ=0&slavenr=2.ProcessData.InputData",
"datatype": "Byte Array",
"value": "",
"name": "",
"x": 297.11112213134766,
"y": 540.111123085022,
"wires": [
[
"936db14a473ab75b"
]
]
},
{
"id": "936db14a473ab75b",
"type": "OpcUa-Client",
"z": "d46daf54501e291d",
"endpoint": "d5876577da118764",
"action": "read",
"deadbandtype": "a",
"deadbandvalue": 1,
"time": 10,
"timeUnit": "s",
"certificate": "n",
"localfile": "",
"localkeyfile": "",
"securitymode": "None",
"securitypolicy": "None",
"useTransport": false,
"maxChunkCount": 1,
"maxMessageSize": 8192,
"receiveBufferSize": 8192,
"sendBufferSize": 8192,
"setstatusandtime": false,
"keepsessionalive": false,
"name": "",
"x": 485.11112213134766,
"y": 540.1111240386963,
"wires": [
[
"a607bbea08af8f97",
"13b6ec4236cb4585"
],
[],
[]
]
},
{
"id": "a607bbea08af8f97",
"type": "debug",
"z": "d46daf54501e291d",
"name": "Output of OPC client",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "true",
"targetType": "full",
"statusVal": "payload",
"statusType": "auto",
"x": 708.1111221313477,
"y": 528.111123085022,
"wires": []
},
{
"id": "d5b6cef6647867bf",
"type": "buffer-parser",
"z": "d46daf54501e291d",
"name": "",
"data": "payload",
"dataType": "msg",
"specification": "spec",
"specificationType": "ui",
"items": [
{
"type": "int16le",
"name": "TiltingTableAngle",
"offset": 2,
"length": 1,
"offsetbit": 0,
"scale": "0.01",
"mask": ""
}
],
"swap1": "",
"swap2": "",
"swap3": "",
"swap1Type": "swap",
"swap2Type": "swap",
"swap3Type": "swap",
"msgProperty": "payload",
"msgPropertyType": "str",
"resultType": "keyvalue",
"resultTypeType": "return",
"multipleResult": false,
"fanOutMultipleResult": false,
"setTopic": false,
"outputs": 1,
"x": 900.1111259460449,
"y": 587.1111545562744,
"wires": [
[
"89189a0edce3a835"
]
]
},
{
"id": "89189a0edce3a835",
"type": "debug",
"z": "d46daf54501e291d",
"name": "debug 9",
"active": false,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 1061.1110649108887,
"y": 586.1111555099487,
"wires": []
},
{
"id": "cf73580e64c54f94",
"type": "inject",
"z": "d46daf54501e291d",
"name": "",
"props": [],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"x": 123.11112213134766,
"y": 695.222240447998,
"wires": [
[
"e2297343b184f20a"
]
],
"l": false
},
{
"id": "e2297343b184f20a",
"type": "function",
"z": "d46daf54501e291d",
"name": "Fake Port1 data (Uint8Array)",
"func": "msg.payload = new Uint8Array([94,18,0,0,0,0,0,0,0,0,0,0,0,0,0,0])\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 288.11112213134766,
"y": 695.222240447998,
"wires": [
[
"787c7220c0098364",
"e8ac9b93237b3259"
]
]
},
{
"id": "e8ac9b93237b3259",
"type": "debug",
"z": "d46daf54501e291d",
"name": "OPC UA Data",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 348.11112213134766,
"y": 755.222240447998,
"wires": []
},
{
"id": "787c7220c0098364",
"type": "function",
"z": "d46daf54501e291d",
"name": "Convert to Buffer",
"func": "msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 558.1111221313477,
"y": 695.222240447998,
"wires": [
[
"2609f20636755837"
]
]
},
{
"id": "2609f20636755837",
"type": "debug",
"z": "d46daf54501e291d",
"name": "Converted for parser",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": true,
"complete": "payload",
"targetType": "msg",
"statusVal": "payload",
"statusType": "auto",
"x": 628.1111221313477,
"y": 755.222240447998,
"wires": []
},
{
"id": "7f1a8165644967b8",
"type": "function",
"z": "d46daf54501e291d",
"name": "Convert to Buffer",
"func": "msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 682.1111297607422,
"y": 264.2222366333008,
"wires": [
[
"166bcf76d196177e"
]
]
},
{
"id": "13b6ec4236cb4585",
"type": "function",
"z": "d46daf54501e291d",
"name": "Convert to Buffer",
"func": "msg.payload = Buffer.from(msg.payload);\nnode.status({ fill: \"red\", shape: \"ring\", text: [...msg.payload.values()].toString() });\nreturn msg;",
"outputs": 1,
"timeout": 0,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 702.1111221313477,
"y": 588.2222394943237,
"wires": [
[
"d5b6cef6647867bf"
]
]
},
{
"id": "6c8927a5ed0034ab",
"type": "mqtt-broker",
"name": "",
"broker": "192.168.1.200",
"port": 1883,
"clientid": "",
"autoConnect": true,
"usetls": false,
"protocolVersion": 4,
"keepalive": 60,
"cleansession": true,
"autoUnsubscribe": true,
"birthTopic": "",
"birthQos": "0",
"birthRetain": "false",
"birthPayload": "",
"birthMsg": {},
"closeTopic": "",
"closeQos": "0",
"closeRetain": "false",
"closePayload": "",
"closeMsg": {},
"willTopic": "",
"willQos": "0",
"willRetain": "false",
"willPayload": "",
"willMsg": {},
"userProps": "",
"sessionExpiry": ""
},
{
"id": "d5876577da118764",
"type": "OpcUa-Endpoint",
"endpoint": "opc.tcp://192.168.10.40:4840",
"secpol": "Basic256",
"secmode": "Sign",
"none": false,
"login": true,
"usercert": false,
"usercertificate": "",
"userprivatekey": ""
},
{
"id": "d95953a57a8ab1a5",
"type": "global-config",
"env": [],
"modules": {
"node-red-contrib-opcua": "0.2.340",
"node-red-contrib-buffer-parser": "3.2.2"
}
}
]