root/applications/pmsm/Barcelona/pwm.m @ 349

Revision 349, 2.0 kB (checked in by smidl, 15 years ago)

Barcelona + mex for pmsm + results of pwm experiment for off-line use with pwm.m (>> pwm(0))

Line 
1function pwm(compute)
2if nargin<1,
3    compute=1;
4end
5
6if compute
7    M=pmsm_estim_mex('pwm_mx.cfg');
8    save pwm M
9else
10    load pwm
11end
12
13time =0.000125*[0:size(M.xia,1)-1];
14
15%%%%%%%%%%%%%% U
16figure(1);
17detail=14000:20000;
18% ua
19subplot(2,2,1);
20plot(time(detail),M.oua(detail)-M.tua(detail));
21title('Difference between simulated and non-compensated observed u_{s,\alpha} (detail)')
22
23subplot(2,2,2);
24hist(M.oua-M.tua,30);
25title('Histogram of difference on the full data record of 8s')
26
27%ub
28subplot(2,2,3);
29plot(time(detail),M.modelub(detail)-M.tub(detail));
30title('Difference between simulated and compensated observed u_{s,\beta} (detail)')
31
32subplot(2,2,4);
33hist(M.modelub-M.tub,30);
34title('Histogram of difference on the full data record of 8s')
35
36dt=0.000125;
37Ls=0.003465;
38
39bnds = [max(abs(M.modelua-M.tua)), max(abs(M.modelub-M.tub)) 0 0];
40Qpwm = (dt/Ls)^2*(2*bnds).^2/12
41
42%%%%%%%%%%%%%%% Integration
43
44figure(2)
45subplot(4,2,1); plot(time,M.erria);xlabel('time [s]');
46title('Integration error on state variables')
47ylabel('Error on i_{s,\alpha}')
48subplot(4,2,2); hist(M.erria,30);
49title('Histogram of errors on state variables')
50
51subplot(4,2,3); plot(time,M.errib);xlabel('time [s]');
52ylabel('Error on i_{s,\beta}')
53subplot(4,2,4); hist(M.errib,30);
54%title('Histogram of error on i_{s,\beta}')
55
56subplot(4,2,5); plot(time,M.errom);xlabel('time [s]');
57ylabel('Error on \omega_{me}')
58subplot(4,2,6); hist(M.errom,30);
59%title('Histogram of error on \omega_{me}')
60
61subplot(4,2,7); plot(time,M.errth); xlabel('time [s]');
62ylabel('Error on \vartheta_{me}')
63subplot(4,2,8); hist(M.errth,30);
64%title('Histogram of error on \vartheta_{me}')
65
66Qint=[var(M.erria), var(M.errib), var(M.errom), var(M.errth)]
67
68bnds=[max(abs(M.erria)), max(abs(M.errib)), max(abs(M.errom)), max(abs(M.errth))]
69Qint = [(2*bnds).^2/12]
70
71%%%%%%%%%%%%%%%% Mz prop
72Fmag= 0.1989;
73p = 4.0;
74J = 0.04;   
75
76Tl=10;
77dom = p/J*Tl*dt
78Qrat=(2*[Fmag/Ls*dt,Fmag/Ls*dt, 1, dt]).^2/12
79
80Qtot=Qpwm+Qint
81Qtot+Qrat
82
83%%%%%%%%%%%%%%%% R
84R=(2*0.085)^2/12*[1 1]
Note: See TracBrowser for help on using the browser.