-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmup.m
132 lines (109 loc) · 2.51 KB
/
mup.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
120
121
122
123
124
125
126
127
128
129
130
131
132
% MUP
% Metoda umiestnenia polov
% Analyticka metoda syntezy regulatora
%
% ---------- PRACA S PRENOSOM ----------------------------------
%
% Vypocet menovatela prenosu
% Prenos v tvare: G(s)=K(s)/menv(s)
% Menovatel v tvare: An*S^n + A(n-1)*S^(n-1) + ... + A1*S + A0
% a = a(end-n)*s^n + a(end-(n-1))*s^(n-1) +... + a(end-2)*s^2 + a(end-1)*s + a(end)
%
if(typ_i==1)
[Kv,menv] = get_tf(1,n,K,T); % Strejcov tvar
else
[Kv,menv] = get_tf(2,ksi_km,K,T_km); % Kmitavy tvar
n=2;
end
% Predelenenie kazdeho koeficientu koeficientom pri najvyssej mocnine:
% s^n, aby sa ziskal koeficient An = 1
Kv = Kv/menv(1);
menv = menv/menv(1);
a=zeros(1,n+1);
for i=1:n+1
a(i)=menv(end+1-i);
end
% P reg
if (n==1&&J3==1)
z_r=(ref(1)-a(1))/Kv;
t_i=1e10;
t_d=0;
simul_param;
end
% P reg - s0
if (n==2&&J3==1)
s0=ref(2)-a(1);
s0=-s0;
if(s0>=0)
pth_fig = mup_info(2,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
else
pth_fig = mup_info(1,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
z_r=(ref(1)-a(1)*s0)/Kv;
t_i=1e10;
t_d=0;
simul_param;
end
end
% PI reg
if (n==1&&J3==2)
z_r = (ref(2)-a(1))/Kv;
t_i = Kv*z_r/ref(1);
t_d = 0;
simul_param;
end
% PI reg - s0
if (n==2&&J3==2)
s0=ref(3)-a(1);
s0=-s0;
if(s0>=0)
pth_fig = mup_info(2,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
else
pth_fig = mup_info(1,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
z_r=(ref(2)-a(1)*s0)/Kv;
t_i=Kv*z_r/ref(1);
t_d=0;
simul_param;
end
end
% PID reg
if (n==2&&J3==3)
z_r=(ref(2)-a(1))/Kv;
t_i=Kv*z_r/ref(1);
t_d=(ref(3)-a(2))/Kv/z_r;
simul_param;
end
% PID reg - s0
if (n==3&&J3==3)
s0=ref(4)-a(2);
s0=-s0;
if(s0>=0)
pth_fig = mup_info(2,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
else
pth_fig = mup_info(1,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
z_r=(ref(2)-a(1)*s0)/Kv;
t_i=Kv*z_r/ref(1);
t_d=(ref(3)-a(1)-a(2)*s0)/Kv/z_r;
simul_param;
end
end
% PD reg
if (n==2&&J3==4)
z_r=(ref(1)-a(1))/Kv;
t_i=1e10;
t_d=(ref(2)-a(2))/Kv/z_r;
simul_param;
end
% PD reg - s0
if (n==3&&J3==4)
s0=ref(3)-a(2);
s0=-s0;
if(s0>=0)
pth_fig = mup_info(2,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
else
pth_fig = mup_info(1,s0,fgcolor,ptv_str_lang,ptv_cfbcg);
z_r=(ref(1)-a(1)*s0)/Kv;
t_i=1e10;
t_d=(ref(2)-a(1)-a(2)*s0)/z_r;
simul_param;
end
end