# Msg.payload is changing two outputs

**URL:** https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789
**Category:** General
**Created:** [21 March 2023 18:47 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789 "2023-03-21T18:47:13Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [21 March 2023 18:47 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/1 "2023-03-21T18:47:13Z")

</div>

Hi guys,

I'm pretty new to both node red and coding so I apologize if this is a stupid question. I'm using a LOGO 8 and node red to mock up a vibration analysis system for bearings. As I don't have any sensors at the moment I'm just injecting values into flag (M) blocks and using the value of that to change an output message using an if statement by monitoring the msg.payload they output. The problem I've come up against is that when I have 2 "bearings" and I click the inject on one of them, the message changes for both. Obviously this is because the msg.payload is changing and my if statement doesn't care where it is from, just that it is changing. My question is, how can I split my msg depending on where the input is from or is there a better way to do this? JS code and a picture of flow are posted below.

```auto

if (msg.payload >= 101) {
    msg.payload = "V. High Hertz - Bearing failure imminent!"
} else if (msg.payload <= 100 && msg.payload >= 81) {
    msg.payload = "High Hz - Bearing failure detected."
} else if (msg.payload <= 80 && msg.payload >= 41) {
    msg.payload = "Bearing Hz within parameters"
} else if (msg.payload <= 40 && msg.payload >= 20) {
    msg.payload = "Low Hz"
} else if (msg.payload == 0) {
    msg.payload = "Machine not running."
}

return msg;

```

 ![Screenshot 2023-03-21 184651](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/2/a2c2b25699bd84b8974b8e2cf8a44b1960e783e0.png)

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [21 March 2023 19:03 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/2 "2023-03-21T19:03:47Z")

</div>

> [@whelpleyjf](#):
>
> Obviously this is because the msg.payload is changing and my if statement doesn't care where it is from, just that it is changing.

Looking at the picture of your flow, I doubt that this is the case.  
If you post the flow data here (export it from the editor via the menu & please format it as "preformatted text"), we'll be able to have a closer look.

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [21 March 2023 19:21 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/3 "2023-03-21T19:21:23Z")

</div>

I assume this is what you want?

```auto
[
    {
        "id": "c565ec84b57dc443",
        "type": "tab",
        "label": "Vibration Analysis Monitoring System",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "dd6c88d00ca9774d",
        "type": "function",
        "z": "c565ec84b57dc443",
        "name": "Hz/If monitor",
        "func": "if (msg.payload >= 101) {\n msg.payload = \"V. High Hertz - Bearing failure imminent!\"\n} else if (msg.payload <= 100 && msg.payload >= 81) {\n msg.payload = \"High Hz - Bearing failure detected.\"\n} else if (msg.payload <= 80 && msg.payload >= 41) {\n msg.payload = \"Bearing Hz within parameters\"\n} else if (msg.payload <= 40 && msg.payload >= 20) {\n msg.payload = \"Low Hz\"\n} else if (msg.payload == 0) {\n msg.payload = \"Machine not running.\"\n}\n\nreturn msg;\n\nvar hzSpike = 0;\n\nif (msg.payload > 100) {\n hzSpike = hzSpike + 1\n}\n\nif (hzSpike >= 10) {\n msg.payload = \"Hz spiking detected!\"\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 20,
        "wires": [
            [
                "8a8adb8828852a4a",
                "bba0907895a46563"
            ]
        ]
    },
    {
        "id": "d749b6750dfcc567",
        "type": "s7 in",
        "z": "c565ec84b57dc443",
        "endpoint": "30d25704f03d7b38",
        "mode": "single",
        "variable": "Bearing 1",
        "diff": true,
        "name": "",
        "x": 60,
        "y": 20,
        "wires": [
            [
                "dd6c88d00ca9774d",
                "224192b56bea68b8"
            ]
        ]
    },
    {
        "id": "06b438c17f8bc55a",
        "type": "s7 out",
        "z": "c565ec84b57dc443",
        "endpoint": "30d25704f03d7b38",
        "variable": "Bearing 1",
        "name": "",
        "x": 380,
        "y": 280,
        "wires": []
    },
    {
        "id": "9f409172000326fa",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "971e59507afd7d4d",
        "order": 12,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "101 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "101",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 220,
        "wires": [
            [
                "06b438c17f8bc55a"
            ]
        ]
    },
    {
        "id": "a3b3f675562eaa8f",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "971e59507afd7d4d",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "0 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "0",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 460,
        "wires": [
            [
                "06b438c17f8bc55a"
            ]
        ]
    },
    {
        "id": "8a8adb8828852a4a",
        "type": "ui_text",
        "z": "c565ec84b57dc443",
        "group": "971e59507afd7d4d",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Bearing 1",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 440,
        "y": 20,
        "wires": []
    },
    {
        "id": "bba0907895a46563",
        "type": "debug",
        "z": "c565ec84b57dc443",
        "name": "debug 7",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 80,
        "wires": []
    },
    {
        "id": "656e8e331da91c7e",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "971e59507afd7d4d",
        "order": 10,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "81 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "81",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 280,
        "wires": [
            [
                "06b438c17f8bc55a"
            ]
        ]
    },
    {
        "id": "ed467d1807ef14ee",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "971e59507afd7d4d",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "41 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "41",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 340,
        "wires": [
            [
                "06b438c17f8bc55a"
            ]
        ]
    },
    {
        "id": "186660b9ee34d2a8",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "971e59507afd7d4d",
        "order": 6,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "20 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "20",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 70,
        "y": 400,
        "wires": [
            [
                "06b438c17f8bc55a"
            ]
        ]
    },
    {
        "id": "114499ce4ec5dea1",
        "type": "function",
        "z": "c565ec84b57dc443",
        "name": "Hz/If monitor",
        "func": "if (msg.payload >= 101) {\n msg.payload = \"V. High Hertz - Bearing failure imminent!\"\n} else if (msg.payload <= 100 && msg.payload >= 81) {\n msg.payload = \"High Hz - Bearing failure detected.\"\n} else if (msg.payload <= 80 && msg.payload >= 41) {\n msg.payload = \"Bearing Hz within parameters\"\n} else if (msg.payload <= 40 && msg.payload >= 20) {\n msg.payload = \"Low Hz\"\n} else if (msg.payload == 0) {\n msg.payload = \"Machine not running.\"\n}\n\nreturn msg;\n\nvar hzSpike = 0;\n\nif (msg.payload > 100) {\n hzSpike = hzSpike + 1\n}\n\nif (hzSpike >= 10) {\n msg.payload = \"Hz spiking detected!\"\n}\n\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 120,
        "wires": [
            [
                "d3937371f8ec1b69",
                "a7dbc91be690bfb6"
            ]
        ]
    },
    {
        "id": "05e35c983b0b2532",
        "type": "s7 in",
        "z": "c565ec84b57dc443",
        "endpoint": "30d25704f03d7b38",
        "mode": "single",
        "variable": "Bearing 2",
        "diff": true,
        "name": "",
        "x": 60,
        "y": 120,
        "wires": [
            [
                "114499ce4ec5dea1",
                "13cf828a78d5300c"
            ]
        ]
    },
    {
        "id": "d3937371f8ec1b69",
        "type": "ui_text",
        "z": "c565ec84b57dc443",
        "group": "3f7cc53c64571341",
        "order": 1,
        "width": 0,
        "height": 0,
        "name": "",
        "label": "Bearing 2",
        "format": "{{msg.payload}}",
        "layout": "row-spread",
        "className": "",
        "x": 440,
        "y": 120,
        "wires": []
    },
    {
        "id": "a7dbc91be690bfb6",
        "type": "debug",
        "z": "c565ec84b57dc443",
        "name": "debug 8",
        "active": false,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 180,
        "wires": []
    },
    {
        "id": "224192b56bea68b8",
        "type": "debug",
        "z": "c565ec84b57dc443",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 200,
        "y": 80,
        "wires": []
    },
    {
        "id": "13cf828a78d5300c",
        "type": "debug",
        "z": "c565ec84b57dc443",
        "name": "debug 10",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 200,
        "y": 180,
        "wires": []
    },
    {
        "id": "f5313920b4045f5a",
        "type": "s7 out",
        "z": "c565ec84b57dc443",
        "endpoint": "30d25704f03d7b38",
        "variable": "Bearing 2",
        "name": "",
        "x": 760,
        "y": 400,
        "wires": []
    },
    {
        "id": "159f9fbbea0c0bda",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "3f7cc53c64571341",
        "order": 12,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "101 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "101",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 450,
        "y": 340,
        "wires": [
            [
                "f5313920b4045f5a"
            ]
        ]
    },
    {
        "id": "1b148bca307ec808",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "3f7cc53c64571341",
        "order": 4,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "0 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "0",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 450,
        "y": 580,
        "wires": [
            [
                "f5313920b4045f5a"
            ]
        ]
    },
    {
        "id": "7d20e59f99f14514",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "3f7cc53c64571341",
        "order": 10,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "81 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "81",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 450,
        "y": 400,
        "wires": [
            [
                "f5313920b4045f5a"
            ]
        ]
    },
    {
        "id": "316718458959d3bf",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "3f7cc53c64571341",
        "order": 8,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "41 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "41",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 450,
        "y": 460,
        "wires": [
            [
                "f5313920b4045f5a"
            ]
        ]
    },
    {
        "id": "5dafba5e5fc206a4",
        "type": "ui_button",
        "z": "c565ec84b57dc443",
        "name": "",
        "group": "3f7cc53c64571341",
        "order": 6,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "20 Hz Inject",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "20",
        "payloadType": "num",
        "topic": "topic",
        "topicType": "msg",
        "x": 450,
        "y": 520,
        "wires": [
            [
                "f5313920b4045f5a"
            ]
        ]
    },
    {
        "id": "30d25704f03d7b38",
        "type": "s7 endpoint",
        "transport": "iso-on-tcp",
        "address": "192.168.0.3",
        "port": "102",
        "rack": "0",
        "slot": "2",
        "localtsaphi": "02",
        "localtsaplo": "00",
        "remotetsaphi": "03",
        "remotetsaplo": "00",
        "connmode": "tsap",
        "adapter": "",
        "busaddr": "2",
        "cycletime": "1000",
        "timeout": "2000",
        "name": "VAMS",
        "vartable": [
            {
                "addr": "DB1,WORD1104",
                "name": "Bearing 1"
            },
            {
                "addr": "DB1,WORD1104.1",
                "name": "Bearing 2"
            }
        ]
    },
    {
        "id": "971e59507afd7d4d",
        "type": "ui_group",
        "name": "Bearing 1",
        "tab": "104e99694bfd0fcc",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "3f7cc53c64571341",
        "type": "ui_group",
        "name": "Bearing 2",
        "tab": "104e99694bfd0fcc",
        "order": 2,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "104e99694bfd0fcc",
        "type": "ui_tab",
        "name": "Vibration Analysis Monitoring System",
        "icon": "dashboard",
        "order": 1,
        "disabled": false,
        "hidden": false
    }
]

```

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [21 March 2023 19:54 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/4 "2023-03-21T19:54:52Z")

</div>

@whelpleyjf

> [@ralphwetzel](#):
>
> Looking at the picture of your flow, I doubt that this is the case.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/9/99ceb46b8e4c9e5a126c4d4db9a63495c0a7478e.jpeg)

Are you sure your variables are configured correctly?  
I **guess** (!!) they are not ... as the `In` node for `Bearing 2` shows a different reading than the `Out` node ... but the same as `Bearing 1`. This might yet be a coincidence...

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [21 March 2023 20:33 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/5 "2023-03-21T20:33:52Z")

</div>

Um....

```auto
if (msg.payload >= 101) {
    msg.payload = "V. High Hertz - Bearing failure imminent!"
} else if (msg.payload <= 100 && msg.payload >= 81) {
    msg.payload = "High Hz - Bearing failure detected."
} else if (msg.payload <= 80 && msg.payload >= 41) {
    msg.payload = "Bearing Hz within parameters"
} else if (msg.payload <= 40 && msg.payload >= 20) {
    msg.payload = "Low Hz"
} else if (msg.payload == 0) {
    msg.payload = "Machine not running."
}

return msg;

```

Won't you need to add `break` in there?

Something like:

```auto
if (msg.payload >= 101) {
    msg.payload = "V. High Hertz - Bearing failure imminent!"
    break;
} else if (msg.payload <= 100 && msg.payload >= 81) {
    msg.payload = "High Hz - Bearing failure detected."
    break;
} else if (msg.payload <= 80 && msg.payload >= 41) {
    msg.payload = "Bearing Hz within parameters"
    break;
} else if (msg.payload <= 40 && msg.payload >= 20) {
    msg.payload = "Low Hz"
    break;
} else if (msg.payload == 0) {
    msg.payload = "Machine not running."
}

return msg;

```

Because it would - otherwise - test ALL of them. Which is not what you want - is it?

## Sorry.

The `else` fixes that - yes?

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [21 March 2023 21:08 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/6 "2023-03-21T21:08:05Z")

</div>

> [@Trying\_to\_learn](#):
>
> Won't you need to add `break` in there?

Break is only for `switch` blocks. You don't need it for if-else

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [21 March 2023 21:10 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/7 "2023-03-21T21:10:46Z")

</div>

Yeah, I sort of realised that after posting.  
That's why I mentioned it.

Maybe I should have deleted the post.  
Thanks though for the clarification.

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 10:31 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/8 "2023-03-25T10:31:51Z")

</div>

Hi, I'm trying to fiddle around with this to see what the problem is. I've tried resetting everything and checking that it is configured correctly. I cannot see where I could have misconfigured it unless I have somehow misunderstood how the variables are addressed. Here are some photos of my S7 In and S7 out blocks. The variables are monitoring the values of 2 flags (or merker).

 ![Screenshot 2023-03-25 102742](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/a/7a3af11013ab6a0680b5d11fe39702666cc72098.png)  
 ![Screenshot 2023-03-25 102641](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/d/0d1b1c5413098af7ccbfcbfb87bb9505aeb8bba3.png)

Separately, can someone clarify how the msg variable works? Is it a global variable or does each "flow" (by which I mean connected line of nodes) have it's own msg variable?

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 10:32 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/9 "2023-03-25T10:32:22Z")

</div>

![Screenshot 2023-03-25 102716](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/e/fe17e62cad5d7a38da0e0f9e2bc302de2e088af7.png)  
 ![Screenshot 2023-03-21 184651](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/8/887443bb44abeb80bb6e6e82a0fe7f486ac48b9c.png)

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [25 March 2023 12:57 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/10 "2023-03-25T12:57:01Z")

</div>

> [@whelpleyjf](#):
>
> Is it a global variable or does each "flow" (by which I mean connected line of nodes) have it's own msg variable?

`msg` itself is non-global.  
If you put the same object into several `msg`s, this object will be passed (as always) by reference and act in some way "global".

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [25 March 2023 13:00 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/11 "2023-03-25T13:00:54Z")

</div>

What happens, if you change the definition of `Bearing 1` into something "weird".  
Does this alter value read by the `In` node of Bearing 2 as well?  
If so, you know there's something wrong with the way you defined those variables...

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 13:15 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/12 "2023-03-25T13:15:24Z")

</div>

Excuse my ignorance, but when you say definition, what exactly do you mean? The name I choose in the variables tab after putting in the address?

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 13:21 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/13 "2023-03-25T13:21:03Z")

