Modbus Master / Slave with 2 RPs

lstiegler
2015-11-17
2016-09-29
  • lstiegler - 2015-11-17

    Hello,
    is there any modbus/TCP example with two Rasperry Pi ?

    Thank you in advance
    Best Regards
    Leonhard Stiegler

     
  • jvondrus - 2015-11-22

    Hello,
    I'm lookig for same connection, do you have some new info about connesc 2 RPis via Modbus?

    Thank you.

     
  • jvondrus - 2015-11-26

    Master Modbus

    1) Add device : Ethernet > Ethernet adapter
    2) Set ethernet adapter: Double click on it, set interface, IP ...
    3) Add device : Modbus > Modbus TCP Master
    4) Set Modbus Master device : Mark auto-reconnect
    5) Add device : Modbus > Modbus TCP Slave
    6) Set Modbus Slave device :
    General: Set Slave (2nd RPi) IP address, port, unit ID
    Slave Channel: Add channel (Reading -FC4 / Writing -FC16 / Both -FC23), set offset to 0x0000, set length
    Add I/O mapping, I'm using full address to WORD, like "Application.PLC_PRG.modbusIn", where "modbusIn" are devined at PLC_PRG as "modbusIn : ARRAY [0..3] OF WORD;"
    7) Go to Device (CODESYS ... Raspberry Pi) > PLC settings and set Bus cycle task to "MainTask"
    Compile
    9) If you are getting some warnings declared variables at library, make a change at LibraryManager. Set version of IoDrvModbusTCP from "3.5.6.0" to "3.5.4.0".
    10) Compile
    11) It's done

    Modbus Slave
    1) Add device : Ethernet > Ethernet adapter
    2) Set ethernet adapter: Double click on it, set interface, IP ...
    3) Add device : Modbus > Modbus TCP Slave
    4) Set Modbus Slave device :
    General: Set slave port, ID, WORD length
    Add I/O mapping, I'm using full address to WORD, like "Application.PLC_PRG.modbusOut", where "modbusOut" are defined at PLC_PRG as "modbusOut" : ARRAY [0..3] OF WORD;"
    Set bus cycle and updating variables to "Use parent device/bus setting"
    5) Go to Device (CODESYS ... Raspberry Pi) > PLC settings and set Bus cycle task to "MainTask"
    6) Compile
    7) It's done

    Both Upload
    Run Both device program
    All done and data are flowing, I hope

     
  • rasputin86 - 2016-09-23

    Hallo,

    ich need some help to get run my two pis over modbus/tcp.
    I have done all steps (Master Modbus) in the description of "jvondrus", but my modbus slave dont run?
    What "set length" I need?

    What can I do?

     
  • rasputin86 - 2016-09-29

    Edwin Schwellinger hat geschrieben:
    Hi,
    use attched example.
    BR
    Edwin

    Thank you, very much!
    Now I've understand it...and the two rapsberry runs!

     

Log in to post a comment.