PID block algorithm in Simatic ?

Just want to make a little correction.
Please, ignore "I think that if pump is subtracting from the level, than there must be sign minus on sum block, but on the side toward "flow", not minus from pump output side." in previous post.
Step change in flow that is connected via sum block (left from tank transfer function) is actually a simulation of disturbance when there is a change in inlet flow.
 
Something is wrong with the pump time constant.

I finally got around to looking at Sigreg's problem an I noticed that the pump time constant is 1.5 minutes. That can't be right. A pump should be able to change speed in a few seconds at most so I would think the pump time constant should be around 0.01. A time constant of 0.01 would let the pump reach full speed in about 3 seconds.

I had never done a pump and tank simulation before. It was interesting. Working the flow into the state space equation was new for me.

I attached my work sheet that show how to calculate the gains and do the simulation. I show how to do everything but the system identification. I just made up some numbers until Sigreg gets back with some numbers that make sense.

The work sheet is for a system where the tank level set point is 2 meters. The pump has a max capacity of 250 liters/minute. During a 6 minute time the simulated flow is changed to show the response to the disturbance.

Note:
1. One can make the response faster by reducing Tc.
2. The response does not over shoot the set point.
3. One can see the controller eventually outputs a control signal proporitonal to the flow by (f/Gp) which is what one would expect.

This is pure gold for those that take the time to understand it.
 
Peter, why did you write that desired CE is (Tc*s+1)^3? Why is that form of CE desired? I see that transfer function of whole system is third order, but why you made equivalence between three colsed loop time constant and system's CE? I mean since system is third order a*s^3+b*s^2+c*s+d =0 this means that it can be written as: a*(s-s1)*(s-s2)*(s-s3), where s1, s2 and s3 are poles (roots) of CE? How do you know it is (s-sn)^3 form?
 
Hello,

Sorry about long silence from my side, but i was out of city during weekend. Peter, you did great work ! I will need some time to understand all these equations.
Today i did some more experiments. We must correct our data. We have problem with flowmeters, im not sure that they are do their measurements correctly. Anyway ... Frequency converter has been updated with new software, flowmeters had been changed too. It is what i got during today experiments:

Maximal pump flow (at 100%) is 1530 cubic meters per hour
Pump needs 25 seconds (!!!) to reach speed from 0 to 100%
At inlet flow equal 1520 cubic meters per hour, and with all pumps turned OFF, level in tank rised from 2 to 2.8 meter in 65 seconds.

These data should allow everybody who would like, to make new mathematical model. Im doing it right now.

And about our PID values. You know ... in my company nobody even tried to make any model, they just do their work, set some PID parameters to have regulation "good enought", and just leave it. Im first who want make it in some more scientific way, to calculate PID parameters before system will be ready. I would like to check few ways of normal PID regulation or maybe some advanced regulation to pick up best solutions, i think that it will be precious for me in my future. I dont wanna make "good enought" systems, i do want learn to make very good ones.
This quite simple object with tank and one pump is working already at typical simple PID, so im making model only to practice, to check, and maybe to make it work better. In this object i saw few problems which should be solved by correct PID parameters, or by using other regulation alghoritm, and model should help me to check other solutions.
What is main problem .... :

- making "fast" PID regulator allows pump "react" faster if inlet flow rise will occur, this should prevent us from eventual tank overflow. But fast regulator gives many and long oscilations too what its not too good.
- making "slow" PID regulator allow pump to accuratelly and slowly reach SP withot many oscilations, and object is stabilized faster. But when inlet flow will rapidly rise, pump speed will rise too slow to prevent from tank overflow.

Correct parameters ... it is what i need, to make regulation fast and accurate enought. Choosing of these parameters cannot be done in this case by "lets type in 20 and lets look what is going on". I think so.

Lets back to real object.
Trying use of step response Ziegler-Nichols method i got an almost unstable object with gain egual: -20, I and D parts was turned off. Level oscilations had period equal 250 seconds, level was changing from 2,48m to 2,75m.

Unfortunatelly im still not able to get any oscillations in my math model if i do use only gain. if i use very high gain equal 200 im getting some stable state after long time, and its all. So something is still wrong in this model, and im thinking that our flowmeters can be damaged or mounted not correctly.

Thank you for your help guys !

Greg
 
Pandiani said:
Peter, why did you write that desired CE is (Tc*s+1)^3? Why is that form of CE desired? I see that transfer function of whole system is third order, but why you made equivalence between three colsed loop time constant and system's CE? I mean since system is third order a*s^3+b*s^2+c*s+d =0 this means that it can be written as: a*(s-s1)*(s-s2)*(s-s3), where s1, s2 and s3 are poles (roots) of CE? How do you know it is (s-sn)^3 form?

I chose (Tc*s+1)^3 because the response will not over shoot. It is that simple. I could have used other values for Tc1, Tc2 and Tc3 and the response still wouldn't overshoot but then I have 3 time constants to choose instead of one and the effect wouldn't be much different. See this thread. Some people choose other polynomials. Some choose the coefficients for Butterworth filters or those that minimize the ITAE. I just recently show how the values people use for minimizing the ITAE for the last 50 years were wrong on sci.eng.control so be careful when using the minimum ITAE coefficients.

