Siemens S7 UDP Connections

S7Guy,
I'm with you. This is a great way to interface with customers and it could also make for easy integration with custom HMI's built using standard programing languages. I was suprised how easily things came together once the configurations were figured out.
 
Just a quick update on how I’m progressing…..

First, this is what my test application looks like: A server application was set up to send UDP broadcasts of 40 bytes. The average throughput was set up to be 80 messages per second (about 12ms per broadcast), but on four separate threads. So, it was possible that the messages could come in bursts rather than evenly spaced apart every 12ms or so.

I found that I can reliably receive broadcasts at this rate on a single port except when a bunch of packets came in at once. I suspect (I can’t find any documentation from Siemens) that the TCP/IP stack on one port in the CP443-1 is 2048k, which would allow room for only four messages to pile up before I started missing them (each UDP packet reserves 512k regardless of the actually length, I believe). With UDP, since there is no error checking or confirmation, the packet is lost to the “ether” if there is no place for it to go. So, theoretically, if more than four packets came in at the same time, only the first four would be retrieved, which is exactly what I was seeing. Again, I’m basing this on what I am seeing, not on any documentation. The buffer could be bigger or smaller than I suspect, but the bottom line is that messages are lost when the buffer is full.

So, I tried setting up multiple ports, which is essentially the same as increasing the bandwidth. I had the server application broadcast to these four ports (one thread per port), and I was able to receive over five million messages without dropping any (the server app included a message index so I could verify this). So, this is where I stand right now: I can reliably receive 80 packets per second, and the packets do not have to be spaced evenly apart. Looking at the time stamps, I can see that sometimes six messages come in within milliseconds of each other, but I am still able to grab them. This suits my needs very well at the moment, so I’m not going to push it any further, but someday when I have more time I’ll see how far I can take it.

Also, I dug into the AG_LRCV function that Siemens provides, and I found that you can eliminate almost all of the code in it. In fact, I started snipping out bits and pieces, and when I was done, I was down to one SFC59 call plus four lines of code. So, you really don’t need the Siemens functions at all to retrieve on UDP, as I just call SFC59 cyclically and grab the data as fast as it comes in. Since my scan time is about 6ms, I assume that would be the throughput limit on one port as long as the packets were broadcast uniformly.

I’m still investigating whether I can use this method to totally replace a tag-based server (such as an OPC server). If I can do that, it relieves a lot of headaches related to tags on the server side. Since it doesn’t care about actual addresses, I can change my data blocks as often as I want without updating any tag databases on the server side.
 
S7Guy

According to the information I have, the maximum length of UDP for a CP443-1 is 2048 bytes, that is using AG_LSEND and AG_LRECV, as you suspected.

I got that info from this document , it might be worth a read.

Paul
 

Similar Topics

I need help from anyone with access to run a test on a 414H, 416H or 417H PLC system. The purpose of the test is to measure the communication...
Replies
0
Views
1,314
Hey, I have just finished doing a project with a Compact logix CPU sending messages (instructions) over UDP to a third party sensor. Did this to...
Replies
5
Views
3,858
I'm using the Siemens PRONETA software to do some IO testing currently. I love the simplicity and fast testing capability. Does anyone know about...
Replies
0
Views
64
Hi, First time user of S5 Siemens. Is there any solution on how to solve this kind of error. HMI OP7 $613 DB-error No. 11 (0: 15) Siemens PLC...
Replies
9
Views
156
Hello, I have an issue where I want to simulate an Siemens HMI panel, through NAT connection to a PLC. I have the possibility through extended...
Replies
4
Views
137
Back
Top Bottom