question

nada avatar image
0 Likes"
nada asked Julie Weller edited

connection nodered and flexsim without modbus simulator

hey everyone . i was able to connect flexsim to node red but with the use of modbus simulator as intermidiate . can anyone have any sollution to connect nodered to flexsim without the use of intermidiate . !

flexsimnoderdmodbus.7z

FlexSim 23.1.2
connection
· 5
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Logan Gold avatar image Logan Gold ♦♦ commented ·

For the community's information, I believe this is related to this question:

https://answers.flexsim.com/questions/142628/connection-node-red-and-flexsim.html

0 Likes 0 ·
Logan Gold avatar image Logan Gold ♦♦ commented ·

@Luciano Cavallero, @Tancredi Canonico, @Fiorenzo A, can you please take a look at this emulation-related question?

0 Likes 0 ·
nada avatar image nada Logan Gold ♦♦ commented ·
can anyone help me plz
0 Likes 0 ·
nada avatar image nada commented ·

any help plz

0 Likes 0 ·
Julie Weller avatar image Julie Weller commented ·

Hi @nada, was Luciano's answer helpful? If so, please click the "Accept" button at the bottom of their answer. Or if you still have questions, add a comment and we'll continue the conversation.

If we haven't heard back from you within 3 business days we'll auto-accept an answer, but you can always comment back to reopen your question.

0 Likes 0 ·

1 Answer

·
Luciano Cavallero avatar image
0 Likes"
Luciano Cavallero answered

Hi,

I taken a look the your video.

To connect Flexsim to node-red directly I installed the 'node-red-contrib-modbus' palette. This palette provide a set of nodes to read/write data using modbus and a node to create a modbus server.

Below a JSON of a simple flow that create a server and write a coil (manually): this coil's changes can be read by FlexSim using the a Modbus TCP control variable.

Copy this code and import in your node-red.
Let me know if this solve your question.

[
    {
        "id": "516f34a37fd9ca8f",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "b1087276c245dd59",
        "type": "modbus-server",
        "z": "516f34a37fd9ca8f",
        "name": "local Modbus server",
        "logEnabled": true,
        "hostname": "0.0.0.0",
        "serverPort": 10502,
        "responseDelay": 100,
        "delayUnit": "ms",
        "coilsBufferSize": "1024",
        "holdingBufferSize": "1024",
        "inputBufferSize": "1024",
        "discreteBufferSize": "1024",
        "showErrors": true,
        "x": 260,
        "y": 180,
        "wires": [
            [
                "2e4504ae37d46948"
            ],
            [
                "06a20a26617f8155"
            ],
            [
                "8ef2824f128f9705"
            ],
            [
                "114eb13f974d836c"
            ],
            [
                "be48a0148fd15ed5"
            ]
        ]
    },
    {
        "id": "d85a3e8499f06b3b",
        "type": "modbus-write",
        "z": "516f34a37fd9ca8f",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "Coil",
        "adr": "1",
        "quantity": "1",
        "server": "db6f9b3e.e5f338",
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 320,
        "y": 380,
        "wires": [
            [
                "8bd5cac1c87591b3"
            ],
            [
                "4b70615abbb827b9"
            ]
        ]
    },
    {
        "id": "8bd5cac1c87591b3",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 1 write FALSE ",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 360,
        "wires": []
    },
    {
        "id": "4b70615abbb827b9",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 2 write FALSE",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 400,
        "wires": []
    },
    {
        "id": "2e4504ae37d46948",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 3",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 120,
        "wires": []
    },
    {
        "id": "06a20a26617f8155",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 4",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 180,
        "wires": []
    },
    {
        "id": "8ef2824f128f9705",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 220,
        "wires": []
    },
    {
        "id": "114eb13f974d836c",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 6",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 260,
        "wires": []
    },
    {
        "id": "be48a0148fd15ed5",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 7",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 440,
        "y": 300,
        "wires": []
    },
    {
        "id": "e620fa03c581a662",
        "type": "inject",
        "z": "516f34a37fd9ca8f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "false",
        "payloadType": "bool",
        "x": 110,
        "y": 360,
        "wires": [
            [
                "d85a3e8499f06b3b"
            ]
        ]
    },
    {
        "id": "e1bcd02cea0c7a7e",
        "type": "inject",
        "z": "516f34a37fd9ca8f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 90,
        "y": 180,
        "wires": [
            [
                "b1087276c245dd59"
            ]
        ]
    },
    {
        "id": "281b06d6960c9eb7",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 2 write TRUE",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 520,
        "wires": []
    },
    {
        "id": "edb022239470c36c",
        "type": "modbus-write",
        "z": "516f34a37fd9ca8f",
        "name": "",
        "showStatusActivities": false,
        "showErrors": false,
        "showWarnings": true,
        "unitid": "1",
        "dataType": "Coil",
        "adr": "1",
        "quantity": "1",
        "server": "db6f9b3e.e5f338",
        "emptyMsgOnFail": false,
        "keepMsgProperties": false,
        "delayOnStart": false,
        "startDelayTime": "",
        "x": 320,
        "y": 500,
        "wires": [
            [
                "9a90992d12a3d8eb"
            ],
            [
                "281b06d6960c9eb7"
            ]
        ]
    },
    {
        "id": "9a90992d12a3d8eb",
        "type": "debug",
        "z": "516f34a37fd9ca8f",
        "name": "debug 1 write TRUE",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "payload",
        "targetType": "msg",
        "statusVal": "",
        "statusType": "auto",
        "x": 580,
        "y": 480,
        "wires": []
    },
    {
        "id": "83642f64bbd72459",
        "type": "inject",
        "z": "516f34a37fd9ca8f",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "true",
        "payloadType": "bool",
        "x": 110,
        "y": 480,
        "wires": [
            [
                "edb022239470c36c"
            ]
        ]
    },
    {
        "id": "db6f9b3e.e5f338",
        "type": "modbus-client",
        "name": "local",
        "clienttype": "tcp",
        "bufferCommands": true,
        "stateLogEnabled": false,
        "tcpHost": "127.0.0.1",
        "tcpPort": "10502",
        "tcpType": "DEFAULT",
        "serialPort": "/dev/ttyUSB",
        "serialType": "RTU-BUFFERD",
        "serialBaudrate": "9600",
        "serialDatabits": "8",
        "serialStopbits": "1",
        "serialParity": "none",
        "serialConnectionDelay": "100",
        "unit_id": 1,
        "commandDelay": 1,
        "clientTimeout": 1000,
        "reconnectTimeout": 2000
    }
]



5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.