> For the complete documentation index, see [llms.txt](https://docs.aitheon.com/industrial-automation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.aitheon.com/industrial-automation/type-of-device-plc/siemens-s1200-plc-modbus-tcp-configuration.md).

# Siemens S1200 PLC Modbus TCP Configuration

## Instruction for configuration Siemens S1200 PLC as Modbus/TCP Server (Slave)

1\. Run TIA Portal and **Create a new project**. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPi1erCvd7W1Nc_Dp7o%2F-MPi2hpK3H7HbvdVirXg%2Fcreate.png?alt=media\&token=8799501d-be60-458d-9254-796fa5940c73)

2\. Select a name and folder for the new project. Click **Create**.&#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPi2o7YTEhAVywDtWbM%2F-MPi3Boj8bpRnXxUO2Gi%2Fname.png?alt=media\&token=1ef8563e-74eb-4ed5-95c1-04f44385e35f)

3\. Select the appropriate device or select **Unspecified CPU 1200**.&#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPi3Mm1ZTlu7CEp8b4J%2F-MPi3fyGC6bbKt9cUZfY%2Fdevice.png?alt=media\&token=540c2d1d-5efd-4f2d-bf27-7355bed5941a)

4\. On the left side of the program window select the **Device configuration** menu and click **detect** on the main window. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPi3Mm1ZTlu7CEp8b4J%2F-MPi4CUHNhkmr4Q98OcD%2Fdetect.png?alt=media\&token=4ef20464-04e5-4bd2-a635-f384f21f1c47)

5\. In the additional window select **Start search** (please do not forget to connect your PLC to PC). &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPi3Mm1ZTlu7CEp8b4J%2F-MPi4cXM0F5ym-hHSdNL%2Fsearch.png?alt=media\&token=c2aed119-1e8e-404f-8453-dde1e1ac9143)

6\. After searching choose the right PLC and click **Detect**. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPi3Mm1ZTlu7CEp8b4J%2F-MPi4y0USLtjK3QswooA%2Fdetectd.png?alt=media\&token=1addbf8c-e1ac-4ea7-9aca-9cca34754532)

7\. After adding proper PLC to the main window make double click on its **Ethernet port** (with the prompt **PROFINET interface\_1** on the screenshot)to setup. Add **IP address**, **Submask**, and choose **IP address is set directly at the device**. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPiNl6fdwjV8yq7NWyp%2F-MPiRBOssg5YhLZhYVeP%2Fethernet.png?alt=media\&token=a3757174-7091-4bc8-a3ac-48c2179fcfc0)

8\. Go to *PLC\_1 -> Program blocks -> Main*. On the right side of the window choose *Communication -> Other -> Modbus TCP -> MB\_SERVER*. Select it and drag to **Network 1**. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPiNl6fdwjV8yq7NWyp%2F-MPiRjVK9Bsnq31MbUsf%2Fserver.png?alt=media\&token=a07be66c-31c1-45c3-bdb0-ee3c1b6f48b6)

9\. Go to the **Program blocks** menu at the left side of the window and select **Add new block**. In the pop-up window choose **Data block**, add a name for it (in the example - **ModbusConfigDB**). Click **OK**.&#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPiRma1l6uOGm9XGMJ4%2F-MPiSUey3JO6XKOfilOF%2Fnew%20block.png?alt=media\&token=21b6619e-9ba7-439e-a295-e531b06aa1b5)

10\. In the new pop-up window add the next variables to the Data block (we can see its name **ModbusConfigDB** in the left menu):

* **CONNECT** (type: **BOOL**);&#x20;
* **MB\_HOLD\_REG** (type: **Array\[0..20] of Int**);&#x20;
* **CONNECT** (type: **TCON\_IP\_v4**, you need to fill additional lines **InterfaceId** - **64**; **ID** - **1**; **ConnectionType** - **11**; **ActiveEstablished** - empty; **RemoteAddress** - set IP address of **Modbus TCP Client**; **RemotePort** - **502**; **LocalPort** - **502**);&#x20;
* **NDR** (type: **BOOL**); &#x20;
* **DR** (type: **BOOL**);
* **ERROR** (type: **BOOL**);&#x20;
* **STATUS** (type: **BOOL**). &#x20;

After adding all variables click the right-click of the mouse on this Data block (in the left menu) and select *Compile -> Software (only changes)*. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPiRma1l6uOGm9XGMJ4%2F-MPiURSVrrpXp3BTving%2Fsettings.png?alt=media\&token=8499da8e-0d41-4add-9289-6184c2dd1fd7)

11\. Drag and drop each variable one by one from the table (a pop-up window from #10 of this tutorial) to the corresponding link on the **MB\_SERVER** function block (a pop-up window from #8 of this tutorial).&#x20;

The result must be the following:

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPhdNh0bXbH1hCAbP-y%2F-MPhfxtXC7SAg2NU42o0%2FPicture15.png?alt=media\&token=8011072b-a4f6-4f47-841a-66f255a0bdf5)

12\. Click **COMPILE** on the top of the program window.

After that click **Download to device**. Find the right PLC and **Load** a program. &#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPiRma1l6uOGm9XGMJ4%2F-MPiWBiAA0JhyhzCL1wx%2Fload.png?alt=media\&token=832e677d-31c1-4a18-800e-188a6c654820)

13\. You can monitor your connection from the **online mode** in **TIA Portal** (you can switch online and offline modes with the buttons at the top).&#x20;

Variable Status will be **7006** if the connection is Ok. If not - summon TIA portal **Help** with **F1** key.&#x20;

![](https://2932290758-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-MPhYZyRjl1LMzh5UVLj%2F-MPiRma1l6uOGm9XGMJ4%2F-MPiWhqQffSx0dgqyigR%2Fonline.png?alt=media\&token=416f70a7-3cf2-4b9f-a8bc-adb1049c8777)

![](file:////tmp/wps-maksym/ksohtml/wpsFwFYcH.jpg)