ttp://groups-beta.google.com/group/sci.engr.control/browse_frm/thread/64d35b9b6b8c3768/0221acdf6655d0fe#0221acdf6655d0fe

Now you can tune your systems to get just about any response you want.
 
sigreg said:
Hello,

Sorry about long silence from my side, but i was out of city during weekend. Peter, you did great work ! I will need some time to understand all these equations.
Today i did some more experiments. We must correct our data. We have problem with flowmeters, im not sure that they are do their measurements correctly. Anyway ... Frequency converter has been updated with new software, flowmeters had been changed too. It is what i got during today experiments:

Maximal pump flow (at 100%) is 1530 cubic meters per hour
Pump needs 25 seconds (!!!) to reach speed from 0 to 100%
This means a time constant is about 5 seconds because it takes 5 time constants to get within %1 percent.

At inlet flow equal 1520 cubic meters per hour, and with all pumps turned OFF, level in tank rised from 2 to 2.8 meter in 65 seconds.
This is not as useful as knowing the Gt which is basically the inverse of surface area of the tank.

And about our PID values. You know ... in my company nobody even tried to make any model, they just do their work, set some PID parameters to have regulation "good enought", and just leave it. Im first who want make it in some more scientific way, to calculate PID parameters before system will be ready. I would like to check few ways of normal PID regulation or maybe some advanced regulation to pick up best solutions, i think that it will be precious for me in my future. I dont wanna make "good enought" systems, i do want learn to make very good ones.
Good for you. Real engineers don't guess. They calculate or estimate.
In some applications the difference between good and bad tuning can be a lot of money. I know in our applications, good tuning means a good product is made.

- making "fast" PID regulator allows pump "react" faster if inlet flow rise will occur, this should prevent us from eventual tank overflow. But fast regulator gives many and long oscilations too what its not too good.
The trick is to get the tuning right. You may not be able to get the control near as pretty as my simulation because of the slow response of the pump . See how changing Tp changes the gains.

- making "slow" PID regulator allow pump to accuratelly and slowly reach SP withot many oscilations, and object is stabilized faster. But when inlet flow will rapidly rise, pump speed will rise too slow to prevent from tank overflow.
If you use my formulas you will need to reduce Tc until the overflow does not occur.

Lets back to real object.
Trying use of step response Ziegler-Nichols method i got an almost unstable object with gain egual: -20, I and D parts was turned off. Level oscilations had period equal 250 seconds, level was changing from 2,48m to 2,75m.
Ziegler-Nichols is not the method to use because the response does oscillate.

