example.m 2.18 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
% This example demonstrates how to invoke the scripts for obtaining
%IE-optimal and IAE optimal (with or without LP filter) PID controllers.
%
% Downloaded from git@gitlab.control.lth.se:kristian/PIDopt.git

%% SETUP
% Process model (continuous time LTI SISO system)
s = tf('s');
P = 5/(s+1)/(3*s+1)*exp(-2*s);

% Note: While defaults in the optimization code work for many processes,
% you may need to change grids and tolerances for some.
%
% Note: The optimization scripts were primarily written with stable process
% models in mind. If applied to unstable process models, they may need to
% be modified.
%
% Note: The optimization scripts assume contunuous time process models.
% Modifying them to accomodate discrete time process models is
% straightforward.
%
% Note: If a filter has been designed for the process, simply incorprate it
% into the process model (that is, as a series connected component of P).

Ms = 1.5; % Maximum allowed sensitivity function magnitude
Mt = 1.5; % Maximum allowed complementary sensitivity function magnitude
Mks = 10; % Maximum allowed magnitude of transfer function from process
          % output to control signal, sometimes referred to as noise
          % sensitivity.
          
          
%% Design

% IE-optimal design
p0 = [0 0 0]'; % Parameters of any PID controller, which stabilizes P.
             % See pidIE.m for details. Use p = [0 0] to synthesize PI
             % controller.
             
[K1,p1] = pidIE(P,Ms,Mt,Mks,p0)

% IAE-optimal design
[K2,p2] = pidIAE(P,Ms,Mt,Mks,p1) % Hot-start with K1 parameters

% IAE-optimal design with filter
[K,p3] = pidfIAE(P,Ms,Mt,Mks,p2) % Hot-start with K2 parameters

% Note: The IE-optimal design method relies on convex-concave optimization.
% It guarantees robustness but not stability. So if you choose the grid in
% an unfortunate way, you might end up with a robustly unstable design.

% Note: Behaviour of the methods is undefined (or at least unexplained
% here) if the constraint combinatioon Ms,Mt,Mks is infeasible for P.
%
% Note: Neither the IE nor IAE (with or without filter) guarantee
% optimality. However, both methods have been verified to find the true
% optimum in a large number of cases, such as ...

%% Evaluation