S7-1200, Profinet, Modbus TCP

Just to follow up with my findings now that this job is complete:

The Modbus TCP method worked well in the end. I have seen no issues with talking Profinet to the HMI and Modbus TCP to the Weight Transmitter out of the same port simultaneously. Comms seems to be quite steady and reliable.

Once I got it communicating with the simulator (as described above), the only thing I had to change to get it talking to the Weight Transmitter was the CONNECT_ID of the MB_CLIENT block. For some reason, it kept giving me an error saying that that connection ID was already in use, even when I deleted all other instances of modbus communications blocks. I tried values of 1 and 2; neither worked. But a value of 10 did. I ended up using 10 for my read and 20 for my write and that was that.

To be honest, it probably would have been more cost effective in the situation I started in to just buy the Profibus card as JRW suggested. I did burn a lot of time working out the Modbus setup, although this was in part due to the unusual way that the particular weight transmitter arranges it's data for Modbus. But the flip side of that is that I'm now confident to do Modbus TCP on the next project that comes along with a similar situation, and while I did burn a few hours on learning it, I think it was worth it for the benefits that will be had next time.

Anyway thanks everyone for your input, it's been invaluable! If you ever find yourself in Melbourne, I'll buy you a beer 🍻
 
I am trying to read through modbus TCP using S7-1200 as client. I am using the MB client block and I have to read from different IP's. The problem I am facing is that I cannot synchronize the reading and there is a conflict between the values that I receive from the different IP's. I tried to solve it by using a sequence to the 'disconnect' of the MB client block and when i read the first value the 'done' value goes to the first 'disconnect' and proceed to the second reading and so on. But the values I read are mixed as from one IP to the other. What is the way to read properly from one IP and then read from another? How should I organize the MB client block?
 
I have to connect to 9 Modbus masters and read from them 22 values. I am using a FC for each master where I have a call for each value and store the values to a DB for each master. The problem is when i read the first master and try to connect to the second, the values I am reading are mixed ( values from the first and values from the second) as if the IP is not changed. In the DB of the first master I have values from the second master and vise versa.
 
Since this is my first project with S7-1200 Modbus please be kind! I want to read values from 9 modbus servers. I have build a FC for each server (each IP) and in each FC I read 22 values using a MB_client call for each reading. When i read the 22 values (MBCLIENT1) I go to the next FC and change the IP so as to connect to the next modbus server and read the next 22 values (MBCLIENT2). The problem is that the values that I read are mixed as if when I read from one IP the code receives data from the previous IP. I assume that the connection is not terminated properly and because of this I have this conflict between the readings. How should I disconnect from one IP and then connect to the next one? Thank you all in advance for your time and any example would be much appreciated!

MBclient1.jpg MBclient2.jpg
 
Last edited:
You are using the same MB_Client_DB for all Modbus Clients and you are using the same MB_Config_1 for all Modbus Clients. You must have separate MB_Client_DB for each Modbus use, so you don't need to change the IP addresses because they are hard coded in each 'Connect' DB. So if you look at my versions I have DriveDataA that has its own DB29 and its own Connect memory locations, DriveDataB with a DB29 and its own Connect memory locations. The YouTube video shows how to create some memory locations, I have combined them all in to one DB.

I initially did what you did and tried to save memory by keeping everything using single DBs, I also found that it doesn't work, to be fair to Siemens it does say that you have to use separate DBs for each instance of the Modbus Client.

DriveDataA.jpg DriveDataB.jpg Multiple DBs in one.JPG
 
You probably can have same DB for all blocks, but then only one block can be enabled at moment. (You can use counter for enable pin, count up when error or COM OK from earlier modbus query)
But this goes easilly difficult, maybe. This at least work on modbus RTU side.

Also for TCP you can guery several modbus querys on same time, this speeds up little bit communications.

Max query's goes prbably by hardware, you can check from online (Hardware config and CPU) how many communications are on at same time from/to CPU.

I think that max connections is same than for profinet on harware. There is at least 2 communication selected by default for panels.
Others can correct if max connections are only for profinet and Modbus TCP is without max simultaneous connections.
 
OK, so now you have it working if everything is working, then you have to think what you want to do if something fails. If you do nothing then the last value received from the server will remain in memory and it will look as though everything is working, when it isn't. You need to look at the Modbus Error and Status values. You will have to decide how bad things have to be before you raise an alarm, can you loose one reading and still no have danger or confusion. In many ways getting it to work is the easy part, getting it to make sense when something has gone wrong often takes a lot more thought.
 
I am taking into account the status and the error values. So, When the project would be finished, I would probably freeze the reading value with the help of a move function, which will work if I dont have an error. If an error cames, then it will not write a new value to the DB.
 
Back to the problems, now I am facing problem when adding more than 4 IP's to the project. Does anyone knows how to adjust "Blocked_Proc_Timeout" and "Rcv_Timeout"? I saw that adjusting these timers can make difference but I dont know how to calculate them.
 

Similar Topics

Hello All I have a modbus tcp device(Julabo magio) with an DB9 pin assignment. Pin3=B and Pin8=A. I would like to connect it on the secondary...
Replies
4
Views
1,584
Hi I'm wanting to basically get data from a Siemens S7-1200 PLC and write it in to my D registers on my Q series PLC. If I went for profinet...
Replies
6
Views
2,229
Hi Guys, I am trying to establish communication over profinet between Siemens S7-1200 PLC as IO device and codesys plc as IO controller. But I am...
Replies
43
Views
2,564
Hello all, I'm working with an s7-1200 and a stepper motor in Tia portal v17. This stepper motor is an SMD23E2 and I am attempting to connect...
Replies
19
Views
2,839
Hey. I have an S7-1200 system, which i intend to communicate with a eurotherm Epack 1ph controller via profinet. I have installed the GSD and...
Replies
6
Views
2,273
Back
Top Bottom