Advanced Control - System Identification

Hello guys,
I'm trying to implement AutoTune for second order system.
I'm having some difficulties but don't want any help (yet).
I want to be sure I'm on the right track.
In attachment you will find one .pdf file with little theory and scilab script.
In the script I have simulated one example of second order system.
Please, can you confirm, that I have done all things in the files correctly.
If I have done that, then I can concetrate on AutoTune to make it work somehow.
I'll ask for help if I start to feel desperate.
Cheers!
 
Your calculations match mine for doing the conversion to the z domain

Since you can do this the hard way I will show you the easy way when I get home. Scilab can compute these coefficients for you. I am sure Matlab can too. As I said about there are a couple of ways of doing this. The z transform tables are not easy to use when the system gets larger.

I will need to check the rest of the program when I get home but it looks like the second order simulation is OK. Now we just need add the part where we subtract EV from PV to get the array of errors. Good job.
 
Yes, I'm doing it the hard way, because you told me that only right way to actually understand what is going on to do it myself manually, because I had bad experience when I tried to let Matlab doing job for me. When I become really comfortable with this stuff or when this becomes overkill, I'll use software built in tools. I didn't manage to make AutoTune program to work yet, but I'm trying...
 
I got a version of AutoTuneSOPDT working.

I had expected that the second order solution would be much better that the first order solution but it isn't better at all. The SOPDT MinSSE is 1.0038801. It also takes a little longer to execute. Now I will combine the two routines into one.
I will do the first order system ID first. I can then use the PVss, Kp and nDT as the initial guess for the SOPDT system identification. Note, you can't start Tp1 and Tp2 at the same point. You will get divide by 0 errors.
 
Peter Nachtwey said:
Note, you can't start Tp1 and Tp2 at the same point. You will get divide by 0 errors.
Yes, I know that, but I have problems because for Tp1 I'm getting negative value. I modified your code to handle SOPDT, but I'll need to examine it onece again, to find error in my code. Give me one more day to try to make it work. If I don't manage to get it to work, I'll ask help.
Cheers!
 
Pandiani


what happen ot your flag
flag.JPG
 
I too get negative time constants.

This is a limitation with lsqrsolve in that it doesn't permit us to specify upper and lower bounds for the gains and time constants. My second order solution is very similar to my first order solution. One of the two time constants is less than T which means our second order model really isn't valid. What this is telling us is that the system is closer to a first order model than a second order model. Once must sanity check the solutions at all times. You are right to question the negative time constants. I found that the time constants got shorter as the dead time increased. When the dead time got to 64 second I got the MinSSE but one of the time constants is very small. When a dead time of 66 was tried, one of the time constants would go negative.

I will see if I can dig up the old 'Hotrod' data Ron Beaufort sent me a few years back. We can test our programs on that.
 
Hi people!

What`s about some new algorithms, like adaptive control and tuning functions? Some of you try to program and implement this?

Regards
 
misamark said:
What`s about some new algorithms, like adaptive control and tuning functions? Some of you try to program and implement this?
The first and hardest step is system identification. Once you have a model for the system then calculating the PID gains is easy. See the previous "Advanced Control" threads and www.controlguru.com.

Adaptive control just requires processing power and a lot of math which is outside the scope or capabilities of what can be done on a PLC. Of course we are using PCs to do the system identification to calculate the PID gains for the PLC.
 
Peter, can you post scilab script here? I'd like to compare your solution and mine. I would post my code, but now I'm at work and don't have it here neither, I can install Scilab, because I don't have admin privilege.
 
Last edited:
SOPDT, what I have so far

Code:
	   ___________________________________________
						 scilab-4.1

				  Copyright (c) 1989-2006
			  Consortium Scilab (INRIA, ENPC)
		___________________________________________


Startup execution:
  loading initial environment

-->scipad();

--> [Minp,MinDT,MinSSE]=AutoTuneSOPDT()
 MinSSE  =

	1.003864
 MinDT  =

	64.
 Minp  =

  - 0.5265539	0.5390575	58.647306	160.49028

-->
SOPDT.gif


You can see the results are similar.

I just hacked and slashed the FOPDT code for about two hours while watching football and added a SOPDT routine. I still need to change the comments. I will work on this more this weekend.

Notice that one of the time constants is 0.539. This is smaller than our sample period which tells use that for all practical purposes the second time consant doesn't exist. It makes sense that the sum of the delays can't be too big because the PV does eventually react to the CO. However, I question the results. I expected the minimum SSE would have a smaller dead time and the there would be two meaningful time constants. I expected the SOPDT model to follow the PV very closely. I need to justify why this model doesn't work like I expected. I need to test this on other data.
 
Finally, the AutoTune.sci program all 2 of you have been waiting for.

