Tutorials on the PID Controller Optimizer Interface

Dingyu Xue

Northeastern University, P R China

E-mail: xuedingyu@mail.neu.edu.cn

 

1. What is PID Controller Optimizer?

PID Controller Optimizer is a MATLAB based interface written by the author and it can be used to optimize PID parameters for the plant model defined by the user. In the package, Simulink is used in modelling the plant, which can be SISO continuous/discrete/hybrid, and linear/nonlinear systems of any complexity. The optimization criteria are ITAE, ISE, IAE and others, which will be defined later in the tutorial.

One may install the package to a MATLAB directory and include the path with "File/Set Path" menu item. Then type pid_optimizer under MATLAB prompt, the design interface will be displayed below.

This is Version 2 of PID Controller Optimizer Interface, released in Sept 2011. The first version was developed in 2008, mainly by the student Dong Wenbin, and the new one is completely rewritten, with much simpler coding, due to the release of the PID controller block in Simulink since 2009b. This version works ONLY for MATLAB R2009b onward and was fully tested in MATLAB R2011a.

2. Meaningful Optimization Criteria

The block diagram of the controlled system is shown below, where the sophistigated PID controller block in the new version of MATLAB/Simulink is used as the kernel, such that the controller can be tuned with the easy-to-use manner. The interface is fully tested under MATLAB R2011a, and may work well with the versions where PID controller block is provided.

The user may construct the plant model with Simulink. The optimized controller parameters can be obtained by minimizing one of the following criteria

The ITAE criterion is recommended for a good controller.

3. Optimization Problem Solvers and Other Specifications

The following optimization tools are used.

Plain MATLAB

Commercial Optimization Toolbox

GADS Toolbox,

Free GAOT Toolbox

PSO Toolbox

 

These free toolboxes can be downloaded from The MathWorks website, in the "MATLAB File-exchange" pages.

4. How to run the program?

To run the interface, one can issue the command "optimpid" to start the PID Controller Optimizer program. The interface shown below will be displayed. An internal Simulink main model is opened and hidden. The plant model should be created before the interface can be used.   If the model created is "mod_1.mdl", the file name should be entered into the "Plant model name" edit box.  To display the plant model, the button "Show Model" can be clicked.

One may use the following essential procedures to design the controller

(1) Enter the Simulink file name in the edit box "Plant model name",  and if a linear plant is involved, one can fill in in the edit box the pre-composed Simulink model name "mod_lti". The plant model can also be specified with the dialog box braught in by the file opening icon.

(2) Specify the terminate time tf in the "Terminate Time" edit box.

(3) Click "Create Files" can be used to generate the objective function in MATLAB.

(4) Click "Optimize" button to design the controller and meanwhile visualing the optimization process by displaying the relevant curves with the Scope.

 

The type of PID type controller can be specified in the group "Controller Type", where different forms of PID controllers are supported.  The available controller structure can be selected from the "P/PI/PD/PID/I" controllers list, also "anti-windup PI and PID" controllers are also supported. The actuator saturation of the controller can be assigned, if applicable, bt the "Actuator Saturation" group. The currently allowed criterion can be selected from the "ISE/ITAE/IAE/ITSE/IT^2SE/IT^2AE" list box. 

 

The button "Show Model" can be used to show the plant model in Simulink.

 

The "Show File" button can be used to display the objective function generated. 

 

The "Refresh" button can be used to delete all the existing plant model files, if any. And also the initial values. 

 

The "Simulation" button can evaluate multi-stairs simulation, and the driven signal and terminating time can be specified with the "Multi-stairs Signal" group.  The "Hold" checkbox can be used to design optimal controller under multi-stairs signal instead.

 

The optimized controller parameters can be returned in "Tuned Controller" edit box, while the allowed lower and upper bounds in the optimization process. These parameters can be set in the "Controller Parameters" group. 

5. PID Controller Design by Examples

5.1 PID Control for linear plants

If the plant model is linear with out time delay, the pre-designed Simulink models "mod_lti.mdl", "mod_ltid.mdl" can be used as the plant model. MATLAB variable "G" should be specified in MATLAB environment. The variable G can be specified by any LTI (linear time-invariant) form, i.e., G can be ss, tf, or zpk objects. They could be in continuous or discrete models.  If delay is involved, the model  "mod_ltid.mdl" should be used instead, and the delay constant by a MATLAB variable "tau".

Assume that the plant model is

the following MATLAB commands should be used

>> num=1; den=[1 4 6 4 1 0]; G=tf(num,den); tau=1;

the interface can then be used by filing "mod_lti.mdl" in "Plant model name" edit box, and "Terminate Time" edit box with "30". The optimum PID controller can be designed with the interface. During the design process, the button "Create File" should be clicked first to generate a "*.m" file for the objective function. One can then click "Optimize" button to design the controller. During the design process, the scope shown below is displayed.

  

 

5.2 How to select the terminate time?

The terminate time is very important in optimal controller design.  Since the integrand in the criterion is non-negative, the integral is a non-dicreasing function.  The curve is settling down when the error signal is approaching to zero.  In the above curve, the time when the integral tends to be flat is around 22, and the terminating simulation time can be selected within the interval of (22,44), twice of the time t1. The terminating time should be validated when the controller is designed.  If tf is chosen too small, the controller designed is not acceptable, however, if tf is selected too large, the effect in the initial time may be neglected.  Thus a good "Terminate Time" should be selected.

5.3 Nonlinear models

If the plant model is nonlinear, which can be either a block diagram or a math model of the form

one may model it with Simulink as shown below, and it should be noted that only one inport block and one outport block are allowed in the block diagram. One should save the Simulink model, say mod_1.mdl, for the system.

Then one fill in the "Plant model name" edit box the file name "mod_1", then repeat the proceeding procedure to design the controller. The button "Show Plant" can be clicked to display the plant model.

Specifying in the vectors of t and v in the "Multi-stairs Signal" group such that "[0, 15, 45, 65]" and "[3 4 2 5]", and specifying "End Time" edit box with "100". The optimum PID controller can be designed.  One can then click "Simulation" button to start multi-stairs simulation as shown below.

One can check "Hold" so that if one clicks "Optimize" again, the new optimal PID controller can be designed again, due to the request for the multi-stairs signal, rather than the original unit step signal. The system response is shown below and it can be seen that the overall criterion value is significantly reduced.

References

Dingyu Xue, YanQuan Chen and Derek P Atherton, Linear Feedback Control --- Analysis and Design with MATLAB, SIAM Press, 2007

Dingyu Xue and YangQuan Chen, Solving Applied Mathematical Problems with MATLAB, CRC Press, 2008