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¶
- In the Project tree view: Device_name→Program_blocks Select Add new block.
- In the Add new block window, click on the Data block icon located in the lower left side of the window.
- Give to the new DB a name, for example Modbus_server and click ok.
Define the Modbus Server parameters in the DB¶
- Open the newly created DB Modbus_server.
- Add a parameter with the name Connection_1 and with Data type TCON_IP_v4.
- Add a parameter with the name Holding_register and with Data type Array[0..150] of Word.
- 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:
Creating Modbus Serve¶
- Open your main program OB1.
- 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.
- Set the MB_Server inputs and outputs as shown in the picture below:
Now, you can access the holding registers (read/write) from the Modbus_server DB. Finally upload the program and start it in your PLC.