</div>

Here's how the variables are assigned. Again, I'm new to this but after reading some documentation this is my understanding of how I address flags that I've set up in the LOGO!softcomfort software.  
 ![Screenshot 2023-03-25 131824](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/1/91f6d81a2f4f005e7883a960ac74042520663a03.png)

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [25 March 2023 13:24 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/14 "2023-03-25T13:24:31Z")

</div>

> [@whelpleyjf](#):
>
> Excuse my ignorance, but when you say definition, what exactly do you mean?

Sorry. Most probably my proposal wasn't clear enough: I was referring "definition" to the `DB1,INT1104`.

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 13:39 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/15 "2023-03-25T13:39:25Z")

</div>

Understood. So I'm using this list I found online to define my addresses.

[Logo-VM-Adressen — IP-Symcon :: Automatisierungssoftware](https://www.symcon.de/de/service/dokumentation/modulreferenz/sps-siemens-vipa-logo/logovmadressen/#Logo_8_Merker_Bit)

I've addressed them both as DB1,INTxxxx as I'm trying to pick up integer values.

I've already tried changing Bearing 1 to DB1,INT1104.0 but this throws an error.

I'm rather confused as to what I am doing wrong here but I think you are on the right track.

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [25 March 2023 18:59 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/16 "2023-03-25T18:59:16Z")

</div>

> [@whelpleyjf](#):
>
> I've already tried changing Bearing 1 to DB1,INT1104.0 but this throws an error.

I've the impression, `Bearing 1` works / worked properly.  
What happens when you change the definition of `Bearing 2` ?

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 19:21 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/17 "2023-03-25T19:21:08Z")

</div>

I've managed to make some progress. I changed the flags in LOGO!softcomfort from M1 and M2 to M1 and M9. I also played around with the variable type in node-red and found that BYTE almost works. My only problem is now that when I press the button to inject a value, the value recorded is 1 less than what I injected. So if inject 81 I it shows 80. Strangely though the 0 and 20 buttons inject the correct value. Any idea what is going on here?

 ![Screenshot 2023-03-25 191838](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/0/20cf2058fb272954c2c5e3f141a291d6141f0937.png)

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [25 March 2023 19:38 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/18 "2023-03-25T19:38:06Z")

</div>

> [@whelpleyjf](#):
>
> So if inject 81 I it shows 80.

> [@whelpleyjf](#):
>
> Any idea what is going on here?

Not at all; just guessing: Could it be that the Hz figure is rounded down to the next 10th value? What happens, when you inject e.g. 83 ? Is it 82 or 80 as well?

---

<div class="post-metadata">

### Author: ![whelpleyjf](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/whelpleyjf/32/75782_2.png) [@whelpleyjf](https://discourse.nodered.org/u/whelpleyjf)
#### Post date: [25 March 2023 19:44 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/19 "2023-03-25T19:44:04Z")

</div>

Injecting 79 shows 78, injecting 80 shows 80, 81 shows 80, 82 shows 82, 83 shows 82. Really have no idea what is going on here. I'm glad it's not just me who is confused.

---

<div class="post-metadata">

### Author: ![ralphwetzel](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ralphwetzel/32/53713_2.png) [@ralphwetzel](https://discourse.nodered.org/u/ralphwetzel)
#### Post date: [25 March 2023 19:50 UTC](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789/20 "2023-03-25T19:50:49Z")

</div>

Is there a pattern in this data?  
Looks like it shows only even numbers?

[Next page](https://discourse.nodered.org/t/msg-payload-is-changing-two-outputs/76789.md?page=2)
