cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

How to trigger inject node 1 time when PLC BOOL variable become true?

How to trigger inject node 1 time when PLC BOOL variable become true?

Open
Occasional Contributor

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,

2 REPLIES 2

CodeShepherd
Community Moderator
Community Moderator

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.

Open
Occasional Contributor

Hello CodeShepherd,

I got it Thank you for your reply!

Open_0-1677487794502.png

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,

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist