Siemens TIA Portal & s7-1200 PLC & Modbus TCP Protocol [5]

In this tutorial, you will learn how to communicate with your hardware using Modbus TCP Protocol. If you missed it, check out the last post where we explain the most used bit logic operations and the Timers Operation.

Parts Required



  • s7-1200 1214 DC/DC/DC PLC

TIA Portal

To create our Modbus connection in TIA Portal we will start for add the MB_Server Block. To do that, you should go to the Instructions menu, select the Communication and Others-Modbus TCP as you can see in Figure [1].

Figure [1] – MB_Server

After that, you can drag and drop this block in Network 1 and start to create the basic control tags as you can see in Figure [2].

  • x_Connect – To enable the connection of Modbus Block;
  • x_Disconnect – To disconnect the communication of the Modbus Block;
  • x_Error – To verify in your program if the connection was an active error or not;
  • s_Status – To check the status of the connection (if it is well made or not, if is sending data…);
Figure [2] – Control Tags

As you can see there are more 2 tags that you need to fill in MB_Server Block.

The Connect Tag is a special tag where you will configure the IP Address, the ID, the local port, the interfaceId, the connection type, and if your connection is active or passive.

The MB_Hold_Reg is the data that you will send/receive.

To create the connect tag you should create a new Data Block as you can see in Figure [3].

Figure [3] – Create a new Data Block

Then in this new Data Block, you must have to create the connect tag with a data Type “TCON_IP_v4”. When you create you will notice that will appear some other configurations as you can see in Figure [5].

The InterfaceId in my case is the port 64 but you can check yours by following the steps in Figure [4].

Figure [4] – InterafaceId

The ID of the connection depends on your installation. Each connection should have a different ID. If in your installation, as in mine, is the first hardware connection in Modbus TCP Protocol you can select ID=1.

The ConnectionType value depends on our connection type. In My case I want to make a connection by TCP/IP so, the ConnectionType value should be 11.

The ActiveEstablished Value depends if your connection is active or passive. In My case, the PLC will open the connection and then my PC connects when i want, so the PLC is Passive. To select Passive connection you should give the ActiveEstablished tag the value false.

The RemoteAddress should be the address of the hardware that will connect to the PLC. As in my case, this hardware is my PC, I select the IP of my PC (

As my connection is Local, I will just fill the LocalPort tag with port 502. This Port must be equal on your active connection hardware ( in my case is my PC).

Figure [5] – Connect Tag

After Creating the connect tag you will have to add it in your MB_Server Block. To do that, go to the main, select the Data block you have created, go to details view, and drag and drop the tag to the Connect tag of MB_Server Block as you can see in Figure [6].

Figure [6] – Link the tag connect to the MB_server Block

After this step, you should create another data block where you will save the data sent and received between your PLC and your Hardware. To do that you should follow the steps in Figure[7].

Figure [7] – Data Transmited Block

Now you should create a Tag to Transmit between hardware as you see in Figure [8]. To do that you can create a tag named “Data” with a Data Type of “Array[0..9] of Int. It means that inside this tag you will have 10 Integer tags arranged in one array.

Figure [8] – Data Tag to Send/Receive

After Creating this tag, you have to follow the same steps that you followed to add the connect tag as you can see in Figure [9].

Figure [9] – Data Tag Added

Download the program to the PLC, and activate the connect tag as you can see in Figure[10].

Figure [10] – Open Connection in PLC

All steps are made in Tia Portal, now you will need to follow the next steps where you will configure the Radzio Modbus Simulator.


After opening the Radzio Simulator software you should create a new file and enter in setting menu as you can see in Figure [11].

Figure [11] – Create a new File

Now you have to configure the Modbus TCP communication on the Software side as you can see in Figure [12].

  • Connection: Modbus TCP
  • IP Address: 192.168.123 ( The same IP Address of the PLC)
  • TCP Port: 502 ( The Same Port you decide on PLC for Local Port)
Figure [12] – Configuration Radzio

Select the Length of the message (10 in my case because I choose an array of 10 integers) and then select Holding registers. Now that it’s all made, check the connection by pressing the connect button as you can see in Figure [13].

Figure [13] – Check the Connection

On TIA Portal, go to the Data Block you create with your data and select the online visualization. Follow the steps of the Figure [14] by double clicking on hand nrº 2, select the value you want in nrº 3, update the value on nrº 4, and check if the value you choose appear ins nrº 5.

This is the fifth post on Siemens TIA Portal. You have learned how to create a connection between your PLC and your hardware by Modbus TCP.

If you like this kind of post, if you want to know more about Siemens TIA Portal, or if you have doubts about the Industrial Automation area don’t forget to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *

Ads Blocker Image Powered by Code Help Pro

Ads Blocker Detected!

Hello! We have noticed you are using an ad blocker. Our website is funded by advertising which allows you to access all our content for free. By disabling your ad blocker, you are contributing to the sustainability of our project and ensuring we continue to provide high-quality, useful tutorials. We appreciate your support!