I am trying to write an INT value to a data block of an S7 1500 PLC. The PUT/GET is active on the PLC and the data block is set as non-optimized.
Unfortunately, the connection fails and there are multiple SET/RESET messages coming on the debug window. The PLC loses its connection.
Could anyone tell me where I am wrong?Below is the flow script.
[
{
"id": "3795c868.c46f28",
"type": "tab",
"label": "Flow 1",
"disabled": false,
"info": ""
},
{
"id": "449fe82c.bbd1d8",
"type": "sqlite",
"z": "3795c868.c46f28",
"mydb": "6d91ad95.41cb34",
"sqlquery": "msg.topic",
"sql": "",
"name": "first DB",
"x": 340,
"y": 100,
"wires": [
[
"b9566216.e59c4"
]
]
},
{
"id": "a838e9b6.bda7e8",
"type": "inject",
"z": "3795c868.c46f28",
"name": "",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "SELECT EmployeeCode FROM main_main where EmployeeCode=3191;",
"payload": "",
"payloadType": "date",
"x": 120,
"y": 100,
"wires": [
[
"449fe82c.bbd1d8"
]
]
},
{
"id": "d61145d.b09bbb8",
"type": "sqlite",
"z": "3795c868.c46f28",
"mydb": "d43ee697.382ab8",
"sqlquery": "msg.topic",
"sql": "temp2",
"name": "second DB",
"x": 410,
"y": 320,
"wires": [
[
"e4189c35.a8af7"
]
]
},
{
"id": "b9566216.e59c4",
"type": "function",
"z": "3795c868.c46f28",
"name": "first function",
"func": "//msg.payload = msg.payload[0].EmployeeCode;\n\n//SELECT access_level FROM ID_Authentication_Acess where employee_id=3191\n\n\n//var temp = context.get('temp');\n\n//var tttt= msg.payload[0].EmployeeCode;\n//context.set('temp' ,tttt);\n//return msg;\n\n\n\n//flow.set('temp1',msg.payload= temp1;\n\nvar myDataArray = msg.payload;\nvar id_1 = myDataArray[0].EmployeeCode;\nmsg.topic = \"SELECT access_level FROM ID_Authentication_Acess where employee_id=\"+ id_1;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 190,
"y": 260,
"wires": [
[
"7742086c.55c1d8"
]
]
},
{
"id": "7742086c.55c1d8",
"type": "function",
"z": "3795c868.c46f28",
"name": "second function",
"func": "//var ttt= msg.payload[0].EmployeeCode;\n//var temp2 = {\n //\"topic\":\"SELECT access_level FROM ID_Authentication_Acess where employee_id=\"+ttt };\n//msg.payload=msg.payload+temp2;\n\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 360,
"y": 220,
"wires": [
[
"d61145d.b09bbb8"
]
]
},
{
"id": "c2266158.feef7",
"type": "debug",
"z": "3795c868.c46f28",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "false",
"statusVal": "",
"statusType": "auto",
"x": 890,
"y": 220,
"wires": []
},
{
"id": "e4189c35.a8af7",
"type": "function",
"z": "3795c868.c46f28",
"name": "Function 3",
"func": "msg.payload = msg.payload[0].access_level;\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"x": 630,
"y": 320,
"wires": [
[
"edd2cd9c.1f053",
"c2266158.feef7"
]
]
},
{
"id": "edd2cd9c.1f053",
"type": "s7 control",
"z": "3795c868.c46f28",
"endpoint": "fc286d57.9b9d1",
"function": "trigger",
"name": "S7 1500",
"x": 900,
"y": 400,
"wires": [
[]
]
},
{
"id": "6d91ad95.41cb34",
"type": "sqlitedb",
"z": "",
"db": "C:\\Users\\amaresh.lenka\\Documents\\WebsiteDevelopment\\GUI\\mysite\\db.sqlite3",
"mode": "RO"
},
{
"id": "d43ee697.382ab8",
"type": "sqlitedb",
"z": "",
"db": "C:\\Users\\amaresh.lenka\\Documents\\Database\\ID_access_DB.db",
"mode": "RWC"
},
{
"id": "fc286d57.9b9d1",
"type": "s7 endpoint",
"z": "",
"transport": "iso-on-tcp",
"address": "192.168.50.10",
"port": "102",
"rack": "0",
"slot": "1",
"localtsaphi": "01",
"localtsaplo": "00",
"remotetsaphi": "01",
"remotetsaplo": "00",
"connmode": "rack-slot",
"adapterauto": true,
"adapterport": "",
"busaddr": "2",
"adapteraddr": "0",
"cycletime": "500",
"timeout": "1500",
"verbose": "on",
"name": "",
"vartable": [
{
"addr": "DB6, I2",
"name": "DB6, I2"
}
]
}
]