Proces modelling in a PLC.

JesperMP

Lifetime Supporting Member + Moderator
Join Date
Feb 2003
Location
ᚴᚬᛒᛅᚾᚼᚬᚠᚾ
Posts
16,292
Hi,

I am a little nervous when I write this, it can be the start of a timeconsuming involvement. But it has been on my mind for a long time. And a recent thread (http://www.plctalk.net/qanda/showthread.php?s=&postid=51903) persuaded me to try to see if there are others that could be keen to pick up the topic.

Here goes:
PIDs can be implemented in PLCs to control processes of various kinds. But PID is not enough in many cases. More advanced methods could be applied such as implementing modelbased controls.
Models could be automatically determined in the PLC.
And control could be applied by means of the model.

But all comercially available modelling software is expensive and PC based (or DCS based). I would like to avoid PCs alltogether from the control loop.
PLCs gets more powerful (more memory, faster processing, more advanced programming capabilities), so the idea of putting the whole thing in the PLC enters my mind.

Are anybody interested in creating a "studying group" with the aim to develop program libraries and techniques for modelbased controls ?

Any takers :)
 
Well, this isn't a completely new concept, and it is ceratainly feasible. What I think you are really talking about is feedforward control, or perhaps what is known as a "Smith Linear Predictor". In both cases you essentially measure the inputs to the process and use a mathematical model of the process to calculate the value of the controlled variable required to maintain the process at the desired operating point. Is that what you mean?

This is different from a feedback system, where the control output changes in response to error, i.e. a difference between actual and desired results.

General purpose modelling software is very complex, in part because it requires a user interface, in part because they have to include all kinds of non-linear response algorithms, and in part because they have to take care of dynamic response conditions.

In an actual control environment a lot of that isn't necessary. You are dealilng with a specific process, hopefully operating with all variables inside a known range. Because you are measuring and calculating in real time, you can ignore many dynamic aspects, except for response delays and so on. Most individual processes can be modeled with linear equations and calculated with four function math. That makes predictive control or feedforward control for an individual process in a PLC very straight forward, once you have the governing physics of the model worked out.
 
Last edited:
I did something like your reqeust... My solution was to take external variables (as a input conveyor speed) and to re-calculate the P, I and D..
Real tricky to mess with variable PID, but it was working.
 
Nice idea, but do you know....

differential equations
matrix math
least squares system identication
recursive least squares system identication (for updates on-the-fly)
Ackermann's formula.
Laplace transform
Z transforms

Some of these things like the matrix math requires matrix inversion which is quite computer intensive. Also most PLCs don't have the memory or the matrix math functions. A S7 or Control Logix might be able to do this but it would be difficult. Ladder or STL is not the tool for the job. I use MathCad for research and C++ with a matrix library for actual implementation.

It is cheaper to buy the tuning software rather the re-invent the wheel. We can justify the effort because we make motion control products. We need to know all of this to make better products.


A Power Point Presentation on Auto Tuning a Hydraulic Cylinder.

I give this presentation at some trade shows. Note that the good parts that aren't generally known are left out. This should be considered to be a outline, but it is a real cylinder that is being tuned.

Now is anybody still up for it?
 
Last edited:
Wow so thats what I learned all that stuff for.

Going through college we learned all that good stuff, but In the real world I am just not finding a use for it. The closest I have come to using is tunnig my PID loops. Even then it is kinda light on the calc stuff. I must say I am very happy to have MathLab, as I am quite happy with not reinventing the wheel. Its nice to know some one out there actual uses the hevy stuff.
 
I think this thread can be broken into two parts.
The first issue is system identification. I'm with Peter on this. If you need to identify a relatively static, albeit complex, system then get your hands on the commercial stuff that's already out there. You can be reasonably sure it works and once you have it you can use it to identify as many systems as you like. So your cost gets amortized over many uses and the per use cost isn't too bad.
The second issue is continuously adaptive models. This would be required in systems that change quickly enough or with enough regularity that the model is always in flux. I haven't been around all that long but I have never come across one of these. Petroleum distillation might fit this catagory. I have seen relatively complex dynamic systems, but the system has always been stable. In a system like this having the modeling software in a plc might be nice. But I don't know that a plc is how you would do a system like this. You might already be in the higher power, proprietary, turnkey systems at that point. Like Jesper says, plcs are getting more powerful every day. Maybe there is a market for something like this. I just don't know if it is here today.

Keith
 
You all are way over my head. If it's auto tune you want, Omega makes a 1/16 din controller with continuous auto tune. Dump the set point from the plc into it and let it fly. $130 per unit.

Andy
 
Well I just finished reading this string over again, and going through your Power point demo Peter. I am not sure but i think the start of the string was about getting the PLC to set up the model, and do the tunning Calcs. I am going to have to agree with Tom in that this is not feasable with a PLC. The PLC is the end device used for implemention.

