]> Creatis software - CreaPhase.git/blob - octave_packages/control-2.3.52/optiPIDfun.m
Add a useful package (from Source forge) for octave
[CreaPhase.git] / octave_packages / control-2.3.52 / optiPIDfun.m
1 % ===============================================================================
2 % optiPIDfun                       Lukas Reichlin                       July 2009
3 % ===============================================================================
4 % Objective Function
5 % Reference: Guzzella, L. (2007) Analysis and Synthesis of SISO Control Systems.
6 %            vdf Hochschulverlag, Zurich
7 % ===============================================================================
8
9 function J = optiPIDfun (C_par)
10
11   % Global Variables
12   global P t dt mu_1 mu_2 mu_3
13
14   % Function Argument -> Controller Parameters
15   kp = C_par(1);
16   Ti = C_par(2);
17   Td = C_par(3);
18
19   % PID Controller with Roll-Off
20   C = optiPIDctrl (kp, Ti, Td);
21
22   % Open Loop
23   L = P * C;
24
25   % Sum Block: e = r - y
26   SUM = ss ([1, -1]);  % Matlab converts to SS (and back) for MIMO TF connections
27
28   % Group Sum Block and Open Loop
29   SUML = append (SUM, L);
30
31   % Build System Interconnections
32   CM = [3, 1;          % Controller Input with Sum Block Output 
33         2, 2];         % Sum Block Negative Input with Plant Output
34
35   inputs = [1];        % Input 1: reference r(t)
36   outputs = [1, 2];    % Output 1: error e(t), Output 2: output y(t)
37
38   SUML = connect (SUML, CM, inputs, outputs);
39
40   % Simulation
41   [y, t_y] = step (SUML, t);
42
43   % ITAE Criterion
44   itae = dt * (t_y.' * abs (y(:, 1)));
45
46   % Sensitivity
47   S = inv (1 + L);
48   Ms = norm (S, inf);
49
50   % Objective Function
51   J = mu_1 * itae  +  mu_2 * (max (y(:, 2)) - 1)  +  mu_3 * Ms;
52
53 end  % function
54
55 % ===============================================================================
56