Unfortunately im still not able to get any oscillations in my math model if i do use only gain. if i use very high gain equal 200 im getting some stable state after long time, and its all. So something is still wrong in this model, and im thinking that our flowmeters can be damaged or mounted not correctly.
I can increase the gains on my simulation and get oscillations, but I am not sure I can make the simulation go unstable. I will check.
I will change my flow values to cubic meters / minute so I will consistently use meters and minutes.
I have fixed my spelling errors :(.

At what level does the tank overflow? What is the set point?
 
Very interesting and valuable. Peter, I have more questions about the way you design state feedback controller, but I'll leave it for later discussion. What is interesting me here is the way how system identification is performed. Sigreg used K/(Ts+1) model for pump and for me it makes sense to use first order model. Now, question is how to determine K and T. Since pump needs 25 seconds to reach speed from 0 to 100%, it makes sense to conclude that T = 5 sec =1/12 min. Now how to determine K in this case, and what informations from sigreg's post are useful for this purpose?
Thanks
 
Pandiani said:
Very interesting and valuable. Peter, I have more questions about the way you design state feedback controller, but I'll leave it for later discussion.
There is the Advanced Control thread for these questions. Note, the calculated gains will work for both the S7 PID and the state feedback since the characteristic equation doesn't change.

What is interesting me here is the way how system identification is performed.
Sigreg used K/(Ts+1) model for pump and for me it makes sense to use first order model. Now, question is how to determine K and T. Since pump needs 25 seconds to reach speed from 0 to 100%, it makes sense to conclude that T = 5 sec =1/12 min. Now how to determine K in this case, and what informations from sigreg's post are useful for this purpose?
Thanks
The pump gain should have units that make sense. In my example the pump gain has units of liters per minute per percent control output. I will change that to cubic meters per minute per percent output. Take the total pump capacity and divide by 100 and that is your pump gain. Do you also see the Gt is 1/(square meters of the tank surface)? Greg indicates that Gt is 0.00073 or that the tank has a surface area of 1370 square meters. Hopefully Greg can verify that. These are the important numbers needed to calculate the controller gains but I still wanted a set point and a over flow level for the simulation.

Note, the minimum controller update time shoud be at most .5 second or 10 times less that the pump time constant. If very fact response is desired then Tc can be reduced to below 5 seconds like in which case the controller time should be 10 times less that Tc.

Tonight I will update my work sheet with the data provided by Greg.
 
Peter Nachtwey said:
Take the total pump capacity and divide by 100 and that is your pump gain.
Okay, this would be 1520 m^3/h = 25.33 m^3/min, so K = 25.33/100 = 0.2533. Now pump's transfer function is: 0.2533/(s/12+1).
Is this correct?
 
Close, I think you are using the wrong number.

Pandiani said:
Okay, this would be 1520 m^3/h = 25.33 m^3/min, so K = 25.33/100 = 0.2533. Now pump's transfer function is: 0.2533/(s/12+1).
Is this correct?
Max pump flow is 1530 so the gain is .255. The pump barely has enough capacity to handle the max flow.

I now you bring it up. The Gt is also wrong.

Maximal pump flow (at 100%) is 1530 cubic meters per hour
Pump needs 25 seconds (!!!) to reach speed from 0 to 100%
At inlet flow equal 1520 cubic meters per hour, and with all pumps turned OFF, level in tank rised from 2 to 2.8 meter in 65 seconds.

1520 m^3/h*(1/h/60min)*(68s/60s)/.8m = 35.89 m^2 Therefore the gain is 1/35.89 or Gt=.0279 (m level / m^3)

I will use these numbers when I update my .pdf tonight
 
Peter, I would also like to ask more questions about controller design procedure. In that heat exchanger example on www.controlguru.com, controller output was percent of how much valve that control cooling liquid flow is opened. Here, we can take frequeny convertor as final control element i.e. we can observe percent of convertor's load (0% pump is OFF, 100 % pump has max. flow), so we determine gain constants by dividing with 100. I want to know if this is general rule, I mean if we need to try to use percent when ever is that possible?

I suspect that because of this, more apporiate would be to use FB 41 with variables in percent not physical values.

Also, how we would determine CObias value here?
 
Please, read this pdf file and, if you can, try to answer questions that bother me regarding CObias.
Thank you very much
 
This is a much different systems than the Controlguru tank level system

we can take frequeny convertor as final control element i.e. we can observe percent of convertor's load (0% pump is OFF, 100 % pump has max. flow), so we determine gain constants by dividing with 100. I want to know if this is general rule,

Yes, but others may do it slightly differently. Some use a proportional band which I think is stupid.

I mean if we need to try to use percent when ever is that possible?
Yes, at least I do. In the past the would express gain as flow/volt of control output or flow/amp of control output but you can see that is very hardware specific. Now I use percent for calculations.

I suspect that because of this, more apporiate would be to use FB 41 with variables in percent not physical values.

I haven't used FB 41, I think you would need to equat 100% to 27??? counts to on the output stage. You must try to keep all the resolution you can.
Many PID controllers use counts to do their calculations. This is NOT good. The calculations should be done in floating point.

SIGreg's tank level control system is much different from Controlguru's tank level control system because SIGreg's pump is on the outlet and Controlguru's pump is on the inlet. Notice that the transfer function is different. SIGreg's system is called a type 1 first order lag. It is a type 1 because the tank integrates. the flows. The Controlguru's does not.

SIGreg's is not a good system for a COBias unless one somehow knows what the flow is at all times.

Pandiani, there should be no overshoot in the response in your simulation. Do you have the controller up date time the same?
You should be able to convert the continos domain to the z domain and check the coefficicients.

Use the C2D function to see if your discrete arrays are the same as mine.
 
Last edited:
Peter, as you can see, I didn't use state space model. I use continuous simulation in Matlab, so I use directly coontinuous transfer functions. Pump's transfer function is Gpump = -0.255/(0.083s+1), tank's transfer function is 0.0279/s.

PID block has transfer function Gpid = -605.4-807.2/s. Input is step change from 0 to 2. This simulation shows overshoot. Disturbance is kept at zero level. This simulation assumes that all initial conditions are zero. As you can see, I didn't use state space model.
http://www.plctalk.net/qanda/uploads/Tank_level_model.jpg
 

Similar Topics

HI.I REVIEWED A PROJECT DONE. THIS FB41 PID BLOCK WAS USED FOR THE PASTEURIZATION PROCESS. THE PROCESS I CAN'T UNDERSTAND IS THE ACTION. WHILE THE...
Replies
2
Views
1,117
Hello, I have a PID block in my program controlling pump speed in order to get a correct Differential pressure. The way I have it set up is the...
Replies
3
Views
1,271
Is there a way to create proportional logic for a control valve without using a PID function? I want to create a simple P controller without...
Replies
8
Views
2,628
So I have a PID block on CCW set up to control a motor. I have my variables input and the absolute error is changing but the CV is always 0. There...
Replies
1
Views
1,620
I want to change the setpoint of PID block in Codesys for every 1 hour. like that i have to give 48 setpoints for 48 hours. So how can I give 48...
Replies
2
Views
1,529
Back
Top Bottom