Code:
     		___________________________________________
     						 scilab-4.1
     
     				  Copyright (c) 1989-2006
     			  Consortium Scilab (INRIA, ENPC)
     		___________________________________________
     
     
     Startup execution:
       loading initial environment
     
     -->scipad();
     
   
     -->AutoTune("hotrod.txt")
     .............................................................
     
     FOPDT SSE=5224.191295
     Kp=3.681728 Tp=3.072843 DT=0.948582
     The FOPDT gains are Kc=0.097762 Ti=3.072843 Td=0.000000
     ...............................................
     
     SOPDT SSE=250.142924
     Kp=3.757500 Tp1=0.684833 Tp2=2.849185 DT=0.362117
     The SOPDT gains are Kc=0.043611 Ti=3.534018 Td=0.552124
     
     The plant is a SOPDT
     
     -->AutoTune("heatexchanger.txt")
     ..................................................................
     
     FOPDT SSE=0.979093
     Kp=-0.529879 Tp=0.956088 DT=1.120814
     The FOPDT gains are Kc=-0.178873 Ti=0.956088 Td=0.000000
     ........................................................................................................................
     ........................................................................................................................
     ........................................................................................................................
     ........................................................................................................................
     ........................................................................................................................
     ........................................................................................................................
     ........................................................................................................................
     ...........................
     
     SOPDT SSE=0.620602
     Kp=-0.520742 Tp1=0.567659 Tp2=0.567651 DT=0.867117
     The SOPDT gains are Kc=-0.157143 Ti=1.135310 Td=0.283828
     
     The plant is a SOPDT
     
     -->

Analysis of hotrod.txt

hotrod.gif
hotrod.gif

hotrod.gif


Analysis of heatexchanger.txt

heatexchanger.gif


This latest verion not only calculates the system identification but also calculates the PID gains so it effectively does "semi-auto" tuning. The changes are

1. does both FOPDT and SOPDT system id and tuning
2. ALl times are in minutes or converted to minutes because PLC PID use time constants in minutes.
3. I found a way to make the dead time continuous so the LM algorithm can also find the best dead time. This is a significant improvement and it makes the program much shorter and cleaner
4. Better comments.
5. Both the FOPDT and SOPDT responses are plotted on the same graph.
6. The AutoTune.sci routine takes a file name for a parameter. The file name is no longer hard coded.
7. Initializing the first two estimated values to the average of the first two PV readings makes ensures the initial rate is zero.
8. Unfortunately the closed loop time constant for both the FOPDT and SOPDT models is fixed to a conservative value. I will eventually add a HMI so the closed loop time constant (Tc) can be changed using a slider bar and plot a simulated closed loop response.

Ron Beaufort has agree to test this program using his 'Hotrod' system which is basically a wood burn iron with a temperature sensor.

AutoTune.sci needs to have a text file with the time, CO and PV in each row as and will be interpreted as floating point numbers like this

0.0 10.0 140.1
0.1 10.3 143.2
0.2 10.7 149.7

The sampling interval can be at almost any rate. The hotrod.txt data is collected at 1 second intervals and the heatexchanger data collected at 2 second intervals. RSLogic makes this easy with the trends. The trends allow one to save away a .dbf file that can be imported into Excel. This data can be exported as a text file.

For some reason I can't get the hotrod.gif to display but it is included in the autotune.zip
 
Last edited:
Hello Peter and Pandiani;

Finally, the AutoTune.sci program all 2 of you have been waiting for.

Our silence is more reverence than disinterest, believe me.
This is the second thread where I follow your discussions, and I am learning with everyone of your posts. I never could get much above the "standard" PID tuning methods (trial and error, basically, sometimes Coon-Cohen method) in the past. Model identification was always the blocking point; thanks to your discussions I am making some headway into mathematical models, and I will be attempting to improve our loop tuning in the coming year.
I will be asking questions soon, though; that's the problem with mentorship, you can attract more adepts than you thought yopu could handle.
Thanks again guys.
Daniel Chartier
 
Thank you for this wonderful program Peter. I see you used fractional part of dead time and used it in CO's interpolation. That was supposed to be my next question. I realy don't know how to thank you. If you were closer I'd buy you a beer :)
 
I don't know why I never thought of interpolating between the sample points earlier. It appears to work very well and greatly simplifies the program. Notice that I eliminated the fct function and call the FOPDT and SOPDT directly.

Did you change the %f to %t to enable printing the debug info? The debug info shows how the LM algorithm searches for the best solution. Hopefully you understand why I wanted to you to try the manual version first.

Where to the equations for the FOPDT and SOPDT PID gains come from. The FOPDT equations are presented on www.controlguru.com but not the SOPDT equations. One should notice that calculating the gains is simples compared to identifying the system.

Do you understand what Tc is? You should try overriding my equations for setting Tc and make it smaller to see the results. This would require plotting how well the PID ,with calculated gains, controls the model. I would like to add a slider bar to make changing Tc easier.

The equations for calculating Tc are fixed and conservative. The PV reaches is the SP without overshooting or oscillating. I think this is too conservative for some applications. We should investigate the Smith Predictor do see if the Smith Predictor would allow us to increase the gains and make the response faster.

Take your time to understand the program. Mean while I am hoping Ron Beaufort will get involved and try using AutoTune.sci to tune his 'hotrod' system. Then we will have a real system to verify the results for both the tuning and the Smith Predictor.
 

Similar Topics

This video shows the things I think about on page 1. I use Laplace transforms a lot. Laplace transforms allow one to express differential...
Replies
2
Views
1,823
Instead of this info getting lost in another thread I will start a new thread. For those that don't know you can search for Advanced Control on...
Replies
8
Views
2,673
sampling data. I will probably use this in a magazine article.
Replies
18
Views
8,466
This topic deserved to be a separate thread with and Advanced Control header. The first video was made from videos a couple of years back. You...
Replies
3
Views
1,553
Hello dear experts! I use WinCC Advanced Runtime V15 as a HMI for the process. I grab values from AB Micro 850 PLC via Modbus TCP. On the HMI...
Replies
2
Views
2,422
Back
Top Bottom