Ethernet to Modbus / Profinet to Modbus Communication
Thank you for reading this post, don't forget to subscribe!
After selecting the CPU:
Find GSD files from the adapter website or other sites.

On Tia Portal Use Options/Manage general station description files (GSD)
Extract first and then uploaded it and install it.


Add the Profinet IO device called PN2-MB. (This is the hardware to be bused for Profinet to Modbus communication), set the network connection between two devices, and assign an IP address in the same VLAN for both PLC and PN2-MB.


Go to Device View and the holding registers for reading and writing both. You need to select the number of words you are going to read and write. In this example, we are going to read 4 Words and wight 4 words. The library to select the required registers is called: MBRTU Master Holding Registers 4xxxxx. Majority of the time devices dedicate 4xxxx series of register for this purpose, as shown.
As you double click it will appear on Device Overview section:

Check and fix the properties:
- Select UART Port, either RS 485 or RS 422.
- Modbus RTU Slave address: this depend how many slaves are there to communicate.
- Function Code is to 3 for reading:
- Start address:
- Quantity of Register: 4, select as reading 4 words earlier.
- Transmission Type: Poll Trigger. It will be polled from PLC Master.

Check the System constants: To find the Hardware identification that will be used in the MB block on the network.

Repeat the same thing for writing into the Modbus device, as shown:
Note:
- Function Code is 16 for writing, and some instances it is 4, selected by Tia Portal.




Create a Data Block for reading the data from the Modbus device and to write data to Modbus Block:


Search DPRD_DAT instruction: and drag and drop it into your network:This is to read data from Modbus device:


Use the Data Block created for both Read and Write for the Modbus instruction library parameters, as shown.


Note: Record is a pointer (P#) pointing to the address created in the datablock.
- For Reading block,

- Record is pointing as: (P#DB1.DBX0.0 BYTE 8)
- (Pointer, DataBlock address, Starting bit, number of bytes)
DB1,
0.0, 0.1,…0.7, —> Data1
1.0,1.1,…1.7, —-> Data1
2.0,2.1…2.7, —–> Data2
3.0,3.1,…3.7, —-> Data2
4.0,4.1,…4.7, —-> Data3
5.0,5.1,…5.7, —-> Data3
6.0,6.1,…6.7 —-> Data4
7.0,7.1,…7.7, —-> Data4
Same thing as a Record applies for writing register

Same thing as a Record applies for writing register
