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

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

pridani slozky pcrb s cramer-rao mezi

Line 
1%simulator PMSM for PCRB, choice: Ls/Ldq & control
2clear all;
3%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
4%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5
6%   settings
7    % ON/OFF  MODEL       INDUCT. L
8model(1) = 1; % alpha-beta          Ls
9model(2) = 0; % alpha-beta          Ldq
10model(3) = 0; % reduced alpha-beta          Ls
11model(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   
25control = 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   
32amp = 10.0;
33injom = 5000;
34
35    %cov Q, R matrices
36%         %noise
37% Q = diag([0.0013 0.0013 5.0e-6 1.0e-10]);
38% R = diag([0.0006 0.0006]);
39%         %EKF
40Q = diag([0.1 0.1 0.1 0.001]);
41R = diag([0.05 0.05]);
42%         %test
43% Q = diag([0.1 0.1 0.1 10]);
44% R = diag([0.5 0.5]);
45
46%horizont
47T = 120000;
48
49%reference signal
50% ref_profile = [1, 10, 50, 200, 200, 30, 0, 0, -1, -10, -50, -200, -200, -30, 0];
51ref_profile = [0, -1, 3, 6, 9, 6, 3, 0, 0, 0, 0, 0, 0,-3, -6, -3];
52% ref_profile = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];
53% ref_profile = ones(1,16);
54
55[var_ome, var_th] = fpcrb2(model, control, amp, injom, Q, R, T, ref_profile, eye(4));
56
57%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
58%   plot
59
60%axis
61xax = 1:T-1;
62dt = 0.000125;
63timex = (xax)*dt;
64cmp = lines(sum(model));
65for i=1:sum(model)
66    figure(1);
67    hold on;
68    plot(timex, var_ome(xax,i),'Color',cmp(i,:));
69   
70    figure(2);
71    hold on;
72    plot(timex, var_th(xax,i),'Color',cmp(i,:));   
73end
74
75% sound(chirp(0:0.001:2,0,1,150));
Note: See TracBrowser for help on using the browser.