Hi
Exactly why do you have to construct a S7-300 PID controller from scratch by writing it yourself? Siemens have several options. There are the basic PID controller blocks they provide with every STEP7 installation: FB41, FB42, FB42, FB58 and FB59. If these are too restrictive then they sell add-on software called "Standard PID" which has a series of other blocks with even more detailed parameters and access to the internal workings of the loop. And I think, although I've never seen or used it, they do yet another software option "Modular PID". With this I think you can select components of a PID function such as the P, or the I, or a filter, or a limiting function, or a switch etc and assemble exactly the loop control model you need.
In my experience with Siemens it's not often they don't have the answer. More usually they have 10 answers and you have to spend ages working out which one is the right one for your requirements!
Ken