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(kT-T))/T
int(x) = T*sum(x(i-1)) where we summing by variable from i=1 to i = k;
Knowing that and using Z-transform tables we can finally obtain expression:
Gpid(z)= GAIN(1 + T/Ti * z/(z-1)+Td/T * (z-1)/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 timeintegral 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
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(kT-T))/T
int(x) = T*sum(x(i-1)) where we summing by variable from i=1 to i = k;
Knowing that and using Z-transform tables we can finally obtain expression:
Gpid(z)= GAIN(1 + T/Ti * z/(z-1)+Td/T * (z-1)/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 timeintegral 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