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
Analysis of heatexchanger.txt
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