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:
- Right click the device folder in the project tree.
- Select the item Properties... in the menu.
- In the opened window open the entry PROFINET interface and Ethernet addresses in the list of the tab General.
- You can set the new IP for your PLC in the IP protocol section.
- The PLCs IP will be updated when you upload the TIA project to the device.
Setup for using the PLC as a Modbus Server¶
- In the Project tree select the PLC > Program blocks > Main Organization Block (OB).
- Open Instructions on the right, open the folder Communication > Others > Modbus TCP.
- Drag&drop the MB_SERVER into a free network of the Main OB.
- Name the data block of the function block, e.g. MB_SERVER_DB.
- Create a new data block by selecting Add new block in the PLCs Program blocks
- Name it similar to Modbus_server.
- 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.
- 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.
- 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.
- 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.
|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 0.0.0.0 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¶
- Add the Line Controller component at the robot system component list to your setup.
- Configure the parameter PLC Modbus IP for your setup. It has to match with the IP configured in the section Change the PLCs IP.
- 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.
- Eventually adjust the number of digital inputs and outputs, if your PLC has a different number than defined by the default settings.