Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Modbus Wert zu Boolean splitten

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Modbus Wert zu Boolean splitten

    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      markusn78 last edited by

      Hallo zusammen,
      ich vermute das wurde schon mal behandelt, ich finde gerade nur nicht die richtigen Suchbegriffe.

      Worum gehts: Ich empfange über meinen Modbus-Adapter aus meiner Wago Steuerung ein Word, in diesem sind halt 16 Bits also Booleans die ich gerne aufsplitten würde. Wonach müsste ich jetzt suchen um mich dort ein zu lesen?

      gruss Markus

      paul53 1 Reply Last reply Reply Quote 0
      • paul53
        paul53 @markusn78 last edited by

        @markusn78
        Siehe hier

        M 1 Reply Last reply Reply Quote 1
        • M
          markusn78 @paul53 last edited by

          @paul53
          Danke für den Hinweis,
          ich habe mir jetzt einen passenden Flow bei Node-Red angelegt. Habe den aber nicht selber erfunden sondern nur auf meine Bedürfnisse angepasst.

          [
              {
                  "id": "7b93b0c.402c65",
                  "type": "tab",
                  "label": "Flow 2",
                  "disabled": false,
                  "info": ""
              },
              {
                  "id": "df41c583.24ff58",
                  "type": "function",
                  "z": "7b93b0c.402c65",
                  "name": "word to binary",
                  "func": "// initialize bit array to 0s\nvar bits0thru31 = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];\n\nfor (i = 0; i < 32; i++){\n bits0thru31[i] = (msg.payload >> i) & 0x1;\n}\n\nvar bit0 = {payload: bits0thru31[0]};\nvar bit1 = {payload: bits0thru31[1]};\nvar bit2 = {payload: bits0thru31[2]};\nvar bit3 = {payload: bits0thru31[3]};\nvar bit4 = {payload: bits0thru31[4]};\nvar bit5 = {payload: bits0thru31[5]};\nvar bit6 = {payload: bits0thru31[6]};\nvar bit7 = {payload: bits0thru31[7]};\nvar bit8 = {payload: bits0thru31[8]};\nvar bit9 = {payload: bits0thru31[9]};\nvar bit10 = {payload: bits0thru31[10]};\nvar bit11 = {payload: bits0thru31[11]};\nvar bit12 = {payload: bits0thru31[12]};\nvar bit13 = {payload: bits0thru31[13]};\nvar bit14 = {payload: bits0thru31[14]};\nvar bit15 = {payload: bits0thru31[15]};\n\nreturn[ bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7, bit8, bit9, bit10, bit11, bit12, bit13, bit14, bit15 ];\n",
                  "outputs": 16,
                  "noerr": 0,
                  "initialize": "",
                  "finalize": "",
                  "libs": [],
                  "x": 640,
                  "y": 400,
                  "wires": [
                      [
                          "aa201119.796068"
                      ],
                      [
                          "8756f456.0d6bf"
                      ],
                      [
                          "6d516811.372178"
                      ],
                      [
                          "948f3ad4.183b88"
                      ],
                      [
                          "8f435811.a4be68"
                      ],
                      [
                          "cdb17f80.fac8e8"
                      ],
                      [
                          "75ff10d8.fba63"
                      ],
                      [
                          "e5d55421.de459"
                      ],
                      [
                          "86b811c3.0ac84"
                      ],
                      [
                          "e45a7d02.79caa"
                      ],
                      [
                          "b2aefbfc.aa2338"
                      ],
                      [
                          "2617a6bb.218c8a"
                      ],
                      [
                          "97ee1c07.1628"
                      ],
                      [
                          "79b46191.21538"
                      ],
                      [
                          "7e37e721.5da318"
                      ],
                      [
                          "3b04cc79.d38d54"
                      ]
                  ]
              },
              {
                  "id": "aa201119.796068",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 260,
                  "wires": []
              },
              {
                  "id": "8756f456.0d6bf",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "false",
                  "x": 850,
                  "y": 300,
                  "wires": []
              },
              {
                  "id": "6d516811.372178",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "false",
                  "x": 850,
                  "y": 340,
                  "wires": []
              },
              {
                  "id": "948f3ad4.183b88",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 380,
                  "wires": []
              },
              {
                  "id": "8f435811.a4be68",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 420,
                  "wires": []
              },
              {
                  "id": "cdb17f80.fac8e8",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 460,
                  "wires": []
              },
              {
                  "id": "75ff10d8.fba63",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 500,
                  "wires": []
              },
              {
                  "id": "e5d55421.de459",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "tosidebar": true,
                  "console": false,
                  "tostatus": false,
                  "complete": "payload",
                  "targetType": "msg",
                  "statusVal": "",
                  "statusType": "auto",
                  "x": 850,
                  "y": 540,
                  "wires": []
              },
              {
                  "id": "e3ba4514.dd9e88",
                  "type": "ioBroker in",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "topic": "modbus.0.holdingRegisters.1.12326_MW38_OG_Stat_Kind2",
                  "payloadType": "value",
                  "onlyack": "",
                  "func": "all",
                  "gap": "",
                  "fireOnStart": "true",
                  "x": 280,
                  "y": 400,
                  "wires": [
                      [
                          "df41c583.24ff58"
                      ]
                  ]
              },
              {
                  "id": "86b811c3.0ac84",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "tosidebar": true,
                  "console": false,
                  "tostatus": false,
                  "complete": "payload",
                  "targetType": "msg",
                  "statusVal": "",
                  "statusType": "auto",
                  "x": 850,
                  "y": 580,
                  "wires": []
              },
              {
                  "id": "e45a7d02.79caa",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 620,
                  "wires": []
              },
              {
                  "id": "b2aefbfc.aa2338",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 660,
                  "wires": []
              },
              {
                  "id": "2617a6bb.218c8a",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 700,
                  "wires": []
              },
              {
                  "id": "97ee1c07.1628",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 740,
                  "wires": []
              },
              {
                  "id": "79b46191.21538",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 780,
                  "wires": []
              },
              {
                  "id": "7e37e721.5da318",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 820,
                  "wires": []
              },
              {
                  "id": "3b04cc79.d38d54",
                  "type": "debug",
                  "z": "7b93b0c.402c65",
                  "name": "",
                  "active": true,
                  "console": "false",
                  "complete": "payload",
                  "x": 850,
                  "y": 860,
                  "wires": []
              }
          ]
          

          Screenshot 2022-01-11 090115.png

          Im Modbus-Adapter habe ich dann Unsigned 16bit (Little Endian) verwendet. In der Wago SPS schreibe ich auf ein %MW.

          Falls mal jemand diese Informationen brauchen sollte.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          Support us

          ioBroker
          Community Adapters
          Donate

          840
          Online

          31.8k
          Users

          80.0k
          Topics

          1.3m
          Posts

          2
          3
          162
          Loading More Posts
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes
          Reply
          • Reply as topic
          Log in to reply
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
          The ioBroker Community 2014-2023
          logo