-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathextraCompensation.m
119 lines (91 loc) · 3.16 KB
/
extraCompensation.m
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
function [compensationPart,forwardOrder] = extraCompensation(G,ffMethod,compensationOrder)
if nargin == 2
compensationOrder = 1;
end
[~,~,Ts] = tfdata(G,'v');
ffMethod = lower(ffMethod);
switch ffMethod
case 'zpetc'
compensationPart = ZPETC(G,compensationOrder);
case 'zmetc'
compensationPart = ZMETC(G,compensationOrder);
case 'ignore'
compensationPart = nonminimumIgnore(G,compensationOrder);
case 'seriestruncation'
otherwise
end
forwardOrder = numel(zero(compensationPart)) - numel(pole(compensationPart));
function F = ZPETC(G,compensationOrder)
%%
[z,p,k,Ts] = zpkdata(G,'v');
% relativeDegree = numel(p) - numel(z);
bound = 1;
index = abs(z) >= bound;
nonminimumZero = z( index );
alpha1 = -1 * Ts * Ts * sum( nonminimumZero./(1 - nonminimumZero).^2 );
z = tf('z',Ts);
phai1 = (1-z^-1)/Ts;
phai2 = phai1^2;
F = minreal(-alpha1 * z * phai2);
end
function F = ZMETC(G,compensationOrder)
%%
[z,p,k,Ts] = zpkdata(G,'v');
% relativeDegree = numel(p) - numel(z);
bound = 1;
index = abs(z) >= bound;
nonminimumZero = z( index );
num = numel(nonminimumZero);
alpha1 = Ts * sum( 2 * nonminimumZero ./ (1 - nonminimumZero) );
alpha2 = 0;
for i = num:-1:2
for j = 1:i-1
alpha2 = alpha2 + 4 * Ts * Ts * nonminimumZero(i) * nonminimumZero(j) / ( (1-nonminimumZero(i)) * (1 - nonminimumZero(j)) );
end
end
for i = 1:num
beta = nonminimumZero(i);
alpha2 = alpha2 + (3*beta^2-beta)*Ts^2 / (beta - 1)^2;
end
z = tf('z',Ts);
phai1 = (1-z^-1)/Ts;
phai2 = phai1^2;
if(compensationOrder == 1)
F = minreal( -alpha1 * phai1);
elseif (compensationOrder == 2)
alpha2 = real(alpha2);
F = minreal( -alpha1 * z * phai1 + (alpha1^2 - alpha2) * z^2 * phai2 );
else
end
end
function F = nonminimumIgnore(G,compensationOrder)
%%
[z,p,k,Ts] = zpkdata(G,'v');
% relativeDegree = numel(p) - numel(z);
bound = 1;
index = abs(z) >= bound;
nonminimumZero = z( index );
num = numel(nonminimumZero);
alpha1 = Ts * sum( nonminimumZero ./ (1 - nonminimumZero) );
alpha2 = 0;
for i = num:-1:2
for j = 1:i-1
if ( j~=i)
alpha2 = alpha2 + Ts * Ts * nonminimumZero(i) * nonminimumZero(j) / ( (1-nonminimumZero(i)) * (1 - nonminimumZero(j)) );
end
end
end
z = tf('z',Ts);
phai1 = (1-z^-1)/Ts;
phai2 = phai1^2;
alpha2 = real(alpha2);
if(compensationOrder == 1)
F = minreal( -alpha1 * phai1);
elseif (compensationOrder == 2)
F = minreal( -alpha1 * phai1 + (alpha1^2 - alpha2) * phai2 );
else
end
end
function F = seriesTruncation(G)
end
end