FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
02-22-2023 09:05 AM - edited 02-22-2023 09:05 AM
Hello Community,
I have a PLC BOOL variable, when become true i want to trigger an inject node 1 time, how can it be done?
Warmest regards,
Solved! Go to Solution.
02-24-2023 03:21 PM - edited 02-24-2023 03:22 PM
I guess you are talking about an inject node in Node-RED. I would simply subscribe to the Boolean value and check in a function if its true and pass a message to the following nodes for that case. So your function is the trigger and no inject node is needed.
02-27-2023 09:50 AM - edited 02-27-2023 09:55 AM
Hello CodeShepherd,
I got it Thank you for your reply!
Below is my node red flow:
[
{
"id": "b2877cafbca42cf0",
"type": "trigger",
"z": "b052b93d5f84889b",
"name": "",
"op1": "1",
"op2": "0",
"op1type": "str",
"op2type": "str",
"duration": "-1",
"extend": false,
"overrideDelay": false,
"units": "s",
"reset": "",
"bytopic": "all",
"topic": "topic",
"outputs": 1,
"x": 960,
"y": 220,
"wires": [
[
"a8bbd8933e5e95a8"
]
]
},
{
"id": "f7b1bd6d2bc3e375",
"type": "switch",
"z": "b052b93d5f84889b",
"name": "",
"property": "payload",
"propertyType": "msg",
"rules": [
{
"t": "eq",
"v": "1",
"vt": "num"
}
],
"checkall": "true",
"repair": false,
"outputs": 1,
"x": 730,
"y": 220,
"wires": [
[
"b2877cafbca42cf0",
"a46ab9947e2d09aa"
]
]
},
{
"id": "e36410cfd03fd9cf",
"type": "function",
"z": "b052b93d5f84889b",
"name": "function 1",
"func": "if (msg.payload == true){\n msg.payload = 1\n}else{\nmsg.payload =0\n}\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 220,
"wires": [
[
"f7b1bd6d2bc3e375"
]
]
},
{
"id": "ec2fb91b01ca9d98",
"type": "debug",
"z": "b052b93d5f84889b",
"name": "debug 36",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "payload",
"targetType": "msg",
"statusVal": "",
"statusType": "auto",
"x": 540,
"y": 160,
"wires": []
},
{
"id": "bc39c6782c1dc096",
"type": "ctrlx-datalayer-subscribe",
"z": "b052b93d5f84889b",
"subscription": "966476dc2fbcc0ca",
"path": "plc/app/Application/sym/GVL/bStartRecord",
"name": "",
"x": 280,
"y": 220,
"wires": [
[
"ec2fb91b01ca9d98",
"e36410cfd03fd9cf"
]
]
},
{
"id": "966476dc2fbcc0ca",
"type": "ctrlx-config-subscription",
"device": "ec1807ac.c7c0e8",
"name": "ctrlX",
"publishIntervalMs": ""
},
{
"id": "ec1807ac.c7c0e8",
"type": "ctrlx-config",
"name": "ctrlX",
"hostname": "192.168.1.1",
"debug": true
}
]
In my PLC program i wrote my BOOL variable to stay TRUE for 5 seconds so that my node red will not have response time issue.
Warmest regards,