Categories &

Functions List

Function Reference: optiPID

Example Script: optiPID

Numerical optimization of a PID controller using an objective function.

The objective function is located in the file optiPIDfun. Type which optiPID to locate, edit optiPID to open and simply optiPID to run the example file. In this example called optiPID, loosely based on [1], it is assumed that the plant $$ P(s) = \frac{1}{(s^{2} + s + 1)(s + 1)^{4}} $$ is controlled by a PID controller with second-order roll-off $$ C(s) = K_P (1 + \frac{1}{T_Is} + T_D s) \frac{1}{(\tau s + 1)^{2}} $$ in the usual negative feedback structure $$ T(s) = \frac{L(s)}{1 + L(s)} = \frac{P(s) C(s)}{1 + P(s)C(s)} $$ The plant P(s) is of higher order but benign. The initial values for the controller parameters \(K_P,T_I\mbox{ and } T_D\) are obtained by applying the Astroem and Haegglund rules [2]. These values are to be improved using a numerical optimization as shown below. As with all numerical methods, this approach can never guarantee that a proposed solution is a global minimum. Therefore, good initial guesses for the parameters to be optimized are very important. The Octave function fminsearch minimizes the objective function J, which is chosen to be $$ J(K_P, T_I, T_D) = \mu_1 \int_0^{\infty} \! t |e(t)| dt + \mu_2 (|| y(t) ||_{\infty} - 1) + \mu_3 ||S(jw)||_{\infty} $$ This particular objective function penalizes the integral of time-weighted absolute error $$ ITAE = \int_0^{\infty} \! t |e(t)| dt $$ and the maximum overshoot $$ y_{max} - 1 = || y(t) ||_{\infty} - 1 $$ to a unity reference step \(r(t) = \varepsilon (t)\) in the time domain. In the frequency domain, the sensitivity \(M_s = ||S(jw)||_{\infty}\) is minimized for good robustness, where S(s) denotes the sensitivity transfer function $$ S(s) = \frac{1}{1 + L(s)} = \frac{1}{1 + P(s)\,C(s)} $$ The constants \(\mu_1,\, \mu_2 \mbox{ and } \mu_3\) are relative weighting factors or «tuning knobs» which reflect the importance of the different design goals. Varying these factors corresponds to changing the emphasis from, say, high performance to good robustness. The main advantage of this approach is the possibility to explore the tradeoffs of the design problem in a systematic way. In a first approach, all three design objectives are weigthed equally. In subsequent iterations, the parameters \(\mu_1 = 1,\, \mu_2 = 10 \mbox{ and } \mu_3 = 20\) are found to yield satisfactory closed-loop performance. This controller results in a system with virtually no overshoot and a phase margin of 64 degrees.


References
[1] Guzzella, L. Analysis and Design of SISO Control Systems, VDF Hochschulverlag, ETH Zurich, 2007
[2] Astroem, K. and Haegglund, T. PID Controllers: Theory, Design and Tuning, Second Edition, Instrument Society of America, 1995

Source Code: optiPID