root/applications/dual/vahala/pcrb/pcrb_E3.m @ 1416

Revision 1416, 2.6 kB (checked in by vahalam, 12 years ago)

pridani slozky pcrb s cramer-rao mezi

Line 
1%simulator PMSM for PCRB, choice: Ls/Ldq & correct/incorrect expectation
2clear all;
3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6%for experiments
7    %ctrl.> 2,5,9,10
8    %model> {1},{7},{4,6,10},{12} - {eq.} sort from worst
9
10%   settings
11    % ON/OFF  MODEL    IS CORR. E   INDUCT. L
12model(1) = 1; % alpha-beta    nE      Ls
13model(2) = 0; % d-q           nE      Ls
14model(3) = 0; % 5sc           nE      Ls
15
16model(4) = 0; % alpha-beta    E       Ls
17model(5) = 0; % d-q           E       Ls
18model(6) = 0; % 5sc           E       Ls
19
20model(7) = 1; % alpha-beta    nE      Ldq
21model(8) = 0; % d-q           nE      Ldq
22model(9) = 0; % 5sc           nE      Ldq
23
24model(10) = 0; % alpha-beta   E       Ldq
25model(11) = 0; % d-q          E       Ldq
26model(12) = 0; % 5sc          E       Ldq
27
28    % CONTROL
29    % 1 -   ome = ref_ome, the = integral(ome), ial = ibe = 0
30    % 2 -   PI control   
31    % 3 -   PI + injection (sin -> dq)
32    % 4 -   PI + injection (rect. -> dq)
33    % 5 -   PI + injection (const. -> ud) *J4 ~ 3e-6 for all exc. dq
34    % 6 -   PI + rnd error (ref_ome) *J4: dq bad; ab,5sc Ls ~ 4e-4; ab,5sc Ldq ~5e-6 
35    % 7 -   PI + injection (sin -> al-be)
36    % 8 -   PI + injection (rect. -> al-be)
37    % 9 -   PI + bicrit. (sign) *J4 ~ 1e-3 for all exc. dq
38    % 10 -  PI + rnd bicrit. selection (5)
39   
40% control = 2;
41% control = 5;
42% control = 8; %high frekq.
43% control = 9;
44control = 10;
45    % param. amp*phi(injom*dt*t) //phi = sin,cos,sign(sin),sing(cos)
46   
47amp = 10.0;
48injom = 5000;
49
50    %cov Q, R matrices
51%         %noise
52% Q = diag([0.0013 0.0013 5.0e-6 1.0e-10]);
53% R = diag([0.0006 0.0006]);
54%         %EKF
55% Q = diag([0.1 0.1 0.1 0.001]);
56% R = diag([0.05 0.05]);
57%         %test
58Q = diag([0.1 0.1 0.1 10]);
59R = diag([0.5 0.5]);
60
61%horizont
62T = 120000;
63
64%reference signal
65% ref_profile = [1, 10, 50, 200, 200, 30, 0, 0, -1, -10, -50, -200, -200, -30, 0];
66ref_profile = [0, -1, 3, 6, 9, 6, 3, 0, 0, 0, 0, 0,0,-3, -6, -3];
67% ref_profile = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
68% ref_profile = ones(1,16);
69
70[var_ome, var_th, var_th2] = fpcrb(model, control, amp, injom, Q, R, T, ref_profile);
71
72%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73%   plot
74
75%axis
76xax = 1:T-1;
77dt = 0.000125;
78timex = (xax)*dt;
79cmp = lines(sum(model));
80for i=1:sum(model)
81    figure(1);
82    hold on;
83    plot(timex, var_ome(xax,i),'Color',cmp(i,:));
84   
85    figure(2);
86    hold on;
87    plot(timex, var_th(xax,i),'Color',cmp(i,:));
88   
89    figure(3);
90    hold on;
91    plot(timex, var_th2(xax,i),'Color',cmp(i,:));
92end
93
94sound(chirp(0:0.001:2,0,1,150));
Note: See TracBrowser for help on using the browser.