1 | %simulator PMSM for PCRB, choice: Ls/Ldq & control |
---|
2 | clear all; |
---|
3 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
4 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
5 | |
---|
6 | % settings |
---|
7 | % ON/OFF MODEL INDUCT. L |
---|
8 | model(1) = 1; % alpha-beta Ls |
---|
9 | model(2) = 0; % alpha-beta Ldq |
---|
10 | model(3) = 0; % reduced alpha-beta Ls |
---|
11 | model(4) = 0;%zatim nefunguje % reduced alpha-beta Ldq |
---|
12 | |
---|
13 | % CONTROL |
---|
14 | % 1 - ome = ref_ome, the = integral(ome), ial = ibe = 0 |
---|
15 | % 2 - PI control |
---|
16 | % 3 - PI + injection (sin -> dq) |
---|
17 | % 4 - PI + injection (rect. -> dq) |
---|
18 | % 5 - PI + injection (const. -> ud) *J4 ~ 3e-6 for all exc. dq |
---|
19 | % 6 - PI + rnd error (ref_ome) *J4: dq bad; ab,5sc Ls ~ 4e-4; ab,5sc Ldq ~5e-6 |
---|
20 | % 7 - PI + injection (sin -> al-be) |
---|
21 | % 8 - PI + injection (rect. -> al-be) |
---|
22 | % 9 - PI + bicrit. (sign) *J4 ~ 1e-3 for all exc. dq |
---|
23 | % 10 - PI + rnd bicrit. selection (5) |
---|
24 | |
---|
25 | % control = 2; |
---|
26 | control = 5; |
---|
27 | % control = 8; %high frekq. |
---|
28 | % control = 9; |
---|
29 | % control = 10; |
---|
30 | % param. amp*phi(injom*dt*t) //phi = sin,cos,sign(sin),sing(cos) |
---|
31 | |
---|
32 | |
---|
33 | % amp = 0.001 -- 10; |
---|
34 | injom = 5000; |
---|
35 | |
---|
36 | %cov Q, R matrices |
---|
37 | % %noise |
---|
38 | % Q = diag([0.0013 0.0013 5.0e-6 1.0e-10]); |
---|
39 | % R = diag([0.0006 0.0006]); |
---|
40 | % %EKF |
---|
41 | Q = diag([0.1 0.1 0.1 0.001]); |
---|
42 | R = diag([0.05 0.05]); |
---|
43 | % %test |
---|
44 | % Q = diag([0.1 0.1 0.1 10]); |
---|
45 | % R = diag([0.5 0.5]); |
---|
46 | |
---|
47 | %horizont |
---|
48 | T = 120000; |
---|
49 | |
---|
50 | %reference signal |
---|
51 | % ref_profile = [1, 10, 50, 200, 200, 30, 0, 0, -1, -10, -50, -200, -200, -30, 0]; |
---|
52 | % ref_profile = [0, -1, 3, 6, 9, 6, 3, 0, 0, 0, 0, 0, 0,-3, -6, -3]; |
---|
53 | ref_profile = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; |
---|
54 | % ref_profile = ones(1,16); |
---|
55 | |
---|
56 | % [var_ome, var_th] = fpcrb2(model, control, amp, injom, Q, R, T, ref_profile, 100*eye(4)); |
---|
57 | |
---|
58 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
59 | % plot |
---|
60 | |
---|
61 | p0 = 1; |
---|
62 | |
---|
63 | %axis |
---|
64 | xax = 1:T-1; |
---|
65 | dt = 0.000125; |
---|
66 | timex = (xax)*dt; |
---|
67 | cmp = hsv(10); |
---|
68 | |
---|
69 | [var_ome, var_th] = fpcrb2(model, control, 10, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
70 | figure(1); |
---|
71 | hold on; |
---|
72 | plot(timex, var_th(xax,1),'Color',cmp(1,:)); |
---|
73 | |
---|
74 | [var_ome, var_th] = fpcrb2(model, control, 1, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
75 | figure(1); |
---|
76 | hold on; |
---|
77 | plot(timex, var_th(xax,1),'Color',cmp(2,:)); |
---|
78 | |
---|
79 | [var_ome, var_th] = fpcrb2(model, control, 0.1, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
80 | figure(1); |
---|
81 | hold on; |
---|
82 | plot(timex, var_th(xax,1),'Color',cmp(3,:)); |
---|
83 | |
---|
84 | [var_ome, var_th] = fpcrb2(model, control, 0.02, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
85 | figure(1); |
---|
86 | hold on; |
---|
87 | plot(timex, var_th(xax,1),'Color',cmp(4,:)); |
---|
88 | |
---|
89 | [var_ome, var_th] = fpcrb2(model, control, 0.01, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
90 | figure(1); |
---|
91 | hold on; |
---|
92 | plot(timex, var_th(xax,1),'Color',cmp(5,:)); |
---|
93 | |
---|
94 | [var_ome, var_th] = fpcrb2(model, control, 0.005, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
95 | figure(1); |
---|
96 | hold on; |
---|
97 | plot(timex, var_th(xax,1),'Color',cmp(6,:)); |
---|
98 | |
---|
99 | [var_ome, var_th] = fpcrb2(model, control, 0.003, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
100 | figure(1); |
---|
101 | hold on; |
---|
102 | plot(timex, var_th(xax,1),'Color',cmp(7,:)); |
---|
103 | |
---|
104 | [var_ome, var_th] = fpcrb2(model, control, 0.002, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
105 | figure(1); |
---|
106 | hold on; |
---|
107 | plot(timex, var_th(xax,1),'Color',cmp(8,:)); |
---|
108 | |
---|
109 | [var_ome, var_th] = fpcrb2(model, control, 0.0015, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
110 | figure(1); |
---|
111 | hold on; |
---|
112 | plot(timex, var_th(xax,1),'Color',cmp(9,:)); |
---|
113 | |
---|
114 | [var_ome, var_th] = fpcrb2(model, control, 0.001, injom, Q, R, T, ref_profile, p0*eye(4)); |
---|
115 | figure(1); |
---|
116 | hold on; |
---|
117 | plot(timex, var_th(xax,1),'Color',cmp(10,:)); |
---|
118 | legend('10','1','0.1','0.02','0.01','0.005','0.003','0.002','0.0015','0.001','Location','NorthEastOutside'); |
---|
119 | |
---|
120 | % sound(chirp(0:0.001:2,0,1,150)); |
---|