I like your demo Peter, but I am not realy sure why you want to add another control unit in the procces., With time put upfront the PLC is perfecly capable of perform the PID control task.

Looking forward to your comments
Allan.
 
Allan Barnes said:
I like your demo Peter, but I am not realy sure why you want to add another control unit in the procces., With time put upfront the PLC is perfecly capable of perform the PID control task.

Looking forward to your comments
Allan.

PLC can do the PID control on many applications. On motion and pressure/force control applications a PLC is not fast enough or have consistent sampling periods. There is a LOT OF STUFF in a motion controller that can't be put in a PLC easily.

The power point presentation really needs to have some one explain it for it to be understood. Understanding the presentation is not important now. I meant it to be a warning more than an education. It shows how those topics I mentioned in my previous post get used. I also show how I use FFT to find the natural frequencies at which the axis will vibrate. I forgot to mention that one.

From here I think it is best to skip the auto tuning and cover the things that will provide the greatest ROI. I think the tuning method mentioned by JohnW on another thread is good. Implementing feed forwards or BIAS can greatly reduce error with little effort.

Does every one know about the ISE I mention in the power point presentation? It provides a good way of telling if the gain changes are for the better or not. For applications were the SP is allowed to jump from one setting to another a better way of evaluating the tuning is to use ITAE ( integrated time absolute error ). The formula for this is:

ITAE = sum(abs(SP-PV)*time)

This method of evaluating the response penalizes for taking a long time to get to set point. Remember, the goal is to minimize ITAE or ISE. Using these evaluation techniques is a lot better than guessing. OK, you still may be guessing but at least you know if your new guess was better than the old guess. After a while one learns what gains will reduce the ITAE or ISE and the guesses become educated guesses.
 
Tom, yes it is exactly that what I want to do.
Thats part two of the project: Use the model to control the proces.
Part one is to create the model. I can imagine two fundamentally different ways to do that:
1. Determining the model analytically. Then creating custom code that represents the model. Finally verify and tune the model on the real proces.
The advantage of this method is that the best control can be achieved, pending that a sufficiently good model can be established.
2. Have a generic algorithm make an estimated model by constantly analysing control, feedfoward and feedback variables.
It is also called adaptive control.
My electrical engineering graduation project was about such a system (15 years ago !).
The advantage of this method is that it is generic, no custom code needs to be made (at least in theory).

Peter, I am familiar with the things you listed (not Ackermanns formula though), but its been some time I have worked seriously with it.

The processes that I am thinking of, are relatively slow, but tricky by nature. The ones that I have to deal with both have dynamic properties vary over the time, and sigificant dead times - where the dead time varies with how the main variable is loaded. We are an OEM company, which means that we design and commision the systems, but we are not onsite allways, so an adaptive system is my personal favourite.
That said, I am not particularly looking to solve this problem, but rather to get a technique or library to solve many problems.

The hardware platform that I have in mind:
It has to be one of the top models. I have S7-400 available myself.
The ABB MASTER mini-DCS system I had at the time, has approx 10% of the processing power of todays top PLCs (my estimate), so it must be possible.

The software platform that I have in mind:
The natural choice is IEC 61131-3 Structured Text. It will allow the highest degree of crossplatform portability (100 % cannot be achieved, but it will be close). Also, it is the language best suited, given the mathematical nature of the project. The text format makes for easy exchange of code between members of the group.
 
Well, Jesper, I'm not sure that the PLC is the appropriate place for what you have in mind. Most of the time when you start talking about general purpose solutions you are asking for a lot of computing power, and even more significantly, a lot of operator interface activity. I think the PC is the appropriate platform.

In my use of process model based control the relationship between measured variables, transport mechanisms, and process response have been developed "off line" so to speak, and then the model for the single process being controlled is programmed in the PLC. This limits both the program complexity and the amount of operator input to the parameters for the specific application of the general process model. Here is an example:

http://home.earthlink.net/~escor/services/a2c/a2c.html

I have also been involved with a project using "general purpose" process modelling software for control. In this case my PLC system took the process measurements. The data was transferred into the PC for use as inputs to the process model. Then the outputs of the process model were transferred to my PLC system, where I use conventional feedback control to maintain the critical process variables at the setpoint indicated for process optimization. Its only been running a few months, but the plant operator seems pleased with the results.

Either of these will work well for long dead time processes. If you need control of a specific process the first aproach is best. If you truly want a general purpose solutin, I think the second approach is better suited. I just don't think PLCs and HMIs are ready yet to replace PCs for operator interface intensive systems - they are meant for field device interface intensive applications.

Of coursse, a number of PLC platforms now have PC modules that you can slap in the rack, so that kind of hybrid may be ideal for your needs.
 
