Industry Online Support
Technical Forum
7/10/2006 11:34 PM  
Joined: 10/31/2005 Last visit: 9/4/2024 Posts: 366 Rating: (31) 
Ok guys, this is another theoretical description of PID control algorithm and also one attempt to explain why PID blocks (for example FB 41 continuous PID) should be placed in block which is called in fixed, regular intervals such as OB35 block. Not that log ago I and my friend had tough time because our PID controller simply didn't work. Proportional controller worked fine, but when we included time constants it gone crazy. We placed PID block in STEP 7's OB1 and soultion was to placed it to OB35 and to make sure that sample time of PID block is entered exactly to match OB's time interval. After that it worked fine. However I started to wonder why is that and what can this mean. I think I found explanation but that depends on your judgement. As we all know PID form in Laplace domain is: Gpid (s) = Kp+Ki/s+Kds or in other form: Gpid(s) = Kp(1+Ki/Kp*1/s+s*Kd/Kp) = GAIN(1 + 1/Ti * 1/s + Td*s) where Ti = Kp/Ki and Td = Kd/Kp; In time domain latter expression is in form: Gpid = GAIN(e+1/Ti * integral(e)+Td*derivation(e)) where e(t) is error (i.e. difference between desired and actual response). Since PLC is digital device it must convert transfer function into z domain since s domain is used for continuous and z domain is used for discrete systems. If we use aproximations formulas for integral and derivation we can get this: dx/dt = (x(kT)x(kTT))/T int(x) = T*sum(x(i1)) where we summing by variable from i=1 to i = k; Knowing that and using Ztransform tables we can finally obtain expression: Gpid(z)= GAIN(1 + T/Ti * z/(z1)+Td/T * (z1)/z) where T is sampling time. Since in controller we have another variable (sampling time T), at the end of PID output calculation this sample time will be compensated. Now when PID block is placed in OB 35 sample time is equal to calling time and there is no problem, PLC know exactly how to compensate this time because Tcalling = Tsampling (by Tsampling I mean time that is entered as bolck FB41 parameter). However if PID is placed into OB1, OB1 is not called at fixed time intervals, so this time Tcalling != Tsampling, controller is sampled in fact with calling time of OB block but ton sample time, and compensation is done with sample time. Only this time integral and derivation time constants don't mean anything since these time coonstants are function of (Tsampling, Tcalling). Since each time OB1 is called with different time it's not interrupted at regular interval), this PID constants will be different each time and hence process control is messed up. This is what I think is happening. If you know more or you think I missed something please let me know. Please, comment this. Thanks 
7/11/2006 9:23 PM  
Joined: 9/23/2005 Last visit: 11/4/2024 Posts: 4351 Rating: (1452) 
Hi, you can measuere the last OB1 cyclus time (local variable in OB1 header) and use it in you PID. So it is possible run the FB 41 in OB1. Pay atention, that the maximal cyclus time must be relactiv shorter as the time constants of your process. 
Denilson Pegaia 

Follow us on