Revision 1255, 0.7 kB
(checked in by zimamiro, 14 years ago)
|
|
Line | |
---|
1 | function [best_control system]=control(system,x_hat,dual)
|
---|
2 | omegar=system.x_opt(3);
|
---|
3 |
|
---|
4 | i_d=x_hat(1)*cos(x_hat(4))+x_hat(2)*sin(x_hat(4));
|
---|
5 | i_q=x_hat(2)*cos(x_hat(4))-x_hat(1)*sin(x_hat(4));
|
---|
6 |
|
---|
7 | [i_q_bar system]=PI_controler(omegar-x_hat(3),system,1);
|
---|
8 | [u_d system]=PI_controler(-i_d,system,2);
|
---|
9 | [u_q system]=PI_controler(i_q_bar-i_q,system,3);
|
---|
10 |
|
---|
11 | u_d=u_d-0.003465*x_hat(3)*i_q_bar;
|
---|
12 | u_q=u_q+0.1989*x_hat(3);
|
---|
13 |
|
---|
14 | U=max(sqrt(u_d^2+u_q^2)+dual,0);
|
---|
15 | fi=atan(u_q/u_d)+x_hat(4);
|
---|
16 | if u_d<0
|
---|
17 | fi=fi+pi;
|
---|
18 | end
|
---|
19 |
|
---|
20 | best_control(1,1) = U*cos(fi);
|
---|
21 | best_control(2,1) = U*sin(fi);
|
---|
22 |
|
---|
23 | %best_control(1,1) = 1;
|
---|
24 | %best_control(2,1) = 1;
|
---|
25 |
|
---|
26 | n=best_control'*best_control;
|
---|
27 | if n>100
|
---|
28 | best_control=best_control*sqrt(100/n);
|
---|
29 | end
|
---|
30 | end |
---|