1 | function [x_s, y_s] = evolSys(x, u, nQ, nR, noise, simulator) |
---|
2 | if ((simulator == 1)||(simulator == 10))%simulator |
---|
3 | ua = 3*u(1); |
---|
4 | ub = 3*u(2); |
---|
5 | %kompenzace ubytku |
---|
6 | if(simulator == 10) |
---|
7 | ua = ua + comps(x(1)); |
---|
8 | ub = ub + comps(x(2)); |
---|
9 | end |
---|
10 | |
---|
11 | [tx, ty] = pmsm_sim(ua, ub, 0); |
---|
12 | |
---|
13 | x_s = tx(1:4); %isa, isb, omega, theta |
---|
14 | y_s = ty(3:4); %isa, isb |
---|
15 | |
---|
16 | elseif (simulator == 0)%matlab - stejne indukcnosti |
---|
17 | dt = 0.000125; |
---|
18 | a = 0.9898; |
---|
19 | b = 0.0072; |
---|
20 | c = 0.0361; |
---|
21 | d = 1.0; |
---|
22 | e = 0.0149; |
---|
23 | |
---|
24 | x_s(1) = a*x(1) + b*x(3)*sin(x(4)) + c*u(1) + noise*sqrt(nQ(1,1))*randn(); |
---|
25 | x_s(2) = a*x(2) - b*x(3)*cos(x(4)) + c*u(2) + noise*sqrt(nQ(2,2))*randn(); |
---|
26 | x_s(3) = d*x(3) + e*(x(2)*cos(x(4)) - x(1)*sin(x(4))) + noise*sqrt(nQ(3,3))*randn(); |
---|
27 | x_s(4) = x(4) + dt*x(3) + noise*sqrt(nQ(4,4))*randn(); |
---|
28 | |
---|
29 | y_s(1) = x_s(1) + noise*sqrt(nR(1,1))*randn(); |
---|
30 | y_s(2) = x_s(2) + noise*sqrt(nR(2,2))*randn(); |
---|
31 | |
---|
32 | else %matlab - ruzne indukcnosti |
---|
33 | Rs = 0.28; |
---|
34 | Ls = 0.003465; |
---|
35 | psipm = 0.1989; |
---|
36 | B = 0; |
---|
37 | kp = 1.5; |
---|
38 | pp = 4.0; |
---|
39 | J = 0.04; |
---|
40 | dt = 0.000125; |
---|
41 | Lq = 1.0*Ls; |
---|
42 | Ld = 0.9*Ls; |
---|
43 | |
---|
44 | id = x(1)*cos(x(4)) + x(2)*sin(x(4)); |
---|
45 | iq = x(2)*cos(x(4)) - x(1)*sin(x(4)); |
---|
46 | om = x(3); |
---|
47 | th = x(4); |
---|
48 | ud = u(1)*cos(x(4)) + u(2)*sin(x(4)); |
---|
49 | uq = u(2)*cos(x(4)) - u(1)*sin(x(4)); |
---|
50 | |
---|
51 | idp = (1 - Rs*dt/Ld)*id + Lq*dt/Ld*om*iq + dt/Ld*ud; |
---|
52 | iqp = (1 - Rs*dt/Lq)*iq - psipm*dt/Lq*om - Ld*dt/Lq*om*id + dt/Lq*uq; |
---|
53 | omp = (1 - B*dt/J)*om + kp*pp*pp*dt/J*((Ld-Lq)*id*iq + psipm*iq); |
---|
54 | thp = th + dt*om; |
---|
55 | |
---|
56 | x_s(1) = idp*cos(thp) - iqp*sin(thp) + noise*sqrt(nQ(1,1))*randn(); |
---|
57 | x_s(2) = iqp*cos(thp) + idp*sin(thp) + noise*sqrt(nQ(2,2))*randn(); |
---|
58 | x_s(3) = omp + noise*sqrt(nQ(3,3))*randn(); |
---|
59 | x_s(4) = thp + noise*sqrt(nQ(4,4))*randn(); |
---|
60 | |
---|
61 | y_s(1) = x_s(1) + noise*sqrt(nR(1,1))*randn(); |
---|
62 | y_s(2) = x_s(2) + noise*sqrt(nR(2,2))*randn(); |
---|
63 | |
---|
64 | end |
---|
65 | end |
---|