Skip to content


This package is DEPRECATED, please use the Modbus TCP/IP Interface package instead.

Siemens S7-1200: Setup


Please make sure you use a word array size of at least 142 elements (Array[0..141] of Word) in the Holding_register variable as stated in the section Setup for using the PLC as a Modbus Server below.

Using the Siemens S7-1200 PLC requires advanced knowledge in PLC programming and the Siemens TIA environment. It is not recommended to be used by beginners in PLC programming and Siemens TIA.

Import TIA library

  • Download 💾 the drag&bot TIA library for the TIA v15. and unzip it to find the zal15_1 file, which can be also extracted if required.
  • Add the drag&bot TIA library to your project.

Alternative: Download 💾 the SCL code directly, if your system does not support TIA version 15 and create an own TIA library. Please note that you need to add the user defined datatype Pose as described in the respective screenshot image.

Change the PLCs IP

You can change the PLCs IP address for your project with the following steps:

  1. Right click the device folder in the project tree.
  2. Select the item Properties... in the menu.
  3. In the opened window open the entry PROFINET interface and Ethernet addresses in the list of the tab General.
  4. You can set the new IP for your PLC in the IP protocol section.
  5. The PLCs IP will be updated when you upload the TIA project to the device.

Setup for using the PLC as a Modbus Server

  1. In the Project tree select the PLC > Program blocks > Main Organization Block (OB).
  2. Open Instructions on the right, open the folder Communication > Others > Modbus TCP.
  3. Drag&drop the MB_SERVER into a free network of the Main OB.
  4. Name the data block of the function block, e.g. MB_SERVER_DB.
  5. Create a new data block by selecting Add new block in the PLCs Program blocks
  6. Name it similar to Modbus_server.
  7. In the static section should be an empty variable. If not select Add row or Insert row from the menu bar over the data blocks name, name the variable Modbus_connection and type TCON_IP_v4 as the data type.
  8. The created variable is a struct. Open it by clicking the small arrow next to its name and fill the variables according the table below.
  9. Outside the struct create a word array Holding_register with a size between 142 and 511 (Array[0..141] of Word).
    A larger size of the Holding Register allows the creation of longer commands and faster transfer of long strings, but takes more of the PLCs internal memory.
  10. Finally, in the Main Organization Block, link the inputs of the MB_SERVER function block to the data block Modbus_server. For this link the input MB_HOLD_REG to "Modbus_server".Holding_register and the input CONNECT to "Modbus_server".Modbus_connection.
Parameter Description
InterfaceId The Hardware ID of the Ethernet socket. To find the interface ID select PLC tags > Show all tags in the Project tree and switch to the tab System constants (selectable top right). Here the Hardware ID can be found (Data type Hw_Interface and name Local~PROFINET_interface_...).
ID Unique identifier to this connection, range 1 to 4095. It is arbitrary.
ConnectionType Enter 11 for TCP.
ActiveEstablished Enter 0 so that the server is waiting for connection requests.
RemoteAddress[] The server allows just connections from the configured IP. If is configured all IPs are allowed. Otherwise the IP of the drag&bot IPC must be configured.
RemotePort Must be 0 for Server connection.
LocalPort The IP port number of the connection, default is 5225. This port must also be configured in the drag&bot Line Controller component.

Setup for drag&bot Studio

  1. Add the Line Controller component at the robot system component list to your setup.
  2. Configure the parameter PLC Modbus IP for your setup. It has to match with the IP configured in the section Change the PLCs IP.
  3. Configure the parameter PLC Modbus Port for your setup. It has to match with the parameter LocalPort configured in the section Setup for using the PLC as a Modbus Server.
  4. Eventually adjust the number of digital inputs and outputs, if your PLC has a different number than defined by the default settings.