Siemens PID block, theoretical analysis

Pandiani

Lifetime Supporting Member
Join Date
Apr 2005
Location
Tz
Posts
718
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
 
While I agree that the jitter in the update time was cwertainly not helping you any, I think the biggest issue was that the update time was so much shorter than you expected. OB1 will run as fast as it possibly can. If all you had in the program was a single occurance of FB41 I would think your OB1 scan time was pretty fast. Your integral and derivative time constants were most likely too high for the scan rate.

By using OB35 you have a controllable scan rate at a much lower rate (presumably) than OB1.

Keith
 
You are right.

The sample time must be the same as what the PID's thinks the sample time is or the zeros will not be in the right place in the z domain. This is why using a timed interrupt works. DO NOT use a timer in OB1. Timers are only good for making sure a period of time has passed an OB1 only executes when other interrupts are done. Timers DO NOT and CAN NOT ensure the exact time has passed, you need an interrupt for that.

I am not a fan of timers. They are handy is some instances for a quick and dirty delay but they are not precise. The problem is that too many use timers when they should be using interrupts or the system millisecond timer.

There have been many threads about PID updates for Rockwell PLCs. Even though the PLC is not the same the principles still are. See some of Ron Beaufort's threads on PID update times. However, they will just say what you already know.

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).
Sure we all know that ;), well I do anyway.
 
Peter Nachtwey said:
when other interrupts are done. Timers DO NOT and CAN NOT ensure the exact time has passed, you need an interrupt for that.

Well i think timers arfe suitable to use if high precision is not needed, for example if counts tim to 20-30 seconds in which cases a couple of ms is not that important.
I'm glad you agree with my "theoretical" explanation what is really happening in FB 41 and STEP7.
Thank you.
 

Similar Topics

Using siemens block to control pressure level. The PV is pressure in Bar and the output is vsd fan speed in %. What I require is when the PV is...
Replies
6
Views
3,029
Hello everyone, I'm new in using plc software. I want to set a parameter for my centrifugal pump using an i/p from PID block so that the range of...
Replies
0
Views
1,271
Hello, This is my first time configuring a siemens PID block i have some knowledge with using PID but when i saw the PID block for siemens i...
Replies
0
Views
2,159
Hello, I need to set up the following PID controller: K(1+1/(Tis)+Tds)=0.6(1+1/(8s)+2s) (s-domain) in Step 7 project using PID FB41. I set up...
Replies
9
Views
9,445
Hello all, A group I am involved with is just completing converting a Siemens APACS control system over to an RSLogix PLC. The subject came up of...
Replies
1
Views
1,154
Back
Top Bottom