But now a user can press a button and write data back to the S7-1200:
...
Normally it works fine. But here and there data are not written to the PLC (always ErrorCode = 0).
Maybe data writing is messed when a user pushes button and at the same time your timer tries to read data? If that is the case then you can try to solve it in different ways by serializing reading and writing. Like adding data write request to some list, and then sending everything from this list at the start of the timer and then execute data read requests. Or you could hold reading while writing is in progress and vice versa, or...
If you are using more then one S7/PG connection (like creating new connection for each data write packet), then you should change that and use only one S7/PG connection for all communication. The reason for this is that number of S7/PG connections is limited and must be reserved in advance, so if you don't have any available your connection will be refused. Depending on your ethernet card model you should be able to parametrize this setting and increase reserved number of S7, PG or OP connections.
Btw1: Are you aware of PascalSCADA (
http://www.pascalscada.com)?
Btw2: Polling period of 1500 ms is good if you have only one polling tags group in your SCADA application. If you have many groups (for example 1st at 1500ms, 2nd at 500ms, 3rd at 1000ms), then you could use prime numbers to prevent all of them constantly trying to communicate with PLC at the same time and avoid congestion. In such a case setting polling periods to near by prime numbers would have a consequence of much more PLC communication friendly polling distribution. For example 1511ms, 503ms and 997ms. In first poll after SCADA is started all 3 groups will try to communicate at the same time, but it will take more then 8 days until that happens again!
http://www.mathsisfun.com/numbers/prime-numbers-to-10k.html