Skip to content

Creating a Modbus Server on the Siemens PLC

This page describes how to create a simple Modbus server on a Siemens PLC using Siemens TIA Portal. Please check your PLC manual for more details and information.

Creating DataBase for Modbus Server

  1. In the Project tree view: Device_name→Program_blocks Select Add new block.
    01
  2. In the Add new block window, click on the Data block icon located in the lower left side of the window.
  3. Give to the new DB a name, for example Modbus_server and click ok.

Define the Modbus Server parameters in the DB

  1. Open the newly created DB Modbus_server.
  2. Add a parameter with the name Connection_1 and with Data type TCON_IP_v4.
  3. Add a parameter with the name Holding_register and with Data type Array[0..150] of Word.
  4. Extend the Connection_1 view by clicking the arrow in front of it, then give to the connection parameters the same values displayed in the following picture:
    01

Creating Modbus Serve

  1. Open your main program OB1.
  2. Go to the Instructions window. Then in the Communication tab expand Others, then Modbus TCP and finally drag and drop the MB_Server to the OB1.
    01
  3. Set the MB_Server inputs and outputs as shown in the picture below:
    01

Now, you can access the holding registers (read/write) from the Modbus_server DB. Finally upload the program and start it in your PLC.