Welcome to our new forum
All users of the legacy CODESYS Forums, please create a new account at account.codesys.com. But make sure to use the same E-Mail address as in the old Forum. Then your posts will be matched. Close

Modbus RTU over TCP/IP

2020-12-05
2020-12-13
  • ristokarmas - 2020-12-05

    Hello,

    I have device where serial data is mirrored into TCP port(Lantronix Xport). There is also Modbus possible but it`s MB RTU over TCP. Is there any good way to use mb rtu protocol over tcp?

    Best Regards,
    Risto

     
  • i-campbell

    i-campbell - 2020-12-05

    Is there a user-manual? Is there a part number?

     
  • ristokarmas - 2020-12-05

    User manual of that device?
    If i`m using some mb sotware where i can choose rtu over tcp everything works fine. One option is to create virtual com port and use it as mb com port. But i was hoping there is good option to do all code and config inside CodeSys.
    Cant find any information about that issue.

    There is possibility to set mb Slave, com port under mb TCP Slave. Looks like the option i need, but cant find any documentation and will recive "TCP communication error" after i configure any slave channel.

    BR.
    Risto

     
  • i-campbell

    i-campbell - 2020-12-06

    "Modbus RTU over TCP" isn't really one of the Modbus standards. I don't know how to help you further, sorry.

     
  • ristokarmas - 2020-12-06

    ok, thank you anyway. Will use socat to virtualize port.

     
  • damian177 - 2020-12-10

    Do you want use modbus RTU encapsulation on Ethernet ? Or do you want use modbusRTU <=> modbus TCP ? This can be do by MGAte MOXA devices (rich solution). Recently I used cheap solution (https://pl.aliexpress.com/item/32903944684.html)
    This can be work in both mention configuration. In attachements I send example how I do communication with modbus RTU Slave by Modbus TCP.

     
    • ristokarmas - 2020-12-12

      Hello Damina177
      I want to use this "cheap" solution but it`s Lantronix x port embedded into device. Can you please send me this example how you communicate with RTU slave by TCP?

      BR.Risto

       
  • damian177 - 2020-12-13

    If you want communicate with Modbus RTU slave by Modbus TCP you should connected RS485 to device server and Ethernet to yours Codesys device. Next in codesys you should add Ethernet adapter (IP addres like you use to connect by Codesys environment- look on attachement1), next add Modbus TCP Master (look on attachement2), next you can add several Modbus TCP Slave's.
    For example if you want communicate with slave 9600/8 / N / 1 and number 2, you should add add Modbus TCP Slave like in attachement3. Unit ID is the same like number Modbus RTU Slave. Device only convert Modbus TCP to RTU and other side.
    To above settings you should setting first port in device like in attachement0 .

     

    Last edit: damian177 2020-12-13
  • damian177 - 2020-12-13

    Now you can adds channel to communicate with your slave Modbus RTU by modbus function 3,4,6,16 etc .... (look on attachment4)

     

Log in to post a comment.