hello Steve;
If you want to do simple PID on S7 CPUs, try the PID blocks provided by Siemens: FB41 is the analog PID block, FB42 (with FB43) is the discrete version.
If you want to use FB41, call it in OB35 (cyclic interrupt, 100 ms); plug in the address of the analog input (PIWxxx) into the PV_PER parameter (proces value, periphery), set up the gain value, and integral and differential parameters, if needed. You will read an outpout value that you can send to your analog adfdress (PQWxxx)at parameter LMN_PER (manipulated value, periphery).
Of course, there are many other inputs and outputs to FB41; most of them are either set-up parameters (like I_sel, value=1 to use the integral parameter (as in a PI controller), value = 0 to not use it (as in a straight P controller)), or loop parameters. You will have to read through the documentation for the FB41 and determine the values for each parameter required for your process.
For most parameters you wish to use, it is best to set up a memory address thaqt you cam manipulate through your program or a VAT table (for example, the GAIN parameter (Kp) could be set-up at MD20(as a REAL variable); that way you can modify the value in runtime; if you write a constant value to the parameter (say 0,82) the parameter value cannot be modified unless you write a new value, save and download.
One element missing from the docs: parameter Com_Rst (complete restart) must be SET in OB100 (start-up OB), and the RESET in OB35 after the PID block has been launched. That way, FB41 will be restarted every time the CPU goes into run mode, and it will see a falling edge required for it to run.
Hope this helps,
Daniel Chartier