I dont think that the PLC was "meant" for anything in particular - apart from the very beginning where replacement of relay controls was the selling point.
I find that I am putting more and more "advanced" stuff into these things. But what I do is proprietary. Rather than reinventing the wheel, why not in cooperation make a general program library for all to add to and use - Linux style.
I agree that a PLC library function will not be as userfriendly and powerful as a PC based solution, but if the userfriendliness is good enough, and the power is sufficient for the application - then why not ?
There are advantages to doing it in a PLC:
- It is "free" (not counting the time necessarry for implementing the library), PLC/HMI/Datalogging is probably allready available many places just waiting for you to add more functionality.
- It can cut down on the complexity. No need to split the job between PC and PLC and the necessity to pass data and configurations between them.
- The system will get one of the main advantages of the PLC: Robustness. And thats a major concern for an OEM like me that ships all over the world.

By the way Tom, your link gave me some memories of my old job.
We made turbo blowers (HV-Turbo) with WWT plants being the main market. So I have been to these places many times !
 
Here is an example of what I have in mind.
Its a very short summary of how a continously adaptive controller is implemented.
As you can see, the controller isnt too complicated.
To implement least squares approximation methods can be a bit more involved, but not at all impossible.

Adaptive controller output formula
OUT(t) := OUT(t-1) + [ka0/[ka0^2 + kQ]]x[[1 - kPL][REF(t) - FB(t)] - SUMa - SUMb - SUMc]]

SUMa := Ka1[FB(t-1) - FB(t-2)]
+ Ka2[FB(t-2) - FB(t-3)]
+ Ka3[FB(t-3) - FB(t-4)]
+ Ka4[FB(t-4) - FB(t-5)]

SUMb := Kb0[OUT(t) - OUT(t-1)]
+ Kb1[OUT(t-1) - OUT(t-2)]
+ Kb2[OUT(t-2) - OUT(t-3)]
+ Kb3[OUT(t-3) - OUT(t-4)]
+ Kb4[OUT(t-4) - OUT(t-5)]

SUMc := KC0[FF(t) - FF(t-1)]
+ KC1[FF(t-1) - FF(t-2)]
+ KC2[FF(t-2) - FF(t-3)]
+ KC3[FF(t-3) - FF(t-4)]
+ KC4[FF(t-4) - FF(t-5)]

REF := the reference (setpoint)
OUT := samples of the controller output
FB := samples of the Feedback variable
FF := samples of the Feedforward variable.

kQ := Moderation factor. The greater kQ is, the slower is the control.
kPL := Decides the pole in the closed loop. 0.0 < kPL < 1.0. kPL is typically 0.3

ka0..ka4 := Control coefficients of the influence from the output.
kb0..kb4 := Control coefficients of the influence from the feedback.
kc0..kc4 := Control coefficients of the influence from the feedforward.
ka0..ka4 + kb0..kb4 + kc0..kc4 is the "model" of the proces.
The proces variables OUT, FB and FF are sampled,
and the relation between OUT(t) and OUT(t-1).. and FB(t).. and FF(t)..
via the coefficients can then be found with the use of the "least squares" approximation.

 
Hello,

I'm not confident that your study group would succeed in making the switch between PC and PLC. Use the PLC were it's build for. There is an excellent software of Emerson with all those capabilities.

Delta-V Inspect
Delta-V Tune
Delta-V Fuzzy
Delta-V Neural
Delta-V Predict

There is also an excellent book about this subject available.

Advanced Control Unleashed. Which you can order at ww.easydeltaV.com/bookstore

Rudi
 
You have a long way to go.

Honestly, you are not even close. Your model is assuming there are 3 poles and zeros. If you check out the power point in the link above you will see that finding out how many poles and zeros a plant has is one of the key items.

Recursive Least Squares Estimation

Some light reading :)

If have an off line Mathcad work sheet that can do recursive least squares estimation. However, the main point is to adjust the model on-the-fly. I have not had enough processing power to do this on a motion controller until recently. I have been able to test the formula on real data off line and verify the gains looked reasonable. The main problem I have found is that the sample time must not be too fast or the poles in the Z-domain get too close to the unit circle. On a motion controller, the gains could be autmatically adjusted to match the load within 20-50 milliseconds. See the .pdf. I verified their formulas and speeds for adapting to load changes.

Another thing you need to know is observers.

Have fun researching.
 

Similar Topics

I heard that in Step 7 there should be a subpackage or utility called 'proces diagnostics' or something like that. Does someone know what it can...
Replies
1
Views
1,402
Hi, whats the difference between the above two types of PID controllers. For example, there are the S7 PID blocks FB41 CONT_C and FB58 TCONT_CP...
Replies
1
Views
8,406
Hi guys, these days, I was trying to get water tank temperature model which is used in genetic algorithm to tune PID parameter. The heater in the...
Replies
2
Views
1,877
Hello guys, it's time to talk about modeling and simulation again. I've been doing some research and saw different models. I noticed that in...
Replies
11
Views
7,644
I'm starting a new PLC control project and would appreciate some guidance on how to do things right. I need to model/describe what is it that I...
Replies
6
Views
2,661
Back
Top Bottom